Netservices modded to read fragmented HTTP respsonse/payload from special purpose server - 180 bytes only

Committer:
RodColeman
Date:
Thu Sep 08 10:41:36 2011 +0000
Revision:
0:8f5825f330b0
setDataLen hacked to 180bytes

Who changed what in which revision?

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