summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2006-08-24 02:58:45 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2006-08-24 02:58:45 +0000
commit01f422c12f5799a44832eb26967a906edfc2ba55 (patch)
tree1e8bdcaab1f4da088cc1c490bf96c361a663e0c4 /libc/sysdeps/linux/common
parentd2db9bdb4c79afcd4b09353346cd4eaf63b6cd2c (diff)
downloaduClibc-alpine-01f422c12f5799a44832eb26967a906edfc2ba55.tar.bz2
uClibc-alpine-01f422c12f5799a44832eb26967a906edfc2ba55.tar.xz
Well, this is everything for my NPTL implementation. The 'uClibc-nptl' branch is now the exact code that I have. I am going to re-run tests now to verify everything one more time. The next step after that is to merge from trunk with the latest stuff from Mike and Peter.
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/__rt_sigtimedwait.c5
-rw-r--r--libc/sysdeps/linux/common/__rt_sigwaitinfo.c5
-rw-r--r--libc/sysdeps/linux/common/__syscall_fcntl.c96
-rw-r--r--libc/sysdeps/linux/common/_exit.c38
-rw-r--r--libc/sysdeps/linux/common/acct.c2
-rw-r--r--libc/sysdeps/linux/common/bits/errno.h2
-rw-r--r--libc/sysdeps/linux/common/bits/kernel_sigaction.h10
-rw-r--r--libc/sysdeps/linux/common/bits/poll.h6
-rw-r--r--libc/sysdeps/linux/common/bits/posix_opt.h30
-rw-r--r--libc/sysdeps/linux/common/bits/sched.h5
-rw-r--r--libc/sysdeps/linux/common/bits/siginfo.h5
-rw-r--r--libc/sysdeps/linux/common/bits/socket.h2
-rw-r--r--libc/sysdeps/linux/common/bits/types.h166
-rw-r--r--libc/sysdeps/linux/common/bits/uio.h1
-rw-r--r--libc/sysdeps/linux/common/chown.c3
-rw-r--r--libc/sysdeps/linux/common/chroot.c2
-rw-r--r--libc/sysdeps/linux/common/fsync.c21
-rw-r--r--libc/sysdeps/linux/common/getdnnm.c8
-rw-r--r--libc/sysdeps/linux/common/geteuid.c26
-rw-r--r--libc/sysdeps/linux/common/getpagesize.c1
-rw-r--r--libc/sysdeps/linux/common/gettimeofday.c5
-rw-r--r--libc/sysdeps/linux/common/getuid.c20
-rw-r--r--libc/sysdeps/linux/common/llseek.c1
-rw-r--r--libc/sysdeps/linux/common/madvise.c2
-rw-r--r--libc/sysdeps/linux/common/open64.c59
-rw-r--r--libc/sysdeps/linux/common/poll.c66
-rw-r--r--libc/sysdeps/linux/common/pselect.c28
-rw-r--r--libc/sysdeps/linux/common/readv.c37
-rw-r--r--libc/sysdeps/linux/common/sbrk.c1
-rw-r--r--libc/sysdeps/linux/common/select.c2
-rw-r--r--libc/sysdeps/linux/common/setdomainname.c2
-rw-r--r--libc/sysdeps/linux/common/setegid.c4
-rw-r--r--libc/sysdeps/linux/common/seteuid.c4
-rw-r--r--libc/sysdeps/linux/common/setgroups.c3
-rw-r--r--libc/sysdeps/linux/common/sethostname.c2
-rw-r--r--libc/sysdeps/linux/common/settimeofday.c3
-rw-r--r--libc/sysdeps/linux/common/sigprocmask.c9
-rw-r--r--libc/sysdeps/linux/common/sigsuspend.c37
-rw-r--r--libc/sysdeps/linux/common/stime.c3
-rw-r--r--libc/sysdeps/linux/common/sysfs.c5
-rw-r--r--libc/sysdeps/linux/common/umount.c2
-rw-r--r--libc/sysdeps/linux/common/utime.c2
-rw-r--r--libc/sysdeps/linux/common/vhangup.c2
-rw-r--r--libc/sysdeps/linux/common/wait.c38
-rw-r--r--libc/sysdeps/linux/common/waitpid.c50
-rw-r--r--libc/sysdeps/linux/common/writev.c38
46 files changed, 627 insertions, 232 deletions
diff --git a/libc/sysdeps/linux/common/__rt_sigtimedwait.c b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
index f468222af..5d034795c 100644
--- a/libc/sysdeps/linux/common/__rt_sigtimedwait.c
+++ b/libc/sysdeps/linux/common/__rt_sigtimedwait.c
@@ -10,6 +10,9 @@
#include "syscalls.h"
#include <signal.h>
+#include <string.h>
+
+libc_hidden_proto(memcpy)
#ifdef __NR_rt_sigtimedwait
@@ -30,7 +33,7 @@ static int do_sigtimedwait(const sigset_t *set, siginfo_t *info,
{
/* Create a temporary mask without the bit for SIGCANCEL set. */
// We are not copying more than we have to.
- __memcpy (&tmpset, set, _NSIG / 8);
+ memcpy (&tmpset, set, _NSIG / 8);
__sigdelset (&tmpset, SIGCANCEL);
# ifdef SIGSETXID
__sigdelset (&tmpset, SIGSETXID);
diff --git a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
index 81c34435f..c9a497503 100644
--- a/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
+++ b/libc/sysdeps/linux/common/__rt_sigwaitinfo.c
@@ -10,6 +10,9 @@
#include "syscalls.h"
#include <signal.h>
+#include <string.h>
+
+libc_hidden_proto(memcpy)
#ifdef __NR_rt_sigtimedwait
@@ -29,7 +32,7 @@ static int do_sigwaitinfo(const sigset_t *set, siginfo_t *info)
{
/* Create a temporary mask without the bit for SIGCANCEL set. */
// We are not copying more than we have to.
- __memcpy (&tmpset, set, _NSIG / 8);
+ memcpy (&tmpset, set, _NSIG / 8);
__sigdelset (&tmpset, SIGCANCEL);
# ifdef SIGSETXID
__sigdelset (&tmpset, SIGSETXID);
diff --git a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
index ca9aff5e7..56a282a6a 100644
--- a/libc/sysdeps/linux/common/__syscall_fcntl.c
+++ b/libc/sysdeps/linux/common/__syscall_fcntl.c
@@ -2,49 +2,91 @@
/*
* __syscall_fcntl() for uClibc
*
- * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+ * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include "syscalls.h"
#include <stdarg.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
+#endif
#include <fcntl.h>
+#include <bits/wordsize.h>
-#undef __fcntl
+extern __typeof(fcntl) __libc_fcntl;
+libc_hidden_proto(__libc_fcntl)
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
-extern int __fcntl64(int fd, int cmd, ...) attribute_hidden;
-#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+int __fcntl_nocancel (int fd, int cmd, ...)
+{
+ va_list ap;
+ void *arg;
+
+ va_start (ap, cmd);
+ arg = va_arg (ap, void *);
+ va_end (ap);
-#undef fcntl
-#define __NR___syscall_fcntl __NR_fcntl
-static inline
-_syscall3(int, __syscall_fcntl, int, fd, int, cmd, long, arg);
+# if __WORDSIZE == 32
+ if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
+# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
+ return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+# else
+ __set_errno(ENOSYS);
+ return -1;
+# endif
+ }
+# endif
+ return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+}
+#endif
-int attribute_hidden __fcntl(int fd, int cmd, ...)
+int __libc_fcntl (int fd, int cmd, ...)
{
- long arg;
- va_list list;
+ va_list ap;
+ void *arg;
- va_start(list, cmd);
- arg = va_arg(list, long);
- va_end(list);
+ va_start (ap, cmd);
+ arg = va_arg (ap, void *);
+ va_end (ap);
- if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
-#if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
- return __fcntl64(fd, cmd, arg);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
+# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
+ return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+# else
+ return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+# endif
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
+ int result = INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+# else
+ int result = INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
+# endif
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
#else
+# if __WORDSIZE == 32
+ if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
+# if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
+ return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
+# else
__set_errno(ENOSYS);
return -1;
-#endif
+# endif
}
- return (__syscall_fcntl(fd, cmd, arg));
-}
-strong_alias(__fcntl,fcntl)
-weak_alias(__fcntl,__libc_fcntl)
-#if ! defined __NR_fcntl64 && defined __UCLIBC_HAS_LFS__
-hidden_strong_alias(__fcntl,__fcntl64)
-weak_alias(__fcntl,fcntl64)
-weak_alias(__fcntl,__libc_fcntl64)
+# endif
+ return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
#endif
+}
+libc_hidden_def(__libc_fcntl)
+
+libc_hidden_proto(fcntl)
+weak_alias(__libc_fcntl,fcntl)
+libc_hidden_weak(fcntl)
diff --git a/libc/sysdeps/linux/common/_exit.c b/libc/sysdeps/linux/common/_exit.c
index 4e450bbc5..4614ef9e0 100644
--- a/libc/sysdeps/linux/common/_exit.c
+++ b/libc/sysdeps/linux/common/_exit.c
@@ -2,29 +2,22 @@
/*
* exit syscall for uClibc
*
- * Copyright (C) 2002 by Erik Andersen <andersen@codepoet.org>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2002-2006 by Erik Andersen <andersen@codepoet.org>
*
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include <features.h>
#include <errno.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/syscall.h>
+#ifdef __UCLIBC_HAS_THREADS__
+#include <sysdep.h>
+#endif
+
+libc_hidden_proto(_exit)
#ifndef INLINE_SYSCALL
#define INLINE_SYSCALL(name, nr, args...) __syscall_exit (args)
@@ -32,12 +25,17 @@
static inline _syscall1(void, __syscall_exit, int, status);
#endif
-#undef _exit
-#undef _exit_internal
-void attribute_noreturn attribute_hidden _exit_internal(int status)
+void attribute_noreturn _exit(int status)
{
/* The loop is added only to keep gcc happy. */
while(1)
+ {
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# ifdef __NR_exit_group
+ INLINE_SYSCALL(exit_group, 1, status);
+# endif
+#endif
INLINE_SYSCALL(exit, 1, status);
+ }
}
-strong_alias(_exit_internal,_exit)
+libc_hidden_def(_exit)
diff --git a/libc/sysdeps/linux/common/acct.c b/libc/sysdeps/linux/common/acct.c
index 5c64623fb..2e7d1c600 100644
--- a/libc/sysdeps/linux/common/acct.c
+++ b/libc/sysdeps/linux/common/acct.c
@@ -9,4 +9,6 @@
#include "syscalls.h"
#include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
_syscall1(int, acct, const char *, filename);
+#endif
diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h
index 03d4729f6..f5831ef4d 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -19,7 +19,7 @@
#ifdef _ERRNO_H
-# include <bits/errno_values.h>
+#include <bits/errno_values.h>
#ifndef ENOTSUP
# define ENOTSUP EOPNOTSUPP
diff --git a/libc/sysdeps/linux/common/bits/kernel_sigaction.h b/libc/sysdeps/linux/common/bits/kernel_sigaction.h
index 5baf1e224..2fdfc897e 100644
--- a/libc/sysdeps/linux/common/bits/kernel_sigaction.h
+++ b/libc/sysdeps/linux/common/bits/kernel_sigaction.h
@@ -1,5 +1,5 @@
-#ifndef _BITS_STAT_STRUCT_H
-#define _BITS_STAT_STRUCT_H
+#ifndef _BITS_SIGACTION_STRUCT_H
+#define _BITS_SIGACTION_STRUCT_H
/* This file provides whatever this particular arch's kernel thinks
* the sigaction struct should look like... */
@@ -59,10 +59,10 @@ struct kernel_sigaction {
#ifndef NO_OLD_SIGACTION
extern int __syscall_sigaction (int, const struct old_kernel_sigaction *__unbounded,
- struct old_kernel_sigaction *__unbounded);
+ struct old_kernel_sigaction *__unbounded) attribute_hidden;
#endif
extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded,
- struct kernel_sigaction *__unbounded, size_t);
+ struct kernel_sigaction *__unbounded, size_t) attribute_hidden;
-#endif /* _BITS_STAT_STRUCT_H */
+#endif /* _BITS_SIGACTION_STRUCT_H */
diff --git a/libc/sysdeps/linux/common/bits/poll.h b/libc/sysdeps/linux/common/bits/poll.h
index dccb8b666..d7996b46c 100644
--- a/libc/sysdeps/linux/common/bits/poll.h
+++ b/libc/sysdeps/linux/common/bits/poll.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,8 +36,10 @@
#endif
#ifdef __USE_GNU
-/* This is an extension for Linux. */
+/* These are extensions for Linux. */
# define POLLMSG 0x400
+# define POLLREMOVE 0x1000
+# define POLLRDHUP 0x2000
#endif
/* Event types always implicitly polled for. These bits need not be set in
diff --git a/libc/sysdeps/linux/common/bits/posix_opt.h b/libc/sysdeps/linux/common/bits/posix_opt.h
index b2cae9d41..ce416c9dd 100644
--- a/libc/sysdeps/linux/common/bits/posix_opt.h
+++ b/libc/sysdeps/linux/common/bits/posix_opt.h
@@ -58,7 +58,7 @@
/* Setting of memory protections is supported. */
#ifdef __ARCH_USE_MMU__
-# define _POSIX_MEMORY_PROTECTION 1
+# define _POSIX_MEMORY_PROTECTION 200112L
#else
# undef _POSIX_MEMORY_PROTECTION
#endif
@@ -101,7 +101,7 @@
/* We have the reentrant functions described in POSIX. */
#ifdef __UCLIBC_HAS_THREADS__
-# define _POSIX_REENTRANT_FUNCTIONS 1
+# define _POSIX_REENTRANT_FUNCTIONS 1
# define _POSIX_THREAD_SAFE_FUNCTIONS 1
#else
# undef _POSIX_REENTRANT_FUNCTIONS
@@ -165,6 +165,14 @@
# define _POSIX_THREAD_CPUTIME 200912L
#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+/* CPU-time clocks support needs to be checked at runtime. */
+#define _POSIX_CPUTIME 0
+
+/* Clock support in threads must be also checked at runtime. */
+#define _POSIX_THREAD_CPUTIME 0
+#endif
+
/* Reader/Writer locks are available. */
#define _POSIX_READER_WRITER_LOCKS 200912L
@@ -190,7 +198,23 @@
/* The barrier functions are available. */
#define _POSIX_BARRIERS 200912L
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+/* POSIX message queues are available. */
+# define _POSIX_MESSAGE_PASSING 200112L
+#else
/* POSIX message queues are not yet supported. */
-#undef _POSIX_MESSAGE_PASSING
+# undef _POSIX_MESSAGE_PASSING
+#endif
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+/* Thread process-shared synchronization is supported. */
+#define _POSIX_THREAD_PROCESS_SHARED 200112L
+
+/* The monotonic clock might be available. */
+#define _POSIX_MONOTONIC_CLOCK 0
+
+/* The clock selection interfaces are available. */
+#define _POSIX_CLOCK_SELECTION 200112L
+#endif
#endif /* bits/posix_opt.h */
diff --git a/libc/sysdeps/linux/common/bits/sched.h b/libc/sysdeps/linux/common/bits/sched.h
index df1d2f6da..af6276b5a 100644
--- a/libc/sysdeps/linux/common/bits/sched.h
+++ b/libc/sysdeps/linux/common/bits/sched.h
@@ -1,6 +1,6 @@
/* Definitions of constants and data structure for POSIX 1003.1b-1993
scheduling interface.
- Copyright (C) 1996, 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1996-1999,2001-2003,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -29,6 +29,9 @@
#define SCHED_OTHER 0
#define SCHED_FIFO 1
#define SCHED_RR 2
+#if 0 /*def __USE_GNU*/
+# define SCHED_BATCH 3
+#endif
#ifdef __USE_MISC
/* Cloning flags. */
diff --git a/libc/sysdeps/linux/common/bits/siginfo.h b/libc/sysdeps/linux/common/bits/siginfo.h
index 03c1c11fc..4e9fd6ab4 100644
--- a/libc/sysdeps/linux/common/bits/siginfo.h
+++ b/libc/sysdeps/linux/common/bits/siginfo.h
@@ -301,8 +301,11 @@ enum
# define SIGEV_SIGNAL SIGEV_SIGNAL
SIGEV_NONE, /* Other notification: meaningless. */
# define SIGEV_NONE SIGEV_NONE
- SIGEV_THREAD /* Deliver via thread creation. */
+ SIGEV_THREAD, /* Deliver via thread creation. */
# define SIGEV_THREAD SIGEV_THREAD
+
+ SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */
+#define SIGEV_THREAD_ID SIGEV_THREAD_ID
};
#endif /* have _SIGNAL_H. */
diff --git a/libc/sysdeps/linux/common/bits/socket.h b/libc/sysdeps/linux/common/bits/socket.h
index 894cf0da2..2466c0cd1 100644
--- a/libc/sysdeps/linux/common/bits/socket.h
+++ b/libc/sysdeps/linux/common/bits/socket.h
@@ -264,7 +264,7 @@ extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr,
# define _EXTERN_INLINE extern __inline
# endif
_EXTERN_INLINE struct cmsghdr *
-__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW
+__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
{
if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
/* The kernel header does this so there may be a reason. */
diff --git a/libc/sysdeps/linux/common/bits/types.h b/libc/sysdeps/linux/common/bits/types.h
index 6068f6fd2..755af2ec9 100644
--- a/libc/sysdeps/linux/common/bits/types.h
+++ b/libc/sysdeps/linux/common/bits/types.h
@@ -70,94 +70,136 @@ typedef struct
} __u_quad_t;
#endif
+
+/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
+ macros for each of the OS types we define below. The definitions
+ of those macros must use the following macros for underlying types.
+ We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned
+ variants of each of the following integer types on this machine.
+
+ 16 -- "natural" 16-bit type (always short)
+ 32 -- "natural" 32-bit type (always int)
+ 64 -- "natural" 64-bit type (long or long long)
+ LONG32 -- 32-bit type, traditionally long
+ QUAD -- 64-bit type, always long long
+ WORD -- natural type of __WORDSIZE bits (int or long)
+ LONGWORD -- type of __WORDSIZE bits, traditionally long
+
+ We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the
+ conventional uses of `long' or `long long' type modifiers match the
+ types we define, even when a less-adorned type would be the same size.
+ This matters for (somewhat) portably writing printf/scanf formats for
+ these types, where using the appropriate l or ll format modifiers can
+ make the typedefs and the formats match up across all GNU platforms. If
+ we used `long' when it's 64 bits where `long long' is expected, then the
+ compiler would warn about the formats not matching the argument types,
+ and the programmer changing them to shut up the compiler would break the
+ program's portability.
+
+ Here we assume what is presently the case in all the GCC configurations
+ we support: long long is always 64 bits, long is always word/address size,
+ and int is always 32 bits. */
+
+#define __S16_TYPE short int
+#define __U16_TYPE unsigned short int
+#define __S32_TYPE int
+#define __U32_TYPE unsigned int
+#define __SLONGWORD_TYPE long int
+#define __ULONGWORD_TYPE unsigned long int
#if __WORDSIZE == 32
+# define __SQUAD_TYPE __quad_t
+# define __UQUAD_TYPE __u_quad_t
# define __SWORD_TYPE int
+# define __UWORD_TYPE unsigned int
+# define __SLONG32_TYPE long int
+# define __ULONG32_TYPE unsigned long int
+# define __S64_TYPE __quad_t
+# define __U64_TYPE __u_quad_t
+/* We want __extension__ before typedef's that use nonstandard base types
+ such as `long long' in C89 mode. */
+# define __STD_TYPE __extension__ typedef
#elif __WORDSIZE == 64
+# define __SQUAD_TYPE long int
+# define __UQUAD_TYPE unsigned long int
# define __SWORD_TYPE long int
+# define __UWORD_TYPE unsigned long int
+# define __SLONG32_TYPE int
+# define __ULONG32_TYPE unsigned int
+# define __S64_TYPE long int
+# define __U64_TYPE unsigned long int
+/* No need to mark the typedef with __extension__. */
+# define __STD_TYPE typedef
#else
# error
#endif
-
-typedef __u_quad_t __dev_t; /* Type of device numbers. */
-typedef __u_int __uid_t; /* Type of user identifications. */
-typedef __u_int __gid_t; /* Type of group identifications. */
-typedef __u_long __ino_t; /* Type of file serial numbers. */
-typedef __u_int __mode_t; /* Type of file attribute bitmasks. */
-typedef __u_int __nlink_t; /* Type of file link counts. */
-typedef long int __off_t; /* Type of file sizes and offsets. */
-typedef __quad_t __loff_t; /* Type of file sizes and offsets. */
-typedef int __pid_t; /* Type of process identifications. */
-typedef __SWORD_TYPE __ssize_t; /* Type of a byte count, or error. */
-typedef __u_long __rlim_t; /* Type of resource counts. */
-typedef __u_quad_t __rlim64_t; /* Type of resource counts (LFS). */
-typedef __u_int __id_t; /* General type for ID. */
-
-typedef struct
- {
- int __val[2];
- } __fsid_t; /* Type of file system IDs. */
-
-/* Everythin' else. */
-typedef int __daddr_t; /* The type of a disk address. */
-typedef __quad_t *__rqaddr_t;
-typedef char *__caddr_t;
-typedef long int __time_t;
-typedef unsigned int __useconds_t;
-typedef long int __suseconds_t;
-typedef long int __swblk_t; /* Type of a swap block maybe? */
-
-typedef long int __clock_t;
+#include <bits/typesizes.h> /* Defines __*_T_TYPE macros. */
+
+
+__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */
+__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */
+__STD_TYPE __GID_T_TYPE __gid_t; /* Type of group identifications. */
+__STD_TYPE __INO_T_TYPE __ino_t; /* Type of file serial numbers. */
+__STD_TYPE __INO64_T_TYPE __ino64_t; /* Type of file serial numbers (LFS).*/
+__STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks. */
+__STD_TYPE __NLINK_T_TYPE __nlink_t; /* Type of file link counts. */
+__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */
+__STD_TYPE __OFF64_T_TYPE __off64_t; /* Type of file sizes and offsets (LFS). */
+__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */
+__STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs. */
+__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */
+__STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */
+__STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */
+__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
+__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
+__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */
+__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */
+
+__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */
+__STD_TYPE __SWBLK_T_TYPE __swblk_t; /* Type of a swap block maybe? */
+__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */
/* Clock ID used in clock and timer functions. */
-typedef int __clockid_t;
+__STD_TYPE __CLOCKID_T_TYPE __clockid_t;
/* Timer ID returned by `timer_create'. */
-typedef void *__timer_t;
-
-
-/* Number of descriptors that can fit in an `fd_set'. */
-#define __FD_SETSIZE 1024
-
-
-typedef int __key_t;
-
-/* Used in `struct shmid_ds'. */
-typedef __kernel_ipc_pid_t __ipc_pid_t;
-
+__STD_TYPE __TIMER_T_TYPE __timer_t;
/* Type to represent block size. */
-typedef long int __blksize_t;
+__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;
/* Types from the Large File Support interface. */
-/* Type to count number os disk blocks. */
-typedef long int __blkcnt_t;
-typedef __quad_t __blkcnt64_t;
+/* Type to count number of disk blocks. */
+__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;
+__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;
/* Type to count file system blocks. */
-typedef __u_long __fsblkcnt_t;
-typedef __u_quad_t __fsblkcnt64_t;
-
-/* Type to count file system inodes. */
-typedef __u_long __fsfilcnt_t;
-typedef __u_quad_t __fsfilcnt64_t;
+__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;
+__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;
-/* Type of file serial numbers. */
-typedef __u_quad_t __ino64_t;
+/* Type to count file system nodes. */
+__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;
+__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;
-/* Type of file sizes and offsets. */
-typedef __loff_t __off64_t;
+__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */
-/* Used in XTI. */
-typedef long int __t_scalar_t;
-typedef unsigned long int __t_uscalar_t;
+/* These few don't really vary by system, they always correspond
+ to one of the other defined types. */
+typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */
+typedef __quad_t *__qaddr_t;
+typedef char *__caddr_t;
/* Duplicates info from stdint.h but this is used in unistd.h. */
-typedef __SWORD_TYPE __intptr_t;
+__STD_TYPE __SWORD_TYPE __intptr_t;
/* Duplicate info from sys/socket.h. */
-typedef unsigned int __socklen_t;
+__STD_TYPE __U32_TYPE __socklen_t;
+
+
+#undef __STD_TYPE
+/* Used in `struct shmid_ds'. */
+typedef __kernel_ipc_pid_t __ipc_pid_t;
/* Now add the thread types. */
#if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98)
diff --git a/libc/sysdeps/linux/common/bits/uio.h b/libc/sysdeps/linux/common/bits/uio.h
index 84b4805fe..8e6bac984 100644
--- a/libc/sysdeps/linux/common/bits/uio.h
+++ b/libc/sysdeps/linux/common/bits/uio.h
@@ -36,6 +36,7 @@
functionality even if the currently running kernel does not support
this large value the readv/writev call will not fail because of this. */
#define UIO_MAXIOV 1024
+#define UIO_FASTIOV 8
/* Structure for scatter/gather I/O. */
diff --git a/libc/sysdeps/linux/common/chown.c b/libc/sysdeps/linux/common/chown.c
index 8ca955de5..d6461394b 100644
--- a/libc/sysdeps/linux/common/chown.c
+++ b/libc/sysdeps/linux/common/chown.c
@@ -10,6 +10,8 @@
#include "syscalls.h"
#include <unistd.h>
+libc_hidden_proto(chown)
+
#define __NR___syscall_chown __NR_chown
static inline _syscall3(int, __syscall_chown, const char *, path,
__kernel_uid_t, owner, __kernel_gid_t, group);
@@ -23,3 +25,4 @@ int chown(const char *path, uid_t owner, gid_t group)
}
return (__syscall_chown(path, owner, group));
}
+libc_hidden_def(chown)
diff --git a/libc/sysdeps/linux/common/chroot.c b/libc/sysdeps/linux/common/chroot.c
index fcf2adac2..527310a15 100644
--- a/libc/sysdeps/linux/common/chroot.c
+++ b/libc/sysdeps/linux/common/chroot.c
@@ -12,6 +12,7 @@
#include <string.h>
#include <sys/param.h>
+#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);
@@ -19,3 +20,4 @@ int chroot(const char *path)
{
return __syscall_chroot(path);
}
+#endif
diff --git a/libc/sysdeps/linux/common/fsync.c b/libc/sysdeps/linux/common/fsync.c
index 677f3e3d6..7ca709887 100644
--- a/libc/sysdeps/linux/common/fsync.c
+++ b/libc/sysdeps/linux/common/fsync.c
@@ -9,8 +9,27 @@
#include "syscalls.h"
#include <unistd.h>
+#ifdef __UCLIBC__HAS_THREADS__
+# include <sysdep-cancel.h>
+#endif
extern __typeof(fsync) __libc_fsync;
-#define __NR___libc_fsync __NR_fsync
+#ifdef __UCLIBC__HAS_THREADS__
+int __libc_fsync (int fd)
+{
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (fsync, 1, fd);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = INLINE_SYSCALL (fsync, 1, fd);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+#else
+# define __NR___libc_fsync __NR_fsync
_syscall1(int, __libc_fsync, int, fd);
+#endif
weak_alias(__libc_fsync, fsync)
diff --git a/libc/sysdeps/linux/common/getdnnm.c b/libc/sysdeps/linux/common/getdnnm.c
index d4caec6ad..ee1b012c4 100644
--- a/libc/sysdeps/linux/common/getdnnm.c
+++ b/libc/sysdeps/linux/common/getdnnm.c
@@ -11,14 +11,13 @@
#include <errno.h>
#include <sys/utsname.h>
-libc_hidden_proto(getdomainname)
-
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
libc_hidden_proto(strlen)
libc_hidden_proto(strcpy)
libc_hidden_proto(uname)
-int
-getdomainname(char *name, size_t len)
+libc_hidden_proto(getdomainname)
+int getdomainname(char *name, size_t len)
{
struct utsname uts;
@@ -45,3 +44,4 @@ getdomainname(char *name, size_t len)
return 0;
}
libc_hidden_def(getdomainname)
+#endif
diff --git a/libc/sysdeps/linux/common/geteuid.c b/libc/sysdeps/linux/common/geteuid.c
index 3936739b3..247f1bfda 100644
--- a/libc/sysdeps/linux/common/geteuid.c
+++ b/libc/sysdeps/linux/common/geteuid.c
@@ -2,27 +2,35 @@
/*
* geteuid() for uClibc
*
- * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- * GNU Library General Public License (LGPL) version 2 or later.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define getuid __getuid
-
#include "syscalls.h"
#include <unistd.h>
-#ifdef __NR_geteuid
-#define __NR___syscall_geteuid __NR_geteuid
+libc_hidden_proto(geteuid)
+
+#if defined(__NR_geteuid32)
+# undef __NR_geteuid
+# define __NR_geteuid __NR_geteuid32
+_syscall0(uid_t, geteuid);
+
+#elif defined(__NR_geteuid)
+# define __NR___syscall_geteuid __NR_geteuid
static inline _syscall0(int, __syscall_geteuid);
-uid_t attribute_hidden __geteuid(void)
+uid_t geteuid(void)
{
return (__syscall_geteuid());
}
+
#else
-uid_t attribute_hidden __geteuid(void)
+libc_hidden_proto(getuid)
+uid_t geteuid(void)
{
return (getuid());
}
#endif
-strong_alias(__geteuid,geteuid)
+
+libc_hidden_def(geteuid)
diff --git a/libc/sysdeps/linux/common/getpagesize.c b/libc/sysdeps/linux/common/getpagesize.c
index 4a35d0775..efb5fcb7f 100644
--- a/libc/sysdeps/linux/common/getpagesize.c
+++ b/libc/sysdeps/linux/common/getpagesize.c
@@ -21,7 +21,6 @@
#include <sys/param.h>
extern size_t __pagesize;
-libc_hidden_proto(__pagesize)
/* Return the system page size. */
/* couldn't make __getpagesize hidden, because shm.h uses it in a macro */
diff --git a/libc/sysdeps/linux/common/gettimeofday.c b/libc/sysdeps/linux/common/gettimeofday.c
index 2d8a6cb25..8e1cf57eb 100644
--- a/libc/sysdeps/linux/common/gettimeofday.c
+++ b/libc/sysdeps/linux/common/gettimeofday.c
@@ -11,6 +11,9 @@
#include <sys/time.h>
libc_hidden_proto(gettimeofday)
-
+#ifdef __USE_BSD
_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
+#else
+_syscall2(int, gettimeofday, struct timeval *, tv, void *, tz);
+#endif
libc_hidden_def(gettimeofday)
diff --git a/libc/sysdeps/linux/common/getuid.c b/libc/sysdeps/linux/common/getuid.c
index 7c81ccf48..21c504d65 100644
--- a/libc/sysdeps/linux/common/getuid.c
+++ b/libc/sysdeps/linux/common/getuid.c
@@ -2,23 +2,17 @@
/*
* getuid() for uClibc
*
- * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- * GNU Library General Public License (LGPL) version 2 or later.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include "syscalls.h"
#include <unistd.h>
-#if defined (__alpha__)
-#define __NR_getuid __NR_getxuid
+#if defined __NR_getxuid
+# define __NR_getuid __NR_getxuid
#endif
-#define __NR___syscall_getuid __NR_getuid
-
-static inline _syscall0(int, __syscall_getuid);
-
-uid_t attribute_hidden __getuid(void)
-{
- return (__syscall_getuid());
-}
-strong_alias(__getuid,getuid)
+libc_hidden_proto(getuid)
+_syscall0(uid_t, getuid);
+libc_hidden_def(getuid)
diff --git a/libc/sysdeps/linux/common/llseek.c b/libc/sysdeps/linux/common/llseek.c
index 76354fa15..0cfbe1a46 100644
--- a/libc/sysdeps/linux/common/llseek.c
+++ b/libc/sysdeps/linux/common/llseek.c
@@ -39,4 +39,3 @@ loff_t __libc_lseek64(int fd, loff_t offset, int whence)
libc_hidden_proto(lseek64)
weak_alias(__libc_lseek64,lseek64)
libc_hidden_weak(lseek64)
-//strong_alias(__libc_lseek64,_llseek)
diff --git a/libc/sysdeps/linux/common/madvise.c b/libc/sysdeps/linux/common/madvise.c
index 70ed9c4cb..8c3918060 100644
--- a/libc/sysdeps/linux/common/madvise.c
+++ b/libc/sysdeps/linux/common/madvise.c
@@ -9,6 +9,6 @@
#include "syscalls.h"
#include <sys/mman.h>
-#ifdef __NR_madvise
+#if defined __NR_madvise && defined __USE_BSD
_syscall3(int, madvise, void *, __addr, size_t, __len, int, __advice);
#endif
diff --git a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c
index f577d9507..5c19d63b5 100644
--- a/libc/sysdeps/linux/common/open64.c
+++ b/libc/sysdeps/linux/common/open64.c
@@ -1,35 +1,30 @@
-/* Copyright (C) 1991, 1995-1997, 1999, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <features.h>
#include <fcntl.h>
#include <stdarg.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <sysdep-cancel.h>
+#endif
+
+#ifdef __UCLIBC_HAS_LFS__
#ifndef O_LARGEFILE
-#define O_LARGEFILE 0100000
+# define O_LARGEFILE 0100000
#endif
-#ifdef __UCLIBC_HAS_LFS__
+extern __typeof(open64) __libc_open64;
+extern __typeof(open) __libc_open;
+libc_hidden_proto(__libc_open)
+
/* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
a third argument is the file protection. */
-#undef open64
-int attribute_hidden __open64 (const char *file, int oflag, ...)
+int __libc_open64 (const char *file, int oflag, ...)
{
int mode = 0;
@@ -41,8 +36,22 @@ int attribute_hidden __open64 (const char *file, int oflag, ...)
va_end (arg);
}
- return __open(file, oflag | O_LARGEFILE, mode);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = INLINE_SYSCALL (open, 3, file, oflag | O_LARGEFILE, mode);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+#else
+ return __libc_open(file, oflag | O_LARGEFILE, mode);
+#endif
}
-strong_alias(__open64,open64)
-weak_alias(__open64,__libc_open64)
+libc_hidden_proto(open64)
+weak_alias(__libc_open64,open64)
+libc_hidden_weak(open64)
#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c
index c957f1edf..61c6d18ea 100644
--- a/libc/sysdeps/linux/common/poll.c
+++ b/libc/sysdeps/linux/common/poll.c
@@ -17,16 +17,33 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define getdtablesize __getdtablesize
-#define select __select
-
#include "syscalls.h"
#include <sys/poll.h>
+libc_hidden_proto(poll)
+
#ifdef __NR_poll
-#define __NR___poll __NR_poll
-attribute_hidden _syscall3(int, __poll, struct pollfd *, fds,
+# ifdef __UCLIBC__HAS_THREADS__
+# include <sysdep-cancel.h>
+
+/* The real implementation. */
+int poll (struct pollfd *fds, nfsd_t nfds, int timeout)
+{
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+# else
+_syscall3(int, poll, struct pollfd *, fds,
unsigned long int, nfds, int, timeout);
+# endif
#else
#include <alloca.h>
@@ -37,6 +54,11 @@ attribute_hidden _syscall3(int, __poll, struct pollfd *, fds,
#include <sys/param.h>
#include <unistd.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(getdtablesize)
+libc_hidden_proto(select)
+
/* uClinux 2.0 doesn't have poll, emulate it using select */
/* Poll the file descriptors described by the NFDS structures starting at
@@ -45,7 +67,7 @@ attribute_hidden _syscall3(int, __poll, struct pollfd *, fds,
Returns the number of file descriptors with events, zero if timed out,
or -1 for errors. */
-int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
static int max_fd_size;
struct timeval tv;
@@ -65,9 +87,9 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
/* We can't call FD_ZERO, since FD_ZERO only works with sets
of exactly __FD_SETSIZE size. */
- __memset (rset, 0, bytes);
- __memset (wset, 0, bytes);
- __memset (xset, 0, bytes);
+ memset (rset, 0, bytes);
+ memset (wset, 0, bytes);
+ memset (xset, 0, bytes);
for (f = fds; f < &fds[nfds]; ++f)
{
@@ -89,13 +111,13 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
nwset = alloca (nbytes);
nxset = alloca (nbytes);
- __memset ((char *) nrset + bytes, 0, nbytes - bytes);
- __memset ((char *) nwset + bytes, 0, nbytes - bytes);
- __memset ((char *) nxset + bytes, 0, nbytes - bytes);
+ memset ((char *) nrset + bytes, 0, nbytes - bytes);
+ memset ((char *) nwset + bytes, 0, nbytes - bytes);
+ memset ((char *) nxset + bytes, 0, nbytes - bytes);
- rset = __memcpy (nrset, rset, bytes);
- wset = __memcpy (nwset, wset, bytes);
- xset = __memcpy (nxset, xset, bytes);
+ rset = memcpy (nrset, rset, bytes);
+ wset = memcpy (nwset, wset, bytes);
+ xset = memcpy (nxset, xset, bytes);
bytes = nbytes;
}
@@ -129,9 +151,9 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
struct timeval sngl_tv;
/* Clear the original set. */
- __memset (rset, 0, bytes);
- __memset (wset, 0, bytes);
- __memset (xset, 0, bytes);
+ memset (rset, 0, bytes);
+ memset (wset, 0, bytes);
+ memset (xset, 0, bytes);
/* This means we don't wait for input. */
sngl_tv.tv_sec = 0;
@@ -148,9 +170,9 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
int n;
- __memset (sngl_rset, 0, bytes);
- __memset (sngl_wset, 0, bytes);
- __memset (sngl_xset, 0, bytes);
+ memset (sngl_rset, 0, bytes);
+ memset (sngl_wset, 0, bytes);
+ memset (sngl_xset, 0, bytes);
if (f->events & POLLIN)
FD_SET (f->fd, sngl_rset);
@@ -204,4 +226,4 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
}
#endif
-strong_alias(__poll,poll)
+libc_hidden_def(poll)
diff --git a/libc/sysdeps/linux/common/pselect.c b/libc/sysdeps/linux/common/pselect.c
index 93a85a622..7e93537dd 100644
--- a/libc/sysdeps/linux/common/pselect.c
+++ b/libc/sysdeps/linux/common/pselect.c
@@ -22,6 +22,9 @@
#include <stddef.h> /* For NULL. */
#include <sys/time.h>
#include <sys/select.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+#endif
libc_hidden_proto(sigprocmask)
libc_hidden_proto(select)
@@ -33,8 +36,13 @@ libc_hidden_proto(select)
after waiting the interval specified therein. Additionally set the sigmask
SIGMASK for this call. Returns the number of ready descriptors, or -1 for
errors. */
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+static int
+__pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+#else
int
pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+#endif
const struct timespec *timeout, const sigset_t *sigmask)
{
struct timeval tval;
@@ -64,3 +72,23 @@ pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
return retval;
}
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+int
+pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ const struct timespec *timeout, const sigset_t *sigmask)
+{
+ if (SINGLE_THREAD_P)
+ return __pselect (nfds, readfds, writefds, exceptfds,
+ timeout, sigmask);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = __pselect (nfds, readfds, writefds, exceptfds,
+ timeout, sigmask);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+#endif
diff --git a/libc/sysdeps/linux/common/readv.c b/libc/sysdeps/linux/common/readv.c
index 79ecf6f6d..ebe73185f 100644
--- a/libc/sysdeps/linux/common/readv.c
+++ b/libc/sysdeps/linux/common/readv.c
@@ -2,6 +2,7 @@
/*
* readv() for uClibc
*
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
* Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*
* GNU Library General Public License (LGPL) version 2 or later.
@@ -9,5 +10,41 @@
#include "syscalls.h"
#include <sys/uio.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+
+/* We should deal with kernel which have a smaller UIO_FASTIOV as well
+ as a very big count. */
+static ssize_t __readv (int fd, const struct iovec *vector, int count)
+{
+ ssize_t bytes_read;
+
+ bytes_read = INLINE_SYSCALL (readv, 3, fd, vector, count);
+
+ if (bytes_read >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
+ return bytes_read;
+
+ /* glibc tries again, but we do not. */
+ //return __atomic_readv_replacement (fd, vector, count);
+
+ return -1;
+}
+
+ssize_t readv (int fd, const struct iovec *vector, int count)
+{
+ if (SINGLE_THREAD_P)
+ return __readv (fd, vector, count);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = __readv (fd, vector, count);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+#else
_syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector,
int, count);
+#endif
diff --git a/libc/sysdeps/linux/common/sbrk.c b/libc/sysdeps/linux/common/sbrk.c
index d9a4d6899..f8b568262 100644
--- a/libc/sysdeps/linux/common/sbrk.c
+++ b/libc/sysdeps/linux/common/sbrk.c
@@ -13,7 +13,6 @@ libc_hidden_proto(brk)
/* Defined in brk.c. */
extern void *__curbrk;
-libc_hidden_proto(__curbrk)
/* Extend the process's data space by INCREMENT.
If INCREMENT is negative, shrink data space by - INCREMENT.
diff --git a/libc/sysdeps/linux/common/select.c b/libc/sysdeps/linux/common/select.c
index d5a0663fa..9a50d198a 100644
--- a/libc/sysdeps/linux/common/select.c
+++ b/libc/sysdeps/linux/common/select.c
@@ -8,7 +8,7 @@
*/
#include "syscalls.h"
-#include <unistd.h>
+#include <sys/select.h>
libc_hidden_proto(select)
diff --git a/libc/sysdeps/linux/common/setdomainname.c b/libc/sysdeps/linux/common/setdomainname.c
index 138250d09..3b9f535e5 100644
--- a/libc/sysdeps/linux/common/setdomainname.c
+++ b/libc/sysdeps/linux/common/setdomainname.c
@@ -9,4 +9,6 @@
#include "syscalls.h"
#include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
_syscall2(int, setdomainname, const char *, name, size_t, len);
+#endif
diff --git a/libc/sysdeps/linux/common/setegid.c b/libc/sysdeps/linux/common/setegid.c
index e0bbfd4bc..33c627c51 100644
--- a/libc/sysdeps/linux/common/setegid.c
+++ b/libc/sysdeps/linux/common/setegid.c
@@ -11,7 +11,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
-#if defined __NR_setresgid || defined __NR_setresgid32
+#if (defined __NR_setresgid || defined __NR_setresgid32) && defined __USE_GNU
libc_hidden_proto(setresgid)
#endif
libc_hidden_proto(setregid)
@@ -26,7 +26,7 @@ int setegid(gid_t gid)
return -1;
}
-#if defined __NR_setresgid || defined __NR_setresgid32
+#if (defined __NR_setresgid || defined __NR_setresgid32) && defined __USE_GNU
result = setresgid(-1, gid, -1);
if (result == -1 && errno == ENOSYS)
/* Will also set the saved group ID if egid != gid,
diff --git a/libc/sysdeps/linux/common/seteuid.c b/libc/sysdeps/linux/common/seteuid.c
index e5ed576ff..35a68334d 100644
--- a/libc/sysdeps/linux/common/seteuid.c
+++ b/libc/sysdeps/linux/common/seteuid.c
@@ -13,7 +13,7 @@
libc_hidden_proto(seteuid)
-#if defined __NR_setresuid || defined __NR_setresuid32
+#if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU
libc_hidden_proto(setresuid)
#endif
libc_hidden_proto(setreuid)
@@ -28,7 +28,7 @@ int seteuid(uid_t uid)
return -1;
}
-#if defined __NR_setresuid || defined __NR_setresuid32
+#if (defined __NR_setresuid || defined __NR_setresuid32) && defined __USE_GNU
result = setresuid(-1, uid, -1);
if (result == -1 && errno == ENOSYS)
/* Will also set the saved user ID if euid != uid,
diff --git a/libc/sysdeps/linux/common/setgroups.c b/libc/sysdeps/linux/common/setgroups.c
index dd1a03f38..49f3dc61f 100644
--- a/libc/sysdeps/linux/common/setgroups.c
+++ b/libc/sysdeps/linux/common/setgroups.c
@@ -12,6 +12,8 @@
#include <unistd.h>
#include <grp.h>
+#ifdef __USE_BSD
+
libc_hidden_proto(setgroups)
#if defined(__NR_setgroups32)
@@ -62,3 +64,4 @@ ret_error:
#endif
libc_hidden_def(setgroups)
+#endif
diff --git a/libc/sysdeps/linux/common/sethostname.c b/libc/sysdeps/linux/common/sethostname.c
index d8e0789bb..62867fc16 100644
--- a/libc/sysdeps/linux/common/sethostname.c
+++ b/libc/sysdeps/linux/common/sethostname.c
@@ -9,4 +9,6 @@
#include "syscalls.h"
#include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
_syscall2(int, sethostname, const char *, name, size_t, len);
+#endif
diff --git a/libc/sysdeps/linux/common/settimeofday.c b/libc/sysdeps/linux/common/settimeofday.c
index 2dc2a6a44..a0ae95fa5 100644
--- a/libc/sysdeps/linux/common/settimeofday.c
+++ b/libc/sysdeps/linux/common/settimeofday.c
@@ -10,8 +10,11 @@
#include "syscalls.h"
#include <sys/time.h>
+#ifdef __USE_BSD
+
libc_hidden_proto(settimeofday)
_syscall2(int, settimeofday, const struct timeval *, tv,
const struct timezone *, tz);
libc_hidden_def(settimeofday)
+#endif
diff --git a/libc/sysdeps/linux/common/sigprocmask.c b/libc/sysdeps/linux/common/sigprocmask.c
index 803f5b4ae..58be06ea1 100644
--- a/libc/sysdeps/linux/common/sigprocmask.c
+++ b/libc/sysdeps/linux/common/sigprocmask.c
@@ -13,6 +13,8 @@
#undef sigprocmask
+libc_hidden_proto(sigprocmask)
+
#ifdef __NR_rt_sigprocmask
#define __NR___rt_sigprocmask __NR_rt_sigprocmask
@@ -20,7 +22,7 @@ static inline
_syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
sigset_t *, oldset, size_t, size);
-int __sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
+int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
#ifdef SIGCANCEL
sigset_t local_newmask;
@@ -55,7 +57,7 @@ static inline
_syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
sigset_t *, oldset);
-int __sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
+int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
#ifdef SIGCANCEL
sigset_t local_newmask;
@@ -82,5 +84,4 @@ int __sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
return (__syscall_sigprocmask(how, set, oldset));
}
#endif
-
-weak_alias (__sigprocmask, sigprocmask)
+libc_hidden_def(sigprocmask)
diff --git a/libc/sysdeps/linux/common/sigsuspend.c b/libc/sysdeps/linux/common/sigsuspend.c
index be69c62c2..0e0df6c61 100644
--- a/libc/sysdeps/linux/common/sigsuspend.c
+++ b/libc/sysdeps/linux/common/sigsuspend.c
@@ -2,31 +2,56 @@
/*
* sigsuspend() for uClibc
*
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
* Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*
- * GNU Library General Public License (LGPL) version 2 or later.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include "syscalls.h"
#include <signal.h>
#undef sigsuspend
+libc_hidden_proto(sigsuspend)
+
#ifdef __NR_rt_sigsuspend
-#define __NR___rt_sigsuspend __NR_rt_sigsuspend
+# define __NR___rt_sigsuspend __NR_rt_sigsuspend
+
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# include <errno.h>
+# include <sysdep-cancel.h>
+
+/* Change the set of blocked signals to SET,
+ wait until a signal arrives, and restore the set of blocked signals. */
+int sigsuspend (const sigset_t *set)
+{
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+# else
static inline _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
-int attribute_hidden __sigsuspend(const sigset_t * mask)
+int sigsuspend(const sigset_t * mask)
{
return __rt_sigsuspend(mask, _NSIG / 8);
}
+# endif
#else
-#define __NR___syscall_sigsuspend __NR_sigsuspend
+# define __NR___syscall_sigsuspend __NR_sigsuspend
static inline _syscall3(int, __syscall_sigsuspend, int, a, unsigned long int, b,
unsigned long int, c);
-int attribute_hidden __sigsuspend(const sigset_t * set)
+int sigsuspend(const sigset_t * set)
{
return __syscall_sigsuspend(0, 0, set->__val[0]);
}
#endif
-strong_alias(__sigsuspend,sigsuspend)
+libc_hidden_def(sigsuspend)
diff --git a/libc/sysdeps/linux/common/stime.c b/libc/sysdeps/linux/common/stime.c
index 9f9615d3e..387122ff3 100644
--- a/libc/sysdeps/linux/common/stime.c
+++ b/libc/sysdeps/linux/common/stime.c
@@ -10,6 +10,8 @@
#include "syscalls.h"
#include <time.h>
#include <sys/time.h>
+
+#ifdef __USE_SVID
#ifdef __NR_stime
_syscall1(int, stime, const time_t *, t);
#else
@@ -28,3 +30,4 @@ int stime(const time_t * when)
return settimeofday(&tv, (struct timezone *) 0);
}
#endif
+#endif
diff --git a/libc/sysdeps/linux/common/sysfs.c b/libc/sysdeps/linux/common/sysfs.c
index 28350fdd2..e3cf0f15b 100644
--- a/libc/sysdeps/linux/common/sysfs.c
+++ b/libc/sysdeps/linux/common/sysfs.c
@@ -7,5 +7,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+/* libc isn't really supposed to export this */
+#if 0
+
#include "syscalls.h"
_syscall3(int, sysfs, int, option, unsigned int, index, char, addr);
+
+#endif
diff --git a/libc/sysdeps/linux/common/umount.c b/libc/sysdeps/linux/common/umount.c
index 1480b63cd..550003d1b 100644
--- a/libc/sysdeps/linux/common/umount.c
+++ b/libc/sysdeps/linux/common/umount.c
@@ -8,11 +8,11 @@
*/
#include "syscalls.h"
+#include <sys/mount.h>
/* arch provides umount() syscall */
#ifdef __NR_umount
-# include <sys/mount.h>
_syscall1(int, umount, const char *, specialfile);
/* arch provides umount2() syscall */
diff --git a/libc/sysdeps/linux/common/utime.c b/libc/sysdeps/linux/common/utime.c
index 5641cc6f0..5d289aede 100644
--- a/libc/sysdeps/linux/common/utime.c
+++ b/libc/sysdeps/linux/common/utime.c
@@ -13,7 +13,7 @@
libc_hidden_proto(utime)
#ifdef __NR_utime
-attribute_hidden _syscall2(int, utime, const char *, file, const struct utimbuf *, times);
+_syscall2(int, utime, const char *, file, const struct utimbuf *, times);
#else
#include <stdlib.h>
#include <sys/time.h>
diff --git a/libc/sysdeps/linux/common/vhangup.c b/libc/sysdeps/linux/common/vhangup.c
index f6dc0865f..984a09dec 100644
--- a/libc/sysdeps/linux/common/vhangup.c
+++ b/libc/sysdeps/linux/common/vhangup.c
@@ -9,4 +9,6 @@
#include "syscalls.h"
#include <unistd.h>
+#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98)
_syscall0(int, vhangup);
+#endif
diff --git a/libc/sysdeps/linux/common/wait.c b/libc/sysdeps/linux/common/wait.c
index b2a6d2295..d4b79bd37 100644
--- a/libc/sysdeps/linux/common/wait.c
+++ b/libc/sysdeps/linux/common/wait.c
@@ -1,5 +1,9 @@
-#define wait4 __wait4
-
+/*
+ * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <stdlib.h>
#include <syscall.h>
#include <sys/types.h>
@@ -8,8 +12,32 @@
/* Wait for a child to die. When one does, put its status in *STAT_LOC
* and return its process ID. For errors, return (pid_t) -1. */
-__pid_t wait (__WAIT_STATUS_DEFN stat_loc)
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <sysdep-cancel.h>
+
+pid_t attribute_hidden
+__libc_wait (__WAIT_STATUS_DEFN stat_loc)
+{
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (wait4, 4, WAIT_ANY, stat_loc, 0,
+ (struct rusage *) NULL);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ pid_t result = INLINE_SYSCALL (wait4, 4, WAIT_ANY, stat_loc, 0,
+ (struct rusage *) NULL);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+#else
+/* Wait for a child to die. When one does, put its status in *STAT_LOC
+ * and return its process ID. For errors, return (pid_t) -1. */
+__pid_t __libc_wait (__WAIT_STATUS_DEFN stat_loc)
{
- return __wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL);
+ return wait4 (WAIT_ANY, stat_loc, 0, (struct rusage *) NULL);
}
-weak_alias(wait,__libc_wait)
+#endif
+weak_alias(__libc_wait,wait)
diff --git a/libc/sysdeps/linux/common/waitpid.c b/libc/sysdeps/linux/common/waitpid.c
index 612917fcf..902a39496 100644
--- a/libc/sysdeps/linux/common/waitpid.c
+++ b/libc/sysdeps/linux/common/waitpid.c
@@ -1,14 +1,52 @@
-#define wait4 __wait4
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <stdlib.h>
#include <sys/types.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <sys/resource.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <sysdep-cancel.h>
+#else
+
+libc_hidden_proto(wait4)
+#endif
-__pid_t attribute_hidden __waitpid(__pid_t pid, int *wait_stat, int options)
+extern __typeof(waitpid) __libc_waitpid;
+__pid_t __libc_waitpid(__pid_t pid, int *wait_stat, int options)
{
- return __wait4(pid, wait_stat, options, NULL);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if (SINGLE_THREAD_P)
+ {
+#ifdef __NR_waitpid
+ return INLINE_SYSCALL (waitpid, 3, pid, wait_stat, options);
+#else
+ return INLINE_SYSCALL (wait4, 4, pid, wait_stat, options, NULL);
+#endif
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+#ifdef __NR_waitpid
+ int result = INLINE_SYSCALL (waitpid, 3, pid, wait_stat, options);
+#else
+ int result = INLINE_SYSCALL (wait4, 4, pid, wait_stat, options, NULL);
+#endif
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+#else
+ return wait4(pid, wait_stat, options, NULL);
}
-strong_alias(__waitpid,waitpid)
-weak_alias(__waitpid,__libc_waitpid)
+#endif
+libc_hidden_proto(waitpid)
+weak_alias(__libc_waitpid,waitpid)
+libc_hidden_weak(waitpid)
diff --git a/libc/sysdeps/linux/common/writev.c b/libc/sysdeps/linux/common/writev.c
index 4979fade9..cfb758974 100644
--- a/libc/sysdeps/linux/common/writev.c
+++ b/libc/sysdeps/linux/common/writev.c
@@ -2,6 +2,7 @@
/*
* writev() for uClibc
*
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
* Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
*
* GNU Library General Public License (LGPL) version 2 or later.
@@ -9,5 +10,42 @@
#include "syscalls.h"
#include <sys/uio.h>
+
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <sysdep-cancel.h>
+
+/* We should deal with kernel which have a smaller UIO_FASTIOV as well
+ as a very big count. */
+static ssize_t __writev (int fd, const struct iovec *vector, int count)
+{
+ ssize_t bytes_written;
+
+ bytes_written = INLINE_SYSCALL (writev, 3, fd, vector, count);
+
+ if (bytes_written >= 0 || errno != EINVAL || count <= UIO_FASTIOV)
+ return bytes_written;
+
+ /* glibc tries again, but we do not. */
+ //return __atomic_writev_replacement (fd, vector, count);
+
+ return -1;
+}
+
+ssize_t writev (int fd, const struct iovec *vector, int count)
+{
+ if (SINGLE_THREAD_P)
+ return __writev (fd, vector, count);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ ssize_t result = __writev (fd, vector, count);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+#else
_syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector,
int, count);
+#endif