summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/_exit.c1
-rw-r--r--libc/sysdeps/linux/common/bits/errno.h6
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_stdio.h2
-rw-r--r--libc/sysdeps/linux/common/clock_getres.c1
-rw-r--r--libc/sysdeps/linux/common/clock_gettime.c1
-rw-r--r--libc/sysdeps/linux/common/clock_settime.c1
-rw-r--r--libc/sysdeps/linux/common/getdnnm.c10
-rw-r--r--libc/sysdeps/linux/common/getpriority.c2
-rw-r--r--libc/sysdeps/linux/common/getsid.c2
-rw-r--r--libc/sysdeps/linux/common/llseek.c13
-rw-r--r--libc/sysdeps/linux/common/pread_write.c43
-rw-r--r--libc/sysdeps/linux/common/setegid.c5
-rw-r--r--libc/sysdeps/linux/common/seteuid.c5
-rw-r--r--libc/sysdeps/linux/common/setresgid.c2
-rw-r--r--libc/sysdeps/linux/common/setresuid.c2
-rw-r--r--libc/sysdeps/linux/common/setrlimit.c2
-rw-r--r--libc/sysdeps/linux/common/sync.c1
-rw-r--r--libc/sysdeps/linux/common/syscalls.h1
-rw-r--r--libc/sysdeps/linux/common/ulimit.c15
-rw-r--r--libc/sysdeps/linux/common/xstatconv.c20
20 files changed, 44 insertions, 91 deletions
diff --git a/libc/sysdeps/linux/common/_exit.c b/libc/sysdeps/linux/common/_exit.c
index d86aca009..02c951152 100644
--- a/libc/sysdeps/linux/common/_exit.c
+++ b/libc/sysdeps/linux/common/_exit.c
@@ -7,7 +7,6 @@
* 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>
diff --git a/libc/sysdeps/linux/common/bits/errno.h b/libc/sysdeps/linux/common/bits/errno.h
index 679600e5e..45a0ec0d1 100644
--- a/libc/sysdeps/linux/common/bits/errno.h
+++ b/libc/sysdeps/linux/common/bits/errno.h
@@ -37,15 +37,13 @@ extern int errno;
/* Function to get address of global `errno' variable. */
extern int *__errno_location (void) __THROW __attribute__ ((__const__));
-# if defined _LIBC
-#ifdef IS_IN_libc
+# if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc )
libc_hidden_proto(__errno_location)
-#endif
/* We wouldn't need a special macro anymore but it is history. */
# define __set_errno(val) ((errno) = (val))
# endif /* _LIBC */
-# if defined __UCLIBC_HAS_THREADS__
+# ifdef __UCLIBC_HAS_THREADS__
/* When using threads, errno is a per-thread value. */
# define errno (*__errno_location ())
# endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index 3c12a74dc..5b6b35496 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -237,7 +237,7 @@ typedef struct {
__io_close_fn *close;
} _IO_cookie_io_functions_t;
-#if defined(_LIBC) || defined(_GNU_SOURCE)
+#ifdef __USE_GNU
typedef __io_read_fn cookie_read_function_t;
typedef __io_write_fn cookie_write_function_t;
diff --git a/libc/sysdeps/linux/common/clock_getres.c b/libc/sysdeps/linux/common/clock_getres.c
index 41d5079b9..8ee782845 100644
--- a/libc/sysdeps/linux/common/clock_getres.c
+++ b/libc/sysdeps/linux/common/clock_getres.c
@@ -7,7 +7,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include "syscalls.h"
#include <time.h>
#include <unistd.h>
diff --git a/libc/sysdeps/linux/common/clock_gettime.c b/libc/sysdeps/linux/common/clock_gettime.c
index 703399406..c6b4111fe 100644
--- a/libc/sysdeps/linux/common/clock_gettime.c
+++ b/libc/sysdeps/linux/common/clock_gettime.c
@@ -8,7 +8,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include "syscalls.h"
#include <time.h>
#include <sys/time.h>
diff --git a/libc/sysdeps/linux/common/clock_settime.c b/libc/sysdeps/linux/common/clock_settime.c
index 93e1b72a7..6ad7872ae 100644
--- a/libc/sysdeps/linux/common/clock_settime.c
+++ b/libc/sysdeps/linux/common/clock_settime.c
@@ -7,7 +7,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include "syscalls.h"
#include <time.h>
#include <sys/time.h>
diff --git a/libc/sysdeps/linux/common/getdnnm.c b/libc/sysdeps/linux/common/getdnnm.c
index ab33dc01a..d4caec6ad 100644
--- a/libc/sysdeps/linux/common/getdnnm.c
+++ b/libc/sysdeps/linux/common/getdnnm.c
@@ -4,11 +4,11 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
+#include <features.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#define __USE_GNU
#include <sys/utsname.h>
libc_hidden_proto(getdomainname)
@@ -29,11 +29,19 @@ getdomainname(char *name, size_t len)
if (uname(&uts) == -1) return -1;
+#ifdef __USE_GNU
if (strlen(uts.domainname)+1 > len) {
+#else
+ if (strlen(uts.__domainname)+1 > len) {
+#endif
__set_errno(EINVAL);
return -1;
}
+#ifdef __USE_GNU
strcpy(name, uts.domainname);
+#else
+ strcpy(name, uts.__domainname);
+#endif
return 0;
}
libc_hidden_def(getdomainname)
diff --git a/libc/sysdeps/linux/common/getpriority.c b/libc/sysdeps/linux/common/getpriority.c
index 96156841b..41cc3eb49 100644
--- a/libc/sysdeps/linux/common/getpriority.c
+++ b/libc/sysdeps/linux/common/getpriority.c
@@ -19,7 +19,7 @@ static inline _syscall2(int, __syscall_getpriority,
/* The return value of __syscall_getpriority is biased by this value
* to avoid returning negative values. */
#define PZERO 20
-int getpriority(enum __priority_which which, id_t who)
+int getpriority(__priority_which_t which, id_t who)
{
int res;
diff --git a/libc/sysdeps/linux/common/getsid.c b/libc/sysdeps/linux/common/getsid.c
index 1a574441c..aaac0ceb9 100644
--- a/libc/sysdeps/linux/common/getsid.c
+++ b/libc/sysdeps/linux/common/getsid.c
@@ -10,6 +10,7 @@
#include "syscalls.h"
#include <unistd.h>
+#ifdef __USE_XOPEN_EXTENDED
libc_hidden_proto(getsid)
#define __NR___syscall_getsid __NR_getsid
@@ -20,3 +21,4 @@ pid_t getsid(pid_t pid)
return (__syscall_getsid(pid));
}
libc_hidden_def(getsid)
+#endif
diff --git a/libc/sysdeps/linux/common/llseek.c b/libc/sysdeps/linux/common/llseek.c
index 33cbe46c2..7b39a3064 100644
--- a/libc/sysdeps/linux/common/llseek.c
+++ b/libc/sysdeps/linux/common/llseek.c
@@ -7,19 +7,8 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
-#define _LARGEFILE64_SOURCE
-#include <features.h>
-#undef __OPTIMIZE__
-/* We absolutely do _NOT_ want interfaces silently
- * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
-#include <errno.h>
+#include "syscalls.h"
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
#if defined __NR__llseek && defined __UCLIBC_HAS_LFS__
diff --git a/libc/sysdeps/linux/common/pread_write.c b/libc/sysdeps/linux/common/pread_write.c
index 327a9c785..45a94cfb8 100644
--- a/libc/sysdeps/linux/common/pread_write.c
+++ b/libc/sysdeps/linux/common/pread_write.c
@@ -13,26 +13,13 @@
* from GNU libc 2.2.5, but reworked considerably...
*/
-#define _GNU_SOURCE
-#define _LARGEFILE64_SOURCE
-#include <features.h>
-#undef __OPTIMIZE__
-/* We absolutely do _NOT_ want interfaces silently
- * * * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
-
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
+#include "syscalls.h"
#include <unistd.h>
#include <stdint.h>
#ifdef __NR_pread
-#define __NR___syscall_pread __NR_pread
+# define __NR___syscall_pread __NR_pread
static inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
size_t, count, off_t, offset_hi, off_t, offset_lo);
@@ -42,7 +29,7 @@ ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
}
strong_alias(__libc_pread,pread)
-#if defined __UCLIBC_HAS_LFS__
+# ifdef __UCLIBC_HAS_LFS__
ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
{
uint32_t low = offset & 0xffffffff;
@@ -50,14 +37,13 @@ ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
return(__syscall_pread(fd, buf, count, __LONG_LONG_PAIR (high, low)));
}
strong_alias(__libc_pread64,pread64)
-#endif /* __UCLIBC_HAS_LFS__ */
+# endif /* __UCLIBC_HAS_LFS__ */
#endif /* __NR_pread */
-
#ifdef __NR_pwrite
-#define __NR___syscall_pwrite __NR_pwrite
+# define __NR___syscall_pwrite __NR_pwrite
static inline _syscall5(ssize_t, __syscall_pwrite, int, fd, const void *, buf,
size_t, count, off_t, offset_hi, off_t, offset_lo);
@@ -67,7 +53,7 @@ ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
}
strong_alias(__libc_pwrite,pwrite)
-#if defined __UCLIBC_HAS_LFS__
+# ifdef __UCLIBC_HAS_LFS__
ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
{
uint32_t low = offset & 0xffffffff;
@@ -75,11 +61,9 @@ ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
return(__syscall_pwrite(fd, buf, count, __LONG_LONG_PAIR (high, low)));
}
strong_alias(__libc_pwrite64,pwrite64)
-#endif /* __UCLIBC_HAS_LFS__ */
+# endif /* __UCLIBC_HAS_LFS__ */
#endif /* __NR_pwrite */
-
-
#if ! defined __NR_pread || ! defined __NR_pwrite
libc_hidden_proto(read)
libc_hidden_proto(write)
@@ -123,7 +107,7 @@ static ssize_t __fake_pread_write(int fd, void *buf,
return(result);
}
-#if defined __UCLIBC_HAS_LFS__
+# ifdef __UCLIBC_HAS_LFS__
static ssize_t __fake_pread_write64(int fd, void *buf,
size_t count, off64_t offset, int do_pwrite)
{
@@ -158,7 +142,7 @@ static ssize_t __fake_pread_write64(int fd, void *buf,
__set_errno (save_errno);
return result;
}
-#endif /* __UCLIBC_HAS_LFS__ */
+# endif /* __UCLIBC_HAS_LFS__ */
#endif /* ! defined __NR_pread || ! defined __NR_pwrite */
#ifndef __NR_pread
@@ -168,16 +152,15 @@ ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
}
strong_alias(__libc_pread,pread)
-#if defined __UCLIBC_HAS_LFS__
+# ifdef __UCLIBC_HAS_LFS__
ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
{
return(__fake_pread_write64(fd, buf, count, offset, 0));
}
strong_alias(__libc_pread64,pread64)
-#endif /* __UCLIBC_HAS_LFS__ */
+# endif /* __UCLIBC_HAS_LFS__ */
#endif /* ! __NR_pread */
-
#ifndef __NR_pwrite
ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
{
@@ -187,11 +170,11 @@ ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
}
strong_alias(__libc_pwrite,pwrite)
-#if defined __UCLIBC_HAS_LFS__
+# ifdef __UCLIBC_HAS_LFS__
ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
{
return(__fake_pread_write64(fd, (void*)buf, count, offset, 1));
}
strong_alias(__libc_pwrite64,pwrite64)
-#endif /* __UCLIBC_HAS_LFS__ */
+# endif /* __UCLIBC_HAS_LFS__ */
#endif /* ! __NR_pwrite */
diff --git a/libc/sysdeps/linux/common/setegid.c b/libc/sysdeps/linux/common/setegid.c
index 759c9b0f3..92ef3a05d 100644
--- a/libc/sysdeps/linux/common/setegid.c
+++ b/libc/sysdeps/linux/common/setegid.c
@@ -4,7 +4,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
@@ -12,7 +11,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
-#ifdef __NR_setresgid
+#if defined __NR_setresgid && defined __USE_GNU
libc_hidden_proto(setresgid)
#endif
libc_hidden_proto(setregid)
@@ -27,7 +26,7 @@ int setegid(gid_t gid)
return -1;
}
-#ifdef __NR_setresgid
+#if defined __NR_setresgid && 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 dc4b82c4c..6d8c9ae3e 100644
--- a/libc/sysdeps/linux/common/seteuid.c
+++ b/libc/sysdeps/linux/common/seteuid.c
@@ -4,7 +4,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
@@ -14,7 +13,9 @@
libc_hidden_proto(seteuid)
+#if defined __NR_setresuid && defined __USE_GNU
libc_hidden_proto(setresuid)
+#endif
libc_hidden_proto(setreuid)
int seteuid(uid_t uid)
@@ -27,7 +28,7 @@ int seteuid(uid_t uid)
return -1;
}
-#ifdef __NR_setresuid
+#if defined __NR_setresuid && 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/setresgid.c b/libc/sysdeps/linux/common/setresgid.c
index aa331e3bb..40e9e8a11 100644
--- a/libc/sysdeps/linux/common/setresgid.c
+++ b/libc/sysdeps/linux/common/setresgid.c
@@ -10,7 +10,7 @@
#include "syscalls.h"
#include <unistd.h>
-#ifdef __NR_setresgid
+#if defined __NR_setresgid && defined __USE_GNU
libc_hidden_proto(setresgid)
#define __NR___syscall_setresgid __NR_setresgid
diff --git a/libc/sysdeps/linux/common/setresuid.c b/libc/sysdeps/linux/common/setresuid.c
index 7e23774ac..dd1915706 100644
--- a/libc/sysdeps/linux/common/setresuid.c
+++ b/libc/sysdeps/linux/common/setresuid.c
@@ -10,7 +10,7 @@
#include "syscalls.h"
#include <unistd.h>
-#ifdef __NR_setresuid
+#if defined __NR_setresuid && defined __USE_GNU
libc_hidden_proto(setresuid)
#define __NR___syscall_setresuid __NR_setresuid
diff --git a/libc/sysdeps/linux/common/setrlimit.c b/libc/sysdeps/linux/common/setrlimit.c
index 2e62a5e1d..7a53e043f 100644
--- a/libc/sysdeps/linux/common/setrlimit.c
+++ b/libc/sysdeps/linux/common/setrlimit.c
@@ -36,7 +36,7 @@ int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits)
#undef RMIN
#else /* We don't need to wrap setrlimit */
-_syscall2(int, setrlimit, unsigned int, resource,
+_syscall2(int, setrlimit, __rlimit_resource_t, resource,
const struct rlimit *, rlim);
#endif
libc_hidden_def(setrlimit)
diff --git a/libc/sysdeps/linux/common/sync.c b/libc/sysdeps/linux/common/sync.c
index 7bfea0d70..48fac63ea 100644
--- a/libc/sysdeps/linux/common/sync.c
+++ b/libc/sysdeps/linux/common/sync.c
@@ -7,7 +7,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#include <features.h>
#include <errno.h>
#include <sys/types.h>
diff --git a/libc/sysdeps/linux/common/syscalls.h b/libc/sysdeps/linux/common/syscalls.h
index d3f7fea51..af015246a 100644
--- a/libc/sysdeps/linux/common/syscalls.h
+++ b/libc/sysdeps/linux/common/syscalls.h
@@ -7,7 +7,6 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
#define _LARGEFILE64_SOURCE
#include <features.h>
#include <errno.h>
diff --git a/libc/sysdeps/linux/common/ulimit.c b/libc/sysdeps/linux/common/ulimit.c
index 523beae47..75d7a8237 100644
--- a/libc/sysdeps/linux/common/ulimit.c
+++ b/libc/sysdeps/linux/common/ulimit.c
@@ -5,21 +5,10 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define _GNU_SOURCE
-#define _LARGEFILE64_SOURCE
-#include <features.h>
-#undef __OPTIMIZE__
-/* We absolutely do _NOT_ want interfaces silently
- * * * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
+#include "syscalls.h"
#ifdef __NR_ulimit
-#include <sys/types.h>
-#include <sys/syscall.h>
-
_syscall2(long, ulimit, int, cmd, int, arg);
#else
@@ -27,7 +16,6 @@ _syscall2(long, ulimit, int, cmd, int, arg);
#include <stdarg.h>
#include <unistd.h>
#include <ulimit.h>
-#include <errno.h>
#include <sys/resource.h>
libc_hidden_proto(sysconf)
@@ -68,4 +56,3 @@ long int ulimit(int cmd, ...)
return result;
}
#endif
-
diff --git a/libc/sysdeps/linux/common/xstatconv.c b/libc/sysdeps/linux/common/xstatconv.c
index 407f32496..58e05c437 100644
--- a/libc/sysdeps/linux/common/xstatconv.c
+++ b/libc/sysdeps/linux/common/xstatconv.c
@@ -20,15 +20,7 @@
Modified for uClibc by Erik Andersen <andersen@codepoet.org>
*/
-#define _GNU_SOURCE
-#define _LARGEFILE64_SOURCE
-#include <features.h>
-#undef __OPTIMIZE__
-/* We absolutely do _NOT_ want interfaces silently
- * * * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
+#include "syscalls.h"
#include <sys/stat.h>
#include "xstatconv.h"
@@ -55,16 +47,16 @@ void attribute_hidden __xstat_conv(struct kernel_stat *kbuf, struct stat *buf)
#endif
}
-#if defined(__UCLIBC_HAS_LFS__)
+#ifdef __UCLIBC_HAS_LFS__
void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *buf)
{
/* Convert to current kernel version of `struct stat64'. */
buf->st_dev = kbuf->st_dev;
buf->st_ino = kbuf->st_ino;
-#ifdef _HAVE_STAT64___ST_INO
+# ifdef _HAVE_STAT64___ST_INO
buf->__st_ino = kbuf->__st_ino;
-#endif
+# endif
buf->st_mode = kbuf->st_mode;
buf->st_nlink = kbuf->st_nlink;
buf->st_uid = kbuf->st_uid;
@@ -76,11 +68,11 @@ void attribute_hidden __xstat64_conv(struct kernel_stat64 *kbuf, struct stat64 *
buf->st_atime = kbuf->st_atime;
buf->st_mtime = kbuf->st_mtime;
buf->st_ctime = kbuf->st_ctime;
-#ifdef STAT_HAVE_NSEC
+# ifdef STAT_HAVE_NSEC
buf->st_atimensec = kbuf->st_atime_nsec;
buf->st_mtimensec = kbuf->st_mtime_nsec;
buf->st_ctimensec = kbuf->st_ctime_nsec;
-#endif
+# endif
}
#endif /* __UCLIBC_HAS_LFS__ */