Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / network / stacks / AROSTCP / bsdsocket / sys / synch.h
blob8abb9a28ca8e59a8588ac5ac1964df283cca0561
1 /*
2 * Copyright (C) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
4 * All rights reserved.
5 * Copyright (C) 2005 Neil Cafferkey
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19 * MA 02111-1307, USA.
23 #ifndef SYS_SYNCH_H
24 #define SYS_SYNCH_H
26 #ifndef SYS_TYPES_H
27 #include <sys/types.h>
28 #endif
30 #ifndef EXEC_TYPES_H
31 #include <exec/types.h>
32 #endif
34 #ifndef SYS_TIME_H
35 #include <sys/time.h>
36 #endif
38 #if !defined(AMIGA_INCLUDES_H) && defined(DEBUG)
39 #include <kern/amiga_includes.h> /* for the inline spl_n() */
40 #endif
42 #include <proto/exec.h>
44 extern BOOL sleep_init(void);
45 extern void tsleep_send_timeout(struct SocketBase *, const struct timeval *);
46 extern void tsleep_abort_timeout(struct SocketBase *, const struct timeval *);
47 extern void tsleep_enter(struct SocketBase *, caddr_t, const char *);
48 extern int tsleep_main(struct SocketBase *, ULONG blockmask);
49 extern int tsleep(struct SocketBase *, caddr_t, const char *,const struct timeval *);
50 extern void wakeup(caddr_t);
53 * Spl-levels used in this implementation
55 #define SPL0 0
56 #define SPLSOFTCLOCK 1
57 #define SPLNET 2
58 #define SPLIMP 3
61 * Spl-function prototypes and definitions.
63 * spl_t is the return type of the spl_n(). It should be used when defining
64 * storage to store the return value, using int may be little slower :-)
67 extern BOOL spl_init(void);
69 /*#ifdef DEBUG*/ /* NC */
70 #if 1
72 typedef int spl_t;
74 extern spl_t spl_n(spl_t newlevel);
76 #define spl0() spl_n(SPL0)
77 #define splsoftclock() spl_n(SPLSOFTCLOCK)
78 #define splnet() spl_n(SPLNET)
79 #define splimp() spl_n(SPLIMP)
80 #define splx(s) spl_n(s)
82 #else
84 typedef BYTE spl_t; /* the type of SysBase->TDNestCnt */
86 extern struct ExecBase * SysBase;
88 extern spl_t spl_level;
90 static inline spl_t
91 splx(spl_t new_level)
93 spl_t old_level;
95 old_level = spl_level;
96 if(spl_level == SPL0 && new_level > SPL0)
97 Forbid();
98 spl_level = new_level;
99 if(old_level > SPL0 && new_level == SPL0)
100 Permit();
102 return old_level;
105 #define spl0() splx(SPL0)
106 #define splsoftclock() splx(SPLSOFTCLOCK)
107 #define splnet() splx(SPLNET)
108 #define splimp() splx(SPLIMP)
110 #endif /* DEBUG */
112 #endif /* !SYS_SYNCH_H */