aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/portability.h9
-rw-r--r--toys.h5
-rw-r--r--toys/dirname.c1
-rw-r--r--toys/id.c7
-rw-r--r--toys/ls.c8
-rw-r--r--toys/sort.c1
-rw-r--r--toys/uname.c1
-rw-r--r--toys/unshare.c2
-rw-r--r--toys/who.c2
9 files changed, 14 insertions, 22 deletions
diff --git a/lib/portability.h b/lib/portability.h
index d4edfb6d..0887d873 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -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 504e0dcb..f4ef2efd 100644
--- a/toys.h
+++ b/toys.h
@@ -15,8 +15,11 @@
#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>
@@ -31,9 +34,11 @@
#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
diff --git a/toys/dirname.c b/toys/dirname.c
index bac0fd40..5dc60181 100644
--- a/toys/dirname.c
+++ b/toys/dirname.c
@@ -18,7 +18,6 @@ config DIRNAME
*/
#include "toys.h"
-#include <libgen.h>
void dirname_main(void)
{
diff --git a/toys/id.c b/toys/id.c
index 6ae3efe5..aaea3e37 100644
--- 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,
diff --git a/toys/ls.c b/toys/ls.c
index 7610920d..ec5606f5 100644
--- 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
diff --git a/toys/sort.c b/toys/sort.c
index fabff694..89a97026 100644
--- a/toys/sort.c
+++ b/toys/sort.c
@@ -61,7 +61,6 @@ config SORT_FLOAT
*/
#include "toys.h"
-#include <math.h>
DEFINE_GLOBALS(
char *key_separator;
diff --git a/toys/uname.c b/toys/uname.c
index dd29ec17..185d633e 100644
--- a/toys/uname.c
+++ b/toys/uname.c
@@ -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.
diff --git a/toys/unshare.c b/toys/unshare.c
index 6485e334..8257b7c8 100644
--- a/toys/unshare.c
+++ b/toys/unshare.c
@@ -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};
diff --git a/toys/who.c b/toys/who.c
index f6559bc7..d407c6b2 100644
--- a/toys/who.c
+++ b/toys/who.c
@@ -21,8 +21,6 @@ config WHO
*/
#include "toys.h"
-#include <time.h>
-#include <utmpx.h>
void who_main(void)
{