Donatien Garnier / LwIPNetworking

Dependencies:   DebugLib Socket lwip lwip-sys

Dependents:   EthernetInterface

Fork of NetworkingCoreLib by Donatien Garnier

Committer:
donatien
Date:
Thu May 24 14:49:40 2012 +0000
Revision:
0:013f5d54248c
Initial Commit

Who changed what in which revision?

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