Debian Codegraph @

contrib/ports/unix/port/include/arch/sys_arch.h

raw
1 /*
2 * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 * OF SUCH DAMAGE.
26 *
27 * This file is part of the lwIP TCP/IP stack.
28 *
29 * Author: Adam Dunkels <[email protected]>
30 *
31 */
32 #ifndef LWIP_ARCH_SYS_ARCH_H
33 #define LWIP_ARCH_SYS_ARCH_H
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #define SYS_MBOX_NULL NULL
40 #define SYS_SEM_NULL NULL
41
42 /*typedef u32_t sys_prot_t;*/
43
44 struct sys_sem;
45 typedef struct sys_sem * sys_sem_t;
46 #define sys_sem_valid(sem) (((sem) != NULL) && (*(sem) != NULL))
47 #define sys_sem_valid_val(sem) ((sem) != NULL)
48 #define sys_sem_set_invalid(sem) do { if((sem) != NULL) { *(sem) = NULL; }}while(0)
49 #define sys_sem_set_invalid_val(sem) do { (sem) = NULL; }while(0)
50
51 struct sys_mutex;
52 typedef struct sys_mutex * sys_mutex_t;
53 #define sys_mutex_valid(mutex) sys_sem_valid(mutex)
54 #define sys_mutex_set_invalid(mutex) sys_sem_set_invalid(mutex)
55
56 struct sys_mbox;
57 typedef struct sys_mbox * sys_mbox_t;
58 #define sys_mbox_valid(mbox) sys_sem_valid(mbox)
59 #define sys_mbox_valid_val(mbox) sys_sem_valid_val(mbox)
60 #define sys_mbox_set_invalid(mbox) sys_sem_set_invalid(mbox)
61 #define sys_mbox_set_invalid_val(mbox) sys_sem_set_invalid_val(mbox)
62
63 struct sys_thread;
64 typedef struct sys_thread * sys_thread_t;
65
66 #if LWIP_NETCONN_SEM_PER_THREAD
67 sys_sem_t* sys_arch_netconn_sem_get(void);
68 void sys_arch_netconn_sem_alloc(void);
69 void sys_arch_netconn_sem_free(void);
70 #define LWIP_NETCONN_THREAD_SEM_GET() sys_arch_netconn_sem_get()
71 #define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_arch_netconn_sem_alloc()
72 #define LWIP_NETCONN_THREAD_SEM_FREE() sys_arch_netconn_sem_free()
73 #endif /* #if LWIP_NETCONN_SEM_PER_THREAD */
74
75 #define LWIP_EXAMPLE_APP_ABORT() lwip_unix_keypressed()
76 int lwip_unix_keypressed(void);
77
78 /*
79 ---------------------------------------
80 ---------- Threading options ----------
81 ---------------------------------------
82 */
83
84 void sys_mark_tcpip_thread(void);
85 #define LWIP_MARK_TCPIP_THREAD() sys_mark_tcpip_thread()
86
87 #if LWIP_TCPIP_CORE_LOCKING
88 void sys_lock_tcpip_core(void);
89 #define LOCK_TCPIP_CORE() sys_lock_tcpip_core()
90 void sys_unlock_tcpip_core(void);
91 #define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core()
92 #endif
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif /* LWIP_ARCH_SYS_ARCH_H */