From b02e50be3e853e6a67c9ed986b994fbeebb0f0a5 Mon Sep 17 00:00:00 2001
From: Eric Andersen <andersen@codepoet.org>
Date: Tue, 16 Jan 2001 10:08:27 +0000
Subject: Facelist/cleanup for several syscalls.  Added poll.

---
 libc/sysdeps/linux/arm/bits/poll.h   |  51 ++++++++++++++++
 libc/sysdeps/linux/common/syscalls.c | 109 ++++++++++-------------------------
 libc/sysdeps/linux/common/tell.c     |   8 +--
 libc/sysdeps/linux/i386/bits/poll.h  |  51 ++++++++++++++++
 libc/sysdeps/linux/m68k/bits/poll.h  |   9 ++-
 5 files changed, 139 insertions(+), 89 deletions(-)
 create mode 100644 libc/sysdeps/linux/arm/bits/poll.h
 create mode 100644 libc/sysdeps/linux/i386/bits/poll.h

(limited to 'libc')

diff --git a/libc/sysdeps/linux/arm/bits/poll.h b/libc/sysdeps/linux/arm/bits/poll.h
new file mode 100644
index 000000000..4aec021fe
--- /dev/null
+++ b/libc/sysdeps/linux/arm/bits/poll.h
@@ -0,0 +1,51 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _SYS_POLL_H
+# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#endif
+
+/* Event types that can be polled for.  These bits may be set in `events'
+   to indicate the interesting event types; they will appear in `revents'
+   to indicate the status of the file descriptor.  */
+#define POLLIN		0x001		/* There is data to read.  */
+#define POLLPRI		0x002		/* There is urgent data to read.  */
+#define POLLOUT		0x004		/* Writing now will not block.  */
+
+#ifdef __USE_XOPEN
+/* These values are defined in XPG4.2.  */
+# define POLLRDNORM	0x040		/* Normal data may be read.  */
+# define POLLRDBAND	0x080		/* Priority data may be read.  */
+# define POLLWRNORM	0x100		/* Writing now will not block.  */
+# define POLLWRBAND	0x200		/* Priority data may be written.  */
+#endif
+
+#ifdef __USE_GNU
+/* This is an extension for Linux.  */
+# define POLLMSG	0x400
+#endif
+
+/* Event types always implicitly polled for.  These bits need not be set in
+   `events', but they will appear in `revents' to indicate the status of
+   the file descriptor.  */
+#define POLLERR		0x008		/* Error condition.  */
+#define POLLHUP		0x010		/* Hung up.  */
+#define POLLNVAL	0x020		/* Invalid polling request.  */
+
+/* Canonical number of polling requests to read in at a time in poll.  */
+#define NPOLLFILE	30
diff --git a/libc/sysdeps/linux/common/syscalls.c b/libc/sysdeps/linux/common/syscalls.c
index 534f3779c..f426c3f7f 100644
--- a/libc/sysdeps/linux/common/syscalls.c
+++ b/libc/sysdeps/linux/common/syscalls.c
@@ -668,9 +668,7 @@ _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
 //#define __NR_ioperm           101
 #ifdef L_ioperm
 #include <sys/io.h>
-syscall3(int, ioperm, unsigned, long, from, unsigned long, num, int,
-
-		 turn_on);
+_syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
 #endif
 #endif
 
@@ -808,12 +806,13 @@ _syscall1(int, swapoff, const char *, path);
 //#define __NR_sysinfo          116
 #ifdef L_sysinfo
 #include <sys/sysinfo.h>
-_sysinfo(int, sysinfo, struct sysinfo *, info);
+_syscall1(int, sysinfo, struct sysinfo *, info);
 #endif
 
 //#define __NR_ipc              117
-#ifdef L_ipc
-//_syscall6(int,ipc,unsigned int,call, int,first, int,second, int,third, void *,ptr, long, fifth);
+#ifdef L___ipc
+#define __NR___ipc __NR_ipc
+_syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
 #endif
 
 //#define __NR_fsync            118
@@ -892,15 +891,9 @@ _syscall1(int, fchdir, int, fd);
 //#define __NR_afs_syscall      137
 
 //#define __NR_setfsuid         138
-#ifdef L_setfsuid
-SYSCALL__(setfsuid, 1)
-	ret
-#endif
+
 //#define __NR_setfsgid         139
-#ifdef L_setfsgid
-	SYSCALL__(setfsgid, 1)
-	ret
-#endif
+
 //#define __NR__llseek          140
 #ifdef L__llseek
 extern int _llseek(int fd, off_t hoff, off_t loff, loff_t *res, int whence);
@@ -951,14 +944,11 @@ _syscall2(int,flock,int,fd, int,operation);
 #endif
 
 //#define __NR_msync            144
-#ifdef L_msync
-	SYSCALL__(msync, 3)
-	ret
-#endif
 //#define __NR_readv            145
+
 #ifdef L_readv
 #include <sys/uio.h>
-	_syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
+_syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
 		  count);
 #endif
 
@@ -976,97 +966,55 @@ _syscall1(pid_t, getsid, pid_t, pid);
 #endif
 
 //#define __NR_fdatasync        148
-#ifdef L_fdatasync
-	SYSCALL__(fdatasync, 1)
-	ret
-#endif
+//
 //#define __NR__sysctl          149
+//#ifdef L_sysctl
+//_syscall1(int, sysctl, struct __sysctl_args *, args);
+//#endif	
+
 //#define __NR_mlock            150
-#ifdef L_mlock
-	SYSCALL__(mlock, 2)
-	ret
-#endif
 //#define __NR_munlock          151
-#ifdef L_munlock
-	SYSCALL__(munlock, 2)
-	ret
-#endif
 //#define __NR_mlockall         152
-#ifdef L_mlockall
-	SYSCALL__(mlockall, 1)
-	ret
-#endif
 //#define __NR_munlockall       153
-#ifdef L_munlockall
-	SYSCALL__(munlockall, 0)
-	ret
-#endif
 //#define __NR_sched_setparam   154
-#ifdef L_sched_setparam
-	SYSCALL__(sched_setparam, 2)
-	ret
-#endif
 //#define __NR_sched_getparam   155
-#ifdef L_sched_getparam
-	SYSCALL__(sched_getparam, 2)
-	ret
-#endif
 //#define __NR_sched_setscheduler       156
-#ifdef L_sched_setscheduler
-	SYSCALL__(sched_setscheduler, 3)
-	ret
-#endif
 //#define __NR_sched_getscheduler       157
-#ifdef L_sched_getscheduler
-	SYSCALL__(sched_getscheduler, 1)
-	ret
-#endif
 //#define __NR_sched_yield              158
-#ifdef L_sched_yield
-	SYSCALL__(sched_yield, 0)
-	ret
-#endif
 //#define __NR_sched_get_priority_max   159
-#ifdef L_sched_get_priority_max
-	SYSCALL__(sched_get_priority_max, 1)
-	ret
-#endif
 //#define __NR_sched_get_priority_min   160
-#ifdef L_sched_get_priority_min
-	SYSCALL__(sched_get_priority_min, 1)
-	ret
-#endif
 //#define __NR_sched_rr_get_interval    161
-#ifdef L_sched_rr_get_interval
-	SYSCALL__(sched_rr_get_interval, 2)
-	ret
-#endif
+
 //#define __NR_nanosleep                162
 #ifdef L_nanosleep
-	SYSCALL__(nanosleep, 2)
-	ret
+#include <time.h>
+_syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem);
 #endif
+
 //#define __NR_mremap                   163
 #ifdef L_mremap
 #include <unistd.h>
 #include <sys/mman.h>
-	_syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t,
+_syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t,
 		  new_size, int, may_move);
 #endif
 
 //#define __NR_setresuid                164
-
 //#define __NR_getresuid                165
-
 //#define __NR_vm86                     166
 
 //#define __NR_query_module             167
+#ifdef L_query_module
+_syscall5(int, query_module, const char *, name, int, which,
+		void *, buf, size_t, bufsize, size_t*, ret);
+#endif	
 
 //#define __NR_poll                     168
 #ifdef L_poll
-SYSCALL__(poll, 3)
-	ret
+#include <sys/poll.h>
+_syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
 #endif
+
 //#define __NR_nfsservctl               169
 //#define __NR_setresgid                170
 //#define __NR_getresgid                171
@@ -1083,10 +1031,11 @@ SYSCALL__(poll, 3)
 //#define __NR_chown                    182
 #ifdef L_chown
 #include <unistd.h>
-	_syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
+_syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
 #endif
 
 //#define __NR_getcwd                   183
+// See unistd/getcwd.c -- we don't use the syscall, even when it is available...
 
 //#define __NR_capget                   184
 
@@ -1101,6 +1050,6 @@ SYSCALL__(poll, 3)
 //#define __NR_putpmsg                  189
 
 //#define __NR_vfork                    190
-//See architecture specific implementation...
+//See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
 
 
diff --git a/libc/sysdeps/linux/common/tell.c b/libc/sysdeps/linux/common/tell.c
index dcae83206..e02001d0d 100644
--- a/libc/sysdeps/linux/common/tell.c
+++ b/libc/sysdeps/linux/common/tell.c
@@ -1,16 +1,10 @@
-#define lseek __normal_lseek
 #include <errno.h>
 #include <unistd.h>
 #include <syscall.h>
-#undef lseek
-
-static inline
-_syscall3(off_t,lseek,int,fildes,off_t,offset,int,origin)
 
 off_t tell(int);
 
-off_t
-tell (int fildes)
+off_t tell (int fildes)
 {
   return lseek (fildes, 0, SEEK_CUR);
 }
diff --git a/libc/sysdeps/linux/i386/bits/poll.h b/libc/sysdeps/linux/i386/bits/poll.h
new file mode 100644
index 000000000..4aec021fe
--- /dev/null
+++ b/libc/sysdeps/linux/i386/bits/poll.h
@@ -0,0 +1,51 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _SYS_POLL_H
+# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#endif
+
+/* Event types that can be polled for.  These bits may be set in `events'
+   to indicate the interesting event types; they will appear in `revents'
+   to indicate the status of the file descriptor.  */
+#define POLLIN		0x001		/* There is data to read.  */
+#define POLLPRI		0x002		/* There is urgent data to read.  */
+#define POLLOUT		0x004		/* Writing now will not block.  */
+
+#ifdef __USE_XOPEN
+/* These values are defined in XPG4.2.  */
+# define POLLRDNORM	0x040		/* Normal data may be read.  */
+# define POLLRDBAND	0x080		/* Priority data may be read.  */
+# define POLLWRNORM	0x100		/* Writing now will not block.  */
+# define POLLWRBAND	0x200		/* Priority data may be written.  */
+#endif
+
+#ifdef __USE_GNU
+/* This is an extension for Linux.  */
+# define POLLMSG	0x400
+#endif
+
+/* Event types always implicitly polled for.  These bits need not be set in
+   `events', but they will appear in `revents' to indicate the status of
+   the file descriptor.  */
+#define POLLERR		0x008		/* Error condition.  */
+#define POLLHUP		0x010		/* Hung up.  */
+#define POLLNVAL	0x020		/* Invalid polling request.  */
+
+/* Canonical number of polling requests to read in at a time in poll.  */
+#define NPOLLFILE	30
diff --git a/libc/sysdeps/linux/m68k/bits/poll.h b/libc/sysdeps/linux/m68k/bits/poll.h
index 2d4e6f6f0..4aec021fe 100644
--- a/libc/sysdeps/linux/m68k/bits/poll.h
+++ b/libc/sysdeps/linux/m68k/bits/poll.h
@@ -31,8 +31,13 @@
 /* These values are defined in XPG4.2.  */
 # define POLLRDNORM	0x040		/* Normal data may be read.  */
 # define POLLRDBAND	0x080		/* Priority data may be read.  */
-# define POLLWRNORM	POLLOUT		/* Writing now will not block.  */
-# define POLLWRBAND	0x100		/* Priority data may be written.  */
+# define POLLWRNORM	0x100		/* Writing now will not block.  */
+# define POLLWRBAND	0x200		/* Priority data may be written.  */
+#endif
+
+#ifdef __USE_GNU
+/* This is an extension for Linux.  */
+# define POLLMSG	0x400
 #endif
 
 /* Event types always implicitly polled for.  These bits need not be set in
-- 
cgit v1.2.3