Consolidate headers.
authorRob Landley <rob@landley.net>
Thu, 8 Mar 2012 01:04:50 +0000 (19:04 -0600)
committerRob Landley <rob@landley.net>
Thu, 8 Mar 2012 01:04:50 +0000 (19:04 -0600)
lib/portability.h
toys.h
toys/dirname.c
toys/id.c
toys/ls.c
toys/sort.c
toys/uname.c
toys/unshare.c
toys/who.c

index d4edfb6..0887d87 100644 (file)
@@ -7,8 +7,13 @@
 
 #undef _FORTIFY_SOURCE
 
-// Humor glibc to get dprintf, then #define it to something more portable.
-#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+
+#define _POSIX_C_SOURCE 200809L
+#define _XOPEN_SOURCE 600
+#define _BSD_SOURCE
+#define _SVID_SOURCE
+
 #include <stdio.h>
 #define fdprintf(...) dprintf(__VA_ARGS__)
 
diff --git a/toys.h b/toys.h
index 504e0dc..f4ef2ef 100644 (file)
--- a/toys.h
+++ b/toys.h
 #include <grp.h>
 #include <inttypes.h>
 #include <limits.h>
+#include <libgen.h>
+#include <math.h>
 #include <pty.h>
 #include <pwd.h>
+#include <sched.h>
 #include <setjmp.h>
 #include <stdarg.h>
 #include <stdint.h>
 #include <sys/sysinfo.h>
 #include <sys/swap.h>
 #include <sys/types.h>
+#include <sys/utsname.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #include <utime.h>
+#include <utmpx.h>
 
 #undef _XOPEN_SOURCE
 #define _XOPEN_SOURCE 600
index bac0fd4..5dc6018 100644 (file)
@@ -18,7 +18,6 @@ config DIRNAME
 */
 
 #include "toys.h"
-#include <libgen.h>
 
 void dirname_main(void)
 {
index 6ae3efe..aaea3e3 100644 (file)
--- a/toys/id.c
+++ b/toys/id.c
@@ -25,9 +25,6 @@ config ID
          -u    Show only the effective user ID
 */
 
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
 #include "toys.h"
 
 #define FLAG_n (1<<4)
@@ -36,8 +33,8 @@ config ID
 #define FLAG_r (1<<1)
 #define FLAG_u 1
 
-void
-pretty_print(struct passwd *pw, struct group *grp, struct group **grps, int n)
+void pretty_print(struct passwd *pw, struct group *grp, struct group **grps,
+               int n)
 {
        int i;
        printf("uid= %d(%s) gid= %d(%s)", pw->pw_uid, pw->pw_name,
index 7610920..ec5606f 100644 (file)
--- a/toys/ls.c
+++ b/toys/ls.c
@@ -22,14 +22,6 @@ config LS
           -l    show full details for each file
 */
 
-/* So that we can do 64-bit stat etc... */
-#define _FILE_OFFSET_BITS 64
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <grp.h>
-#include <pwd.h>
-
 #include "toys.h"
 
 #define FLAG_a 1
index fabff69..89a9702 100644 (file)
@@ -61,7 +61,6 @@ config SORT_FLOAT
 */
 
 #include "toys.h"
-#include <math.h>
 
 DEFINE_GLOBALS(
     char *key_separator;
index dd29ec1..185d633 100644 (file)
@@ -25,7 +25,6 @@ config UNAME
 */
 
 #include "toys.h"
-#include <sys/utsname.h>
 
 // If a 32 bit x86 build environment working in a chroot under an x86-64
 // kernel returns x86_64 for -m it confuses ./configure.  Special case it.
index 6485e33..8257b7c 100644 (file)
@@ -27,8 +27,6 @@ config UNSHARE
 
 #include "toys.h"
 
-#include <sched.h>
-
 void unshare_main(void)
 {
        unsigned flags[]={CLONE_NEWNS, CLONE_NEWUTS, CLONE_NEWIPC, CLONE_NEWNET,0};
index f6559bc..d407c6b 100644 (file)
@@ -21,8 +21,6 @@ config WHO
 */
 
 #include "toys.h"
-#include <time.h>
-#include <utmpx.h>
 
 void who_main(void)
 {