2 * Copyright (C) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
3 * Helsinki University of Technology, Finland.
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,
23 #ifndef AMIGA_LIBCALLENTRY_H
24 #define AMIGA_LIBCALLENTRY_H
27 #error include amiga_api.h before this (libcallentry.h)
31 #include <sys/cdefs.h>
35 #include <sys/errno.h>
39 #include <sys/syslog.h>
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); \
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); \
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); \
79 #define API_STD_RETURN(error, ret) \
82 writeErrnoValue(libPtr, error); \
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
)
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
);
109 #include <api/amiga_raf.h>
112 #endif /* !AMIGA_LIBCALLENTRY_H */