|
38 | 38 | #include <stdlib.h> |
39 | 39 | #endif |
40 | 40 |
|
41 | | -// Workaround for noexcept functions in glibc when using clang. |
42 | | -// clang errors if declaration without exception specification preceeds |
43 | | -// noexcept declaration, but not the other way around. |
44 | | -#ifdef __clang__ |
45 | | -#include <stdio.h> |
46 | | -#include <string.h> |
47 | | -#include <wchar.h> |
48 | | -#endif |
49 | | - |
50 | 41 | #ifdef _WINDOWS |
51 | 42 | #include "forbiddenFunctions_windows.hpp" |
52 | 43 | #else |
|
58 | 49 | // or have security concerns, either with preferred alternatives, or to be |
59 | 50 | // avoided entirely. |
60 | 51 |
|
61 | | -FORBID_IMPORTED_NORETURN_C_FUNCTION(void exit(int), "use os::exit") |
62 | | -FORBID_IMPORTED_NORETURN_C_FUNCTION(void _Exit(int), "use os::exit") |
| 52 | +FORBID_IMPORTED_NORETURN_C_FUNCTION(void exit(int), noexcept, "use os::exit") |
| 53 | +FORBID_IMPORTED_NORETURN_C_FUNCTION(void _Exit(int), noexcept, "use os::exit") |
63 | 54 |
|
64 | 55 | // Windows puts _exit in <stdlib.h>, POSIX in <unistd.h>. |
65 | | -FORBID_IMPORTED_NORETURN_C_FUNCTION(void _exit(int), "use os::exit") |
| 56 | +FORBID_IMPORTED_NORETURN_C_FUNCTION(void _exit(int), /* not noexcept */, "use os::exit") |
66 | 57 |
|
67 | | -FORBID_IMPORTED_C_FUNCTION(char* strerror(int), "use os::strerror"); |
68 | | -FORBID_IMPORTED_C_FUNCTION(char* strtok(char*, const char*), "use strtok_r"); |
| 58 | +FORBID_IMPORTED_C_FUNCTION(char* strerror(int), noexcept, "use os::strerror"); |
| 59 | +FORBID_IMPORTED_C_FUNCTION(char* strtok(char*, const char*), noexcept, "use strtok_r"); |
69 | 60 |
|
70 | | -FORBID_C_FUNCTION(int sprintf(char*, const char*, ...), "use os::snprintf"); |
71 | | -FORBID_C_FUNCTION(int snprintf(char*, size_t, const char*, ...), "use os::snprintf"); |
| 61 | +// AIX declarations for sprintf and snprintf are not noexcept, which is |
| 62 | +// inconsistent with most other system header declarations, including being |
| 63 | +// inconsistent with vsprintf and fsnprintf. |
| 64 | +FORBID_C_FUNCTION(int sprintf(char*, const char*, ...), NOT_AIX(noexcept), "use os::snprintf"); |
| 65 | +FORBID_C_FUNCTION(int snprintf(char*, size_t, const char*, ...), NOT_AIX(noexcept), "use os::snprintf"); |
72 | 66 |
|
73 | 67 | PRAGMA_DIAG_PUSH |
74 | 68 | FORBIDDEN_FUNCTION_IGNORE_CLANG_FORTIFY_WARNING |
75 | | -FORBID_C_FUNCTION(int vsprintf(char*, const char*, va_list), "use os::vsnprintf"); |
76 | | -FORBID_C_FUNCTION(int vsnprintf(char*, size_t, const char*, va_list), "use os::vsnprintf"); |
| 69 | +FORBID_C_FUNCTION(int vsprintf(char*, const char*, va_list), noexcept, "use os::vsnprintf"); |
| 70 | +FORBID_C_FUNCTION(int vsnprintf(char*, size_t, const char*, va_list), noexcept, "use os::vsnprintf"); |
77 | 71 | PRAGMA_DIAG_POP |
78 | 72 |
|
79 | 73 | // All of the following functions return raw C-heap pointers (sometimes as an |
80 | 74 | // option, e.g. realpath or getwd) or, in case of free(), take raw C-heap |
81 | 75 | // pointers. We generally want allocation to be done through NMT. |
82 | | -FORBID_IMPORTED_C_FUNCTION(void* malloc(size_t size), "use os::malloc"); |
83 | | -FORBID_IMPORTED_C_FUNCTION(void free(void *ptr), "use os::free"); |
84 | | -FORBID_IMPORTED_C_FUNCTION(void* calloc(size_t nmemb, size_t size), "use os::malloc and zero out manually"); |
85 | | -FORBID_IMPORTED_C_FUNCTION(void* realloc(void *ptr, size_t size), "use os::realloc"); |
86 | | -FORBID_IMPORTED_C_FUNCTION(char* strdup(const char *s), "use os::strdup"); |
87 | | -FORBID_IMPORTED_C_FUNCTION(wchar_t* wcsdup(const wchar_t *s), "don't use"); |
| 76 | +FORBID_IMPORTED_C_FUNCTION(void* malloc(size_t size), noexcept, "use os::malloc"); |
| 77 | +FORBID_IMPORTED_C_FUNCTION(void free(void *ptr), noexcept, "use os::free"); |
| 78 | +FORBID_IMPORTED_C_FUNCTION(void* calloc(size_t nmemb, size_t size), noexcept, "use os::malloc and zero out manually"); |
| 79 | +FORBID_IMPORTED_C_FUNCTION(void* realloc(void *ptr, size_t size), noexcept, "use os::realloc"); |
| 80 | +FORBID_IMPORTED_C_FUNCTION(char* strdup(const char *s), noexcept, "use os::strdup"); |
| 81 | +FORBID_IMPORTED_C_FUNCTION(wchar_t* wcsdup(const wchar_t *s), noexcept, "don't use"); |
88 | 82 |
|
89 | 83 | #endif // SHARE_UTILITIES_FORBIDDENFUNCTIONS_HPP |
0 commit comments