revert between 56095 -> 55830 in arch
[AROS.git] / workbench / network / stacks / AROSTCP / bsdsocket / api / amiga_libcallentry.h
blob0ca10bfbd5211335be4c49e78b217d48ad6fd2f8
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 AMIGA_LIBCALLENTRY_H
24 #define AMIGA_LIBCALLENTRY_H
26 #ifndef AMIGA_API_H
27 #error include amiga_api.h before this (libcallentry.h)
28 #endif
30 #ifndef SYS_CDEFS_H
31 #include <sys/cdefs.h>
32 #endif
34 #ifndef SYS_ERRNO_H
35 #include <sys/errno.h>
36 #endif
38 #ifndef SYS_SYSLOG_H
39 #include <sys/syslog.h>
40 #endif
43 * The following macros are written in each socket library functions
44 * (execpt Errno()). they makes sure that the task that calls library
45 * functions is the opener task of the socketbase it is using.
48 extern const char wrongTaskErrorFmt[];
50 #define CHECK_TASK() \
51 if (libPtr->thisTask != FindTask(NULL)) { \
52 struct Task * wTask = FindTask(NULL); \
53 __log(LOG_CRIT, wrongTaskErrorFmt, wTask, \
54 wTask->tc_Node.ln_Name, libPtr->thisTask, \
55 libPtr->thisTask->tc_Node.ln_Name); \
56 return -1; \
59 #define CHECK_TASK_NULL() \
60 if (libPtr->thisTask != FindTask(NULL)) { \
61 struct Task * wTask = FindTask(NULL); \
62 __log(LOG_CRIT, wrongTaskErrorFmt, wTask, \
63 wTask->tc_Node.ln_Name, libPtr->thisTask, \
64 libPtr->thisTask->tc_Node.ln_Name); \
65 return NULL; \
68 #define CHECK_TASK2() CHECK_TASK_NULL()
70 #define CHECK_TASK_VOID() \
71 if (libPtr->thisTask != FindTask(NULL)) { \
72 struct Task * wTask = FindTask(NULL); \
73 __log(LOG_CRIT, wrongTaskErrorFmt, wTask, \
74 wTask->tc_Node.ln_Name, libPtr->thisTask, \
75 libPtr->thisTask->tc_Node.ln_Name); \
76 return; \
79 #define API_STD_RETURN(error, ret) \
80 if (error == 0) \
81 return ret; \
82 writeErrnoValue(libPtr, error); \
83 return -1;
86 * getSock() gets a socket referenced by given filedescriptor if exists,
87 * returns EBADF (bad file descriptor) if not. (because this now uses
88 * struct socket * pointer and those are often register variables, perhaps
89 * some kind of change is to be done here).
92 static inline LONG getSock(struct SocketBase *p, int fd, struct socket **sop)
94 register struct socket *so;
96 if ((unsigned)fd >= p->dTableSize || (so = p->dTable[(short)fd]) == NULL)
97 return (EBADF);
98 *sop = so;
99 return 0;
103 * Prototype for sdFind. This is located in amiga_syscalls.c and replaces
104 * fdAlloc there. libPtr->nextDToSearch is dumped.
106 LONG sdFind(struct SocketBase * libPtr, LONG *fdp);
108 #ifndef AMIGA_RAF_H
109 #include <api/amiga_raf.h>
110 #endif
112 #endif /* !AMIGA_LIBCALLENTRY_H */