From a6dbcfb227bed9fb8db77f892c98032bbcf08d69 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Mon, 28 Jun 2021 15:49:05 +0200 Subject: [PATCH] add C++ header guards --- include/assert.h | 8 ++++++++ include/ctype.h | 8 ++++++++ include/errno.h | 8 ++++++++ include/fcntl.h | 8 ++++++++ include/fxlibc/printf.h | 12 ++++++++++-- include/inttypes.h | 8 ++++++++ include/locale.h | 8 ++++++++ include/setjmp.h | 8 ++++++++ include/signal.h | 8 ++++++++ include/stdio.h | 8 ++++++++ include/stdlib.h | 13 +++++++++++++ include/string.h | 8 ++++++++ include/sys/mman.h | 8 ++++++++ include/sys/stat.h | 8 ++++++++ include/sys/syscall.h | 8 ++++++++ include/sys/types.h | 8 ++++++++ include/sys/wait.h | 8 ++++++++ include/threads.h | 8 ++++++++ include/time.h | 8 ++++++++ include/unistd.h | 8 ++++++++ 20 files changed, 167 insertions(+), 2 deletions(-) diff --git a/include/assert.h b/include/assert.h index 2aba601..745e0ae 100644 --- a/include/assert.h +++ b/include/assert.h @@ -9,6 +9,10 @@ #define __ASSERT_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* Internal function that prints error message and aborts */ void __assert_fail(char const *__file, int __line, char const *__function, char const *__expression); @@ -25,3 +29,7 @@ void __assert_fail(char const *__file, int __line, char const *__function, #ifndef __cplusplus # define static_assert _Static_assert #endif + +#ifdef __cplusplus +} +#endif diff --git a/include/ctype.h b/include/ctype.h index 372de13..17f42f7 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -1,6 +1,10 @@ #ifndef __CTYPE_H__ # define __CTYPE_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* ** Character classification functions. These are all implemented as sets of ** comparisons. There is an approach with a 128-byte table, but it takes more @@ -103,4 +107,8 @@ extern int toupper(int c); islower(__c0) ? (__c0 & 0xdf) : __c0; \ }) +#ifdef __cplusplus +} +#endif + #endif /*__CTYPE_H__*/ diff --git a/include/errno.h b/include/errno.h index 41f0201..81a9999 100644 --- a/include/errno.h +++ b/include/errno.h @@ -1,6 +1,10 @@ #ifndef __ERRNO_H__ # define __ERRNO_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* Initialized to 0 at startup. Currently not TLS, maybe in the future if threads are supported. */ extern int errno; @@ -9,4 +13,8 @@ extern int errno; #define EILSEQ 2 #define ERANGE 3 +#ifdef __cplusplus +} +#endif + #endif /*__ERRNO_H__*/ diff --git a/include/fcntl.h b/include/fcntl.h index 6c33d08..4b98cc4 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -1,6 +1,10 @@ #ifndef __FCNTL_H__ # define __FCNTL_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -17,4 +21,8 @@ */ extern int open(const char *pathname, int flags, ...); +#ifdef __cplusplus +} +#endif + #endif /*__FCNTL_H__*/ diff --git a/include/fxlibc/printf.h b/include/fxlibc/printf.h index 394dc01..4bb80dd 100644 --- a/include/fxlibc/printf.h +++ b/include/fxlibc/printf.h @@ -1,5 +1,9 @@ #ifndef __FXLIBC_PRINTF_H__ -#define __FXLIBC_PRINTF_H__ +# define __FXLIBC_PRINTF_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* ** This headers covers fxlibc-specific extensions to the *printf API. fxlibc @@ -268,4 +272,8 @@ extern int __printf_digits16(char *__str, int uppercase, uint64_t __n); /* Same in base 8. */ extern int __printf_digits8(char *__str, uint64_t __n); -#endif /* __FXLIBC_PRINTF_H__ */ +#ifdef __cplusplus +} +#endif + +#endif /*__FXLIBC_PRINTF_H__*/ diff --git a/include/inttypes.h b/include/inttypes.h index f7ce4d2..3f93cc1 100644 --- a/include/inttypes.h +++ b/include/inttypes.h @@ -1,6 +1,10 @@ #ifndef __INTTYPES_H__ # define __INTTYPES_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -255,4 +259,8 @@ extern uintmax_t strtoumax( char ** __restrict__ __endptr, int __base); +#ifdef __cplusplus +} +#endif + #endif /*__INTTYPES_H__*/ diff --git a/include/locale.h b/include/locale.h index 9b2f760..9565acf 100644 --- a/include/locale.h +++ b/include/locale.h @@ -1,6 +1,10 @@ #ifndef __LOCALE_H__ # define __LOCALE_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include struct lconv { @@ -40,4 +44,8 @@ struct lconv { extern char *setlocale(int __category, char const *__locale); extern struct lconv *localeconv(void); +#ifdef __cplusplus +} +#endif + #endif /*__LOCALE_H__*/ diff --git a/include/setjmp.h b/include/setjmp.h index e9038e6..66a7b4c 100644 --- a/include/setjmp.h +++ b/include/setjmp.h @@ -1,6 +1,10 @@ #ifndef __SETJMP_H__ # define __SETJMP_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -19,4 +23,8 @@ extern int setjmp(jmp_buf __env); __attribute__((noreturn)) extern void longjmp(jmp_buf __env, int __val); +#ifdef __cplusplus +} +#endif + #endif /*__SETJMP_H__*/ diff --git a/include/signal.h b/include/signal.h index d1e86b2..a181cad 100644 --- a/include/signal.h +++ b/include/signal.h @@ -1,6 +1,10 @@ #ifndef __SIGNAL_H__ # define __SIGNAL_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -48,4 +52,8 @@ extern int kill(pid_t __pid, int __sig); #endif /*_POSIX_C_SOURCE*/ +#ifdef __cplusplus +} +#endif + #endif /*__SIGNAL_H__*/ diff --git a/include/stdio.h b/include/stdio.h index 0648603..d7529e5 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -1,6 +1,10 @@ #ifndef __STDIO_H__ # define __STDIO_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -132,4 +136,8 @@ extern int asprintf(char ** __restrict__ __str, extern int vasprintf(char ** __restrict__ __str, char const * __restrict__ __format, va_list __args); +#ifdef __cplusplus +} +#endif + #endif /*__STDIO_H__*/ diff --git a/include/stdlib.h b/include/stdlib.h index ff4aa32..ca68bff 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -1,6 +1,10 @@ #ifndef __STDLIB_H__ # define __STDLIB_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -143,4 +147,13 @@ extern void srand(unsigned int seed); /* Generate a pseudo-random number between 0 and RAND_MAX. */ extern int rand(void); +/* Searching and sorting utilities. */ + +void qsort(void *base, size_t nmemb, size_t size, + int (*compare)(void const *left, void const *right)); + +#ifdef __cplusplus +} +#endif + #endif /*__STDLIB_H__*/ diff --git a/include/string.h b/include/string.h index ed5c79a..705308d 100644 --- a/include/string.h +++ b/include/string.h @@ -1,6 +1,10 @@ #ifndef __STRING_H__ # define __STRING_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include /* Copying functions. */ @@ -109,4 +113,8 @@ extern char *strdup(char const *__s); /* Duplicate at most __n characters of __s with malloc. */ extern char *strndup(char const *__s, size_t __n); +#ifdef __cplusplus +} +#endif + #endif /*__STRING_H__*/ diff --git a/include/sys/mman.h b/include/sys/mman.h index 960b412..fda57b3 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -1,6 +1,10 @@ #ifndef __SYS_MMAN_H__ # define __SYS_MMAN_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -55,4 +59,8 @@ extern void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t */ extern int munmap(void *addr, size_t length); +#ifdef __cplusplus +} +#endif + #endif /*__SYS_MMAN_H__*/ diff --git a/include/sys/stat.h b/include/sys/stat.h index 282ec38..b8ca1bb 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -1,6 +1,10 @@ #ifndef __SYS_STAT_H__ # define __SYS_STAT_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* File types. */ #define __S_IFMT 0170000 /* These bits determine file type. */ #define __S_IFDIR 0040000 /* Directory. */ @@ -37,4 +41,8 @@ /* Read, write, and execute by others. */ #define S_IRWXO (S_IRWXG >> 3) +#ifdef __cplusplus +} +#endif + #endif /*__SYS_STAT_H__*/ diff --git a/include/sys/syscall.h b/include/sys/syscall.h index fceb98a..14025b8 100644 --- a/include/sys/syscall.h +++ b/include/sys/syscall.h @@ -1,6 +1,10 @@ #ifndef __SYS_SYSCALL_H__ # define __SYS_SYSCALL_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* ** This file should list the numbers of the system calls the system knows. ** But instead of duplicating this we use the information available @@ -15,4 +19,8 @@ */ #include +#ifdef __cplusplus +} +#endif + #endif /*__SYS_SYSCALL_H__*/ diff --git a/include/sys/types.h b/include/sys/types.h index d22f9b7..ec8724a 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -1,6 +1,10 @@ #ifndef __SYS_TYPES_H__ # define __SYS_TYPES_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -23,4 +27,8 @@ typedef int16_t mode_t; typedef uint16_t dev_t; typedef uint16_t umode_t; +#ifdef __cplusplus +} +#endif + #endif /*__SYS_TYPES_H__*/ diff --git a/include/sys/wait.h b/include/sys/wait.h index 67b0069..0108a97 100644 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -1,6 +1,10 @@ #ifndef __SYS_WAIT_H__ # define __SYS_WAIT_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include #include @@ -46,4 +50,8 @@ extern pid_t waitpid(pid_t pid, int *wstatus, int options); */ extern pid_t wait(int *wstatus); +#ifdef __cplusplus +} +#endif + #endif /*__SYS_WAIT_H__*/ diff --git a/include/threads.h b/include/threads.h index 059a89d..056f3c2 100644 --- a/include/threads.h +++ b/include/threads.h @@ -1,6 +1,10 @@ #ifndef __THREADS_H__ # define __THREADS_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -74,4 +78,8 @@ extern uint32_t __thread_atomic_start(void); */ extern uint32_t __thread_atomic_stop(void); +#ifdef __cplusplus +} +#endif + #endif /*__THREADS_H__*/ diff --git a/include/time.h b/include/time.h index 63b755c..a1d9d63 100644 --- a/include/time.h +++ b/include/time.h @@ -1,6 +1,10 @@ #ifndef __TIME_H__ # define __TIME_H__ +#ifdef __cplusplus +extern "C" { +#endif + /* Number of ticks per second in a clock_t value. */ #define CLOCKS_PER_SEC 1000000 @@ -23,4 +27,8 @@ struct tm { int tm_isdst; }; +#ifdef __cplusplus +} +#endif + #endif /*__TIME_H__*/ diff --git a/include/unistd.h b/include/unistd.h index 76096bc..153dd49 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1,6 +1,10 @@ #ifndef __UNISTD_H__ # define __UNISTD_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -83,4 +87,8 @@ extern int close(int __fd); /* Get the value of the system variable NAME. */ extern long int sysconf(int __name); +#ifdef __cplusplus +} +#endif + #endif /*__UNISTD_H__*/