Index: extra/scripts/gen_bits_syscall_h.sh =================================================================== --- extra/scripts/gen_bits_syscall_h.sh (revision 22095) +++ extra/scripts/gen_bits_syscall_h.sh (working copy) @@ -34,7 +34,8 @@ $CC -E $INCLUDE_OPTS - | echo "#ifndef _BITS_SYSNUM_H" ; echo "#define _BITS_SYSNUM_H" ; echo ; - echo "#ifndef _SYSCALL_H" ; + echo "#if !defined _SYSCALL_H || \\" ; + echo " !(defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc))" ; echo "# error \"Never use directly; include instead.\"" ; echo "#endif" ; echo ; sed -ne 's/^UCLIBC_\([A-Za-z0-9_]*\) *\(.*\)/#undef __NR_\1\ Index: extra/Configs/Config.in =================================================================== --- extra/Configs/Config.in (revision 22095) +++ extra/Configs/Config.in (working copy) @@ -538,17 +538,52 @@ config UCLIBC_HAS___PROGNAME If unsure, just answer N. +config UCLIBC_HAS_GNU_ERROR + bool "Support for GNU extensions for error-reporting" + default n + help + Support for the GNU-specific error(), error_at_line(), + void (* error_print_progname)(), error_message_count + functions and variables. Some GNU packages + utilize these for extra useful output, but in general + are not required. + + If unsure, just answer N. + +config UCLIBC_HAS_PTY + bool "Support for pseudo-terminals" + default y + help + This enables support for pseudo-terminals (see man 4 pts + and man 7 pty). + + If unsure, just answer Y. + config UNIX98PTY_ONLY bool "Support only Unix 98 PTYs" default y + depends on UCLIBC_HAS_PTY help If you want to support only Unix 98 PTYs enable this. Some older applications may need this disabled. For most current programs, you can generally answer Y. +config UCLIBC_HAS_GETPT + bool "Support getpt() (glibc-compat)" + default n + depends on UCLIBC_HAS_PTY + help + Some packages may need getpt(). + All of those are non-standard and can be considered + GNU/libc compatibility. + Either use posix_openpt() or just open /dev/ptmx yourself. + + If unsure, just say N. + config ASSUME_DEVPTS bool "Assume that /dev/pts is a devpts or devfs file system" default y + depends on UCLIBC_HAS_PTY help Enable this if /dev/pts is on a devpts or devfs filesystem. Both these filesystems automatically manage permissions on the /dev/pts @@ -649,6 +684,23 @@ config UCLIBC_GRP_BUFFER_SIZE The value can be found using sysconf() with the _SC_GETGR_R_SIZE_MAX parameter. +config UCLIBC_SYSCALL_STUBS + bool "Provide stubs for unavailable syscalls" + default n + help + Provide a stub that sets errno to ENOSYS for syscalls that + are not available in your kernel. + +config UCLIBC_SYSCALL_STUB_WARNING + bool "Enable link-time warning for stubs" + default y + depends on UCLIBC_SYSCALL_STUBS + help + Emit link-time warning when an application tries to link + against a stubbed-out syscall. + +comment "Syscall availability" + config UCLIBC_LINUX_MODULE_24 bool "linux <= 2.4 kernel module functions" default n @@ -658,6 +710,154 @@ config UCLIBC_LINUX_MODULE_24 Say N unless you are using an old kernel and require module support. +config UCLIBC_LINUX_SPECIFIC + bool "Linux specific functions" + default y + help + fstatfs(), inotify_*(), ioperm(), iopl(), madvise(), modify_ldt(), + personality() + +config UCLIBC_BSD_SPECIFIC + bool "BSD specific functions" + default n + help + mincore(), getdomainname(), setdomainname() + +config UCLIBC_NTP_LEGACY + bool "ntp_*() functions" + default n + help + ntp_adjtime(), ntp_gettime() aliases. + +config UCLIBC_SV4_DEPRECATED + bool "Enable SVr4 deprecated functions" + default n + help + These functions are DEPRECATED in System V release 4. + Say N unless you desparately need one of the functions below: + + ustat() [use statfs(2) in your code instead] + +config UCLIBC_HAVE_REALTIME + bool "Realtime-related family of SUSv functions" + default y + help + These functions are part of the Timers option and need not + be available on all implementations. + Includes AIO, message-queue, scheduler, semaphore functions: + + aio.h + mqueue.h + sched.h + semaphore.h + + aio_cancel() + aio_error() + aio_fsync() + aio_read() + aio_return() + aio_suspend() + aio_write() + clock_getres(), clock_gettime, clock_settime + clock_settime() + fdatasync() + lio_listio() + mlockall(), munlockall + mlock(), munlock + mq_close() + mq_getattr() + mq_notify() + mq_open() + mq_receive(), mq_timedreceive + mq_send(), mq_timedsend + mq_setattr() + mq_unlink() + nanosleep() + sched_getparam() + sched_get_priority_max(), sched_get_priority_min + sched_getscheduler() + sched_rr_get_interval() + sched_setparam() + sched_setscheduler() + sem_close() + sem_destroy() + sem_getvalue() + sem_init() + sem_open() + sem_post() + sem_trywait(), sem_wait + sem_unlink() + sem_wait() + shm_open() + shm_unlink() + sigqueue() + sigtimedwait(), sigwaitinfo + sigwaitinfo() + timer_create() + timer_delete() + timer_getoverrun(), timer_gettime, timer_settime + + +config UCLIBC_HAVE_ADVANCED_REALTIME + bool "Advanced realtime-related family of SUSv functions" + default y + depends on UCLIBC_HAVE_REALTIME + help + These functions are part of the Timers option and need not + be available on all implementations. + + clock_getcpuclockid() + clock_nanosleep() + mq_timedreceive() + mq_timedsend() + posix_fadvise() + posix_fallocate() + posix_madvise() + posix_memalign() + posix_mem_offset() + posix_spawnattr_destroy(), posix_spawnattr_init + posix_spawnattr_getflags(), posix_spawnattr_setflags + posix_spawnattr_getpgroup(), posix_spawnattr_setpgroup + posix_spawnattr_getschedparam(), posix_spawnattr_setschedparam + posix_spawnattr_getschedpolicy(), posix_spawnattr_setschedpolicy + posix_spawnattr_getsigdefault(), posix_spawnattr_setsigdefault + posix_spawnattr_getsigmask(), posix_spawnattr_setsigmask + posix_spawnattr_init() + posix_spawnattr_setflags() + posix_spawnattr_setpgroup() + posix_spawnattr_setschedparam() + posix_spawnattr_setschedpolicy() + posix_spawnattr_setsigdefault() + posix_spawnattr_setsigmask() + posix_spawn_file_actions_addclose(), posix_spawn_file_actions_addopen + posix_spawn_file_actions_adddup2() + posix_spawn_file_actions_addopen() + posix_spawn_file_actions_destroy(), posix_spawn_file_actions_init + posix_spawn_file_actions_init() + posix_spawn(), posix_spawnp + posix_spawnp() + posix_typed_mem_get_info() + pthread_mutex_timedlock() + sem_timedwait() + +config UCLIBC_HAVE_EPOLL + bool "epoll" + default y + help + epoll_create(), epoll_ctl(), epoll_wait() functions. + +config UCLIBC_HAVE_XATTR + bool "Extended Attributes" + default y + help + Extended Attributes support. + +config UCLIBC_HAVE_PROFILING + bool "Profiling support" + default n + help + gcc's -finstrument-functions needs these. + endmenu menu "Networking Support" Index: include/sys/syscall.h =================================================================== --- include/sys/syscall.h (revision 22095) +++ include/sys/syscall.h (working copy) @@ -32,6 +32,9 @@ #include #if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) # include +# if 00 // && ndef __SYSCALL_STUB +# include +# endif #endif #endif Index: Makerules =================================================================== --- Makerules (revision 22095) +++ Makerules (working copy) @@ -208,7 +208,7 @@ $(ldso): $(libc): @cd $(top_builddir); $(MAKE) lib/$(patsubst %.$(MAJOR_VERSION),%,$(notdir $@)) -$(headers_dep): +$(headers_dep): $(top_srcdir)extra/scripts/gen_bits_syscall_h.sh $(Q)cd $(top_builddir); $(MAKE) pregen CRT := crt1 Index: ldso/include/dl-syscall.h =================================================================== --- ldso/include/dl-syscall.h (revision 22095) +++ ldso/include/dl-syscall.h (working copy) @@ -51,7 +51,7 @@ #define S_IEXEC 0100 /* Execute by owner. */ - +#include /* Here are the definitions for some syscalls that are used by the dynamic linker. The idea is that we want to be able to call these before the errno symbol is dynamicly linked, so @@ -59,7 +59,11 @@ dynamic linking at all, so we cannot return any error codes. We just punt if there is an error. */ #define __NR__dl_exit __NR_exit -static __always_inline _syscall1(void, _dl_exit, int, status); +static __always_inline attribute_noreturn void _dl_exit(int status) +{ + while (1) + INLINE_SYSCALL(exit, 1, status); +} #define __NR__dl_close __NR_close static __always_inline _syscall1(int, _dl_close, int, fd); Index: libutil/Makefile.in =================================================================== --- libutil/Makefile.in (revision 22095) +++ libutil/Makefile.in (working copy) @@ -20,6 +20,10 @@ libutil_SRC := $(wildcard $(libutil_DIR) ifneq ($(ARCH_USE_MMU),y) libutil_SRC := $(filter-out $(libutil_DIR)/forkpty.c,$(libutil_SRC)) endif +ifneq ($(UCLIBC_HAS_PTY),y) +libutil_SRC := $(filter-out $(libutil_DIR)/openpty.c $(libutil_DIR)/forkpty.c \ + ,$(libutil_SRC)) +endif libutil_OBJ := $(patsubst $(libutil_DIR)/%.c,$(libutil_OUT)/%.o,$(libutil_SRC)) ifeq ($(DOPIC),y) Index: libc/inet/resolv.c =================================================================== --- libc/inet/resolv.c (revision 22095) +++ libc/inet/resolv.c (working copy) @@ -187,7 +187,6 @@ libc_hidden_proto(fopen) libc_hidden_proto(fclose) libc_hidden_proto(random) libc_hidden_proto(getservbyport) -libc_hidden_proto(getdomainname) libc_hidden_proto(uname) libc_hidden_proto(inet_addr) libc_hidden_proto(inet_aton) @@ -222,7 +221,8 @@ libc_hidden_proto(__ctype_b_loc) libc_hidden_proto(__ctype_b) #endif libc_hidden_proto(__uc_malloc) - +extern __typeof(getdomainname) __libc_getdomainname; +libc_hidden_proto(__libc_getdomainname) #define MAX_RECURSE 5 @@ -1886,7 +1886,7 @@ BAD_FAM: if (h) { char *c; if ((flags & NI_NOFQDN) - && (getdomainname (domain, sizeof(domain)) == 0) + && (__libc_getdomainname (domain, sizeof(domain)) == 0) && (c = strstr (h->h_name, domain)) && (c != h->h_name) && (*(--c) == '.')) { strncpy (host, h->h_name, Index: libc/stdlib/Makefile.in =================================================================== --- libc/stdlib/Makefile.in (revision 22095) +++ libc/stdlib/Makefile.in (working copy) @@ -12,16 +12,21 @@ include $(top_srcdir)libc/stdlib/malloc- CSRC := \ abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c \ rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \ - getpt.c ptsname.c grantpt.c unlockpt.c drand48-iter.c jrand48.c \ + getpt.c drand48-iter.c jrand48.c \ jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \ nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \ valloc.c posix_memalign.c a64l.c l64a.c __uc_malloc.c + +ifeq ($(UCLIBC_HAS_PTY),y) +CSRC += grantpt.c unlockpt.c ptsname.c +endif ifeq ($(UCLIBC_HAS_ARC4RANDOM),y) CSRC += arc4random.c endif ifeq ($(UCLIBC_HAS_LFS),y) CSRC += mkstemp64.c endif + ifeq ($(UCLIBC_HAS_FLOATS),y) CSRC += drand48.c drand48_r.c erand48.c erand48_r.c ifeq ($(UCLIBC_SUSV3_LEGACY),y) Index: libc/stdlib/getpt.c =================================================================== --- libc/stdlib/getpt.c (revision 22095) +++ libc/stdlib/getpt.c (working copy) @@ -20,8 +20,13 @@ #include #include #include +#include #include #include +#include + +extern __typeof(statfs) __libc_statfs; +libc_hidden_proto(__libc_statfs) libc_hidden_proto(open) libc_hidden_proto(close) @@ -47,36 +52,37 @@ extern int __bsd_getpt (void) attribute_ /* Open a master pseudo terminal and return its file descriptor. */ int -getpt (void) +posix_openpt (int flags) { +#define have_no_dev_ptmx (1<<0) +#define devpts_mounted (1<<1) #if !defined __UNIX98PTY_ONLY__ - static smallint have_no_dev_ptmx; + static smallint _state; #endif int fd; #if !defined __UNIX98PTY_ONLY__ - if (!have_no_dev_ptmx) + if (!(_state & have_no_dev_ptmx)) #endif { - fd = open (_PATH_DEVPTMX, O_RDWR); + fd = open (_PATH_DEVPTMX, flags); if (fd != -1) { #if defined __ASSUME_DEVPTS__ return fd; #else struct statfs fsbuf; - static smallint devpts_mounted; /* Check that the /dev/pts filesystem is mounted or if /dev is a devfs filesystem (this implies /dev/pts). */ - if (devpts_mounted - || (statfs (_PATH_DEVPTS, &fsbuf) == 0 + if ((_state & devpts_mounted) + || (__libc_statfs (_PATH_DEVPTS, &fsbuf) == 0 && fsbuf.f_type == DEVPTS_SUPER_MAGIC) - || (statfs (_PATH_DEV, &fsbuf) == 0 + || (__libc_statfs (_PATH_DEV, &fsbuf) == 0 && fsbuf.f_type == DEVFS_SUPER_MAGIC)) { /* Everything is ok. */ - devpts_mounted = 1; + _state |= devpts_mounted; return fd; } @@ -84,7 +90,7 @@ getpt (void) are not usable. */ close (fd); #if !defined __UNIX98PTY_ONLY__ - have_no_dev_ptmx = 1; + _state |= have_no_dev_ptmx; #endif #endif } @@ -92,16 +98,25 @@ getpt (void) { #if !defined __UNIX98PTY_ONLY__ if (errno == ENOENT || errno == ENODEV) - have_no_dev_ptmx = 1; + _state |= have_no_dev_ptmx; else #endif return -1; } } + return -1; +} +#if defined __USE_GNU && defined __UCLIBC_HAS_GETPT__ +int +getpt (void) +{ + int fd = posix_openpt(O_RDWR); #if !defined __UNIX98PTY_ONLY__ - return __bsd_getpt (); + if (fd == -1) + fd = __bsd_getpt(); #endif + return fd; } #if !defined __UNIX98PTY_ONLY__ @@ -111,3 +126,4 @@ getpt (void) # define __getpt __bsd_getpt # include "bsd_getpt.c" #endif +#endif /* GNU && __UCLIBC_HAS_GETPT__ */ Index: libc/stdlib/bsd_getpt.c =================================================================== --- libc/stdlib/bsd_getpt.c (revision 22095) +++ libc/stdlib/bsd_getpt.c (working copy) @@ -22,6 +22,7 @@ #include #include +#if defined __USE_BSD libc_hidden_proto(open) /* Experimentally off - libc_hidden_proto(mempcpy) */ @@ -76,3 +77,4 @@ __getpt (void) __set_errno (ENOENT); return -1; } +#endif Index: libc/unistd/pathconf.c =================================================================== --- libc/unistd/pathconf.c (revision 22095) +++ libc/unistd/pathconf.c (working copy) @@ -31,7 +31,8 @@ #include //#include -libc_hidden_proto(statfs) +extern __typeof(statfs) __libc_statfs; +libc_hidden_proto(__libc_statfs) libc_hidden_proto(stat) @@ -83,7 +84,7 @@ pathconf (const char *path, int name) struct statfs buf; int save_errno = errno; - if (statfs (path, &buf) < 0) + if (__libc_statfs (path, &buf) < 0) { if (errno == ENOSYS) { Index: libc/unistd/sleep.c =================================================================== --- libc/unistd/sleep.c (revision 22095) +++ libc/unistd/sleep.c (working copy) @@ -27,6 +27,9 @@ libc_hidden_proto(sleep) libc_hidden_proto(sigaction) libc_hidden_proto(sigprocmask) + +/* version perusing nanosleep */ +#if defined __UCLIBC_HAVE_REALTIME__ //libc_hidden_proto(__sigaddset) //libc_hidden_proto(__sigemptyset) //libc_hidden_proto(__sigismember) @@ -114,4 +117,56 @@ unsigned int sleep (unsigned int seconds return result; } #endif +#else /* __UCLIBC_HAVE_REALTIME__ */ +libc_hidden_proto(sigaction) +/* no nanosleep, use signals and alarm() */ +static void sleep_alarm_handler(int attribute_unused sig) +{ +} +unsigned int sleep (unsigned int seconds) +{ + struct sigaction act, oact; + sigset_t set, oset; + unsigned int result, remaining; + time_t before, after; + int old_errno = errno; + + /* This is not necessary but some buggy programs depend on this. */ + if (seconds == 0) + return 0; + + /* block SIGALRM */ + if (__sigemptyset (&set) < 0 + || __sigaddset (&set, SIGALRM) < 0 + || sigprocmask (SIG_BLOCK, &set, &oset)) + return seconds; + + act.sa_handler = sleep_alarm_handler; + act.sa_flags = 0; + act.sa_mask = oset; + if (sigaction(SIGALRM, &act, &oact) < 0) + return seconds; + + before = time(NULL); + remaining = alarm(seconds); + if (remaining && remaining > seconds) { + /* restore user's alarm */ + (void) sigaction(SIGALRM, &oact, (struct sigaction *) NULL); + alarm(remaining); /* restore old alarm */ + sigsuspend(&oset); + after = time(NULL); + } else { + sigsuspend (&oset); + after = time(NULL); + (void) sigaction (SIGALRM, &oact, NULL); + } + result = after - before; + alarm(remaining > result ? remaining - result : 0); + sigprocmask (SIG_SETMASK, &oset, NULL); + + __set_errno(old_errno); + + return result > seconds ? 0 : seconds - result; +} +#endif /* __UCLIBC_HAVE_REALTIME__ */ libc_hidden_def(sleep) Index: libc/unistd/fpathconf.c =================================================================== --- libc/unistd/fpathconf.c (revision 22095) +++ libc/unistd/fpathconf.c (working copy) @@ -33,7 +33,8 @@ //#include "linux_fsinfo.h" libc_hidden_proto(fstat) -libc_hidden_proto(fstatfs) +extern __typeof(fstatfs) __libc_fstatfs; +libc_hidden_proto(__libc_fstatfs) /* The Linux kernel headers mention this as a kind of generic value. */ #define LINUX_LINK_MAX 127 @@ -55,7 +56,7 @@ long int fpathconf(int fd, int name) struct statfs fsbuf; /* Determine the filesystem type. */ - if (fstatfs (fd, &fsbuf) < 0) + if (__libc_fstatfs (fd, &fsbuf) < 0) { if (errno == ENOSYS) /* not possible, return the default value. */ @@ -129,7 +130,7 @@ long int fpathconf(int fd, int name) struct statfs buf; int save_errno = errno; - if (fstatfs (fd, &buf) < 0) + if (__libc_fstatfs (fd, &buf) < 0) { if (errno == ENOSYS) { Index: libc/unistd/usleep.c =================================================================== --- libc/unistd/usleep.c (revision 22095) +++ libc/unistd/usleep.c (working copy) @@ -9,6 +9,8 @@ #include #include +#if defined __USE_BSD || defined __USE_POSIX98 +#if defined __UCLIBC_HAVE_REALTIME__ /*libc_hidden_proto(nanosleep) need the reloc for cancellation*/ int usleep (__useconds_t usec) @@ -19,3 +21,15 @@ int usleep (__useconds_t usec) }; return(nanosleep(&ts, NULL)); } +#else /* __UCLIBC_HAVE_REALTIME__ */ +libc_hidden_proto(select) +int usleep (__useconds_t usec) +{ + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = usec; + return select(0, NULL, NULL, NULL, &tv); +} +#endif /* __UCLIBC_HAVE_REALTIME__ */ +#endif Index: libc/sysdeps/linux/common/getgid.c =================================================================== --- libc/sysdeps/linux/common/getgid.c (revision 22095) +++ libc/sysdeps/linux/common/getgid.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #if defined __NR_getxgid # undef __NR_getgid Index: libc/sysdeps/linux/common/mlock.c =================================================================== --- libc/sysdeps/linux/common/mlock.c (revision 22095) +++ libc/sysdeps/linux/common/mlock.c (working copy) @@ -10,5 +10,6 @@ #include #include #if defined __ARCH_USE_MMU__ && defined __NR_mlock +#include _syscall2(int, mlock, const void *, addr, size_t, len); #endif Index: libc/sysdeps/linux/common/close.c =================================================================== --- libc/sysdeps/linux/common/close.c (revision 22095) +++ libc/sysdeps/linux/common/close.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include extern __typeof(close) __libc_close; #define __NR___libc_close __NR_close Index: libc/sysdeps/linux/common/poll.c =================================================================== --- libc/sysdeps/linux/common/poll.c (revision 22095) +++ libc/sysdeps/linux/common/poll.c (working copy) @@ -23,12 +23,13 @@ extern __typeof(poll) __libc_poll; #ifdef __NR_poll +#include # define __NR___libc_poll __NR_poll _syscall3(int, __libc_poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout); -#elif defined(__NR_ppoll) +#elif defined(__NR_ppoll) && defined __UCLIBC_LINUX_SPECIFIC__ libc_hidden_proto(ppoll) int __libc_poll(struct pollfd *fds, nfds_t nfds, int timeout) Index: libc/sysdeps/linux/common/setregid.c =================================================================== --- libc/sysdeps/linux/common/setregid.c (revision 22095) +++ libc/sysdeps/linux/common/setregid.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include libc_hidden_proto(setregid) Index: libc/sysdeps/linux/common/utimes.c =================================================================== --- libc/sysdeps/linux/common/utimes.c (revision 22095) +++ libc/sysdeps/linux/common/utimes.c (working copy) @@ -14,6 +14,7 @@ libc_hidden_proto(utimes) #ifdef __NR_utimes +#include _syscall2(int, utimes, const char *, file, const struct timeval *, tvp); #else #include Index: libc/sysdeps/linux/common/munlock.c =================================================================== --- libc/sysdeps/linux/common/munlock.c (revision 22095) +++ libc/sysdeps/linux/common/munlock.c (working copy) @@ -10,5 +10,7 @@ #include #include #if defined __ARCH_USE_MMU__ && defined __NR_munlock +#include + _syscall2(int, munlock, const void *, addr, size_t, len); #endif Index: libc/sysdeps/linux/common/create_module.c =================================================================== --- libc/sysdeps/linux/common/create_module.c (revision 22095) +++ libc/sysdeps/linux/common/create_module.c (working copy) @@ -7,13 +7,16 @@ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ +#include #include #include -#include #include #include -#ifdef __NR_create_module +#ifndef __NR_create_module +# define __SYSCALL_STUB 1 +#endif +#include unsigned long create_module(const char *name, size_t size); @@ -48,12 +51,3 @@ unsigned long create_module(const char * /* Sparc, MIPS, etc don't mistake return values for errors. */ _syscall2(unsigned long, create_module, const char *, name, size_t, size); #endif - -#else /* !__NR_create_module */ -caddr_t create_module(const char *name attribute_unused, size_t size attribute_unused); -caddr_t create_module(const char *name attribute_unused, size_t size attribute_unused) -{ - __set_errno(ENOSYS); - return (caddr_t)-1; -} -#endif Index: libc/sysdeps/linux/common/read.c =================================================================== --- libc/sysdeps/linux/common/read.c (revision 22095) +++ libc/sysdeps/linux/common/read.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include extern __typeof(read) __libc_read; #define __NR___libc_read __NR_read Index: libc/sysdeps/linux/common/posix_fadvise64.c =================================================================== --- libc/sysdeps/linux/common/posix_fadvise64.c (revision 22095) +++ libc/sysdeps/linux/common/posix_fadvise64.c (working copy) @@ -18,6 +18,8 @@ #include #ifdef __UCLIBC_HAS_LFS__ +#include + #ifdef __NR_fadvise64_64 /* 64 bit implementation is cake ... or more like pie ... */ @@ -61,7 +63,7 @@ int posix_fadvise64(int fd, __off64_t of advice)); } #else -#warning _syscall6 has not been defined for your machine :( +#error _syscall6 has not been defined for your machine :( #endif /* _syscall6 */ #else @@ -74,7 +76,8 @@ int posix_fadvise64(int fd, __off64_t of */ int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice) { - return ENOSYS; + __set_errno(ENOSYS); + return -1; } #endif /* __NR_fadvise64_64 */ #endif /* __UCLIBC_HAS_LFS__ */ Index: libc/sysdeps/linux/common/getsid.c =================================================================== --- libc/sysdeps/linux/common/getsid.c (revision 22095) +++ libc/sysdeps/linux/common/getsid.c (working copy) @@ -11,6 +11,7 @@ #include #ifdef __USE_XOPEN_EXTENDED +#include libc_hidden_proto(getsid) #define __NR___syscall_getsid __NR_getsid Index: libc/sysdeps/linux/common/getpriority.c =================================================================== --- libc/sysdeps/linux/common/getpriority.c (revision 22095) +++ libc/sysdeps/linux/common/getpriority.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(getpriority) Index: libc/sysdeps/linux/common/getuid.c =================================================================== --- libc/sysdeps/linux/common/getuid.c (revision 22095) +++ libc/sysdeps/linux/common/getuid.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #if defined __NR_getxuid # undef __NR_getuid Index: libc/sysdeps/linux/common/arch_prctl.c =================================================================== --- libc/sysdeps/linux/common/arch_prctl.c (revision 22095) +++ libc/sysdeps/linux/common/arch_prctl.c (working copy) @@ -8,8 +8,10 @@ */ #include +#ifndef __NR_arch_prctl +# define __SYSCALL_STUB 1 +#endif +#include -#ifdef __NR_arch_prctl extern int arch_prctl(int code, unsigned long addr); _syscall2(int, arch_prctl, int, code, unsigned long, addr); -#endif Index: libc/sysdeps/linux/common/setreuid.c =================================================================== --- libc/sysdeps/linux/common/setreuid.c (revision 22095) +++ libc/sysdeps/linux/common/setreuid.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include libc_hidden_proto(setreuid) Index: libc/sysdeps/linux/common/wait4.c =================================================================== --- libc/sysdeps/linux/common/wait4.c (revision 22095) +++ libc/sysdeps/linux/common/wait4.c (working copy) @@ -8,8 +8,10 @@ */ #include +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED #include #include +#include libc_hidden_proto(wait4) @@ -22,3 +24,4 @@ pid_t wait4(pid_t pid, int *status, int return (__syscall_wait4(pid, status, opts, rusage)); } libc_hidden_def(wait4) +#endif Index: libc/sysdeps/linux/common/sched_get_priority_min.c =================================================================== --- libc/sysdeps/linux/common/sched_get_priority_min.c (revision 22095) +++ libc/sysdeps/linux/common/sched_get_priority_min.c (working copy) @@ -9,4 +9,5 @@ #include #include +#include _syscall1(int, sched_get_priority_min, int, policy); Index: libc/sysdeps/linux/common/sysinfo.c =================================================================== --- libc/sysdeps/linux/common/sysinfo.c (revision 22095) +++ libc/sysdeps/linux/common/sysinfo.c (working copy) @@ -9,4 +9,9 @@ #include #include +#ifndef __NR_sysinfo +# define __SYSCALL_STUB 1 +#endif +#include + _syscall1(int, sysinfo, struct sysinfo *, info); Index: libc/sysdeps/linux/common/ftruncate.c =================================================================== --- libc/sysdeps/linux/common/ftruncate.c (revision 22095) +++ libc/sysdeps/linux/common/ftruncate.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(ftruncate) Index: libc/sysdeps/linux/common/alarm.c =================================================================== --- libc/sysdeps/linux/common/alarm.c (revision 22095) +++ libc/sysdeps/linux/common/alarm.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(alarm) Index: libc/sysdeps/linux/common/setpriority.c =================================================================== --- libc/sysdeps/linux/common/setpriority.c (revision 22095) +++ libc/sysdeps/linux/common/setpriority.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(setpriority) Index: libc/sysdeps/linux/common/readahead.c =================================================================== --- libc/sysdeps/linux/common/readahead.c (revision 22095) +++ libc/sysdeps/linux/common/readahead.c (working copy) @@ -28,6 +28,7 @@ #include <_lfs_64.h> #ifdef __NR_readahead +#include # define __NR___readahead __NR_readahead Index: libc/sysdeps/linux/common/time.c =================================================================== --- libc/sysdeps/linux/common/time.c (revision 22095) +++ libc/sysdeps/linux/common/time.c (working copy) @@ -14,6 +14,7 @@ /* Experimentally off - libc_hidden_proto(time) */ #ifdef __NR_time +#include _syscall1(time_t, time, time_t *, t); #else libc_hidden_proto(gettimeofday) Index: libc/sysdeps/linux/common/fchdir.c =================================================================== --- libc/sysdeps/linux/common/fchdir.c (revision 22095) +++ libc/sysdeps/linux/common/fchdir.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(fchdir) Index: libc/sysdeps/linux/common/access.c =================================================================== --- libc/sysdeps/linux/common/access.c (revision 22095) +++ libc/sysdeps/linux/common/access.c (working copy) @@ -9,4 +9,10 @@ #include #include + +#ifndef __NR_access +# define __SYSCALL_STUB 1 +#endif +#include + _syscall2(int, access, const char *, pathname, int, mode); Index: libc/sysdeps/linux/common/xattr.c =================================================================== --- libc/sysdeps/linux/common/xattr.c (revision 22095) +++ libc/sysdeps/linux/common/xattr.c (working copy) @@ -25,140 +25,94 @@ #include #include + /* sets */ -#ifdef __NR_setxattr + +#ifndef __NR_setxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall5(int, setxattr, const char *, path, const char *, name, const void *, value, size_t, size, int, flags); -#else -int setxattr(__const char *__path, __const char *__name, - __const void *__value, size_t __size, int __flags) -{ - __set_errno(ENOSYS); - return -1; -} -#endif -#ifdef __NR_lsetxattr +#ifndef __NR_lsetxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall5(int, lsetxattr, const char *, path, const char *, name, const void *, value, size_t, size, int, flags); -#else -int lsetxattr(__const char *__path, __const char *__name, - __const void *__value, size_t __size, int __flags) -{ - __set_errno(ENOSYS); - return -1; -} -#endif -#ifdef __NR_fsetxattr +#ifndef __NR_fsetxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall5(int, fsetxattr, int, filedes, const char *, name, const void *, value, size_t, size, int, flags); -#else -int fsetxattr(int __fd, __const char *__name, __const void *__value, - size_t __size, int __flags) -{ - __set_errno(ENOSYS); - return -1; -} -#endif + /* gets */ -#ifdef __NR_getxattr + +#ifndef __NR_getxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall4(ssize_t, getxattr, const char *, path, const char *, name, void *, value, size_t, size); -#else -ssize_t getxattr(__const char *__path, __const char *__name, void *__value, - size_t __size) -{ - __set_errno(ENOSYS); - return -1; -} -#endif -#ifdef __NR_lgetxattr +#ifndef __NR_lgetxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall4(ssize_t, lgetxattr, const char *, path, const char *, name, void *, value, size_t, size); -#else -ssize_t lgetxattr(__const char *__path, __const char *__name, - void *__value, size_t __size) -{ - __set_errno(ENOSYS); - return -1; -} -#endif -#ifdef __NR_fgetxattr +#ifndef __NR_fgetxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall4(ssize_t, fgetxattr, int, filedes, const char *, name, void *, value, size_t, size); -#else -ssize_t fgetxattr(int __fd, __const char *__name, void *__value, - size_t __size) -{ - __set_errno(ENOSYS); - return -1; -} -#endif + /* list */ -#ifdef __NR_listxattr + +#ifndef __NR_listxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall3(ssize_t, listxattr, const char *, path, char *, list, size_t, size); -#else -ssize_t listxattr(__const char *__path, char *__list, size_t __size) -{ - __set_errno(ENOSYS); - return -1; -} -#endif -#ifdef __NR_llistxattr +#ifndef __NR_llistxattr +# define __SYSCALL_STUB 1 +#endif +#include _syscall3(ssize_t, llistxattr, const char *, path, char *, list, size_t, size); -#else -ssize_t llistxattr(__const char *__path, char *__list, size_t __size) -{ - __set_errno(ENOSYS); - return -1; -} -#endif -#ifdef __NR_flistxattr -_syscall3(ssize_t, flistxattr, int, filedes, char *, list, size_t, size); -#else -ssize_t flistxattr(int __fd, char *__list, size_t __size) -{ - __set_errno(ENOSYS); - return -1; -} +#ifndef __NR_flistxattr +# define __SYSCALL_STUB 1 #endif +#include +_syscall3(ssize_t, flistxattr, int, filedes, char *, list, size_t, size); + /* remove */ -#ifdef __NR_removexattr -_syscall2(int, removexattr, const char *, path, const char *, name); -#else -int removexattr(__const char *__path, __const char *__name) -{ - __set_errno(ENOSYS); - return -1; -} + +#ifndef __NR_removexattr +# define __SYSCALL_STUB 1 #endif +#include +_syscall2(int, removexattr, const char *, path, const char *, name); -#ifdef __NR_lremovexattr -_syscall2(int, lremovexattr, const char *, path, const char *, name); -#else -int lremovexattr(__const char *__path, __const char *__name) -{ - __set_errno(ENOSYS); - return -1; -} +#ifndef __NR_lremovexattr +# define __SYSCALL_STUB 1 #endif +#include +_syscall2(int, lremovexattr, const char *, path, const char *, name); -#ifdef __NR_fremovexattr -_syscall2(int, fremovexattr, int, filedes, const char *, name); -#else -int fremovexattr(int __fd, __const char *__name) -{ - __set_errno(ENOSYS); - return -1; -} +#ifndef __NR_fremovexattr +# define __SYSCALL_STUB 1 #endif +#include +_syscall2(int, fremovexattr, int, filedes, const char *, name); Index: libc/sysdeps/linux/common/iopl.c =================================================================== --- libc/sysdeps/linux/common/iopl.c (revision 22095) +++ libc/sysdeps/linux/common/iopl.c (working copy) @@ -9,6 +9,11 @@ #include #if defined __ARCH_USE_MMU__ && defined __NR_iopl +#ifndef __NR_iopl +# define __SYSCALL_STUB 1 +#endif +#include + /* psm: can't #include , some archs miss it */ extern int iopl(int __level) __THROW; _syscall1(int, iopl, int, level); Index: libc/sysdeps/linux/common/statfs.c =================================================================== --- libc/sysdeps/linux/common/statfs.c (revision 22095) +++ libc/sysdeps/linux/common/statfs.c (working copy) @@ -12,6 +12,19 @@ #include #include +#ifndef __NR_statfs +# define __SYSCALL_STUB 1 +#endif +#include + +extern __typeof(statfs) __libc_statfs; +libc_hidden_proto(__libc_statfs) +#define __NR___libc_statfs __NR_statfs +_syscall2(int, __libc_statfs, const char *, path, struct statfs *, buf); +libc_hidden_def(__libc_statfs) + +#if defined __UCLIBC_LINUX_SPECIFIC__ libc_hidden_proto(statfs) -_syscall2(int, statfs, const char *, path, struct statfs *, buf); -libc_hidden_def(statfs) +weak_alias(__libc_statfs,statfs) +libc_hidden_weak(statfs) +#endif Index: libc/sysdeps/linux/common/_exit.c =================================================================== --- libc/sysdeps/linux/common/_exit.c (revision 22095) +++ libc/sysdeps/linux/common/_exit.c (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include libc_hidden_proto(_exit) Index: libc/sysdeps/linux/common/vhangup.c =================================================================== --- libc/sysdeps/linux/common/vhangup.c (revision 22095) +++ libc/sysdeps/linux/common/vhangup.c (working copy) @@ -10,5 +10,6 @@ #include #include #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98) +#include _syscall0(int, vhangup); #endif Index: libc/sysdeps/linux/common/clock_gettime.c =================================================================== --- libc/sysdeps/linux/common/clock_gettime.c (revision 22095) +++ libc/sysdeps/linux/common/clock_gettime.c (working copy) @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef __NR_clock_gettime _syscall2(int, clock_gettime, clockid_t, clock_id, struct timespec*, tp); Index: libc/sysdeps/linux/common/acct.c =================================================================== --- libc/sysdeps/linux/common/acct.c (revision 22095) +++ libc/sysdeps/linux/common/acct.c (working copy) @@ -9,6 +9,11 @@ #include #include + +#ifndef __NR_acct +# define __SYSCALL_STUB 1 +#endif +#include #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98) _syscall1(int, acct, const char *, filename); #endif Index: libc/sysdeps/linux/common/epoll.c =================================================================== --- libc/sysdeps/linux/common/epoll.c (revision 22095) +++ libc/sysdeps/linux/common/epoll.c (working copy) @@ -13,38 +13,27 @@ /* * epoll_create() */ -#ifdef __NR_epoll_create -_syscall1(int, epoll_create, int, size); -#else -int epoll_create(int size) -{ - __set_errno(ENOSYS); - return -1; -} +#ifndef __NR_epoll_create +# define __SYSCALL_STUB 1 #endif +#include +_syscall1(int, epoll_create, int, size); /* * epoll_ctl() */ -#ifdef __NR_epoll_ctl -_syscall4(int,epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event); -#else -int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) -{ - __set_errno(ENOSYS); - return -1; -} +#ifndef __NR_epoll_ctl +# define __SYSCALL_STUB 1 #endif +#include +_syscall4(int,epoll_ctl, int, epfd, int, op, int, fd, struct epoll_event *, event); /* * epoll_wait() */ -#ifdef __NR_epoll_wait -_syscall4(int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout); -#else -int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) -{ - __set_errno(ENOSYS); - return -1; -} +#ifndef __NR_epoll_wait +# define __SYSCALL_STUB 1 #endif +#include +_syscall4(int, epoll_wait, int, epfd, struct epoll_event *, events, int, maxevents, int, timeout); + Index: libc/sysdeps/linux/common/bits/uClibc_syscall-stub.h =================================================================== --- libc/sysdeps/linux/common/bits/uClibc_syscall-stub.h (revision 0) +++ libc/sysdeps/linux/common/bits/uClibc_syscall-stub.h (revision 0) @@ -0,0 +1,96 @@ + +#undef __emit_syscall_link_warn +#if defined __UCLIBC_SYSCALL_STUB_WARNING__ && \ + defined __SYSCALL_STUB && __SYSCALL_STUB +# define __emit_syscall_link_warn(sym, msg) link_warning(sym, msg) +#else +# define __emit_syscall_link_warn(sym, msg) +#endif + + +#undef RETURN_INLINE_SYSCALL +#undef INLINE_SYSCALL +#undef _U +#if !defined __SYSCALL_STUB || (defined __SYSCALL_STUB && !__SYSCALL_STUB) +#define RETURN_INLINE_SYSCALL(type) return (type) +#define INLINE_SYSCALL(name, nr, args...) \ + ({ \ + unsigned int _resultvar = INTERNAL_SYSCALL (name, , nr, args); \ + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_resultvar, ), 0)) \ + { \ + __set_errno (INTERNAL_SYSCALL_ERRNO (_resultvar, )); \ + _resultvar = 0xffffffff; \ + } \ + (int) _resultvar; }) +#define _U +#else /* no impl above, need __SYSCALL_STUB */ +#define RETURN_INLINE_SYSCALL(type) +#define INLINE_SYSCALL(name, nr, args...) \ + ({ \ + __set_errno(ENOSYS); \ + return -1; \ + }) +#define _U attribute_unused +#endif + +#undef __SYSCALL_STUB +#define __SYSCALL_STUB 0 + +#undef _syscall0 +#define _syscall0(type,name) \ +type name(void) \ +{ \ +RETURN_INLINE_SYSCALL(type) (INLINE_SYSCALL(name, 0)); \ +} \ +__emit_syscall_link_warn(name, #name " not implemented") + +#undef _syscall1 +#define _syscall1(type,name,type1,arg1) \ +type name(type1 _U arg1) \ +{ \ +RETURN_INLINE_SYSCALL(type) (INLINE_SYSCALL(name, 1, arg1)); \ +} \ +__emit_syscall_link_warn(name, #name " not implemented") + +#undef _syscall2 +#define _syscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 _U arg1,type2 _U arg2) \ +{ \ +RETURN_INLINE_SYSCALL(type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \ +} \ +__emit_syscall_link_warn(name, #name " not implemented") + +#undef _syscall3 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type name(type1 _U arg1,type2 _U arg2,type3 _U arg3) \ +{ \ +RETURN_INLINE_SYSCALL(type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \ +} \ +__emit_syscall_link_warn(name, #name " not implemented") + +#undef _syscall4 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type name (type1 _U arg1, type2 _U arg2, type3 _U arg3, type4 _U arg4) \ +{ \ +RETURN_INLINE_SYSCALL(type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \ +} \ +__emit_syscall_link_warn(name, #name " not implemented") + +#undef _syscall5 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5) \ +type name (type1 _U arg1,type2 _U arg2,type3 _U arg3,type4 _U arg4,type5 _U arg5) \ +{ \ +RETURN_INLINE_SYSCALL(type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \ +} \ +__emit_syscall_link_warn(name, #name " not implemented") + +#undef _syscall6 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6) \ +type name (type1 _U arg1,type2 _U arg2,type3 _U arg3,type4 _U arg4,type5 _U arg5, type6 _U arg6) \ +{ \ +RETURN_INLINE_SYSCALL(type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \ +} \ +__emit_syscall_link_warn(name, #name " not implemented") + Index: libc/sysdeps/linux/common/fstat.c =================================================================== --- libc/sysdeps/linux/common/fstat.c (revision 22095) +++ libc/sysdeps/linux/common/fstat.c (working copy) @@ -12,6 +12,7 @@ #define fstat64 __hidefstat64 #include +#include #include #include #include "xstatconv.h" Index: libc/sysdeps/linux/common/sysctl.c =================================================================== --- libc/sysdeps/linux/common/sysctl.c (revision 22095) +++ libc/sysdeps/linux/common/sysctl.c (working copy) @@ -8,6 +8,12 @@ */ #include +#if defined __USE_GNU || defined __USE_BSD +#ifndef __NR__sysctl +# define __SYSCALL_STUB 1 +#endif +#include + /* psm: including sys/sysctl.h would depend on kernel headers */ extern int sysctl (int *__name, int __nlen, void *__oldval, size_t *__oldlenp, void *__newval, size_t __newlen) __THROW; @@ -29,13 +35,14 @@ int sysctl(int *name, int nlen, void *ol void *newval, size_t newlen) { struct __sysctl_args args = { - name:name, - nlen:nlen, - oldval:oldval, - oldlenp:oldlenp, - newval:newval, - newlen:newlen + .name = name, + .nlen = nlen, + .oldval = oldval, + .oldlenp = oldlenp, + .newval = newval, + .newlen = newlen }; return _sysctl(&args); } +#endif Index: libc/sysdeps/linux/common/times.c =================================================================== --- libc/sysdeps/linux/common/times.c (revision 22095) +++ libc/sysdeps/linux/common/times.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(times) Index: libc/sysdeps/linux/common/sigsuspend.c =================================================================== --- libc/sysdeps/linux/common/sigsuspend.c (revision 22095) +++ libc/sysdeps/linux/common/sigsuspend.c (working copy) @@ -8,6 +8,9 @@ */ #include + +#if defined __USE_POSIX +#include #include extern __typeof(sigsuspend) __libc_sigsuspend; @@ -33,3 +36,4 @@ int __libc_sigsuspend(const sigset_t * s libc_hidden_proto(sigsuspend) weak_alias(__libc_sigsuspend,sigsuspend) libc_hidden_weak(sigsuspend) +#endif Index: libc/sysdeps/linux/common/clock_settime.c =================================================================== --- libc/sysdeps/linux/common/clock_settime.c (revision 22095) +++ libc/sysdeps/linux/common/clock_settime.c (working copy) @@ -12,6 +12,7 @@ #include #ifdef __NR_clock_settime +#include _syscall2(int, clock_settime, clockid_t, clock_id, const struct timespec*, tp); #else libc_hidden_proto(settimeofday) Index: libc/sysdeps/linux/common/truncate.c =================================================================== --- libc/sysdeps/linux/common/truncate.c (revision 22095) +++ libc/sysdeps/linux/common/truncate.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(truncate) Index: libc/sysdeps/linux/common/getrusage.c =================================================================== --- libc/sysdeps/linux/common/getrusage.c (revision 22095) +++ libc/sysdeps/linux/common/getrusage.c (working copy) @@ -10,4 +10,5 @@ #include #include #include +#include _syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage); Index: libc/sysdeps/linux/common/umount.c =================================================================== --- libc/sysdeps/linux/common/umount.c (revision 22095) +++ libc/sysdeps/linux/common/umount.c (working copy) @@ -8,7 +8,10 @@ */ #include + +#if defined __USE_GNU #include +#include /* arch provides umount() syscall */ #ifdef __NR_umount @@ -36,3 +39,4 @@ int umount(const char *special_file) } #endif +#endif Index: libc/sysdeps/linux/common/sendfile.c =================================================================== --- libc/sysdeps/linux/common/sendfile.c (revision 22095) +++ libc/sysdeps/linux/common/sendfile.c (working copy) @@ -18,6 +18,7 @@ #undef sendfile64 #ifdef __NR_sendfile +#include _syscall4(ssize_t, sendfile, int, out_fd, int, in_fd, __off_t *, offset, size_t, count); Index: libc/sysdeps/linux/common/lchown.c =================================================================== --- libc/sysdeps/linux/common/lchown.c (revision 22095) +++ libc/sysdeps/linux/common/lchown.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #if (__WORDSIZE == 32 && defined(__NR_lchown32)) || __WORDSIZE == 64 # ifdef __NR_lchown32 Index: libc/sysdeps/linux/common/write.c =================================================================== --- libc/sysdeps/linux/common/write.c (revision 22095) +++ libc/sysdeps/linux/common/write.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include extern __typeof(write) __libc_write; #define __NR___libc_write __NR_write @@ -16,7 +17,8 @@ _syscall3(ssize_t, __libc_write, int, fd libc_hidden_proto(write) weak_alias(__libc_write,write) libc_hidden_weak(write) -#if 0 +#if defined __GNUC__ && defined __GNUC__MINOR__ \ + && __GNUC__ != 2 && (__GNUC_MINOR__ != 95 && __GNUC_MINOR__ != 96) /* Stupid libgcc.a from gcc 2.95.x uses __write in pure.o * which is a blatent GNU libc-ism... */ strong_alias(__libc_write,__write) Index: libc/sysdeps/linux/common/sched_setscheduler.c =================================================================== --- libc/sysdeps/linux/common/sched_setscheduler.c (revision 22095) +++ libc/sysdeps/linux/common/sched_setscheduler.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #define __NR___syscall_sched_setscheduler __NR_sched_setscheduler static inline _syscall3(int, __syscall_sched_setscheduler, Index: libc/sysdeps/linux/common/sched_getparam.c =================================================================== --- libc/sysdeps/linux/common/sched_getparam.c (revision 22095) +++ libc/sysdeps/linux/common/sched_getparam.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #define __NR___syscall_sched_getparam __NR_sched_getparam static inline _syscall2(int, __syscall_sched_getparam, Index: libc/sysdeps/linux/common/__syscall_fcntl64.c =================================================================== --- libc/sysdeps/linux/common/__syscall_fcntl64.c (revision 22095) +++ libc/sysdeps/linux/common/__syscall_fcntl64.c (working copy) @@ -12,6 +12,7 @@ #include #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64 +#include extern __typeof(fcntl64) __libc_fcntl64; libc_hidden_proto(__libc_fcntl64) Index: libc/sysdeps/linux/common/sigaltstack.c =================================================================== --- libc/sysdeps/linux/common/sigaltstack.c (revision 22095) +++ libc/sysdeps/linux/common/sigaltstack.c (working copy) @@ -10,7 +10,9 @@ #include #include -#ifdef __NR_sigaltstack +#if defined __USE_BSD || defined __USE_UNIX98 +#include + _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss); #endif Index: libc/sysdeps/linux/common/dup2.c =================================================================== --- libc/sysdeps/linux/common/dup2.c (revision 22095) +++ libc/sysdeps/linux/common/dup2.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(dup2) Index: libc/sysdeps/linux/common/stat.c =================================================================== --- libc/sysdeps/linux/common/stat.c (revision 22095) +++ libc/sysdeps/linux/common/stat.c (working copy) @@ -15,6 +15,7 @@ #include #include #include "xstatconv.h" +#include #undef stat64 Index: libc/sysdeps/linux/common/getcwd.c =================================================================== --- libc/sysdeps/linux/common/getcwd.c (revision 22095) +++ libc/sysdeps/linux/common/getcwd.c (working copy) @@ -14,6 +14,7 @@ #include #include #include +#include libc_hidden_proto(getcwd) libc_hidden_proto(getpagesize) Index: libc/sysdeps/linux/common/chown.c =================================================================== --- libc/sysdeps/linux/common/chown.c (revision 22095) +++ libc/sysdeps/linux/common/chown.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include libc_hidden_proto(chown) Index: libc/sysdeps/linux/common/llseek.c =================================================================== --- libc/sysdeps/linux/common/llseek.c (revision 22095) +++ libc/sysdeps/linux/common/llseek.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include extern __typeof(lseek64) __libc_lseek64; Index: libc/sysdeps/linux/common/execve.c =================================================================== --- libc/sysdeps/linux/common/execve.c (revision 22095) +++ libc/sysdeps/linux/common/execve.c (working copy) @@ -11,6 +11,8 @@ #include #include #include +#include + libc_hidden_proto(execve) _syscall3(int, execve, const char *, filename, Index: libc/sysdeps/linux/common/select.c =================================================================== --- libc/sysdeps/linux/common/select.c (revision 22095) +++ libc/sysdeps/linux/common/select.c (working copy) @@ -9,11 +9,11 @@ #include #include +#include extern __typeof(select) __libc_select; -#if !defined(__NR__newselect) && !defined(__NR_select) - +#if !defined(__NR__newselect) && !defined(__NR_select) && defined __USE_XOPEN2K # define __NR___libc_pselect6 __NR_pselect6 _syscall6(int, __libc_pselect6, int, n, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, const struct timespec *, timeout, Index: libc/sysdeps/linux/common/inotify.c =================================================================== --- libc/sysdeps/linux/common/inotify.c (revision 22095) +++ libc/sysdeps/linux/common/inotify.c (working copy) @@ -11,14 +11,21 @@ #include #include -#ifdef __NR_inotify_init -_syscall0(int, inotify_init); +#ifndef __NR_inotify_init +# define __SYSCALL_STUB 1 #endif +#include +_syscall0(int, inotify_init); -#ifdef __NR_inotify_add_watch -_syscall3(int, inotify_add_watch, int, fd, const char *, path, uint32_t, mask); + +#ifndef __NR_inotify_add_watch +# define __SYSCALL_STUB 1 #endif +#include +_syscall3(int, inotify_add_watch, int, fd, const char *, path, uint32_t, mask); -#ifdef __NR_inotify_rm_watch -_syscall2(int, inotify_rm_watch, int, fd, uint32_t, wd); +#ifndef __NR_inotify_rm_watch +# define __SYSCALL_STUB 1 #endif +#include +_syscall2(int, inotify_rm_watch, int, fd, uint32_t, wd); Index: libc/sysdeps/linux/common/fsync.c =================================================================== --- libc/sysdeps/linux/common/fsync.c (revision 22095) +++ libc/sysdeps/linux/common/fsync.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include extern __typeof(fsync) __libc_fsync; #define __NR___libc_fsync __NR_fsync Index: libc/sysdeps/linux/common/utime.c =================================================================== --- libc/sysdeps/linux/common/utime.c (revision 22095) +++ libc/sysdeps/linux/common/utime.c (working copy) @@ -13,6 +13,7 @@ libc_hidden_proto(utime) #ifdef __NR_utime +#include _syscall2(int, utime, const char *, file, const struct utimbuf *, times); #else #include Index: libc/sysdeps/linux/common/getdtablesize.c =================================================================== --- libc/sysdeps/linux/common/getdtablesize.c (revision 22095) +++ libc/sysdeps/linux/common/getdtablesize.c (working copy) @@ -9,6 +9,8 @@ #include #include +/* XXX: _BSD || _XOPEN_SOURCE >= 500 */ +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED libc_hidden_proto(getdtablesize) libc_hidden_proto(getrlimit) @@ -27,3 +29,4 @@ int getdtablesize (void) return getrlimit (RLIMIT_NOFILE, &ru) < 0 ? __LOCAL_OPEN_MAX : ru.rlim_cur; } libc_hidden_def(getdtablesize) +#endif Index: libc/sysdeps/linux/common/bdflush.c =================================================================== --- libc/sysdeps/linux/common/bdflush.c (revision 22095) +++ libc/sysdeps/linux/common/bdflush.c (working copy) @@ -10,12 +10,9 @@ #include #include -#ifdef __NR_bdflush -_syscall2(int, bdflush, int, __func, long int, __data); -#else -int bdflush(int __func, long int __data) -{ - __set_errno(ENOSYS); - return -1; -} +#ifndef __NR_bdflush +# define __SYSCALL_STUB 1 #endif +#include + +_syscall2(int, bdflush, int, __func, long int, __data); Index: libc/sysdeps/linux/common/sethostname.c =================================================================== --- libc/sysdeps/linux/common/sethostname.c (revision 22095) +++ libc/sysdeps/linux/common/sethostname.c (working copy) @@ -10,5 +10,6 @@ #include #include #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98) +#include _syscall2(int, sethostname, const char *, name, size_t, len); #endif Index: libc/sysdeps/linux/common/fstat64.c =================================================================== --- libc/sysdeps/linux/common/fstat64.c (revision 22095) +++ libc/sysdeps/linux/common/fstat64.c (working copy) @@ -10,6 +10,7 @@ #include #if defined __UCLIBC_HAS_LFS__ && defined __NR_fstat64 +#include #include #include #include "xstatconv.h" Index: libc/sysdeps/linux/common/settimeofday.c =================================================================== --- libc/sysdeps/linux/common/settimeofday.c (revision 22095) +++ libc/sysdeps/linux/common/settimeofday.c (working copy) @@ -11,6 +11,7 @@ #include #ifdef __USE_BSD +#include libc_hidden_proto(settimeofday) Index: libc/sysdeps/linux/common/klogctl.c =================================================================== --- libc/sysdeps/linux/common/klogctl.c (revision 22095) +++ libc/sysdeps/linux/common/klogctl.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #define __NR__syslog __NR_syslog static inline _syscall3(int, _syslog, int, type, char *, buf, int, len); int klogctl(int type, char *buf, int len) Index: libc/sysdeps/linux/common/truncate64.c =================================================================== --- libc/sysdeps/linux/common/truncate64.c (revision 22095) +++ libc/sysdeps/linux/common/truncate64.c (working copy) @@ -19,6 +19,7 @@ #include #if defined __UCLIBC_HAS_LFS__ +#include #if defined __NR_truncate64 @@ -57,7 +58,7 @@ int truncate64 (const char * path, __off } #else /* __WORDSIZE */ -#error Your machine is not 64 bit or 32 bit, I am dazed and confused. +#error Your machine is not 64 bit nor 32 bit, I am dazed and confused. #endif /* __WORDSIZE */ #else /* __NR_truncate64 */ Index: libc/sysdeps/linux/common/fchmod.c =================================================================== --- libc/sysdeps/linux/common/fchmod.c (revision 22095) +++ libc/sysdeps/linux/common/fchmod.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #define __NR___syscall_fchmod __NR_fchmod static inline _syscall2(int, __syscall_fchmod, Index: libc/sysdeps/linux/common/lstat64.c =================================================================== --- libc/sysdeps/linux/common/lstat64.c (revision 22095) +++ libc/sysdeps/linux/common/lstat64.c (working copy) @@ -10,6 +10,7 @@ #include #if defined __UCLIBC_HAS_LFS__ && defined __NR_lstat64 +#include # include # include # include "xstatconv.h" Index: libc/sysdeps/linux/common/sbrk.c =================================================================== --- libc/sysdeps/linux/common/sbrk.c (revision 22095) +++ libc/sysdeps/linux/common/sbrk.c (working copy) @@ -21,7 +21,7 @@ void * sbrk (intptr_t increment) void *oldbrk; if (__curbrk == NULL) - if (brk (0) < 0) /* Initialize the break. */ + if (brk (NULL) < 0) /* Initialize the break. */ return (void *) -1; if (increment == 0) Index: libc/sysdeps/linux/common/mount.c =================================================================== --- libc/sysdeps/linux/common/mount.c (revision 22095) +++ libc/sysdeps/linux/common/mount.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include _syscall5(int, mount, const char *, specialfile, const char *, dir, const char *, filesystemtype, unsigned long, rwflag, const void *, data); Index: libc/sysdeps/linux/common/posix_fadvise.c =================================================================== --- libc/sysdeps/linux/common/posix_fadvise.c (revision 22095) +++ libc/sysdeps/linux/common/posix_fadvise.c (working copy) @@ -18,6 +18,7 @@ #undef posix_fadvise64 #ifdef __NR_fadvise64 +#include #define __NR_posix_fadvise __NR_fadvise64 /* get rid of following conditional when all supported arches are having INTERNAL_SYSCALL defined @@ -46,6 +47,7 @@ strong_alias(posix_fadvise,posix_fadvise #else int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused) { - return ENOSYS; + __set_errno(ENOSYS); + return -1; } #endif Index: libc/sysdeps/linux/common/lseek.c =================================================================== --- libc/sysdeps/linux/common/lseek.c (revision 22095) +++ libc/sysdeps/linux/common/lseek.c (working copy) @@ -15,6 +15,7 @@ libc_hidden_proto(__libc_lseek) #ifdef __NR_lseek #define __NR___libc_lseek __NR_lseek +#include _syscall3(__off_t, __libc_lseek, int, fildes, __off_t, offset, int, whence); #else extern __typeof(lseek64) __libc_lseek64; Index: libc/sysdeps/linux/common/sendfile64.c =================================================================== --- libc/sysdeps/linux/common/sendfile64.c (revision 22095) +++ libc/sysdeps/linux/common/sendfile64.c (working copy) @@ -20,5 +20,6 @@ #include #if defined __UCLIBC_HAS_LFS__ && defined __NR_sendfile64 +#include _syscall4(ssize_t,sendfile64, int, out_fd, int, in_fd, __off64_t *, offset, size_t, count); #endif Index: libc/sysdeps/linux/common/mmap64.c =================================================================== --- libc/sysdeps/linux/common/mmap64.c (revision 22095) +++ libc/sysdeps/linux/common/mmap64.c (working copy) @@ -39,6 +39,7 @@ __ptr_t mmap64(__ptr_t addr, size_t len, } # else +#include # define __NR___syscall_mmap2 __NR_mmap2 static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len, Index: libc/sysdeps/linux/common/swapoff.c =================================================================== --- libc/sysdeps/linux/common/swapoff.c (revision 22095) +++ libc/sysdeps/linux/common/swapoff.c (working copy) @@ -9,9 +9,10 @@ #include -#ifdef __NR_swapoff +#ifndef __NR_swapoff +# define __SYSCALL_STUB 1 +#endif +#include #include _syscall1(int, swapoff, const char *, path); - -#endif Index: libc/sysdeps/linux/common/query_module.c =================================================================== --- libc/sysdeps/linux/common/query_module.c (revision 22095) +++ libc/sysdeps/linux/common/query_module.c (working copy) @@ -8,16 +8,12 @@ */ #include +#ifndef __NR_query_module +# define __SYSCALL_STUB 1 +#endif +#include + int query_module(const char *name attribute_unused, int which attribute_unused, void *buf attribute_unused, size_t bufsize attribute_unused, size_t * ret attribute_unused); -#ifdef __NR_query_module _syscall5(int, query_module, const char *, name, int, which, void *, buf, size_t, bufsize, size_t *, ret); -#else -int query_module(const char *name attribute_unused, int which attribute_unused, - void *buf attribute_unused, size_t bufsize attribute_unused, size_t * ret attribute_unused) -{ - __set_errno(ENOSYS); - return -1; -} -#endif Index: libc/sysdeps/linux/common/sync.c =================================================================== --- libc/sysdeps/linux/common/sync.c (revision 22095) +++ libc/sysdeps/linux/common/sync.c (working copy) @@ -7,11 +7,11 @@ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ -#include -#include -#include #include +# if defined __USE_BSD || defined __USE_UNIX98 +#include #include +#include #ifndef INLINE_SYSCALL #define INLINE_SYSCALL(name, nr, args...) __syscall_sync (args) @@ -23,4 +23,4 @@ void sync(void) { INLINE_SYSCALL(sync, 0); } - +#endif Index: libc/sysdeps/linux/common/getdents.c =================================================================== --- libc/sysdeps/linux/common/getdents.c (revision 22095) +++ libc/sysdeps/linux/common/getdents.c (working copy) @@ -40,7 +40,7 @@ struct kernel_dirent ssize_t __getdents (int fd, char *buf, size_t nbytes) attribute_hidden; #if ! defined __UCLIBC_HAS_LFS__ || ! defined __NR_getdents64 - +#include /* Experimentally off - libc_hidden_proto(memcpy) */ libc_hidden_proto(lseek) Index: libc/sysdeps/linux/common/vmsplice.c =================================================================== --- libc/sysdeps/linux/common/vmsplice.c (revision 22095) +++ libc/sysdeps/linux/common/vmsplice.c (working copy) @@ -10,19 +10,9 @@ #include #include -libc_hidden_proto(vmsplice) - -#ifdef __NR_vmsplice +#ifndef __NR_vmsplice +# define __SYSCALL_STUB 1 +#endif +#include _syscall4(ssize_t, vmsplice, int, __fdout, const struct iovec *, __iov, size_t, __count, unsigned int, __flags); -#else -ssize_t vmsplice(int __fdout, const struct iovec *__iov, size_t __count, - unsigned int __flags) -{ - __set_errno(ENOSYS); - return -1; -} -#endif - -libc_hidden_def(vmsplice) - Index: libc/sysdeps/linux/common/sigprocmask.c =================================================================== --- libc/sysdeps/linux/common/sigprocmask.c (revision 22095) +++ libc/sysdeps/linux/common/sigprocmask.c (working copy) @@ -8,6 +8,9 @@ */ #include + +#if defined __USE_POSIX +#include #include #undef sigprocmask @@ -68,3 +71,4 @@ int sigprocmask(int how, const sigset_t } #endif libc_hidden_def(sigprocmask) +#endif Index: libc/sysdeps/linux/common/getpgid.c =================================================================== --- libc/sysdeps/linux/common/getpgid.c (revision 22095) +++ libc/sysdeps/linux/common/getpgid.c (working copy) @@ -8,7 +8,10 @@ */ #include + +#if defined __USE_UNIX98 #include +#include #define __NR___syscall_getpgid __NR_getpgid static inline _syscall1(__kernel_pid_t, __syscall_getpgid, __kernel_pid_t, pid); @@ -17,3 +20,4 @@ pid_t getpgid(pid_t pid) { return (__syscall_getpgid(pid)); } +#endif Index: libc/sysdeps/linux/common/uselib.c =================================================================== --- libc/sysdeps/linux/common/uselib.c (revision 22095) +++ libc/sysdeps/linux/common/uselib.c (working copy) @@ -6,10 +6,14 @@ * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ +#if 0 +linux specific and we do not use it in uClibc. #include #include #ifdef __NR_uselib +#include int uselib (const char *library); _syscall1(int, uselib, const char *, library); #endif +#endif Index: libc/sysdeps/linux/common/ppoll.c =================================================================== --- libc/sysdeps/linux/common/ppoll.c (revision 22095) +++ libc/sysdeps/linux/common/ppoll.c (working copy) @@ -20,7 +20,8 @@ #include #include -#ifdef __NR_ppoll +#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __NR_ppoll +#include libc_hidden_proto(ppoll) Index: libc/sysdeps/linux/common/dup.c =================================================================== --- libc/sysdeps/linux/common/dup.c (revision 22095) +++ libc/sysdeps/linux/common/dup.c (working copy) @@ -8,4 +8,5 @@ #include #include +#include _syscall1(int, dup, int, oldfd); Index: libc/sysdeps/linux/common/chdir.c =================================================================== --- libc/sysdeps/linux/common/chdir.c (revision 22095) +++ libc/sysdeps/linux/common/chdir.c (working copy) @@ -11,6 +11,7 @@ #include #include #include +#include libc_hidden_proto(chdir) Index: libc/sysdeps/linux/common/modify_ldt.c =================================================================== --- libc/sysdeps/linux/common/modify_ldt.c (revision 22095) +++ libc/sysdeps/linux/common/modify_ldt.c (working copy) @@ -9,7 +9,8 @@ #include -int modify_ldt (int func, void *ptr, unsigned long bytecount); #ifdef __NR_modify_ldt +#include +int modify_ldt (int func, void *ptr, unsigned long bytecount); _syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount); #endif Index: libc/sysdeps/linux/common/ioperm.c =================================================================== --- libc/sysdeps/linux/common/ioperm.c (revision 22095) +++ libc/sysdeps/linux/common/ioperm.c (working copy) @@ -9,6 +9,12 @@ #include #if defined __ARCH_USE_MMU__ && defined __NR_ioperm + +#ifndef __NR_ioperm +# define __SYSCALL_STUB 1 +#endif +#include + /* psm: can't #include , some archs miss it */ extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on) __THROW; _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on); Index: libc/sysdeps/linux/common/mprotect.c =================================================================== --- libc/sysdeps/linux/common/mprotect.c (revision 22095) +++ libc/sysdeps/linux/common/mprotect.c (working copy) @@ -10,6 +10,7 @@ #include #include -#ifdef __NR_mprotect +#if defined __ARCH_USE_MMU__ && defined __NR_mprotect +#include _syscall3(int, mprotect, void *, addr, size_t, len, int, prot); #endif Index: libc/sysdeps/linux/common/__rt_sigtimedwait.c =================================================================== --- libc/sysdeps/linux/common/__rt_sigtimedwait.c (revision 22095) +++ libc/sysdeps/linux/common/__rt_sigtimedwait.c (working copy) @@ -9,13 +9,13 @@ #include #include -#define __need_NULL #include libc_hidden_proto(sigwaitinfo) libc_hidden_proto(sigtimedwait) #ifdef __NR_rt_sigtimedwait +#include #define __NR___rt_sigtimedwait __NR_rt_sigtimedwait static _syscall4(int, __rt_sigtimedwait, const sigset_t *, set, siginfo_t *, info, const struct timespec *, timeout, size_t, setsize); Index: libc/sysdeps/linux/common/mlockall.c =================================================================== --- libc/sysdeps/linux/common/mlockall.c (revision 22095) +++ libc/sysdeps/linux/common/mlockall.c (working copy) @@ -10,5 +10,6 @@ #include #include #if defined __ARCH_USE_MMU__ && defined __NR_mlockall +#include _syscall1(int, mlockall, int, flags); #endif Index: libc/sysdeps/linux/common/setpgid.c =================================================================== --- libc/sysdeps/linux/common/setpgid.c (revision 22095) +++ libc/sysdeps/linux/common/setpgid.c (working copy) @@ -8,7 +8,10 @@ */ #include + +#if defined __USE_UNIX98 || defined __USE_SVID #include +#include libc_hidden_proto(setpgid) @@ -21,3 +24,4 @@ int setpgid(pid_t pid, pid_t pgid) return (__syscall_setpgid(pid, pgid)); } libc_hidden_def(setpgid) +#endif Index: libc/sysdeps/linux/common/ustat.c =================================================================== --- libc/sysdeps/linux/common/ustat.c (revision 22095) +++ libc/sysdeps/linux/common/ustat.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #define __NR___syscall_ustat __NR_ustat static inline _syscall2(int, __syscall_ustat, Index: libc/sysdeps/linux/common/readv.c =================================================================== --- libc/sysdeps/linux/common/readv.c (revision 22095) +++ libc/sysdeps/linux/common/readv.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include extern __typeof(readv) __libc_readv; Index: libc/sysdeps/linux/common/Makefile.in =================================================================== --- libc/sysdeps/linux/common/Makefile.in (revision 22095) +++ libc/sysdeps/linux/common/Makefile.in (working copy) @@ -26,7 +26,53 @@ endif ifneq ($(UCLIBC_LINUX_MODULE_24),y) CSRC := $(filter-out create_module.c delete_module.c init_module.c \ - query_module.c,$(CSRC)) + query_module.c get_kernel_syms.c,$(CSRC)) +endif + +ifneq ($(UCLIBC_LINUX_SPECIFIC),y) +# we need these internally: fstatfs.c statfs.c +CSRC := $(filter-out inotify.c ioperm.c iopl.c madvise.c \ + modify_ldt.c personality.c prctl.c readahead.c reboot.c \ + remap_file_pages.c sched_getaffinity.c sched_setaffinity.c \ + sendfile64.c sendfile.c setfsgid.c setfsuid.c setresuid.c \ + splice.c vmsplice.c tee.c swapoff.c swapon.c sysctl.c sysinfo.c \ + uselib.c vhangup.c,$(CSRC)) +endif + +ifneq ($(UCLIBC_BSD_SPECIFIC),y) +CSRC := $(filter-out mincore.c setdomainname.c,$(CSRC)) +endif + +ifneq ($(UCLIBC_NTP_LEGACY),y) +CSRC := $(filter-out ntp_gettime.c,$(CSRC)) +endif + + +ifneq ($(UCLIBC_HAVE_REALTIME),y) +# aio_cancel|aio_error|aio_fsync|aio_read|aio_return|aio_suspend|aio_write|clock_getres|clock_gettime|clock_settime|clock_settime|fdatasync|lio_listio|mlockall|munlockall|mlock|munlock|mq_close|mq_getattr|mq_notify|mq_open|mq_receive|mq_timedreceive|mq_send|mq_timedsend|mq_setattr|mq_unlink|nanosleep|sched_getparam|sched_get_priority_max|sched_get_priority_min|sched_getscheduler|sched_rr_get_interval|sched_setparam|sched_setscheduler|sem_close|sem_destroy|sem_getvalue|sem_init|sem_open|sem_post|sem_trywait|sem_wait|sem_unlink|sem_wait|shm_open|shm_unlink|sigqueue|sigtimedwait|sigwaitinfo|sigwaitinfo|timer_create|timer_delete|timer_getoverrun|timer_gettime|timer_settime +CSRC := $(filter-out clock_getres.c clock_gettime.c clock_settime.c fdatasync.c Makefile.in mlockall.c mlock.c munlockall.c munlock.c nanosleep.c __rt_sigtimedwait.c sched_getparam.c sched_get_priority_max.c sched_get_priority_min.c sched_getscheduler.c sched_rr_get_interval.c sched_setparam.c sched_setscheduler.c sigqueue.c,$(CSRC)) +endif + + +ifneq ($(UCLIBC_HAVE_ADVANCED_REALTIME),y) +# clock_getcpuclockid|clock_nanosleep|mq_timedreceive|mq_timedsend|posix_fadvise|posix_fallocate|posix_madvise|posix_memalign|posix_mem_offset|posix_spawnattr_destroy|posix_spawnattr_init|posix_spawnattr_getflags|posix_spawnattr_setflags|posix_spawnattr_getpgroup|posix_spawnattr_setpgroup|posix_spawnattr_getschedparam|posix_spawnattr_setschedparam|posix_spawnattr_getschedpolicy|posix_spawnattr_setschedpolicy|posix_spawnattr_getsigdefault|posix_spawnattr_setsigdefault|posix_spawnattr_getsigmask|posix_spawnattr_setsigmask|posix_spawnattr_init|posix_spawnattr_setflags|posix_spawnattr_setpgroup|posix_spawnattr_setschedparam|posix_spawnattr_setschedpolicy|posix_spawnattr_setsigdefault|posix_spawnattr_setsigmask|posix_spawn_file_actions_addclose|posix_spawn_file_actions_addopen|posix_spawn_file_actions_adddup2|posix_spawn_file_actions_addopen|posix_spawn_file_actions_destroy|posix_spawn_file_actions_init|posix_spawn_file_actions_init|posix_spawn|posix_spawnp|posix_spawnp|posix_typed_mem_get_info|pthread_mutex_timedlock|sem_timedwait +CSRC := $(filter-out posix_fadvise64.c posix_fadvise.c,$(CSRC)) +endif + +ifneq ($(UCLIBC_HAVE_EPOLL),y) +CSRC := $(filter-out epoll.c,$(CSRC)) +endif + +ifneq ($(UCLIBC_HAVE_XATTR),y) +CSRC := $(filter-out xattr.c,$(CSRC)) +endif + +ifneq ($(UCLIBC_HAVE_PROFILING),y) +CSRC := $(filter-out noophooks.c pcprofile.c,$(CSRC)) +endif + +ifneq ($(UCLIBC_SV4_DEPRECATED),y) +CSRC := $(filter-out ustat.c,$(CSRC)) endif # fails for some reason Index: libc/sysdeps/linux/common/capget.c =================================================================== --- libc/sysdeps/linux/common/capget.c (revision 22095) +++ libc/sysdeps/linux/common/capget.c (working copy) @@ -8,13 +8,11 @@ */ #include + +#ifndef __NR_capget +# define __SYSCALL_STUB 1 +#endif +#include + int capget(void *header, void *data); -#ifdef __NR_capget _syscall2(int, capget, void *, header, void *, data); -#else -int capget(void *header, void *data) -{ - __set_errno(ENOSYS); - return -1; -} -#endif Index: libc/sysdeps/linux/common/adjtimex.c =================================================================== --- libc/sysdeps/linux/common/adjtimex.c (revision 22095) +++ libc/sysdeps/linux/common/adjtimex.c (working copy) @@ -10,8 +10,15 @@ #include #include +#ifndef __NR_adjtimex +# define __SYSCALL_STUB 1 +#endif +#include + libc_hidden_proto(adjtimex) _syscall1(int, adjtimex, struct timex *, buf); libc_hidden_def(adjtimex) +#if defined __UCLIBC_NTP_LEGACY__ strong_alias(adjtimex,ntp_adjtime) +#endif Index: libc/sysdeps/linux/common/uname.c =================================================================== --- libc/sysdeps/linux/common/uname.c (revision 22095) +++ libc/sysdeps/linux/common/uname.c (working copy) @@ -8,6 +8,8 @@ */ #include + +#include #include libc_hidden_proto(uname) Index: libc/sysdeps/linux/common/swapon.c =================================================================== --- libc/sysdeps/linux/common/swapon.c (revision 22095) +++ libc/sysdeps/linux/common/swapon.c (working copy) @@ -9,9 +9,10 @@ #include -#ifdef __NR_swapon +#ifndef __NR_swapon +# define __SYSCALL_STUB 1 +#endif +#include #include _syscall2(int, swapon, const char *, path, int, swapflags); - -#endif Index: libc/sysdeps/linux/common/getegid.c =================================================================== --- libc/sysdeps/linux/common/getegid.c (revision 22095) +++ libc/sysdeps/linux/common/getegid.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(getegid) Index: libc/sysdeps/linux/common/personality.c =================================================================== --- libc/sysdeps/linux/common/personality.c (revision 22095) +++ libc/sysdeps/linux/common/personality.c (working copy) @@ -9,4 +9,10 @@ #include #include + +#ifndef __NR_personality +# define __SYSCALL_STUB 1 +#endif +#include + _syscall1(int, personality, unsigned long int, __persona); Index: libc/sysdeps/linux/common/ioctl.c =================================================================== --- libc/sysdeps/linux/common/ioctl.c (revision 22095) +++ libc/sysdeps/linux/common/ioctl.c (working copy) @@ -10,7 +10,7 @@ #include #include #include - +#include libc_hidden_proto(ioctl) #define __NR___syscall_ioctl __NR_ioctl Index: libc/sysdeps/linux/common/fstatfs.c =================================================================== --- libc/sysdeps/linux/common/fstatfs.c (revision 22095) +++ libc/sysdeps/linux/common/fstatfs.c (working copy) @@ -8,9 +8,22 @@ */ #include +#include #include -libc_hidden_proto(fstatfs) +#ifndef __NR_fstatfs +# define __SYSCALL_STUB 1 +#endif +#include + +extern __typeof(fstatfs) __libc_fstatfs; +libc_hidden_proto(__libc_fstatfs) +#define __NR___libc_fstatfs __NR_fstatfs +_syscall2(int, __libc_fstatfs, int, fd, struct statfs *, buf); +libc_hidden_def(__libc_fstatfs) -_syscall2(int, fstatfs, int, fd, struct statfs *, buf); -libc_hidden_def(fstatfs) +#if defined __UCLIBC_LINUX_SPECIFIC__ +libc_hidden_proto(fstatfs) +weak_alias(__libc_fstatfs,fstatfs) +libc_hidden_weak(fstatfs) +#endif Index: libc/sysdeps/linux/common/getpid.c =================================================================== --- libc/sysdeps/linux/common/getpid.c (revision 22095) +++ libc/sysdeps/linux/common/getpid.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include extern __typeof(getpid) __libc_getpid; #if defined __NR_getxpid Index: libc/sysdeps/linux/common/sched_yield.c =================================================================== --- libc/sysdeps/linux/common/sched_yield.c (revision 22095) +++ libc/sysdeps/linux/common/sched_yield.c (working copy) @@ -9,4 +9,5 @@ #include #include +#include _syscall0(int, sched_yield); Index: libc/sysdeps/linux/common/nice.c =================================================================== --- libc/sysdeps/linux/common/nice.c (revision 22095) +++ libc/sysdeps/linux/common/nice.c (working copy) @@ -15,6 +15,7 @@ libc_hidden_proto(getpriority) #ifdef __NR_nice +#include # define __NR___syscall_nice __NR_nice static inline _syscall1(int, __syscall_nice, int, incr); Index: libc/sysdeps/linux/common/capset.c =================================================================== --- libc/sysdeps/linux/common/capset.c (revision 22095) +++ libc/sysdeps/linux/common/capset.c (working copy) @@ -8,13 +8,11 @@ */ #include + +#ifndef __NR_capset +# define __SYSCALL_STUB 1 +#endif +#include + int capset(void *header, const void *data); -#ifdef __NR_capset _syscall2(int, capset, void *, header, const void *, data); -#else -int capset(void *header, const void *data) -{ - __set_errno(ENOSYS); - return -1; -} -#endif Index: libc/sysdeps/linux/common/setgid.c =================================================================== --- libc/sysdeps/linux/common/setgid.c (revision 22095) +++ libc/sysdeps/linux/common/setgid.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #if (__WORDSIZE == 32 && defined(__NR_setgid32)) || __WORDSIZE == 64 # ifdef __NR_setgid32 Index: libc/sysdeps/linux/common/writev.c =================================================================== --- libc/sysdeps/linux/common/writev.c (revision 22095) +++ libc/sysdeps/linux/common/writev.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include extern __typeof(writev) __libc_writev; Index: libc/sysdeps/linux/common/__socketcall.c =================================================================== --- libc/sysdeps/linux/common/__socketcall.c (revision 22095) +++ libc/sysdeps/linux/common/__socketcall.c (working copy) @@ -10,6 +10,12 @@ #include #ifdef __NR_socketcall #define __NR___socketcall __NR_socketcall +#endif + +#ifndef __NR___socketcall +# define __SYSCALL_STUB 1 +#endif +#include int __socketcall(int __call, unsigned long *__args) attribute_hidden; _syscall2(int, __socketcall, int, call, unsigned long *, args); -#endif + Index: libc/sysdeps/linux/common/remap_file_pages.c =================================================================== --- libc/sysdeps/linux/common/remap_file_pages.c (revision 22095) +++ libc/sysdeps/linux/common/remap_file_pages.c (working copy) @@ -8,9 +8,11 @@ #include #include -#ifdef __NR_remap_file_pages +#ifndef __NR_remap_file_pages +# define __SYSCALL_STUB 1 +#endif +#include _syscall5(int, remap_file_pages, void *, __start, size_t, __size, int, __prot, size_t, __pgoff, int, __flags); -#endif Index: libc/sysdeps/linux/common/geteuid.c =================================================================== --- libc/sysdeps/linux/common/geteuid.c (revision 22095) +++ libc/sysdeps/linux/common/geteuid.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(geteuid) Index: libc/sysdeps/linux/common/getdents64.c =================================================================== --- libc/sysdeps/linux/common/getdents64.c (revision 22095) +++ libc/sysdeps/linux/common/getdents64.c (working copy) @@ -19,6 +19,7 @@ #include #if defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 +#include /* Experimentally off - libc_hidden_proto(memcpy) */ libc_hidden_proto(lseek64) Index: libc/sysdeps/linux/common/sigpending.c =================================================================== --- libc/sysdeps/linux/common/sigpending.c (revision 22095) +++ libc/sysdeps/linux/common/sigpending.c (working copy) @@ -8,8 +8,11 @@ */ #include + +#if defined __USE_POSIX #include #undef sigpending +#include #ifdef __NR_rt_sigpending # define __NR___rt_sigpending __NR_rt_sigpending @@ -22,3 +25,4 @@ int sigpending(sigset_t * set) #else _syscall1(int, sigpending, sigset_t *, set); #endif +#endif Index: libc/sysdeps/linux/common/msync.c =================================================================== --- libc/sysdeps/linux/common/msync.c (revision 22095) +++ libc/sysdeps/linux/common/msync.c (working copy) @@ -10,17 +10,14 @@ #include #include -#ifdef __NR_msync +#if defined __NR_msync && defined __ARCH_USE_MMU__ +#include #include -#ifdef __ARCH_USE_MMU__ - extern __typeof(msync) __libc_msync; #define __NR___libc_msync __NR_msync _syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags); weak_alias(__libc_msync,msync) #endif - -#endif Index: libc/sysdeps/linux/common/setsid.c =================================================================== --- libc/sysdeps/linux/common/setsid.c (revision 22095) +++ libc/sysdeps/linux/common/setsid.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(setsid) Index: libc/sysdeps/linux/common/sched_get_priority_max.c =================================================================== --- libc/sysdeps/linux/common/sched_get_priority_max.c (revision 22095) +++ libc/sysdeps/linux/common/sched_get_priority_max.c (working copy) @@ -9,4 +9,5 @@ #include #include +#include _syscall1(int, sched_get_priority_max, int, policy); Index: libc/sysdeps/linux/common/quotactl.c =================================================================== --- libc/sysdeps/linux/common/quotactl.c (revision 22095) +++ libc/sysdeps/linux/common/quotactl.c (working copy) @@ -8,6 +8,13 @@ */ #include + +#if defined __USE_BSD +#ifndef __NR_quotactl +# define __SYSCALL_STUB 1 +#endif +#include #include _syscall4(int, quotactl, int, cmd, const char *, special, int, id, caddr_t, addr); +#endif Index: libc/sysdeps/linux/common/munmap.c =================================================================== --- libc/sysdeps/linux/common/munmap.c (revision 22095) +++ libc/sysdeps/linux/common/munmap.c (working copy) @@ -11,7 +11,10 @@ #include #include +#if defined __NR_munmap +#include libc_hidden_proto(munmap) _syscall2(int, munmap, void *, start, size_t, length); libc_hidden_def(munmap) +#endif Index: libc/sysdeps/linux/common/setuid.c =================================================================== --- libc/sysdeps/linux/common/setuid.c (revision 22095) +++ libc/sysdeps/linux/common/setuid.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #if (__WORDSIZE == 32 && defined(__NR_setuid32)) || __WORDSIZE == 64 # ifdef __NR_setuid32 Index: libc/sysdeps/linux/common/munlockall.c =================================================================== --- libc/sysdeps/linux/common/munlockall.c (revision 22095) +++ libc/sysdeps/linux/common/munlockall.c (working copy) @@ -8,7 +8,10 @@ */ #include + +#if defined __NR_munlockall && defined __ARCH_USE_MMU__ +#include #include -#if defined __ARCH_USE_MMU__ + _syscall0(int, munlockall); #endif Index: libc/sysdeps/linux/common/seteuid.c =================================================================== --- libc/sysdeps/linux/common/seteuid.c (revision 22095) +++ libc/sysdeps/linux/common/seteuid.c (working copy) @@ -11,6 +11,11 @@ #include #include +#if !defined __UCLIBC_LINUX_SPECIFIC__ +#undef __NR_setresuid +#undef __NR_setresuid32 +#endif + libc_hidden_proto(seteuid) #if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU Index: libc/sysdeps/linux/common/rename.c =================================================================== --- libc/sysdeps/linux/common/rename.c (revision 22095) +++ libc/sysdeps/linux/common/rename.c (working copy) @@ -12,6 +12,7 @@ #include #include #include +#include #define __NR___syscall_rename __NR_rename static inline _syscall2(int, __syscall_rename, const char *, oldpath, Index: libc/sysdeps/linux/common/delete_module.c =================================================================== --- libc/sysdeps/linux/common/delete_module.c (revision 22095) +++ libc/sysdeps/linux/common/delete_module.c (working copy) @@ -7,13 +7,11 @@ */ #include + +#ifndef __NR_delete_module +# define __SYSCALL_STUB 1 +#endif +#include + int delete_module(const char *name); -#ifdef __NR_delete_module _syscall1(int, delete_module, const char *, name); -#else -int delete_module(const char *name) -{ - __set_errno(ENOSYS); - return -1; -} -#endif Index: libc/sysdeps/linux/common/mknod.c =================================================================== --- libc/sysdeps/linux/common/mknod.c (revision 22095) +++ libc/sysdeps/linux/common/mknod.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include libc_hidden_proto(mknod) Index: libc/sysdeps/linux/common/getdomainname.c =================================================================== --- libc/sysdeps/linux/common/getdomainname.c (revision 22095) +++ libc/sysdeps/linux/common/getdomainname.c (working copy) @@ -16,8 +16,9 @@ /* Experimentally off - libc_hidden_proto(strcpy) */ libc_hidden_proto(uname) -libc_hidden_proto(getdomainname) -int getdomainname(char *name, size_t len) +extern __typeof(getdomainname) __libc_getdomainname; +libc_hidden_proto(__libc_getdomainname) +int __libc_getdomainname(char *name, size_t len) { struct utsname uts; @@ -43,5 +44,10 @@ int getdomainname(char *name, size_t len #endif return 0; } -libc_hidden_def(getdomainname) +libc_hidden_def(__libc_getdomainname) +#if defined __UCLIBC_BSD_SPECIFIC__ +libc_hidden_proto(getdomainname) +weak_alias(__libc_getdomainname,getdomainname) +libc_hidden_weak(getdomainname) +#endif /* __UCLIBC_BSD_SPECIFIC__ */ #endif Index: libc/sysdeps/linux/common/fdatasync.c =================================================================== --- libc/sysdeps/linux/common/fdatasync.c (revision 22095) +++ libc/sysdeps/linux/common/fdatasync.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #if defined __NR_osf_fdatasync # define __NR_fdatasync __NR_osf_fdatasync Index: libc/sysdeps/linux/common/getresgid.c =================================================================== --- libc/sysdeps/linux/common/getresgid.c (revision 22095) +++ libc/sysdeps/linux/common/getresgid.c (working copy) @@ -10,6 +10,7 @@ #include #ifdef __USE_GNU #include +#include #if defined(__NR_getresgid32) # undef __NR_getresgid Index: libc/sysdeps/linux/common/tee.c =================================================================== --- libc/sysdeps/linux/common/tee.c (revision 22095) +++ libc/sysdeps/linux/common/tee.c (working copy) @@ -10,19 +10,9 @@ #include #include -libc_hidden_proto(tee) - -#ifdef __NR_tee +#ifndef __NR_tee +# define __SYSCALL_STUB 1 +#endif +#include _syscall4(ssize_t, tee, int, __fdin, int, __fdout, size_t, __len, unsigned int, __flags); -#else -ssize_t tee(int __fdin, int __fdout, size_t __len, unsigned int __flags) -{ - __set_errno(ENOSYS); - return -1; -} -#endif - -libc_hidden_def(tee) - - Index: libc/sysdeps/linux/common/sched_getaffinity.c =================================================================== --- libc/sysdeps/linux/common/sched_getaffinity.c (revision 22095) +++ libc/sysdeps/linux/common/sched_getaffinity.c (working copy) @@ -29,6 +29,11 @@ /* Experimentally off - libc_hidden_proto(memset) */ +#ifndef __NR_sched_getaffinity +# define __SYSCALL_STUB 1 +#endif +#include + #define __NR___syscall_sched_getaffinity __NR_sched_getaffinity static inline _syscall3(int, __syscall_sched_getaffinity, __kernel_pid_t, pid, size_t, cpusetsize, cpu_set_t *, cpuset); Index: libc/sysdeps/linux/common/umask.c =================================================================== --- libc/sysdeps/linux/common/umask.c (revision 22095) +++ libc/sysdeps/linux/common/umask.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #define __NR___syscall_umask __NR_umask static inline _syscall1(__kernel_mode_t, __syscall_umask, __kernel_mode_t, mode); Index: libc/sysdeps/linux/common/mremap.c =================================================================== --- libc/sysdeps/linux/common/mremap.c (revision 22095) +++ libc/sysdeps/linux/common/mremap.c (working copy) @@ -11,6 +11,7 @@ #include #ifdef __NR_mremap +#include #define mremap _hidemremap #include Index: libc/sysdeps/linux/common/waitid.c =================================================================== --- libc/sysdeps/linux/common/waitid.c (revision 22095) +++ libc/sysdeps/linux/common/waitid.c (working copy) @@ -6,10 +6,16 @@ */ #include + +#if defined __USE_SVID || defined __USE_XOPEN #include #include #include -#ifdef __NR_waitid +#ifndef __NR_waitid +# define __SYSCALL_STUB 1 +#endif +#include + _syscall4(int, waitid, idtype_t, idtype, id_t, id, siginfo_t*, infop, int, options); #endif Index: libc/sysdeps/linux/common/prctl.c =================================================================== --- libc/sysdeps/linux/common/prctl.c (revision 22095) +++ libc/sysdeps/linux/common/prctl.c (working copy) @@ -11,7 +11,10 @@ #include /* psm: including sys/prctl.h would depend on kernel headers */ -#ifdef __NR_prctl +#ifndef __NR_prctl +# define __SYSCALL_STUB 1 +#endif +#include + extern int prctl (int, long, long, long, long); _syscall5(int, prctl, int, option, long, arg2, long, arg3, long, arg4, long, arg5); -#endif Index: libc/sysdeps/linux/common/sched_getscheduler.c =================================================================== --- libc/sysdeps/linux/common/sched_getscheduler.c (revision 22095) +++ libc/sysdeps/linux/common/sched_getscheduler.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #define __NR___syscall_sched_getscheduler __NR_sched_getscheduler static inline _syscall1(int, __syscall_sched_getscheduler, __kernel_pid_t, pid); Index: libc/sysdeps/linux/common/setdomainname.c =================================================================== --- libc/sysdeps/linux/common/setdomainname.c (revision 22095) +++ libc/sysdeps/linux/common/setdomainname.c (working copy) @@ -10,5 +10,6 @@ #include #include #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98) +#include _syscall2(int, setdomainname, const char *, name, size_t, len); #endif Index: libc/sysdeps/linux/common/lstat.c =================================================================== --- libc/sysdeps/linux/common/lstat.c (revision 22095) +++ libc/sysdeps/linux/common/lstat.c (working copy) @@ -12,6 +12,7 @@ #define lstat64 __hidelstat64 #include +#include #include #include #include "xstatconv.h" Index: libc/sysdeps/linux/common/sigqueue.c =================================================================== --- libc/sysdeps/linux/common/sigqueue.c (revision 22095) +++ libc/sysdeps/linux/common/sigqueue.c (working copy) @@ -22,6 +22,8 @@ #include #include +#if defined __USE_POSIX199309 +#include libc_hidden_proto(getpid) libc_hidden_proto(getuid) @@ -51,3 +53,4 @@ int sigqueue (pid_t pid, int sig, const } #endif +#endif Index: libc/sysdeps/linux/common/madvise.c =================================================================== --- libc/sysdeps/linux/common/madvise.c (revision 22095) +++ libc/sysdeps/linux/common/madvise.c (working copy) @@ -8,7 +8,10 @@ */ #include -#include + #if defined __NR_madvise && defined __USE_BSD +#include +#include + _syscall3(int, madvise, void *, __addr, size_t, __len, int, __advice); #endif Index: libc/sysdeps/linux/common/readlink.c =================================================================== --- libc/sysdeps/linux/common/readlink.c (revision 22095) +++ libc/sysdeps/linux/common/readlink.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(readlink) _syscall3(ssize_t, readlink, const char *, path, char *, buf, size_t, bufsiz); Index: libc/sysdeps/linux/common/setresgid.c =================================================================== --- libc/sysdeps/linux/common/setresgid.c (revision 22095) +++ libc/sysdeps/linux/common/setresgid.c (working copy) @@ -10,6 +10,7 @@ #include #ifdef __USE_GNU #include +#include #if defined(__NR_setresgid32) # undef __NR_setresgid Index: libc/sysdeps/linux/common/reboot.c =================================================================== --- libc/sysdeps/linux/common/reboot.c (revision 22095) +++ libc/sysdeps/linux/common/reboot.c (working copy) @@ -8,6 +8,11 @@ */ #include +#ifndef __NR_reboot +# define __SYSCALL_STUB 1 +#endif +#include + #include #define __NR__reboot __NR_reboot static inline _syscall3(int, _reboot, int, magic, int, magic2, int, flag); Index: libc/sysdeps/linux/common/chmod.c =================================================================== --- libc/sysdeps/linux/common/chmod.c (revision 22095) +++ libc/sysdeps/linux/common/chmod.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(chmod) Index: libc/sysdeps/linux/common/get_kernel_syms.c =================================================================== --- libc/sysdeps/linux/common/get_kernel_syms.c (revision 22095) +++ libc/sysdeps/linux/common/get_kernel_syms.c (working copy) @@ -8,15 +8,11 @@ */ #include +#ifndef __NR_get_kernel_syms +# define __SYSCALL_STUB 1 +#endif +#include struct kernel_sym; int get_kernel_syms(struct kernel_sym *table attribute_unused); -#ifdef __NR_get_kernel_syms _syscall1(int, get_kernel_syms, struct kernel_sym *, table); -#else -int get_kernel_syms(struct kernel_sym *table attribute_unused) -{ - __set_errno(ENOSYS); - return -1; -} -#endif Index: libc/sysdeps/linux/common/getresuid.c =================================================================== --- libc/sysdeps/linux/common/getresuid.c (revision 22095) +++ libc/sysdeps/linux/common/getresuid.c (working copy) @@ -10,6 +10,7 @@ #include #ifdef __USE_GNU #include +#include #if defined(__NR_getresuid32) # undef __NR_getresuid Index: libc/sysdeps/linux/common/sched_setaffinity.c =================================================================== --- libc/sysdeps/linux/common/sched_setaffinity.c (revision 22095) +++ libc/sysdeps/linux/common/sched_setaffinity.c (working copy) @@ -33,6 +33,11 @@ libc_hidden_proto(getpid) +#ifndef __NR_sched_setaffinity +# define __SYSCALL_STUB 1 +#endif +#include + #define __NR___syscall_sched_setaffinity __NR_sched_setaffinity static inline _syscall3(int, __syscall_sched_setaffinity, __kernel_pid_t, pid, size_t, cpusetsize, cpu_set_t *, cpuset); Index: libc/sysdeps/linux/common/pipe.c =================================================================== --- libc/sysdeps/linux/common/pipe.c (revision 22095) +++ libc/sysdeps/linux/common/pipe.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(pipe) Index: libc/sysdeps/linux/common/flock.c =================================================================== --- libc/sysdeps/linux/common/flock.c (revision 22095) +++ libc/sysdeps/linux/common/flock.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #define __NR___syscall_flock __NR_flock static inline _syscall2(int, __syscall_flock, int, fd, int, operation); Index: libc/sysdeps/linux/common/getrlimit.c =================================================================== --- libc/sysdeps/linux/common/getrlimit.c (revision 22095) +++ libc/sysdeps/linux/common/getrlimit.c (working copy) @@ -11,13 +11,14 @@ #include #include #include +#include #undef getrlimit64 libc_hidden_proto(getrlimit) /* Only wrap getrlimit if the new ugetrlimit is not present and getrlimit sucks */ -#if defined(__NR_ugetrlimit) +#if defined __NR_ugetrlimit /* just call ugetrlimit() */ # define __NR___syscall_ugetrlimit __NR_ugetrlimit Index: libc/sysdeps/linux/common/unlink.c =================================================================== --- libc/sysdeps/linux/common/unlink.c (revision 22095) +++ libc/sysdeps/linux/common/unlink.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(unlink) Index: libc/sysdeps/linux/common/open.c =================================================================== --- libc/sysdeps/linux/common/open.c (revision 22095) +++ libc/sysdeps/linux/common/open.c (working copy) @@ -13,6 +13,7 @@ #include #include #include +#include extern __typeof(open) __libc_open; extern __typeof(creat) __libc_creat; Index: libc/sysdeps/linux/common/fork.c =================================================================== --- libc/sysdeps/linux/common/fork.c (revision 22095) +++ libc/sysdeps/linux/common/fork.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #ifdef __ARCH_USE_MMU__ #ifdef __NR_fork Index: libc/sysdeps/linux/common/ulimit.c =================================================================== --- libc/sysdeps/linux/common/ulimit.c (revision 22095) +++ libc/sysdeps/linux/common/ulimit.c (working copy) @@ -8,6 +8,7 @@ #include #ifdef __NR_ulimit +#include extern long int ulimit(int cmd, long arg); _syscall2(long, ulimit, int, cmd, long, arg); Index: libc/sysdeps/linux/common/pivot_root.c =================================================================== --- libc/sysdeps/linux/common/pivot_root.c (revision 22095) +++ libc/sysdeps/linux/common/pivot_root.c (working copy) @@ -9,13 +9,10 @@ #include +#ifndef __NR_pivot_root +# define __SYSCALL_STUB 1 +#endif +#include + int pivot_root(const char *new_root, const char *put_old); -#ifdef __NR_pivot_root _syscall2(int, pivot_root, const char *, new_root, const char *, put_old); -#else -int pivot_root(const char *new_root, const char *put_old) -{ - __set_errno(ENOSYS); - return -1; -} -#endif Index: libc/sysdeps/linux/common/ftruncate64.c =================================================================== --- libc/sysdeps/linux/common/ftruncate64.c (revision 22095) +++ libc/sysdeps/linux/common/ftruncate64.c (working copy) @@ -20,6 +20,7 @@ # include # include # include +# include libc_hidden_proto(ftruncate64) Index: libc/sysdeps/linux/common/setresuid.c =================================================================== --- libc/sysdeps/linux/common/setresuid.c (revision 22095) +++ libc/sysdeps/linux/common/setresuid.c (working copy) @@ -8,8 +8,9 @@ */ #include -#ifdef __USE_GNU +#if defined __USE_GNU && defined __UCLIBC_LINUX_SPECIFIC__ #include +#include #if defined(__NR_setresuid32) # undef __NR_setresuid Index: libc/sysdeps/linux/common/init_module.c =================================================================== --- libc/sysdeps/linux/common/init_module.c (revision 22095) +++ libc/sysdeps/linux/common/init_module.c (working copy) @@ -8,18 +8,15 @@ */ #include + +#ifndef __NR_init_module +# define __SYSCALL_STUB 1 +#endif +#include + int init_module(void *first, void *second, void *third, void *fourth, void *fifth); -#ifdef __NR_init_module /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments * (for 2.2 and 2.4 kernels). Use the greatest common denominator, * and let the kernel cope with whatever it gets. It's good at that. */ _syscall5(int, init_module, void *, first, void *, second, void *, third, void *, fourth, void *, fifth); -#else -int init_module(void *first, void *second, void *third, void *fourth, void *fifth) -{ - __set_errno(ENOSYS); - return -1; -} -#endif - Index: libc/sysdeps/linux/common/__syscall_sigaction.c =================================================================== --- libc/sysdeps/linux/common/__syscall_sigaction.c (revision 22095) +++ libc/sysdeps/linux/common/__syscall_sigaction.c (working copy) @@ -10,6 +10,7 @@ #include #ifndef __NR_rt_sigaction +#include #define __NR___syscall_sigaction __NR_sigaction #include int __syscall_sigaction (int __signum, const struct sigaction *__act, struct sigaction *__oldact) attribute_hidden; Index: libc/sysdeps/linux/common/setfsgid.c =================================================================== --- libc/sysdeps/linux/common/setfsgid.c (revision 22095) +++ libc/sysdeps/linux/common/setfsgid.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #if (__WORDSIZE == 32 && defined(__NR_setfsgid32)) || __WORDSIZE == 64 # ifdef __NR_setfsgid32 Index: libc/sysdeps/linux/common/setrlimit.c =================================================================== --- libc/sysdeps/linux/common/setrlimit.c (revision 22095) +++ libc/sysdeps/linux/common/setrlimit.c (working copy) @@ -12,6 +12,7 @@ #include #include #undef setrlimit64 +#include libc_hidden_proto(setrlimit) Index: libc/sysdeps/linux/common/getgroups.c =================================================================== --- libc/sysdeps/linux/common/getgroups.c (revision 22095) +++ libc/sysdeps/linux/common/getgroups.c (working copy) @@ -11,6 +11,7 @@ #include #include #include +#include libc_hidden_proto(getgroups) Index: libc/sysdeps/linux/common/splice.c =================================================================== --- libc/sysdeps/linux/common/splice.c (revision 22095) +++ libc/sysdeps/linux/common/splice.c (working copy) @@ -10,19 +10,10 @@ #include #include -libc_hidden_proto(splice) +#ifndef __NR_splice +# define __SYSCALL_STUB 1 +#endif +#include -#ifdef __NR_splice _syscall6(ssize_t, splice, int, __fdin, __off64_t *, __offin, int, __fdout, __off64_t *, __offout, size_t, __len, unsigned int, __flags); -#else -ssize_t splice(int __fdin, __off64_t *__offin, int __fdout, - __off64_t *__offout, size_t __len, unsigned int __flags) -{ - __set_errno(ENOSYS); - return -1; -} -#endif - -libc_hidden_def(splice) - Index: libc/sysdeps/linux/common/gettimeofday.c =================================================================== --- libc/sysdeps/linux/common/gettimeofday.c (revision 22095) +++ libc/sysdeps/linux/common/gettimeofday.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(gettimeofday) #ifdef __USE_BSD Index: libc/sysdeps/linux/common/stime.c =================================================================== --- libc/sysdeps/linux/common/stime.c (revision 22095) +++ libc/sysdeps/linux/common/stime.c (working copy) @@ -13,6 +13,8 @@ #ifdef __USE_SVID #ifdef __NR_stime +#include + _syscall1(int, stime, const time_t *, t); #else libc_hidden_proto(settimeofday) Index: libc/sysdeps/linux/common/sched_setparam.c =================================================================== --- libc/sysdeps/linux/common/sched_setparam.c (revision 22095) +++ libc/sysdeps/linux/common/sched_setparam.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #define __NR___syscall_sched_setparam __NR_sched_setparam static inline _syscall2(int, __syscall_sched_setparam, Index: libc/sysdeps/linux/common/setfsuid.c =================================================================== --- libc/sysdeps/linux/common/setfsuid.c (revision 22095) +++ libc/sysdeps/linux/common/setfsuid.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #if (__WORDSIZE == 32 && defined(__NR_setfsuid32)) || __WORDSIZE == 64 # ifdef __NR_setfsuid32 Index: libc/sysdeps/linux/common/wait3.c =================================================================== --- libc/sysdeps/linux/common/wait3.c (revision 22095) +++ libc/sysdeps/linux/common/wait3.c (working copy) @@ -4,11 +4,13 @@ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ -#include +#include #include #include #include +#if defined __USE_BSD + libc_hidden_proto(wait4) /* Wait for a child to exit. When one does, put its status in *STAT_LOC and @@ -20,3 +22,4 @@ pid_t wait3 (__WAIT_STATUS stat_loc, int { return wait4 (WAIT_ANY, stat_loc, options, usage); } +#endif Index: libc/sysdeps/linux/common/getitimer.c =================================================================== --- libc/sysdeps/linux/common/getitimer.c (revision 22095) +++ libc/sysdeps/linux/common/getitimer.c (working copy) @@ -9,4 +9,5 @@ #include #include +#include _syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value); Index: libc/sysdeps/linux/common/kill.c =================================================================== --- libc/sysdeps/linux/common/kill.c (revision 22095) +++ libc/sysdeps/linux/common/kill.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(kill) Index: libc/sysdeps/linux/common/setgroups.c =================================================================== --- libc/sysdeps/linux/common/setgroups.c (revision 22095) +++ libc/sysdeps/linux/common/setgroups.c (working copy) @@ -13,6 +13,7 @@ #include #ifdef __USE_BSD +#include libc_hidden_proto(setgroups) Index: libc/sysdeps/linux/common/chroot.c =================================================================== --- libc/sysdeps/linux/common/chroot.c (revision 22095) +++ libc/sysdeps/linux/common/chroot.c (working copy) @@ -12,6 +12,11 @@ #include #include +#ifndef __NR_chroot +# define __SYSCALL_STUB 1 +#endif +#include + #if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K) #define __NR___syscall_chroot __NR_chroot static inline _syscall1(int, __syscall_chroot, const char *, path); Index: libc/sysdeps/linux/common/__syscall_fcntl.c =================================================================== --- libc/sysdeps/linux/common/__syscall_fcntl.c (revision 22095) +++ libc/sysdeps/linux/common/__syscall_fcntl.c (working copy) @@ -11,6 +11,7 @@ #include #include #include +#include extern __typeof(fcntl) __libc_fcntl; libc_hidden_proto(__libc_fcntl) Index: libc/sysdeps/linux/common/clock_getres.c =================================================================== --- libc/sysdeps/linux/common/clock_getres.c (revision 22095) +++ libc/sysdeps/linux/common/clock_getres.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef __NR_clock_getres _syscall2(int, clock_getres, clockid_t, clock_id, struct timespec*, res); Index: libc/sysdeps/linux/common/pread_write.c =================================================================== --- libc/sysdeps/linux/common/pread_write.c (revision 22095) +++ libc/sysdeps/linux/common/pread_write.c (working copy) @@ -17,6 +17,7 @@ #include #include #include +#include extern __typeof(pread) __libc_pread; extern __typeof(pwrite) __libc_pwrite; Index: libc/sysdeps/linux/common/setitimer.c =================================================================== --- libc/sysdeps/linux/common/setitimer.c (revision 22095) +++ libc/sysdeps/linux/common/setitimer.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(setitimer) Index: libc/sysdeps/linux/common/mkdir.c =================================================================== --- libc/sysdeps/linux/common/mkdir.c (revision 22095) +++ libc/sysdeps/linux/common/mkdir.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(mkdir) Index: libc/sysdeps/linux/common/sysfs.c =================================================================== --- libc/sysdeps/linux/common/sysfs.c (revision 22095) +++ libc/sysdeps/linux/common/sysfs.c (working copy) @@ -9,8 +9,15 @@ /* libc isn't really supposed to export this */ #if 0 - #include + +#if defined __USE_SVID +#ifndef __NR_sysfs +# define __SYSCALL_STUB 1 +#endif +#include + _syscall3(int, sysfs, int, option, unsigned int, index, char, addr); #endif +#endif Index: libc/sysdeps/linux/common/getpgrp.c =================================================================== --- libc/sysdeps/linux/common/getpgrp.c (revision 22095) +++ libc/sysdeps/linux/common/getpgrp.c (working copy) @@ -10,6 +10,10 @@ #include #include -#ifdef __NR_getpgrp -_syscall0(pid_t, getpgrp); +#ifndef __NR_getpgrp +# define __SYSCALL_STUB 1 #endif +#include + +/* According to the manpage the POSIX.1 version is favoured */ +_syscall0(pid_t, getpgrp); Index: libc/sysdeps/linux/common/umount2.c =================================================================== --- libc/sysdeps/linux/common/umount2.c (revision 22095) +++ libc/sysdeps/linux/common/umount2.c (working copy) @@ -8,13 +8,14 @@ */ #include -#ifdef __NR_umount2 /* Old kernels don't have umount2 */ + +#if defined __USE_GNU + +#ifndef __NR_umount2 +# define __SYSCALL_STUB 1 +#endif +#include + #include _syscall2(int, umount2, const char *, special_file, int, flags); -#else -int umount2(const char *special_file, int flags) -{ - __set_errno(ENOSYS); - return -1; -} #endif Index: libc/sysdeps/linux/common/rmdir.c =================================================================== --- libc/sysdeps/linux/common/rmdir.c (revision 22095) +++ libc/sysdeps/linux/common/rmdir.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include libc_hidden_proto(rmdir) Index: libc/sysdeps/linux/common/pause.c =================================================================== --- libc/sysdeps/linux/common/pause.c (revision 22095) +++ libc/sysdeps/linux/common/pause.c (working copy) @@ -13,6 +13,7 @@ extern __typeof(pause) __libc_pause; #ifdef __NR_pause +#include #define __NR___libc_pause __NR_pause _syscall0(int, __libc_pause); #else Index: libc/sysdeps/linux/common/__syscall_rt_sigaction.c =================================================================== --- libc/sysdeps/linux/common/__syscall_rt_sigaction.c (revision 22095) +++ libc/sysdeps/linux/common/__syscall_rt_sigaction.c (working copy) @@ -11,10 +11,15 @@ #ifdef __NR_rt_sigaction #include +#define __NR___syscall_rt_sigaction __NR_rt_sigaction +#endif +#ifndef __NR_rt_sigaction +# define __SYSCALL_STUB 1 +#endif +#include int __syscall_rt_sigaction (int __signum, const struct sigaction *__act, struct sigaction *__oldact, size_t __size) attribute_hidden; -#define __NR___syscall_rt_sigaction __NR_rt_sigaction + _syscall4(int, __syscall_rt_sigaction, int, signum, const struct sigaction *, act, struct sigaction *, oldact, size_t, size); -#endif Index: libc/sysdeps/linux/common/ptrace.c =================================================================== --- libc/sysdeps/linux/common/ptrace.c (revision 22095) +++ libc/sysdeps/linux/common/ptrace.c (working copy) @@ -10,6 +10,8 @@ #include #include +#if defined __USE_BSD && defined __USE_MISC +#include #define __NR___syscall_ptrace __NR_ptrace static inline _syscall4(long, __syscall_ptrace, enum __ptrace_request, request, @@ -40,3 +42,4 @@ ptrace (enum __ptrace_request request, . return res; } +#endif Index: libc/sysdeps/linux/common/nanosleep.c =================================================================== --- libc/sysdeps/linux/common/nanosleep.c (revision 22095) +++ libc/sysdeps/linux/common/nanosleep.c (working copy) @@ -10,6 +10,9 @@ #include #include +#if defined __USE_POSIX199309 && defined __NR_nanosleep +#include + extern __typeof(nanosleep) __libc_nanosleep; #define __NR___libc_nanosleep __NR_nanosleep _syscall2(int, __libc_nanosleep, const struct timespec *, req, @@ -17,3 +20,4 @@ _syscall2(int, __libc_nanosleep, const s libc_hidden_proto(nanosleep) weak_alias(__libc_nanosleep,nanosleep) libc_hidden_weak(nanosleep) +#endif Index: libc/sysdeps/linux/common/fchown.c =================================================================== --- libc/sysdeps/linux/common/fchown.c (revision 22095) +++ libc/sysdeps/linux/common/fchown.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #if (__WORDSIZE == 32 && defined(__NR_fchown32)) || __WORDSIZE == 64 # ifdef __NR_fchown32 Index: libc/sysdeps/linux/common/stat64.c =================================================================== --- libc/sysdeps/linux/common/stat64.c (revision 22095) +++ libc/sysdeps/linux/common/stat64.c (working copy) @@ -11,6 +11,7 @@ #include #if defined __UCLIBC_HAS_LFS__ && defined __NR_stat64 +#include libc_hidden_proto(stat64) # define __NR___syscall_stat64 __NR_stat64 Index: libc/sysdeps/linux/common/symlink.c =================================================================== --- libc/sysdeps/linux/common/symlink.c (revision 22095) +++ libc/sysdeps/linux/common/symlink.c (working copy) @@ -8,5 +8,8 @@ */ #include +#if defined __USE_BSD || defined __USE_UNIX98 || defined __USE_XOPEN2K +#include #include _syscall2(int, symlink, const char *, oldpath, const char *, newpath); +#endif Index: libc/sysdeps/linux/common/mmap.c =================================================================== --- libc/sysdeps/linux/common/mmap.c (revision 22095) +++ libc/sysdeps/linux/common/mmap.c (working copy) @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef __NR_mmap Index: libc/sysdeps/linux/common/mincore.c =================================================================== --- libc/sysdeps/linux/common/mincore.c (revision 22095) +++ libc/sysdeps/linux/common/mincore.c (working copy) @@ -7,9 +7,10 @@ */ #include + +#if defined __NR_mincore && (defined __USE_BSD || defined __USE_SVID) #include #include - -#ifdef __NR_mincore +#include _syscall3(int, mincore, void *, start, size_t, length, unsigned char *, vec); #endif Index: libc/sysdeps/linux/common/getppid.c =================================================================== --- libc/sysdeps/linux/common/getppid.c (revision 22095) +++ libc/sysdeps/linux/common/getppid.c (working copy) @@ -9,6 +9,7 @@ #include #include +#include #ifdef __NR_getppid _syscall0(pid_t, getppid); #else Index: libc/sysdeps/linux/common/sched_rr_get_interval.c =================================================================== --- libc/sysdeps/linux/common/sched_rr_get_interval.c (revision 22095) +++ libc/sysdeps/linux/common/sched_rr_get_interval.c (working copy) @@ -10,6 +10,7 @@ #include #include #include +#include #define __NR___syscall_sched_rr_get_interval __NR_sched_rr_get_interval static inline _syscall2(int, __syscall_sched_rr_get_interval, Index: libc/sysdeps/linux/common/link.c =================================================================== --- libc/sysdeps/linux/common/link.c (revision 22095) +++ libc/sysdeps/linux/common/link.c (working copy) @@ -9,4 +9,5 @@ #include #include +#include _syscall2(int, link, const char *, oldpath, const char *, newpath); Index: libc/sysdeps/linux/i386/bits/syscalls.h =================================================================== --- libc/sysdeps/linux/i386/bits/syscalls.h (revision 22095) +++ libc/sysdeps/linux/i386/bits/syscalls.h (working copy) @@ -1,6 +1,6 @@ #ifndef _BITS_SYSCALLS_H #define _BITS_SYSCALLS_H -#ifndef _SYSCALL_H +#if !defined _SYSCALL_H && !defined __SYSCALL_STUB_H__ # error "Never use directly; include instead." #endif @@ -13,7 +13,7 @@ #include -#define SYS_ify(syscall_name) (__NR_##syscall_name) +#define SYS_ify(syscall_name) (__NR_##syscall_name) #define INTERNAL_SYSCALL_DECL(err) do { } while (0) @@ -102,66 +102,6 @@ __asm__ (".L__X'%ebx = 1\n\t" ".endm\n\t"); #endif -#undef _syscall0 -#define _syscall0(type,name) \ -type name(void) \ -{ \ -return (type) (INLINE_SYSCALL(name, 0)); \ -} - -#undef _syscall1 -#define _syscall1(type,name,type1,arg1) \ -type name(type1 arg1) \ -{ \ -return (type) (INLINE_SYSCALL(name, 1, arg1)); \ -} - -#undef _syscall2 -#define _syscall2(type,name,type1,arg1,type2,arg2) \ -type name(type1 arg1,type2 arg2) \ -{ \ -return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \ -} - -#undef _syscall3 -#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ -type name(type1 arg1,type2 arg2,type3 arg3) \ -{ \ -return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \ -} - -#undef _syscall4 -#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ -type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ -{ \ -return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \ -} - -#undef _syscall5 -#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ -{ \ -return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \ -} - -#undef _syscall6 -#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ - type5,arg5,type6,arg6) \ -type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ -{ \ -return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \ -} - #define INLINE_SYSCALL(name, nr, args...) \ - ({ \ - unsigned int _resultvar = INTERNAL_SYSCALL (name, , nr, args); \ - if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_resultvar, ), 0)) \ - { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (_resultvar, )); \ - _resultvar = 0xffffffff; \ - } \ - (int) _resultvar; }) - #define INTERNAL_SYSCALL(name, err, nr, args...) \ ({ \ register unsigned int resultvar; \ Index: libc/misc/error/Makefile.in =================================================================== --- libc/misc/error/Makefile.in (revision 22095) +++ libc/misc/error/Makefile.in (working copy) @@ -6,6 +6,9 @@ # CSRC := error.c err.c +ifneq ($(UCLIBC_HAS_GNU_ERROR),y) +MISC_ERROR_SRC := $(filter-out error.c, $(CSRC)) +endif MISC_ERROR_DIR := $(top_srcdir)libc/misc/error MISC_ERROR_OUT := $(top_builddir)libc/misc/error Index: libc/misc/error/err.c =================================================================== --- libc/misc/error/err.c (revision 22095) +++ libc/misc/error/err.c (working copy) @@ -19,6 +19,8 @@ #warning REMINDER: Deal with wide oriented stderr case. #endif +#if defined __USE_BSD + libc_hidden_proto(vwarn) libc_hidden_proto(vwarnx) libc_hidden_proto(verr) @@ -124,3 +126,4 @@ void attribute_noreturn errx(int status, while(1) va_end(args); } +#endif Index: libc/misc/sysvipc/__syscall_ipc.c =================================================================== --- libc/misc/sysvipc/__syscall_ipc.c (revision 22095) +++ libc/misc/sysvipc/__syscall_ipc.c (working copy) @@ -10,6 +10,7 @@ #include #ifdef __NR_ipc +#include #define __NR___syscall_ipc __NR_ipc #include "ipc.h" _syscall6(int, __syscall_ipc, unsigned int, call, long, first, long, second, long, Index: libc/misc/sysvipc/sem.c =================================================================== --- libc/misc/sysvipc/sem.c (revision 22095) +++ libc/misc/sysvipc/sem.c (working copy) @@ -19,6 +19,7 @@ #include #include +#include #include "ipc.h" @@ -26,6 +27,7 @@ /* Return identifier for array of NSEMS semaphores associated with KEY. */ #include +#include /* arg for semctl system calls. */ union semun { int val; /* value for SETVAL */ @@ -53,7 +55,7 @@ int semctl(int semid, int semnum, int cm #ifdef __NR_semctl return __semctl(semid, semnum, cmd | __IPC_64, arg.__pad); #else - return __syscall_ipc(IPCOP_semctl, semid, semnum, cmd | __IPC_64, &arg, 0); + return __syscall_ipc(IPCOP_semctl, semid, semnum, cmd|__IPC_64, &arg, NULL); #endif } #endif @@ -84,7 +86,7 @@ _syscall3(int, semop, int, semid, struct /* Perform user-defined atomical operation of array of semaphores. */ int semop (int semid, struct sembuf *sops, size_t nsops) { - return __syscall_ipc(IPCOP_semop, semid, (int) nsops, 0, sops, 0); + return __syscall_ipc(IPCOP_semop, semid, (int) nsops, 0, sops, NULL); } #endif #endif Index: libc/misc/statfs/fstatvfs.c =================================================================== --- libc/misc/statfs/fstatvfs.c (revision 22095) +++ libc/misc/statfs/fstatvfs.c (working copy) @@ -34,7 +34,8 @@ libc_hidden_proto(setmntent) libc_hidden_proto(getmntent_r) libc_hidden_proto(endmntent) -libc_hidden_proto(fstatfs) +extern __typeof(fstatfs) __libc_fstatfs; +libc_hidden_proto(__libc_fstatfs) libc_hidden_proto(fstat) libc_hidden_proto(stat) @@ -44,7 +45,7 @@ int fstatvfs (int fd, struct statvfs *bu struct stat st; /* Get as much information as possible from the system. */ - if (fstatfs (fd, &fsbuf) < 0) + if (__libc_fstatfs (fd, &fsbuf) < 0) return -1; #define STAT(st) fstat (fd, st) Index: libc/misc/statfs/statvfs.c =================================================================== --- libc/misc/statfs/statvfs.c (revision 22095) +++ libc/misc/statfs/statvfs.c (working copy) @@ -34,7 +34,8 @@ libc_hidden_proto(setmntent) libc_hidden_proto(getmntent_r) libc_hidden_proto(endmntent) -libc_hidden_proto(statfs) +extern __typeof(statfs) __libc_statfs; +libc_hidden_proto(__libc_statfs) libc_hidden_proto(stat) int statvfs (const char *file, struct statvfs *buf) @@ -43,7 +44,7 @@ int statvfs (const char *file, struct st struct stat st; /* Get as much information as possible from the system. */ - if (statfs (file, &fsbuf) < 0) + if (__libc_statfs (file, &fsbuf) < 0) return -1; #define STAT(st) stat (file, st) Index: libc/signal/sigwait.c =================================================================== --- libc/signal/sigwait.c (revision 22095) +++ libc/signal/sigwait.c (working copy) @@ -22,6 +22,7 @@ #include #include +#if defined __UCLIBC_HAVE_REALTIME__ libc_hidden_proto(sigwaitinfo) int __sigwait (const sigset_t *set, int *sig) attribute_hidden; @@ -34,6 +35,67 @@ int __sigwait (const sigset_t *set, int } return 1; } +#else /* __UCLIBC_HAVE_REALTIME__ */ +/* variant without REALTIME extensions */ +libc_hidden_proto(sigfillset) +libc_hidden_proto(sigaction) +libc_hidden_proto(sigsuspend) + +static int was_sig; /* obviously not thread-safe */ +static void ignore_signal(int sig) +{ + was_sig = sig; +} +int __sigwait (const sigset_t *set, int *sig) attribute_hidden; +int __sigwait (const sigset_t *set, int *sig) +{ + sigset_t tmp_mask; + struct sigaction saved[NSIG]; + struct sigaction action; + int save_errno; + int this; + + /* Prepare set. */ + sigfillset (&tmp_mask); + + /* Unblock all signals in the SET and register our nice handler. */ + action.sa_handler = ignore_signal; + action.sa_flags = 0; + sigfillset (&action.sa_mask); /* Block all signals for handler. */ + + /* Make sure we recognize error conditions by setting WAS_SIG to a + value which does not describe a legal signal number. */ + was_sig = -1; + + for (this = 1; this < NSIG; ++this) + if (__sigismember (set, this)) + { + /* Unblock this signal. */ + __sigdelset (&tmp_mask, this); + + /* Register temporary action handler. */ + if (sigaction (this, &action, &saved[this]) != 0) + goto restore_handler; + } + + /* Now we can wait for signals. */ + sigsuspend (&tmp_mask); + + restore_handler: + save_errno = errno; + + while (--this >= 1) + if (__sigismember (set, this)) + /* We ignore errors here since we must restore all handlers. */ + sigaction (this, &saved[this], NULL); + + __set_errno (save_errno); + + /* Store the result and return. */ + *sig = was_sig; + return was_sig == -1 ? -1 : 0; +} +#endif /* __UCLIBC_HAVE_REALTIME__ */ libc_hidden_proto(sigwait) weak_alias(__sigwait,sigwait) libc_hidden_def(sigwait) Index: librt/mq_open.c =================================================================== --- librt/mq_open.c (revision 22095) +++ librt/mq_open.c (working copy) @@ -10,6 +10,7 @@ #include #ifdef __NR_mq_open +#include #define __NR___syscall_mq_open __NR_mq_open static inline _syscall4(int, __syscall_mq_open, const char *, name, Index: librt/timer_gettime.c =================================================================== --- librt/timer_gettime.c (revision 22095) +++ librt/timer_gettime.c (working copy) @@ -10,6 +10,7 @@ #include "kernel-posix-timers.h" #ifdef __NR_timer_gettime +#include #define __NR___syscall_timer_gettime __NR_timer_gettime static inline _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid, Index: librt/mq_close.c =================================================================== --- librt/mq_close.c (revision 22095) +++ librt/mq_close.c (working copy) @@ -9,6 +9,7 @@ #include #ifdef __NR_mq_open +#include /* * Remove the association between message queue descriptor and its Index: librt/timer_delete.c =================================================================== --- librt/timer_delete.c (revision 22095) +++ librt/timer_delete.c (working copy) @@ -10,6 +10,7 @@ #include "kernel-posix-timers.h" #ifdef __NR_timer_delete +#include #define __NR___syscall_timer_delete __NR_timer_delete static inline _syscall1(int, __syscall_timer_delete, kernel_timer_t, ktimerid); Index: librt/timer_create.c =================================================================== --- librt/timer_create.c (revision 22095) +++ librt/timer_create.c (working copy) @@ -12,6 +12,7 @@ #include "kernel-posix-timers.h" #ifdef __NR_timer_create +#include #ifndef offsetof # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) Index: librt/mq_notify.c =================================================================== --- librt/mq_notify.c (revision 22095) +++ librt/mq_notify.c (working copy) @@ -9,6 +9,7 @@ #include #ifdef __NR_mq_notify +#include #define __NR___syscall_mq_notify __NR_mq_notify static inline _syscall2(int, __syscall_mq_notify, int, mqdes, Index: librt/timer_settime.c =================================================================== --- librt/timer_settime.c (revision 22095) +++ librt/timer_settime.c (working copy) @@ -10,6 +10,7 @@ #include "kernel-posix-timers.h" #ifdef __NR_timer_settime +#include #define __NR___syscall_timer_settime __NR_timer_settime static inline _syscall4(int, __syscall_timer_settime, kernel_timer_t, ktimerid, Index: librt/mq_receive.c =================================================================== --- librt/mq_receive.c (revision 22095) +++ librt/mq_receive.c (working copy) @@ -6,9 +6,10 @@ #include #include #include - +#warning FIXME: hard dependency on ADVANCED REALTIME feature librt_hidden_proto(mq_timedreceive) #ifdef __NR_mq_timedreceive +#include #define __NR___syscall_mq_timedreceive __NR_mq_timedreceive static inline _syscall5(int, __syscall_mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, msg_len, unsigned int *, Index: librt/mq_getsetattr.c =================================================================== --- librt/mq_getsetattr.c (revision 22095) +++ librt/mq_getsetattr.c (working copy) @@ -9,6 +9,7 @@ #include #ifdef __NR_mq_getsetattr +#include librt_hidden_proto(mq_setattr) #define __NR___syscall_mq_getsetattr __NR_mq_getsetattr Index: librt/mq_send.c =================================================================== --- librt/mq_send.c (revision 22095) +++ librt/mq_send.c (working copy) @@ -6,9 +6,11 @@ #include #include #include +#warning FIXME: hard dependency on ADVANCED REALTIME feature librt_hidden_proto(mq_timedsend) #ifdef __NR_mq_timedsend +#include #define __NR___syscall_mq_timedsend __NR_mq_timedsend static inline _syscall5(int, __syscall_mq_timedsend, int, mqdes, const char *, msg_ptr, size_t, msg_len, unsigned int, Index: librt/mq_unlink.c =================================================================== --- librt/mq_unlink.c (revision 22095) +++ librt/mq_unlink.c (working copy) @@ -8,6 +8,7 @@ #include #ifdef __NR_mq_unlink +#include #define __NR___syscall_mq_unlink __NR_mq_unlink static inline _syscall1(int, __syscall_mq_unlink, const char *, name); Index: librt/timer_getoverr.c =================================================================== --- librt/timer_getoverr.c (revision 22095) +++ librt/timer_getoverr.c (working copy) @@ -9,6 +9,7 @@ #include "kernel-posix-timers.h" #ifdef __NR_timer_getoverrun +#include #define __NR___syscall_timer_getoverrun __NR_timer_getoverrun static inline _syscall1(int, __syscall_timer_getoverrun, kernel_timer_t,