Commit 55abdd1f authored by Willy Tarreau's avatar Willy Tarreau Committed by Paul E. McKenney

tools/nolibc: fix missing includes causing build issues at -O0

After the nolibc includes were split to facilitate portability from
standard libcs, programs that include only what they need may miss
some symbols which are needed by libgcc. This is the case for raise()
which is needed by the divide by zero code in some architectures for
example.

Regardless, being able to include only the apparently needed files is
convenient.

Instead of trying to move all exported definitions to a single file,
since this can change over time, this patch takes another approach
consisting in including the nolibc header at the end of all standard
include files. This way their types and functions are already known
at the moment of inclusion, and including any single one of them is
sufficient to bring all the required ones.
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent 184177c3
...@@ -96,4 +96,7 @@ int ispunct(int c) ...@@ -96,4 +96,7 @@ int ispunct(int c)
return isgraph(c) && !isalnum(c); return isgraph(c) && !isalnum(c);
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_CTYPE_H */ #endif /* _NOLIBC_CTYPE_H */
...@@ -24,4 +24,7 @@ static int errno; ...@@ -24,4 +24,7 @@ static int errno;
*/ */
#define MAX_ERRNO 4095 #define MAX_ERRNO 4095
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_ERRNO_H */ #endif /* _NOLIBC_ERRNO_H */
...@@ -19,4 +19,7 @@ int raise(int signal) ...@@ -19,4 +19,7 @@ int raise(int signal)
return sys_kill(sys_getpid(), signal); return sys_kill(sys_getpid(), signal);
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_SIGNAL_H */ #endif /* _NOLIBC_SIGNAL_H */
...@@ -303,4 +303,7 @@ void perror(const char *msg) ...@@ -303,4 +303,7 @@ void perror(const char *msg)
fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno); fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno);
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_STDIO_H */ #endif /* _NOLIBC_STDIO_H */
...@@ -419,4 +419,7 @@ char *u64toa(uint64_t in) ...@@ -419,4 +419,7 @@ char *u64toa(uint64_t in)
return itoa_buffer; return itoa_buffer;
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_STDLIB_H */ #endif /* _NOLIBC_STDLIB_H */
...@@ -285,4 +285,7 @@ char *strrchr(const char *s, int c) ...@@ -285,4 +285,7 @@ char *strrchr(const char *s, int c)
return (char *)ret; return (char *)ret;
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_STRING_H */ #endif /* _NOLIBC_STRING_H */
...@@ -1243,5 +1243,7 @@ ssize_t write(int fd, const void *buf, size_t count) ...@@ -1243,5 +1243,7 @@ ssize_t write(int fd, const void *buf, size_t count)
return ret; return ret;
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_SYS_H */ #endif /* _NOLIBC_SYS_H */
...@@ -25,4 +25,7 @@ time_t time(time_t *tptr) ...@@ -25,4 +25,7 @@ time_t time(time_t *tptr)
return tv.tv_sec; return tv.tv_sec;
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_TIME_H */ #endif /* _NOLIBC_TIME_H */
...@@ -209,4 +209,7 @@ struct stat { ...@@ -209,4 +209,7 @@ struct stat {
}) })
#endif #endif
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_TYPES_H */ #endif /* _NOLIBC_TYPES_H */
...@@ -51,4 +51,7 @@ int tcsetpgrp(int fd, pid_t pid) ...@@ -51,4 +51,7 @@ int tcsetpgrp(int fd, pid_t pid)
return ioctl(fd, TIOCSPGRP, &pid); return ioctl(fd, TIOCSPGRP, &pid);
} }
/* make sure to include all global symbols */
#include "nolibc.h"
#endif /* _NOLIBC_UNISTD_H */ #endif /* _NOLIBC_UNISTD_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment