Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sys.h Source File

sys.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * OS abstraction layer
00004  */
00005 
00006 /*
00007  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without modification,
00011  * are permitted provided that the following conditions are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright notice,
00014  *    this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright notice,
00016  *    this list of conditions and the following disclaimer in the documentation
00017  *    and/or other materials provided with the distribution.
00018  * 3. The name of the author may not be used to endorse or promote products
00019  *    derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00023  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00024  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00026  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00029  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00030  * OF SUCH DAMAGE.
00031  *
00032  * This file is part of the lwIP TCP/IP stack.
00033  *
00034  * Author: Adam Dunkels <adam@sics.se>
00035  */
00036 
00037 #ifndef LWIP_HDR_SYS_H
00038 #define LWIP_HDR_SYS_H
00039 
00040 #include "lwip/opt.h"
00041 
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045 
00046 #if NO_SYS
00047 
00048 /* For a totally minimal and standalone system, we provide null
00049    definitions of the sys_ functions. */
00050 typedef u8_t sys_sem_t;
00051 typedef u8_t sys_mutex_t;
00052 typedef u8_t sys_mbox_t;
00053 
00054 #define sys_sem_new(s, c) ERR_OK
00055 #define sys_sem_signal(s)
00056 #define sys_sem_wait(s)
00057 #define sys_arch_sem_wait(s,t)
00058 #define sys_sem_free(s)
00059 #define sys_sem_valid(s) 0
00060 #define sys_sem_valid_val(s) 0
00061 #define sys_sem_set_invalid(s)
00062 #define sys_sem_set_invalid_val(s)
00063 #define sys_mutex_new(mu) ERR_OK
00064 #define sys_mutex_lock(mu)
00065 #define sys_mutex_unlock(mu)
00066 #define sys_mutex_free(mu)
00067 #define sys_mutex_valid(mu) 0
00068 #define sys_mutex_set_invalid(mu)
00069 #define sys_mbox_new(m, s) ERR_OK
00070 #define sys_mbox_fetch(m,d)
00071 #define sys_mbox_tryfetch(m,d)
00072 #define sys_mbox_post(m,d)
00073 #define sys_mbox_trypost(m,d)
00074 #define sys_mbox_free(m)
00075 #define sys_mbox_valid(m)
00076 #define sys_mbox_valid_val(m)
00077 #define sys_mbox_set_invalid(m)
00078 #define sys_mbox_set_invalid_val(m)
00079 
00080 #define sys_thread_new(n,t,a,s,p)
00081 
00082 #define sys_msleep(t)
00083 
00084 #else /* NO_SYS */
00085 
00086 /** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
00087 #define SYS_ARCH_TIMEOUT 0xffffffffUL
00088 
00089 /** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate.
00090  * For now we use the same magic value, but we allow this to change in future.
00091  */
00092 #define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
00093 
00094 #include "lwip/err.h"
00095 #include "arch/sys_arch.h"
00096 
00097 /** Function prototype for thread functions */
00098 typedef void (*lwip_thread_fn)(void *arg);
00099 
00100 /* Function prototypes for functions to be implemented by platform ports
00101    (in sys_arch.c) */
00102 
00103 /* Mutex functions: */
00104 
00105 /** Define LWIP_COMPAT_MUTEX if the port has no mutexes and binary semaphores
00106     should be used instead */
00107 #ifndef LWIP_COMPAT_MUTEX
00108 #define LWIP_COMPAT_MUTEX 0
00109 #endif
00110 
00111 #if LWIP_COMPAT_MUTEX
00112 /* for old ports that don't have mutexes: define them to binary semaphores */
00113 #define sys_mutex_t                   sys_sem_t
00114 #define sys_mutex_new(mutex)          sys_sem_new(mutex, 1)
00115 #define sys_mutex_lock(mutex)         sys_sem_wait(mutex)
00116 #define sys_mutex_unlock(mutex)       sys_sem_signal(mutex)
00117 #define sys_mutex_free(mutex)         sys_sem_free(mutex)
00118 #define sys_mutex_valid(mutex)        sys_sem_valid(mutex)
00119 #define sys_mutex_set_invalid(mutex)  sys_sem_set_invalid(mutex)
00120 
00121 #else /* LWIP_COMPAT_MUTEX */
00122 
00123 /**
00124  * @ingroup sys_mutex
00125  * Create a new mutex.
00126  * Note that mutexes are expected to not be taken recursively by the lwIP code,
00127  * so both implementation types (recursive or non-recursive) should work.
00128  * The mutex is allocated to the memory that 'mutex'
00129  * points to (which can be both a pointer or the actual OS structure).
00130  * If the mutex has been created, ERR_OK should be returned. Returning any
00131  * other error will provide a hint what went wrong, but except for assertions,
00132  * no real error handling is implemented.
00133  * 
00134  * @param mutex pointer to the mutex to create
00135  * @return ERR_OK if successful, another err_t otherwise
00136  */
00137 err_t sys_mutex_new(sys_mutex_t *mutex);
00138 /**
00139  * @ingroup sys_mutex
00140  * Blocks the thread until the mutex can be grabbed.
00141  * @param mutex the mutex to lock
00142  */
00143 void sys_mutex_lock(sys_mutex_t *mutex);
00144 /**
00145  * @ingroup sys_mutex
00146  * Releases the mutex previously locked through 'sys_mutex_lock()'.
00147  * @param mutex the mutex to unlock
00148  */
00149 void sys_mutex_unlock(sys_mutex_t *mutex);
00150 /**
00151  * @ingroup sys_mutex
00152  * Deallocates a mutex.
00153  * @param mutex the mutex to delete
00154  */
00155 void sys_mutex_free(sys_mutex_t *mutex);
00156 #ifndef sys_mutex_valid
00157 /**
00158  * @ingroup sys_mutex
00159  * Returns 1 if the mutes is valid, 0 if it is not valid.
00160  * When using pointers, a simple way is to check the pointer for != NULL.
00161  * When directly using OS structures, implementing this may be more complex.
00162  * This may also be a define, in which case the function is not prototyped.
00163  */
00164 int sys_mutex_valid(sys_mutex_t *mutex);
00165 #endif
00166 #ifndef sys_mutex_set_invalid
00167 /**
00168  * @ingroup sys_mutex
00169  * Invalidate a mutex so that sys_mutex_valid() returns 0.
00170  * ATTENTION: This does NOT mean that the mutex shall be deallocated:
00171  * sys_mutex_free() is always called before calling this function!
00172  * This may also be a define, in which case the function is not prototyped.
00173  */
00174 void sys_mutex_set_invalid(sys_mutex_t *mutex);
00175 #endif
00176 #endif /* LWIP_COMPAT_MUTEX */
00177 
00178 /* Semaphore functions: */
00179 
00180 /**
00181  * @ingroup sys_sem
00182  * Create a new semaphore
00183  * Creates a new semaphore. The semaphore is allocated to the memory that 'sem'
00184  * points to (which can be both a pointer or the actual OS structure).
00185  * The "count" argument specifies the initial state of the semaphore (which is
00186  * either 0 or 1).
00187  * If the semaphore has been created, ERR_OK should be returned. Returning any
00188  * other error will provide a hint what went wrong, but except for assertions,
00189  * no real error handling is implemented.
00190  *
00191  * @param sem pointer to the semaphore to create
00192  * @param count initial count of the semaphore
00193  * @return ERR_OK if successful, another err_t otherwise
00194  */
00195 err_t sys_sem_new(sys_sem_t *sem, u8_t count);
00196 /**
00197  * @ingroup sys_sem
00198  * Signals a semaphore
00199  * @param sem the semaphore to signal
00200  */
00201 void sys_sem_signal(sys_sem_t *sem);
00202 /**
00203  * @ingroup sys_sem
00204  *  Blocks the thread while waiting for the semaphore to be signaled. If the
00205  * "timeout" argument is non-zero, the thread should only be blocked for the
00206  * specified time (measured in milliseconds). If the "timeout" argument is zero,
00207  * the thread should be blocked until the semaphore is signalled.
00208  * 
00209  * The return value is SYS_ARCH_TIMEOUT if the semaphore wasn't signaled within
00210  * the specified time or any other value if it was signaled (with or without
00211  * waiting).
00212  * Notice that lwIP implements a function with a similar name,
00213  * sys_sem_wait(), that uses the sys_arch_sem_wait() function.
00214  * 
00215  * @param sem the semaphore to wait for
00216  * @param timeout timeout in milliseconds to wait (0 = wait forever)
00217  * @return SYS_ARCH_TIMEOUT on timeout, any other value on success
00218  */
00219 u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout);
00220 /**
00221  * @ingroup sys_sem
00222  * Deallocates a semaphore.
00223  * @param sem semaphore to delete
00224  */
00225 void sys_sem_free(sys_sem_t *sem);
00226 /** Wait for a semaphore - forever/no timeout */
00227 #define sys_sem_wait(sem)                  sys_arch_sem_wait(sem, 0)
00228 #ifndef sys_sem_valid
00229 /**
00230  * @ingroup sys_sem
00231  * Returns 1 if the semaphore is valid, 0 if it is not valid.
00232  * When using pointers, a simple way is to check the pointer for != NULL.
00233  * When directly using OS structures, implementing this may be more complex.
00234  * This may also be a define, in which case the function is not prototyped.
00235  */
00236 int sys_sem_valid(sys_sem_t *sem);
00237 #endif
00238 #ifndef sys_sem_set_invalid
00239 /**
00240  * @ingroup sys_sem
00241  * Invalidate a semaphore so that sys_sem_valid() returns 0.
00242  * ATTENTION: This does NOT mean that the semaphore shall be deallocated:
00243  * sys_sem_free() is always called before calling this function!
00244  * This may also be a define, in which case the function is not prototyped.
00245  */
00246 void sys_sem_set_invalid(sys_sem_t *sem);
00247 #endif
00248 #ifndef sys_sem_valid_val
00249 /**
00250  * Same as sys_sem_valid() but taking a value, not a pointer
00251  */
00252 #define sys_sem_valid_val(sem)       sys_sem_valid(&(sem))
00253 #endif
00254 #ifndef sys_sem_set_invalid_val
00255 /**
00256  * Same as sys_sem_set_invalid() but taking a value, not a pointer
00257  */
00258 #define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem))
00259 #endif
00260 
00261 #ifndef sys_msleep
00262 /**
00263  * @ingroup sys_misc
00264  * Sleep for specified number of ms
00265  */
00266 void sys_msleep(u32_t ms); /* only has a (close to) 1 ms resolution. */
00267 #endif
00268 
00269 /* Mailbox functions. */
00270 
00271 /**
00272  * @ingroup sys_mbox
00273  * Creates an empty mailbox for maximum "size" elements. Elements stored
00274  * in mailboxes are pointers. You have to define macros "_MBOX_SIZE"
00275  * in your lwipopts.h, or ignore this parameter in your implementation
00276  * and use a default size.
00277  * If the mailbox has been created, ERR_OK should be returned. Returning any
00278  * other error will provide a hint what went wrong, but except for assertions,
00279  * no real error handling is implemented.
00280  * 
00281  * @param mbox pointer to the mbox to create
00282  * @param size (minimum) number of messages in this mbox
00283  * @return ERR_OK if successful, another err_t otherwise
00284  */
00285 err_t sys_mbox_new(sys_mbox_t *mbox, int size);
00286 /**
00287  * @ingroup sys_mbox
00288  * Post a message to an mbox - may not fail
00289  * -> blocks if full, only to be used from tasks NOT from ISR!
00290  * 
00291  * @param mbox mbox to posts the message
00292  * @param msg message to post (ATTENTION: can be NULL)
00293  */
00294 void sys_mbox_post(sys_mbox_t *mbox, void *msg);
00295 /**
00296  * @ingroup sys_mbox
00297  * Try to post a message to an mbox - may fail if full.
00298  * Can be used from ISR (if the sys arch layer allows this).
00299  * Returns ERR_MEM if it is full, else, ERR_OK if the "msg" is posted.
00300  * 
00301  * @param mbox mbox to posts the message
00302  * @param msg message to post (ATTENTION: can be NULL)
00303  */
00304 err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg);
00305 /**
00306  * @ingroup sys_mbox
00307  * Try to post a message to an mbox - may fail if full.
00308  * To be be used from ISR.
00309  * Returns ERR_MEM if it is full, else, ERR_OK if the "msg" is posted.
00310  * 
00311  * @param mbox mbox to posts the message
00312  * @param msg message to post (ATTENTION: can be NULL)
00313  */
00314 err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg);
00315 /**
00316  * @ingroup sys_mbox
00317  * Blocks the thread until a message arrives in the mailbox, but does
00318  * not block the thread longer than "timeout" milliseconds (similar to
00319  * the sys_arch_sem_wait() function). If "timeout" is 0, the thread should
00320  * be blocked until a message arrives. The "msg" argument is a result
00321  * parameter that is set by the function (i.e., by doing "*msg =
00322  * ptr"). The "msg" parameter maybe NULL to indicate that the message
00323  * should be dropped.
00324  * The return values are the same as for the sys_arch_sem_wait() function:
00325  * SYS_ARCH_TIMEOUT if there was a timeout, any other value if a messages
00326  * is received.
00327  * 
00328  * Note that a function with a similar name, sys_mbox_fetch(), is
00329  * implemented by lwIP. 
00330  * 
00331  * @param mbox mbox to get a message from
00332  * @param msg pointer where the message is stored
00333  * @param timeout maximum time (in milliseconds) to wait for a message (0 = wait forever)
00334  * @return SYS_ARCH_TIMEOUT on timeout, any other value if a message has been received
00335  */
00336 u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout);
00337 /* Allow port to override with a macro, e.g. special timeout for sys_arch_mbox_fetch() */
00338 #ifndef sys_arch_mbox_tryfetch
00339 /**
00340  * @ingroup sys_mbox
00341  * This is similar to sys_arch_mbox_fetch, however if a message is not
00342  * present in the mailbox, it immediately returns with the code
00343  * SYS_MBOX_EMPTY. On success 0 is returned.
00344  * To allow for efficient implementations, this can be defined as a
00345  * function-like macro in sys_arch.h instead of a normal function. For
00346  * example, a naive implementation could be:
00347  * \#define sys_arch_mbox_tryfetch(mbox,msg) sys_arch_mbox_fetch(mbox,msg,1)
00348  * although this would introduce unnecessary delays.
00349  * 
00350  * @param mbox mbox to get a message from
00351  * @param msg pointer where the message is stored
00352  * @return 0 (milliseconds) if a message has been received
00353  *         or SYS_MBOX_EMPTY if the mailbox is empty
00354  */
00355 u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg);
00356 #endif
00357 /**
00358  * For now, we map straight to sys_arch implementation.
00359  */
00360 #define sys_mbox_tryfetch(mbox, msg) sys_arch_mbox_tryfetch(mbox, msg)
00361 /**
00362  * @ingroup sys_mbox
00363  * Deallocates a mailbox. If there are messages still present in the
00364  * mailbox when the mailbox is deallocated, it is an indication of a
00365  * programming error in lwIP and the developer should be notified.
00366  * 
00367  * @param mbox mbox to delete
00368  */
00369 void sys_mbox_free(sys_mbox_t *mbox);
00370 #define sys_mbox_fetch(mbox, msg) sys_arch_mbox_fetch(mbox, msg, 0)
00371 #ifndef sys_mbox_valid
00372 /**
00373  * @ingroup sys_mbox
00374  * Returns 1 if the mailbox is valid, 0 if it is not valid.
00375  * When using pointers, a simple way is to check the pointer for != NULL.
00376  * When directly using OS structures, implementing this may be more complex.
00377  * This may also be a define, in which case the function is not prototyped.
00378  */
00379 int sys_mbox_valid(sys_mbox_t *mbox);
00380 #endif
00381 #ifndef sys_mbox_set_invalid
00382 /**
00383  * @ingroup sys_mbox
00384  * Invalidate a mailbox so that sys_mbox_valid() returns 0.
00385  * ATTENTION: This does NOT mean that the mailbox shall be deallocated:
00386  * sys_mbox_free() is always called before calling this function!
00387  * This may also be a define, in which case the function is not prototyped.
00388  */
00389 void sys_mbox_set_invalid(sys_mbox_t *mbox);
00390 #endif
00391 #ifndef sys_mbox_valid_val
00392 /**
00393  * Same as sys_mbox_valid() but taking a value, not a pointer
00394  */
00395 #define sys_mbox_valid_val(mbox)       sys_mbox_valid(&(mbox))
00396 #endif
00397 #ifndef sys_mbox_set_invalid_val
00398 /**
00399  * Same as sys_mbox_set_invalid() but taking a value, not a pointer
00400  */
00401 #define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox))
00402 #endif
00403 
00404 
00405 /**
00406  * @ingroup sys_misc
00407  * The only thread function:
00408  * Starts a new thread named "name" with priority "prio" that will begin its
00409  * execution in the function "thread()". The "arg" argument will be passed as an
00410  * argument to the thread() function. The stack size to used for this thread is
00411  * the "stacksize" parameter. The id of the new thread is returned. Both the id
00412  * and the priority are system dependent.
00413  * ATTENTION: although this function returns a value, it MUST NOT FAIL (ports have to assert this!)
00414  * 
00415  * @param name human-readable name for the thread (used for debugging purposes)
00416  * @param thread thread-function
00417  * @param arg parameter passed to 'thread'
00418  * @param stacksize stack size in bytes for the new thread (may be ignored by ports)
00419  * @param prio priority of the new thread (may be ignored by ports) */
00420 sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
00421 
00422 #endif /* NO_SYS */
00423 
00424 /**
00425  * @ingroup sys_misc
00426  * sys_init() must be called before anything else.
00427  * Initialize the sys_arch layer.
00428  */
00429 void sys_init(void);
00430 
00431 #ifndef sys_jiffies
00432 /**
00433  * Ticks/jiffies since power up.
00434  */
00435 u32_t sys_jiffies(void);
00436 #endif
00437 
00438 /**
00439  * @ingroup sys_time
00440  * Returns the current time in milliseconds,
00441  * may be the same as sys_jiffies or at least based on it.
00442  * Don't care for wraparound, this is only used for time diffs.
00443  * Not implementing this function means you cannot use some modules (e.g. TCP
00444  * timestamps, internal timeouts for NO_SYS==1).
00445  */
00446 u32_t sys_now(void);
00447 
00448 /* Critical Region Protection */
00449 /* These functions must be implemented in the sys_arch.c file.
00450    In some implementations they can provide a more light-weight protection
00451    mechanism than using semaphores. Otherwise semaphores can be used for
00452    implementation */
00453 #ifndef SYS_ARCH_PROTECT
00454 /** SYS_LIGHTWEIGHT_PROT
00455  * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
00456  * for certain critical regions during buffer allocation, deallocation and memory
00457  * allocation and deallocation.
00458  */
00459 #if SYS_LIGHTWEIGHT_PROT
00460 
00461 /**
00462  * @ingroup sys_prot
00463  * SYS_ARCH_DECL_PROTECT
00464  * declare a protection variable. This macro will default to defining a variable of
00465  * type sys_prot_t. If a particular port needs a different implementation, then
00466  * this macro may be defined in sys_arch.h.
00467  */
00468 #define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev
00469 /**
00470  * @ingroup sys_prot
00471  * SYS_ARCH_PROTECT
00472  * Perform a "fast" protect. This could be implemented by
00473  * disabling interrupts for an embedded system or by using a semaphore or
00474  * mutex. The implementation should allow calling SYS_ARCH_PROTECT when
00475  * already protected. The old protection level is returned in the variable
00476  * "lev". This macro will default to calling the sys_arch_protect() function
00477  * which should be implemented in sys_arch.c. If a particular port needs a
00478  * different implementation, then this macro may be defined in sys_arch.h
00479  */
00480 #define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect()
00481 /**
00482  * @ingroup sys_prot
00483  * SYS_ARCH_UNPROTECT
00484  * Perform a "fast" set of the protection level to "lev". This could be
00485  * implemented by setting the interrupt level to "lev" within the MACRO or by
00486  * using a semaphore or mutex.  This macro will default to calling the
00487  * sys_arch_unprotect() function which should be implemented in
00488  * sys_arch.c. If a particular port needs a different implementation, then
00489  * this macro may be defined in sys_arch.h
00490  */
00491 #define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev)
00492 sys_prot_t sys_arch_protect(void);
00493 void sys_arch_unprotect(sys_prot_t pval);
00494 
00495 #else
00496 
00497 #define SYS_ARCH_DECL_PROTECT(lev)
00498 #define SYS_ARCH_PROTECT(lev)
00499 #define SYS_ARCH_UNPROTECT(lev)
00500 
00501 #endif /* SYS_LIGHTWEIGHT_PROT */
00502 
00503 #endif /* SYS_ARCH_PROTECT */
00504 
00505 /*
00506  * Macros to set/get and increase/decrease variables in a thread-safe way.
00507  * Use these for accessing variable that are used from more than one thread.
00508  */
00509 
00510 #ifndef SYS_ARCH_INC
00511 #define SYS_ARCH_INC(var, val) do { \
00512                                 SYS_ARCH_DECL_PROTECT(old_level); \
00513                                 SYS_ARCH_PROTECT(old_level); \
00514                                 var += val; \
00515                                 SYS_ARCH_UNPROTECT(old_level); \
00516                               } while(0)
00517 #endif /* SYS_ARCH_INC */
00518 
00519 #ifndef SYS_ARCH_DEC
00520 #define SYS_ARCH_DEC(var, val) do { \
00521                                 SYS_ARCH_DECL_PROTECT(old_level); \
00522                                 SYS_ARCH_PROTECT(old_level); \
00523                                 var -= val; \
00524                                 SYS_ARCH_UNPROTECT(old_level); \
00525                               } while(0)
00526 #endif /* SYS_ARCH_DEC */
00527 
00528 #ifndef SYS_ARCH_GET
00529 #define SYS_ARCH_GET(var, ret) do { \
00530                                 SYS_ARCH_DECL_PROTECT(old_level); \
00531                                 SYS_ARCH_PROTECT(old_level); \
00532                                 ret = var; \
00533                                 SYS_ARCH_UNPROTECT(old_level); \
00534                               } while(0)
00535 #endif /* SYS_ARCH_GET */
00536 
00537 #ifndef SYS_ARCH_SET
00538 #define SYS_ARCH_SET(var, val) do { \
00539                                 SYS_ARCH_DECL_PROTECT(old_level); \
00540                                 SYS_ARCH_PROTECT(old_level); \
00541                                 var = val; \
00542                                 SYS_ARCH_UNPROTECT(old_level); \
00543                               } while(0)
00544 #endif /* SYS_ARCH_SET */
00545 
00546 #ifndef SYS_ARCH_LOCKED
00547 #define SYS_ARCH_LOCKED(code) do { \
00548                                 SYS_ARCH_DECL_PROTECT(old_level); \
00549                                 SYS_ARCH_PROTECT(old_level); \
00550                                 code; \
00551                                 SYS_ARCH_UNPROTECT(old_level); \
00552                               } while(0)
00553 #endif /* SYS_ARCH_LOCKED */
00554 
00555 
00556 #ifdef __cplusplus
00557 }
00558 #endif
00559 
00560 #endif /* LWIP_HDR_SYS_H */