Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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