Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sherckuith 0:479ce5546098 1 /*
sherckuith 0:479ce5546098 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
sherckuith 0:479ce5546098 3 * All rights reserved.
sherckuith 0:479ce5546098 4 *
sherckuith 0:479ce5546098 5 * Redistribution and use in source and binary forms, with or without modification,
sherckuith 0:479ce5546098 6 * are permitted provided that the following conditions are met:
sherckuith 0:479ce5546098 7 *
sherckuith 0:479ce5546098 8 * 1. Redistributions of source code must retain the above copyright notice,
sherckuith 0:479ce5546098 9 * this list of conditions and the following disclaimer.
sherckuith 0:479ce5546098 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
sherckuith 0:479ce5546098 11 * this list of conditions and the following disclaimer in the documentation
sherckuith 0:479ce5546098 12 * and/or other materials provided with the distribution.
sherckuith 0:479ce5546098 13 * 3. The name of the author may not be used to endorse or promote products
sherckuith 0:479ce5546098 14 * derived from this software without specific prior written permission.
sherckuith 0:479ce5546098 15 *
sherckuith 0:479ce5546098 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
sherckuith 0:479ce5546098 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
sherckuith 0:479ce5546098 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
sherckuith 0:479ce5546098 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
sherckuith 0:479ce5546098 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
sherckuith 0:479ce5546098 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
sherckuith 0:479ce5546098 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
sherckuith 0:479ce5546098 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
sherckuith 0:479ce5546098 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
sherckuith 0:479ce5546098 25 * OF SUCH DAMAGE.
sherckuith 0:479ce5546098 26 *
sherckuith 0:479ce5546098 27 * This file is part of the lwIP TCP/IP stack.
sherckuith 0:479ce5546098 28 *
sherckuith 0:479ce5546098 29 * Author: Adam Dunkels <adam@sics.se>
sherckuith 0:479ce5546098 30 *
sherckuith 0:479ce5546098 31 */
sherckuith 0:479ce5546098 32 #ifndef __LWIP_SYS_H__
sherckuith 0:479ce5546098 33 #define __LWIP_SYS_H__
sherckuith 0:479ce5546098 34
sherckuith 0:479ce5546098 35 #include "lwip/opt.h"
sherckuith 0:479ce5546098 36
sherckuith 0:479ce5546098 37 #ifdef __cplusplus
sherckuith 0:479ce5546098 38 extern "C" {
sherckuith 0:479ce5546098 39 #endif
sherckuith 0:479ce5546098 40
sherckuith 0:479ce5546098 41 #if NO_SYS
sherckuith 0:479ce5546098 42
sherckuith 0:479ce5546098 43 /* For a totally minimal and standalone system, we provide null
sherckuith 0:479ce5546098 44 definitions of the sys_ functions. */
sherckuith 0:479ce5546098 45 typedef u8_t sys_sem_t;
sherckuith 0:479ce5546098 46 typedef u8_t sys_mutex_t;
sherckuith 0:479ce5546098 47 typedef u8_t sys_mbox_t;
sherckuith 0:479ce5546098 48
sherckuith 0:479ce5546098 49 #define sys_sem_new(s, c) ERR_OK
sherckuith 0:479ce5546098 50 #define sys_sem_signal(s)
sherckuith 0:479ce5546098 51 #define sys_sem_wait(s)
sherckuith 0:479ce5546098 52 #define sys_arch_sem_wait(s,t)
sherckuith 0:479ce5546098 53 #define sys_sem_free(s)
sherckuith 0:479ce5546098 54 #define sys_mutex_new(mu) ERR_OK
sherckuith 0:479ce5546098 55 #define sys_mutex_lock(mu)
sherckuith 0:479ce5546098 56 #define sys_mutex_unlock(mu)
sherckuith 0:479ce5546098 57 #define sys_mutex_free(mu)
sherckuith 0:479ce5546098 58 #define sys_mbox_new(m, s) ERR_OK
sherckuith 0:479ce5546098 59 #define sys_mbox_fetch(m,d)
sherckuith 0:479ce5546098 60 #define sys_mbox_tryfetch(m,d)
sherckuith 0:479ce5546098 61 #define sys_mbox_post(m,d)
sherckuith 0:479ce5546098 62 #define sys_mbox_trypost(m,d)
sherckuith 0:479ce5546098 63 #define sys_mbox_free(m)
sherckuith 0:479ce5546098 64
sherckuith 0:479ce5546098 65 #define sys_thread_new(n,t,a,s,p)
sherckuith 0:479ce5546098 66
sherckuith 0:479ce5546098 67 #define sys_msleep(t)
sherckuith 0:479ce5546098 68
sherckuith 0:479ce5546098 69 #else /* NO_SYS */
sherckuith 0:479ce5546098 70
sherckuith 0:479ce5546098 71 /** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
sherckuith 0:479ce5546098 72 #define SYS_ARCH_TIMEOUT 0xffffffffUL
sherckuith 0:479ce5546098 73
sherckuith 0:479ce5546098 74 /** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate.
sherckuith 0:479ce5546098 75 * For now we use the same magic value, but we allow this to change in future.
sherckuith 0:479ce5546098 76 */
sherckuith 0:479ce5546098 77 #define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
sherckuith 0:479ce5546098 78
sherckuith 0:479ce5546098 79 #include "lwip/err.h"
sherckuith 0:479ce5546098 80 #include "arch/sys_arch.h"
sherckuith 0:479ce5546098 81
sherckuith 0:479ce5546098 82 /** Function prototype for thread functions */
sherckuith 0:479ce5546098 83 typedef void (*lwip_thread_fn)(void *arg);
sherckuith 0:479ce5546098 84
sherckuith 0:479ce5546098 85 /* Function prototypes for functions to be implemented by platform ports
sherckuith 0:479ce5546098 86 (in sys_arch.c) */
sherckuith 0:479ce5546098 87
sherckuith 0:479ce5546098 88 /* Mutex functions: */
sherckuith 0:479ce5546098 89
sherckuith 0:479ce5546098 90 /** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
sherckuith 0:479ce5546098 91 should be used instead */
sherckuith 0:479ce5546098 92 #if LWIP_COMPAT_MUTEX
sherckuith 0:479ce5546098 93 /* for old ports that don't have mutexes: define them to binary semaphores */
sherckuith 0:479ce5546098 94 #define sys_mutex_t sys_sem_t
sherckuith 0:479ce5546098 95 #define sys_mutex_new(mutex) sys_sem_new(mutex, 1)
sherckuith 0:479ce5546098 96 #define sys_mutex_lock(mutex) sys_sem_wait(mutex)
sherckuith 0:479ce5546098 97 #define sys_mutex_unlock(mutex) sys_sem_signal(mutex)
sherckuith 0:479ce5546098 98 #define sys_mutex_free(mutex) sys_sem_free(mutex)
sherckuith 0:479ce5546098 99 #define sys_mutex_valid(mutex) sys_sem_valid(mutex)
sherckuith 0:479ce5546098 100 #define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex)
sherckuith 0:479ce5546098 101
sherckuith 0:479ce5546098 102 #else /* LWIP_COMPAT_MUTEX */
sherckuith 0:479ce5546098 103
sherckuith 0:479ce5546098 104 /** Create a new mutex
sherckuith 0:479ce5546098 105 * @param mutex pointer to the mutex to create
sherckuith 0:479ce5546098 106 * @return a new mutex */
sherckuith 0:479ce5546098 107 err_t sys_mutex_new(sys_mutex_t *mutex);
sherckuith 0:479ce5546098 108 /** Lock a mutex
sherckuith 0:479ce5546098 109 * @param mutex the mutex to lock */
sherckuith 0:479ce5546098 110 void sys_mutex_lock(sys_mutex_t *mutex);
sherckuith 0:479ce5546098 111 /** Unlock a mutex
sherckuith 0:479ce5546098 112 * @param mutex the mutex to unlock */
sherckuith 0:479ce5546098 113 void sys_mutex_unlock(sys_mutex_t *mutex);
sherckuith 0:479ce5546098 114 /** Delete a semaphore
sherckuith 0:479ce5546098 115 * @param mutex the mutex to delete */
sherckuith 0:479ce5546098 116 void sys_mutex_free(sys_mutex_t *mutex);
sherckuith 0:479ce5546098 117 #ifndef sys_mutex_valid
sherckuith 0:479ce5546098 118 /** Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid */
sherckuith 0:479ce5546098 119 int sys_mutex_valid(sys_mutex_t *mutex);
sherckuith 0:479ce5546098 120 #endif
sherckuith 0:479ce5546098 121 #ifndef sys_mutex_set_invalid
sherckuith 0:479ce5546098 122 /** Set a mutex invalid so that sys_mutex_valid returns 0 */
sherckuith 0:479ce5546098 123 void sys_mutex_set_invalid(sys_mutex_t *mutex);
sherckuith 0:479ce5546098 124 #endif
sherckuith 0:479ce5546098 125 #endif /* LWIP_COMPAT_MUTEX */
sherckuith 0:479ce5546098 126
sherckuith 0:479ce5546098 127 /* Semaphore functions: */
sherckuith 0:479ce5546098 128
sherckuith 0:479ce5546098 129 /** Create a new semaphore
sherckuith 0:479ce5546098 130 * @param sem pointer to the semaphore to create
sherckuith 0:479ce5546098 131 * @param count initial count of the semaphore
sherckuith 0:479ce5546098 132 * @return ERR_OK if successful, another err_t otherwise */
sherckuith 0:479ce5546098 133 err_t sys_sem_new(sys_sem_t *sem, u8_t count);
sherckuith 0:479ce5546098 134 /** Signals a semaphore
sherckuith 0:479ce5546098 135 * @param sem the semaphore to signal */
sherckuith 0:479ce5546098 136 void sys_sem_signal(sys_sem_t *sem);
sherckuith 0:479ce5546098 137 /** Wait for a semaphore for the specified timeout
sherckuith 0:479ce5546098 138 * @param sem the semaphore to wait for
sherckuith 0:479ce5546098 139 * @param timeout timeout in milliseconds to wait (0 = wait forever)
sherckuith 0:479ce5546098 140 * @return time (in milliseconds) waited for the semaphore
sherckuith 0:479ce5546098 141 * or SYS_ARCH_TIMEOUT on timeout */
sherckuith 0:479ce5546098 142 u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout);
sherckuith 0:479ce5546098 143 /** Delete a semaphore
sherckuith 0:479ce5546098 144 * @param sem semaphore to delete */
sherckuith 0:479ce5546098 145 void sys_sem_free(sys_sem_t *sem);
sherckuith 0:479ce5546098 146 /** Wait for a semaphore - forever/no timeout */
sherckuith 0:479ce5546098 147 #define sys_sem_wait(sem) sys_arch_sem_wait(sem, 0)
sherckuith 0:479ce5546098 148 #ifndef sys_sem_valid
sherckuith 0:479ce5546098 149 /** Check if a sempahore is valid/allocated: return 1 for valid, 0 for invalid */
sherckuith 0:479ce5546098 150 int sys_sem_valid(sys_sem_t *sem);
sherckuith 0:479ce5546098 151 #endif
sherckuith 0:479ce5546098 152 #ifndef sys_sem_set_invalid
sherckuith 0:479ce5546098 153 /** Set a semaphore invalid so that sys_sem_valid returns 0 */
sherckuith 0:479ce5546098 154 void sys_sem_set_invalid(sys_sem_t *sem);
sherckuith 0:479ce5546098 155 #endif
sherckuith 0:479ce5546098 156
sherckuith 0:479ce5546098 157 /* Time functions. */
sherckuith 0:479ce5546098 158 #ifndef sys_msleep
sherckuith 0:479ce5546098 159 void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */
sherckuith 0:479ce5546098 160 #endif
sherckuith 0:479ce5546098 161
sherckuith 0:479ce5546098 162 /* Mailbox functions. */
sherckuith 0:479ce5546098 163
sherckuith 0:479ce5546098 164 /** Create a new mbox of specified size
sherckuith 0:479ce5546098 165 * @param mbox pointer to the mbox to create
sherckuith 0:479ce5546098 166 * @param size (miminum) number of messages in this mbox
sherckuith 0:479ce5546098 167 * @return ERR_OK if successful, another err_t otherwise */
sherckuith 0:479ce5546098 168 err_t sys_mbox_new(sys_mbox_t *mbox, int size);
sherckuith 0:479ce5546098 169 /** Post a message to an mbox - may not fail
sherckuith 0:479ce5546098 170 * -> blocks if full, only used from tasks not from ISR
sherckuith 0:479ce5546098 171 * @param mbox mbox to posts the message
sherckuith 0:479ce5546098 172 * @param msg message to post (ATTENTION: can be NULL) */
sherckuith 0:479ce5546098 173 void sys_mbox_post(sys_mbox_t *mbox, void *msg);
sherckuith 0:479ce5546098 174 /** Try to post a message to an mbox - may fail if full or ISR
sherckuith 0:479ce5546098 175 * @param mbox mbox to posts the message
sherckuith 0:479ce5546098 176 * @param msg message to post (ATTENTION: can be NULL) */
sherckuith 0:479ce5546098 177 err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg);
sherckuith 0:479ce5546098 178 /** Wait for a new message to arrive in the mbox
sherckuith 0:479ce5546098 179 * @param mbox mbox to get a message from
sherckuith 0:479ce5546098 180 * @param msg pointer where the message is stored
sherckuith 0:479ce5546098 181 * @param timeout maximum time (in milliseconds) to wait for a message
sherckuith 0:479ce5546098 182 * @return time (in milliseconds) waited for a message, may be 0 if not waited
sherckuith 0:479ce5546098 183 or SYS_ARCH_TIMEOUT on timeout
sherckuith 0:479ce5546098 184 * The returned time has to be accurate to prevent timer jitter! */
sherckuith 0:479ce5546098 185 u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout);
sherckuith 0:479ce5546098 186 /* Allow port to override with a macro, e.g. special timout for sys_arch_mbox_fetch() */
sherckuith 0:479ce5546098 187 #ifndef sys_arch_mbox_tryfetch
sherckuith 0:479ce5546098 188 /** Wait for a new message to arrive in the mbox
sherckuith 0:479ce5546098 189 * @param mbox mbox to get a message from
sherckuith 0:479ce5546098 190 * @param msg pointer where the message is stored
sherckuith 0:479ce5546098 191 * @param timeout maximum time (in milliseconds) to wait for a message
sherckuith 0:479ce5546098 192 * @return 0 (milliseconds) if a message has been received
sherckuith 0:479ce5546098 193 * or SYS_MBOX_EMPTY if the mailbox is empty */
sherckuith 0:479ce5546098 194 u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg);
sherckuith 0:479ce5546098 195 #endif
sherckuith 0:479ce5546098 196 /** For now, we map straight to sys_arch implementation. */
sherckuith 0:479ce5546098 197 #define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg)
sherckuith 0:479ce5546098 198 /** Delete an mbox
sherckuith 0:479ce5546098 199 * @param mbox mbox to delete */
sherckuith 0:479ce5546098 200 void sys_mbox_free(sys_mbox_t *mbox);
sherckuith 0:479ce5546098 201 #define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0)
sherckuith 0:479ce5546098 202 #ifndef sys_mbox_valid
sherckuith 0:479ce5546098 203 /** Check if an mbox is valid/allocated: return 1 for valid, 0 for invalid */
sherckuith 0:479ce5546098 204 int sys_mbox_valid(sys_mbox_t *mbox);
sherckuith 0:479ce5546098 205 #endif
sherckuith 0:479ce5546098 206 #ifndef sys_mbox_set_invalid
sherckuith 0:479ce5546098 207 /** Set an mbox invalid so that sys_mbox_valid returns 0 */
sherckuith 0:479ce5546098 208 void sys_mbox_set_invalid(sys_mbox_t *mbox);
sherckuith 0:479ce5546098 209 #endif
sherckuith 0:479ce5546098 210
sherckuith 0:479ce5546098 211 /** The only thread function:
sherckuith 0:479ce5546098 212 * Creates a new thread
sherckuith 0:479ce5546098 213 * @param name human-readable name for the thread (used for debugging purposes)
sherckuith 0:479ce5546098 214 * @param thread thread-function
sherckuith 0:479ce5546098 215 * @param arg parameter passed to 'thread'
sherckuith 0:479ce5546098 216 * @param stacksize stack size in bytes for the new thread (may be ignored by ports)
sherckuith 0:479ce5546098 217 * @param prio priority of the new thread (may be ignored by ports) */
sherckuith 0:479ce5546098 218 sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
sherckuith 0:479ce5546098 219
sherckuith 0:479ce5546098 220 #endif /* NO_SYS */
sherckuith 0:479ce5546098 221
sherckuith 0:479ce5546098 222 /* sys_init() must be called before anthing else. */
sherckuith 0:479ce5546098 223 void sys_init(void);
sherckuith 0:479ce5546098 224
sherckuith 0:479ce5546098 225 #ifndef sys_jiffies
sherckuith 0:479ce5546098 226 /** Ticks/jiffies since power up. */
sherckuith 0:479ce5546098 227 u32_t sys_jiffies(void);
sherckuith 0:479ce5546098 228 #endif
sherckuith 0:479ce5546098 229
sherckuith 0:479ce5546098 230 /** Returns the current time in milliseconds,
sherckuith 0:479ce5546098 231 * may be the same as sys_jiffies or at least based on it. */
sherckuith 0:479ce5546098 232 u32_t sys_now(void);
sherckuith 0:479ce5546098 233
sherckuith 0:479ce5546098 234 /* Critical Region Protection */
sherckuith 0:479ce5546098 235 /* These functions must be implemented in the sys_arch.c file.
sherckuith 0:479ce5546098 236 In some implementations they can provide a more light-weight protection
sherckuith 0:479ce5546098 237 mechanism than using semaphores. Otherwise semaphores can be used for
sherckuith 0:479ce5546098 238 implementation */
sherckuith 0:479ce5546098 239 #ifndef SYS_ARCH_PROTECT
sherckuith 0:479ce5546098 240 /** SYS_LIGHTWEIGHT_PROT
sherckuith 0:479ce5546098 241 * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
sherckuith 0:479ce5546098 242 * for certain critical regions during buffer allocation, deallocation and memory
sherckuith 0:479ce5546098 243 * allocation and deallocation.
sherckuith 0:479ce5546098 244 */
sherckuith 0:479ce5546098 245 #if SYS_LIGHTWEIGHT_PROT
sherckuith 0:479ce5546098 246
sherckuith 0:479ce5546098 247 /** SYS_ARCH_DECL_PROTECT
sherckuith 0:479ce5546098 248 * declare a protection variable. This macro will default to defining a variable of
sherckuith 0:479ce5546098 249 * type sys_prot_t. If a particular port needs a different implementation, then
sherckuith 0:479ce5546098 250 * this macro may be defined in sys_arch.h.
sherckuith 0:479ce5546098 251 */
sherckuith 0:479ce5546098 252 #define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
sherckuith 0:479ce5546098 253 /** SYS_ARCH_PROTECT
sherckuith 0:479ce5546098 254 * Perform a "fast" protect. This could be implemented by
sherckuith 0:479ce5546098 255 * disabling interrupts for an embedded system or by using a semaphore or
sherckuith 0:479ce5546098 256 * mutex. The implementation should allow calling SYS_ARCH_PROTECT when
sherckuith 0:479ce5546098 257 * already protected. The old protection level is returned in the variable
sherckuith 0:479ce5546098 258 * "lev". This macro will default to calling the sys_arch_protect() function
sherckuith 0:479ce5546098 259 * which should be implemented in sys_arch.c. If a particular port needs a
sherckuith 0:479ce5546098 260 * different implementation, then this macro may be defined in sys_arch.h
sherckuith 0:479ce5546098 261 */
sherckuith 0:479ce5546098 262 #define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
sherckuith 0:479ce5546098 263 /** SYS_ARCH_UNPROTECT
sherckuith 0:479ce5546098 264 * Perform a "fast" set of the protection level to "lev". This could be
sherckuith 0:479ce5546098 265 * implemented by setting the interrupt level to "lev" within the MACRO or by
sherckuith 0:479ce5546098 266 * using a semaphore or mutex. This macro will default to calling the
sherckuith 0:479ce5546098 267 * sys_arch_unprotect() function which should be implemented in
sherckuith 0:479ce5546098 268 * sys_arch.c. If a particular port needs a different implementation, then
sherckuith 0:479ce5546098 269 * this macro may be defined in sys_arch.h
sherckuith 0:479ce5546098 270 */
sherckuith 0:479ce5546098 271 #define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)
sherckuith 0:479ce5546098 272 sys_prot_t sys_arch_protect(void);
sherckuith 0:479ce5546098 273 void sys_arch_unprotect(sys_prot_t pval);
sherckuith 0:479ce5546098 274
sherckuith 0:479ce5546098 275 #else
sherckuith 0:479ce5546098 276
sherckuith 0:479ce5546098 277 #define SYS_ARCH_DECL_PROTECT(lev)
sherckuith 0:479ce5546098 278 #define SYS_ARCH_PROTECT(lev)
sherckuith 0:479ce5546098 279 #define SYS_ARCH_UNPROTECT(lev)
sherckuith 0:479ce5546098 280
sherckuith 0:479ce5546098 281 #endif /* SYS_LIGHTWEIGHT_PROT */
sherckuith 0:479ce5546098 282
sherckuith 0:479ce5546098 283 #endif /* SYS_ARCH_PROTECT */
sherckuith 0:479ce5546098 284
sherckuith 0:479ce5546098 285 /*
sherckuith 0:479ce5546098 286 * Macros to set/get and increase/decrease variables in a thread-safe way.
sherckuith 0:479ce5546098 287 * Use these for accessing variable that are used from more than one thread.
sherckuith 0:479ce5546098 288 */
sherckuith 0:479ce5546098 289
sherckuith 0:479ce5546098 290 #ifndef SYS_ARCH_INC
sherckuith 0:479ce5546098 291 #define SYS_ARCH_INC(var, val) do { \
sherckuith 0:479ce5546098 292 SYS_ARCH_DECL_PROTECT(old_level); \
sherckuith 0:479ce5546098 293 SYS_ARCH_PROTECT(old_level); \
sherckuith 0:479ce5546098 294 var += val; \
sherckuith 0:479ce5546098 295 SYS_ARCH_UNPROTECT(old_level); \
sherckuith 0:479ce5546098 296 } while(0)
sherckuith 0:479ce5546098 297 #endif /* SYS_ARCH_INC */
sherckuith 0:479ce5546098 298
sherckuith 0:479ce5546098 299 #ifndef SYS_ARCH_DEC
sherckuith 0:479ce5546098 300 #define SYS_ARCH_DEC(var, val) do { \
sherckuith 0:479ce5546098 301 SYS_ARCH_DECL_PROTECT(old_level); \
sherckuith 0:479ce5546098 302 SYS_ARCH_PROTECT(old_level); \
sherckuith 0:479ce5546098 303 var -= val; \
sherckuith 0:479ce5546098 304 SYS_ARCH_UNPROTECT(old_level); \
sherckuith 0:479ce5546098 305 } while(0)
sherckuith 0:479ce5546098 306 #endif /* SYS_ARCH_DEC */
sherckuith 0:479ce5546098 307
sherckuith 0:479ce5546098 308 #ifndef SYS_ARCH_GET
sherckuith 0:479ce5546098 309 #define SYS_ARCH_GET(var, ret) do { \
sherckuith 0:479ce5546098 310 SYS_ARCH_DECL_PROTECT(old_level); \
sherckuith 0:479ce5546098 311 SYS_ARCH_PROTECT(old_level); \
sherckuith 0:479ce5546098 312 ret = var; \
sherckuith 0:479ce5546098 313 SYS_ARCH_UNPROTECT(old_level); \
sherckuith 0:479ce5546098 314 } while(0)
sherckuith 0:479ce5546098 315 #endif /* SYS_ARCH_GET */
sherckuith 0:479ce5546098 316
sherckuith 0:479ce5546098 317 #ifndef SYS_ARCH_SET
sherckuith 0:479ce5546098 318 #define SYS_ARCH_SET(var, val) do { \
sherckuith 0:479ce5546098 319 SYS_ARCH_DECL_PROTECT(old_level); \
sherckuith 0:479ce5546098 320 SYS_ARCH_PROTECT(old_level); \
sherckuith 0:479ce5546098 321 var = val; \
sherckuith 0:479ce5546098 322 SYS_ARCH_UNPROTECT(old_level); \
sherckuith 0:479ce5546098 323 } while(0)
sherckuith 0:479ce5546098 324 #endif /* SYS_ARCH_SET */
sherckuith 0:479ce5546098 325
sherckuith 0:479ce5546098 326
sherckuith 0:479ce5546098 327 #ifdef __cplusplus
sherckuith 0:479ce5546098 328 }
sherckuith 0:479ce5546098 329 #endif
sherckuith 0:479ce5546098 330
sherckuith 0:479ce5546098 331 #endif /* __LWIP_SYS_H__ */