aboutsummaryrefslogtreecommitdiff
path: root/tools/build/cross-build/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'tools/build/cross-build/include/linux')
-rw-r--r--tools/build/cross-build/include/linux/unistd.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/build/cross-build/include/linux/unistd.h b/tools/build/cross-build/include/linux/unistd.h
index 9d1bd1bf4025..ea131f1ab732 100644
--- a/tools/build/cross-build/include/linux/unistd.h
+++ b/tools/build/cross-build/include/linux/unistd.h
@@ -41,9 +41,17 @@
/* Ensure that unistd.h pulls in getopt */
#define __USE_POSIX2
#endif
+/*
+ * Before version 2.25, glibc's unistd.h would define the POSIX subset of
+ * getopt.h by defining __need_getopt, including getopt.h (which would
+ * disable the header guard) and then undefining it so later including
+ * getopt.h explicitly would define the extensions. However, we wrap getopt,
+ * and so the wrapper's #pragma once breaks that. Thus getopt.h must be
+ * included before the real unistd.h to ensure we get all the extensions.
+ */
+#include <getopt.h>
#include_next <unistd.h>
#include <fcntl.h>
-#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>