Skip to content

Commit 55abdd1

Browse files
wtarreaupaulmckrcu
authored andcommitted
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: Willy Tarreau <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 184177c commit 55abdd1

File tree

10 files changed

+29
-0
lines changed

10 files changed

+29
-0
lines changed

tools/include/nolibc/ctype.h

+3
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,7 @@ int ispunct(int c)
9696
return isgraph(c) && !isalnum(c);
9797
}
9898

99+
/* make sure to include all global symbols */
100+
#include "nolibc.h"
101+
99102
#endif /* _NOLIBC_CTYPE_H */

tools/include/nolibc/errno.h

+3
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ static int errno;
2424
*/
2525
#define MAX_ERRNO 4095
2626

27+
/* make sure to include all global symbols */
28+
#include "nolibc.h"
29+
2730
#endif /* _NOLIBC_ERRNO_H */

tools/include/nolibc/signal.h

+3
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ int raise(int signal)
1919
return sys_kill(sys_getpid(), signal);
2020
}
2121

22+
/* make sure to include all global symbols */
23+
#include "nolibc.h"
24+
2225
#endif /* _NOLIBC_SIGNAL_H */

tools/include/nolibc/stdio.h

+3
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,7 @@ void perror(const char *msg)
303303
fprintf(stderr, "%s%serrno=%d\n", (msg && *msg) ? msg : "", (msg && *msg) ? ": " : "", errno);
304304
}
305305

306+
/* make sure to include all global symbols */
307+
#include "nolibc.h"
308+
306309
#endif /* _NOLIBC_STDIO_H */

tools/include/nolibc/stdlib.h

+3
Original file line numberDiff line numberDiff line change
@@ -419,4 +419,7 @@ char *u64toa(uint64_t in)
419419
return itoa_buffer;
420420
}
421421

422+
/* make sure to include all global symbols */
423+
#include "nolibc.h"
424+
422425
#endif /* _NOLIBC_STDLIB_H */

tools/include/nolibc/string.h

+3
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,7 @@ char *strrchr(const char *s, int c)
285285
return (char *)ret;
286286
}
287287

288+
/* make sure to include all global symbols */
289+
#include "nolibc.h"
290+
288291
#endif /* _NOLIBC_STRING_H */

tools/include/nolibc/sys.h

+2
Original file line numberDiff line numberDiff line change
@@ -1243,5 +1243,7 @@ ssize_t write(int fd, const void *buf, size_t count)
12431243
return ret;
12441244
}
12451245

1246+
/* make sure to include all global symbols */
1247+
#include "nolibc.h"
12461248

12471249
#endif /* _NOLIBC_SYS_H */

tools/include/nolibc/time.h

+3
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ time_t time(time_t *tptr)
2525
return tv.tv_sec;
2626
}
2727

28+
/* make sure to include all global symbols */
29+
#include "nolibc.h"
30+
2831
#endif /* _NOLIBC_TIME_H */

tools/include/nolibc/types.h

+3
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,7 @@ struct stat {
209209
})
210210
#endif
211211

212+
/* make sure to include all global symbols */
213+
#include "nolibc.h"
214+
212215
#endif /* _NOLIBC_TYPES_H */

tools/include/nolibc/unistd.h

+3
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ int tcsetpgrp(int fd, pid_t pid)
5151
return ioctl(fd, TIOCSPGRP, &pid);
5252
}
5353

54+
/* make sure to include all global symbols */
55+
#include "nolibc.h"
56+
5457
#endif /* _NOLIBC_UNISTD_H */

0 commit comments

Comments
 (0)