Browse Source

Reorder includes and include only what is necessary

Use param.h instead of MIN.
Use stddef.h instead of offsetof.

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Peter S. Mazinger 13 years ago
parent
commit
c28cabb179

+ 1 - 3
libc/sysdeps/linux/common/alarm.c

@@ -10,12 +10,10 @@
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
-
 #ifdef __NR_alarm
 #ifdef __NR_alarm
 _syscall1(unsigned int, alarm, unsigned int, seconds)
 _syscall1(unsigned int, alarm, unsigned int, seconds)
 #else
 #else
-#include <sys/time.h>
-
+# include <sys/time.h>
 
 
 unsigned int alarm(unsigned int seconds)
 unsigned int alarm(unsigned int seconds)
 {
 {

+ 1 - 1
libc/sysdeps/linux/common/arch_prctl.c

@@ -10,6 +10,6 @@
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 
 
 #ifdef __NR_arch_prctl
 #ifdef __NR_arch_prctl
-extern int arch_prctl(int code, unsigned long addr);
+int arch_prctl(int code, unsigned long addr);
 _syscall2(int, arch_prctl, int, code, unsigned long, addr)
 _syscall2(int, arch_prctl, int, code, unsigned long, addr)
 #endif
 #endif

+ 2 - 1
libc/sysdeps/linux/common/capget.c

@@ -8,7 +8,8 @@
  */
  */
 
 
 #include <sys/syscall.h>
 #include <sys/syscall.h>
-int capget(void *header, void *data);
+
 #ifdef __NR_capget
 #ifdef __NR_capget
+int capget(void *header, void *data);
 _syscall2(int, capget, void *, header, void *, data)
 _syscall2(int, capget, void *, header, void *, data)
 #endif
 #endif

+ 1 - 1
libc/sysdeps/linux/common/capset.c

@@ -9,7 +9,7 @@
 
 
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 
 
-int capset(void *header, const void *data);
 #ifdef __NR_capset
 #ifdef __NR_capset
+int capset(void *header, const void *data);
 _syscall2(int, capset, void *, header, const void *, data)
 _syscall2(int, capset, void *, header, const void *, data)
 #endif
 #endif

+ 2 - 1
libc/sysdeps/linux/common/fchdir.c

@@ -10,6 +10,7 @@
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
-
+#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
 _syscall1(int, fchdir, int, fd)
 _syscall1(int, fchdir, int, fd)
 libc_hidden_def(fchdir)
 libc_hidden_def(fchdir)
+#endif

+ 0 - 1
libc/sysdeps/linux/common/ftruncate.c

@@ -10,6 +10,5 @@
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
-
 _syscall2(int, ftruncate, int, fd, __off_t, length)
 _syscall2(int, ftruncate, int, fd, __off_t, length)
 libc_hidden_def(ftruncate)
 libc_hidden_def(ftruncate)

+ 14 - 14
libc/sysdeps/linux/common/getdents.c

@@ -4,22 +4,17 @@
  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  */
  */
 
 
-#include <assert.h>
-#include <errno.h>
+#include <sys/syscall.h>
+#include <bits/wordsize.h>
+
+#if !(defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 && __WORDSIZE == 64)
+
 #include <dirent.h>
 #include <dirent.h>
-#include <stddef.h>
-#include <stdint.h>
 #include <string.h>
 #include <string.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/types.h>
-#include <sys/syscall.h>
 #include <bits/kernel_types.h>
 #include <bits/kernel_types.h>
 #include <bits/kernel-features.h>
 #include <bits/kernel-features.h>
-#include <bits/uClibc_alloc.h>
 
 
-#if !(defined __UCLIBC_HAS_LFS__ && defined __NR_getdents64 && __WORDSIZE == 64)
 /* If the condition above is met, __getdents is defined as an alias
 /* If the condition above is met, __getdents is defined as an alias
  * for __getdents64 (see getdents64.c). Otherwise...
  * for __getdents64 (see getdents64.c). Otherwise...
  */
  */
@@ -31,10 +26,6 @@
  * version / arch details.
  * version / arch details.
  */
  */
 
 
-#ifndef offsetof
-# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
 struct kernel_dirent
 struct kernel_dirent
 {
 {
 	long int d_ino;
 	long int d_ino;
@@ -77,6 +68,13 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
 
 
 #elif ! defined __UCLIBC_HAS_LFS__ || ! defined __NR_getdents64
 #elif ! defined __UCLIBC_HAS_LFS__ || ! defined __NR_getdents64
 
 
+# include <assert.h>
+# include <stddef.h>
+# include <errno.h>
+# include <unistd.h>
+# include <sys/param.h>
+# include <bits/uClibc_alloc.h>
+
 ssize_t __getdents (int fd, char *buf, size_t nbytes)
 ssize_t __getdents (int fd, char *buf, size_t nbytes)
 {
 {
     struct dirent *dp;
     struct dirent *dp;
@@ -138,6 +136,8 @@ ssize_t __getdents (int fd, char *buf, size_t nbytes)
 
 
 #elif __WORDSIZE == 32
 #elif __WORDSIZE == 32
 
 
+# include <stddef.h>
+
 ssize_t __getdents (int fd, char *buf, size_t nbytes)
 ssize_t __getdents (int fd, char *buf, size_t nbytes)
 {
 {
     struct dirent *dp;
     struct dirent *dp;

+ 3 - 4
libc/sysdeps/linux/common/getrlimit.c

@@ -8,8 +8,8 @@
  */
  */
 
 
 #include <sys/syscall.h>
 #include <sys/syscall.h>
-#include <unistd.h>
 #include <sys/resource.h>
 #include <sys/resource.h>
+#include <bits/wordsize.h>
 
 
 /* Only wrap getrlimit if the new ugetrlimit is not present and getrlimit sucks */
 /* Only wrap getrlimit if the new ugetrlimit is not present and getrlimit sucks */
 
 
@@ -22,14 +22,14 @@ _syscall2(int, __syscall_ugetrlimit, enum __rlimit_resource, resource,
           struct rlimit *, rlim)
           struct rlimit *, rlim)
 int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
 int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
 {
 {
-	return (__syscall_ugetrlimit(resource, rlimits));
+	return __syscall_ugetrlimit(resource, rlimits);
 }
 }
 
 
 #elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
 #elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
 
 
 /* We don't need to wrap getrlimit() */
 /* We don't need to wrap getrlimit() */
 _syscall2(int, getrlimit, __rlimit_resource_t, resource,
 _syscall2(int, getrlimit, __rlimit_resource_t, resource,
-		struct rlimit *, rlim)
+	  struct rlimit *, rlim)
 
 
 #else
 #else
 
 
@@ -56,7 +56,6 @@ int getrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
 	return result;
 	return result;
 }
 }
 #endif
 #endif
-
 libc_hidden_def(getrlimit)
 libc_hidden_def(getrlimit)
 
 
 #if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
 #if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64

+ 3 - 2
libc/sysdeps/linux/common/init_module.c

@@ -8,12 +8,13 @@
  */
  */
 
 
 #include <sys/syscall.h>
 #include <sys/syscall.h>
-int init_module(void *first, void *second, void *third, void *fourth, void *fifth);
+
 #ifdef __NR_init_module
 #ifdef __NR_init_module
+int init_module(void *first, void *second, void *third, void *fourth, void *fifth);
 /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
 /* 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,
  * (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. */
  * and let the kernel cope with whatever it gets.  It's good at that. */
 _syscall5(int, init_module, void *, first, void *, second, void *, third,
 _syscall5(int, init_module, void *, first, void *, second, void *, third,
-		  void *, fourth, void *, fifth)
+	  void *, fourth, void *, fifth)
 #endif
 #endif
 
 

+ 4 - 8
libc/sysdeps/linux/common/sendfile.c

@@ -8,16 +8,12 @@
  */
  */
 
 
 #include <sys/syscall.h>
 #include <sys/syscall.h>
-#include <unistd.h>
-#include <sys/sendfile.h>
 
 
 #ifdef __NR_sendfile
 #ifdef __NR_sendfile
-
+# include <sys/sendfile.h>
 _syscall4(ssize_t, sendfile, int, out_fd, int, in_fd, __off_t *, offset,
 _syscall4(ssize_t, sendfile, int, out_fd, int, in_fd, __off_t *, offset,
-		  size_t, count)
-
-#if ! defined __NR_sendfile64 && defined __UCLIBC_HAS_LFS__
+	  size_t, count)
+# if ! defined __NR_sendfile64 && defined __UCLIBC_HAS_LFS__
 strong_alias(sendfile,sendfile64)
 strong_alias(sendfile,sendfile64)
+# endif
 #endif
 #endif
-
-#endif /* __NR_sendfile */

+ 10 - 8
libc/sysdeps/linux/common/setrlimit.c

@@ -8,8 +8,8 @@
  */
  */
 
 
 #include <sys/syscall.h>
 #include <sys/syscall.h>
-#include <unistd.h>
 #include <sys/resource.h>
 #include <sys/resource.h>
+#include <bits/wordsize.h>
 
 
 /* Only wrap setrlimit if the new usetrlimit is not present and setrlimit sucks */
 /* Only wrap setrlimit if the new usetrlimit is not present and setrlimit sucks */
 
 
@@ -22,7 +22,7 @@ _syscall2(int, __syscall_usetrlimit, enum __rlimit_resource, resource,
           const struct rlimit *, rlim)
           const struct rlimit *, rlim)
 int setrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
 int setrlimit(__rlimit_resource_t resource, struct rlimit *rlimits)
 {
 {
-	return (__syscall_usetrlimit(resource, rlimits));
+	return __syscall_usetrlimit(resource, rlimits);
 }
 }
 
 
 #elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
 #elif !defined(__UCLIBC_HANDLE_OLDER_RLIMIT__)
@@ -33,6 +33,11 @@ _syscall2(int, setrlimit, __rlimit_resource_t, resource,
 
 
 #else
 #else
 
 
+# define __need_NULL
+# include <stddef.h>
+# include <errno.h>
+# include <sys/param.h>
+
 /* we have to handle old style setrlimit() */
 /* we have to handle old style setrlimit() */
 # define __NR___syscall_setrlimit __NR_setrlimit
 # define __NR___syscall_setrlimit __NR_setrlimit
 static __always_inline
 static __always_inline
@@ -49,16 +54,13 @@ int setrlimit(__rlimit_resource_t resource, const struct rlimit *rlimits)
 
 
 	/* We might have to correct the limits values.  Since the old values
 	/* We might have to correct the limits values.  Since the old values
 	 * were signed the new values might be too large.  */
 	 * were signed the new values might be too large.  */
-# define RMIN(x, y) ((x) < (y) ? (x) : (y))
-	rlimits_small.rlim_cur = RMIN((unsigned long int) rlimits->rlim_cur,
+	rlimits_small.rlim_cur = MIN((unsigned long int) rlimits->rlim_cur,
 								  RLIM_INFINITY >> 1);
 								  RLIM_INFINITY >> 1);
-	rlimits_small.rlim_max = RMIN((unsigned long int) rlimits->rlim_max,
+	rlimits_small.rlim_max = MIN((unsigned long int) rlimits->rlim_max,
 								  RLIM_INFINITY >> 1);
 								  RLIM_INFINITY >> 1);
-#undef RMIN
-	return (__syscall_setrlimit(resource, &rlimits_small));
+	return __syscall_setrlimit(resource, &rlimits_small);
 }
 }
 #endif
 #endif
-
 libc_hidden_def(setrlimit)
 libc_hidden_def(setrlimit)
 
 
 #if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
 #if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64

+ 0 - 1
libc/sysdeps/linux/common/truncate.c

@@ -10,6 +10,5 @@
 #include <sys/syscall.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <unistd.h>
 
 
-
 _syscall2(int, truncate, const char *, path, __off_t, length)
 _syscall2(int, truncate, const char *, path, __off_t, length)
 libc_hidden_def(truncate)
 libc_hidden_def(truncate)

+ 1 - 4
libc/sysdeps/linux/i386/sysdep.h

@@ -150,10 +150,6 @@ __x86.get_pc_thunk.reg:						      \
 #undef __i686
 #undef __i686
 #endif	/* __ASSEMBLER__ */
 #endif	/* __ASSEMBLER__ */
 
 
-#ifndef offsetof
-# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
 /* For Linux we can use the system call table in the header file
 /* For Linux we can use the system call table in the header file
 	/usr/include/asm/unistd.h
 	/usr/include/asm/unistd.h
    of the kernel.  But these symbols do not follow the SYS_* syntax
    of the kernel.  But these symbols do not follow the SYS_* syntax
@@ -444,6 +440,7 @@ __x86.get_pc_thunk.reg:						      \
 #  define PTR_DEMANGLE(reg)	rorl $9, reg;				      \
 #  define PTR_DEMANGLE(reg)	rorl $9, reg;				      \
 				xorl %gs:POINTER_GUARD, reg
 				xorl %gs:POINTER_GUARD, reg
 # else
 # else
+#  include <stddef.h>
 #  define PTR_MANGLE(var)	__asm__ ("xorl %%gs:%c2, %0\n"		      \
 #  define PTR_MANGLE(var)	__asm__ ("xorl %%gs:%c2, %0\n"		      \
 				     "roll $9, %0"			      \
 				     "roll $9, %0"			      \
 				     : "=r" (var)			      \
 				     : "=r" (var)			      \

+ 1 - 4
librt/timer_create.c

@@ -2,6 +2,7 @@
  * timer_create.c - create a per-process timer.
  * timer_create.c - create a per-process timer.
  */
  */
 
 
+#include <stddef.h>
 #include <errno.h>
 #include <errno.h>
 #include <signal.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <stdlib.h>
@@ -13,10 +14,6 @@
 
 
 #ifdef __NR_timer_create
 #ifdef __NR_timer_create
 
 
-#ifndef offsetof
-# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
 #define __NR___syscall_timer_create __NR_timer_create
 #define __NR___syscall_timer_create __NR_timer_create
 static __inline__ _syscall3(int, __syscall_timer_create, clockid_t, clock_id,
 static __inline__ _syscall3(int, __syscall_timer_create, clockid_t, clock_id,
 			struct sigevent *, evp, kernel_timer_t *, ktimerid);
 			struct sigevent *, evp, kernel_timer_t *, ktimerid);