diff --git a/README b/README index 94f0b7b..d051434 100644 --- a/README +++ b/README @@ -6,8 +6,6 @@ and simply overlays the system headers by using the #include_next extension foun in GCC and clang. It was initially intended to be used on musl[1] based Linux distributions. -NOTE: It does *not* support C++. For C++ programs, the fortify headers -will essentially be a no-op. Features ======== diff --git a/include/poll.h b/include/poll.h index 93976dd..6469acb 100644 --- a/include/poll.h +++ b/include/poll.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef poll extern int __poll_orig(struct pollfd *, nfds_t, int) @@ -35,6 +38,8 @@ int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/stdio.h b/include/stdio.h index f87bd59..5cf5b13 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef fgets #undef fread #undef fwrite @@ -114,6 +117,8 @@ int sprintf(char *s, const char *fmt, ...) return r; } +#ifdef __cplusplus +} #endif #endif diff --git a/include/stdlib.h b/include/stdlib.h index f4a026b..9d3698a 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -9,7 +9,9 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #undef realpath @@ -33,6 +35,8 @@ char *realpath(const char *path, char *resolved) } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/string.h b/include/string.h index 02e931e..f11e388 100644 --- a/include/string.h +++ b/include/string.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef memcpy #undef memmove #undef memset @@ -181,6 +184,8 @@ size_t strlcpy(char *dest, const char *src, size_t n) } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/strings.h b/include/strings.h index 1adbf51..4c1a591 100644 --- a/include/strings.h +++ b/include/strings.h @@ -5,7 +5,9 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || defined(_POSIX_SOURCE) \ || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \ @@ -37,6 +39,8 @@ void bzero(void *src, size_t n) } #endif +#ifdef __cplusplus +} #endif #endif diff --git a/include/sys/select.h b/include/sys/select.h index 7838041..9c3afa5 100644 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -5,7 +5,9 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif static __inline __attribute__((__always_inline__,__gnu_inline__)) int __fortify_FD_CLR(int fd, fd_set *set) @@ -32,6 +34,8 @@ int __fortify_FD_SET(int fd, fd_set *set) #undef FD_SET #define FD_SET(fd, set) __fortify_FD_SET(fd, set) +#ifdef __cplusplus +} #endif #endif diff --git a/include/sys/socket.h b/include/sys/socket.h index 4602866..81358fd 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef recv #undef recvfrom #undef send @@ -61,6 +64,8 @@ ssize_t sendto(int sockfd, const void *buf, size_t n, int flags, return __sendto_orig(sockfd, buf, n, flags, sa, salen); } +#ifdef __cplusplus +} #endif #endif diff --git a/include/unistd.h b/include/unistd.h index aa4ddff..0e5119e 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -5,7 +5,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef confstr #undef getcwd #undef getgroups @@ -165,6 +168,8 @@ ssize_t write(int fd, const void *buf, size_t n) return __write_orig(fd, buf, n); } +#ifdef __cplusplus +} #endif #endif diff --git a/include/wchar.h b/include/wchar.h index dac8435..f613429 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -6,7 +6,10 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#ifndef __cplusplus +#ifdef __cplusplus +extern "C" { +#endif + #undef fgetws #undef mbsnrtowcs #undef mbsrtowcs @@ -246,6 +249,8 @@ wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n) return __wmemset_orig(s, c, n); } +#ifdef __cplusplus +} #endif #endif