diff options
| author | sin | 2015-01-28 16:07:24 +0000 |
|---|---|---|
| committer | sin | 2015-01-28 16:07:24 +0000 |
| commit | de7999ee82b87ef262d0601a40169775b8e94285 (patch) | |
| tree | 084b9d0f1922840242e7b0281a27d1a6aada4f0a /include/string.h | |
| parent | 6bb34c15b4d7989c5785577fbee72fdffa198d1f (diff) | |
Move defines to the bottom
This allows us to re-use the functions internally.
Diffstat (limited to 'include/string.h')
| -rw-r--r-- | include/string.h | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/include/string.h b/include/string.h index 7e6873e..e24f63e 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -17,9 +17,6 @@ void *__fortify_memcpy(void *__restrict dest, const void *__restrict src, size_t | |||
| 17 | return memcpy(dest, src, n); | 17 | return memcpy(dest, src, n); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | #undef memcpy | ||
| 21 | #define memcpy(dest, src, n) __fortify_memcpy(dest, src, n) | ||
| 22 | |||
| 23 | static inline __attribute__ ((always_inline)) | 20 | static inline __attribute__ ((always_inline)) |
| 24 | void *__fortify_memmove(void *__restrict dest, const void *__restrict src, size_t n) | 21 | void *__fortify_memmove(void *__restrict dest, const void *__restrict src, size_t n) |
| 25 | { | 22 | { |
| @@ -32,9 +29,6 @@ void *__fortify_memmove(void *__restrict dest, const void *__restrict src, size_ | |||
| 32 | return memmove(dest, src, n); | 29 | return memmove(dest, src, n); |
| 33 | } | 30 | } |
| 34 | 31 | ||
| 35 | #undef memmove | ||
| 36 | #define memmove(dest, src, n) __fortify_memmove(dest, src, n) | ||
| 37 | |||
| 38 | static inline __attribute__ ((always_inline)) | 32 | static inline __attribute__ ((always_inline)) |
| 39 | void *__fortify_memset(void *dest, int c, size_t n) | 33 | void *__fortify_memset(void *dest, int c, size_t n) |
| 40 | { | 34 | { |
| @@ -47,9 +41,6 @@ void *__fortify_memset(void *dest, int c, size_t n) | |||
| 47 | return memset(dest, c, n); | 41 | return memset(dest, c, n); |
| 48 | } | 42 | } |
| 49 | 43 | ||
| 50 | #undef memset | ||
| 51 | #define memset(dest, src, n) __fortify_memset(dest, src, n) | ||
| 52 | |||
| 53 | static inline __attribute__ ((always_inline)) | 44 | static inline __attribute__ ((always_inline)) |
| 54 | char *__fortify_strcat(char *__restrict dest, const char *__restrict src) | 45 | char *__fortify_strcat(char *__restrict dest, const char *__restrict src) |
| 55 | { | 46 | { |
| @@ -62,9 +53,6 @@ char *__fortify_strcat(char *__restrict dest, const char *__restrict src) | |||
| 62 | return strcat(dest, src); | 53 | return strcat(dest, src); |
| 63 | } | 54 | } |
| 64 | 55 | ||
| 65 | #undef strcat | ||
| 66 | #define strcat(dest, src) __fortify_strcat(dest, src) | ||
| 67 | |||
| 68 | static inline __attribute__ ((always_inline)) | 56 | static inline __attribute__ ((always_inline)) |
| 69 | char *__fortify_strcpy(char *__restrict dest, const char *__restrict src) | 57 | char *__fortify_strcpy(char *__restrict dest, const char *__restrict src) |
| 70 | { | 58 | { |
| @@ -77,9 +65,6 @@ char *__fortify_strcpy(char *__restrict dest, const char *__restrict src) | |||
| 77 | return strcpy(dest, src); | 65 | return strcpy(dest, src); |
| 78 | } | 66 | } |
| 79 | 67 | ||
| 80 | #undef strcpy | ||
| 81 | #define strcpy(dest, src) __fortify_strcpy(dest, src) | ||
| 82 | |||
| 83 | static inline __attribute__ ((always_inline)) | 68 | static inline __attribute__ ((always_inline)) |
| 84 | char *__fortify_strncat(char *__restrict dest, const char *__restrict src, size_t n) | 69 | char *__fortify_strncat(char *__restrict dest, const char *__restrict src, size_t n) |
| 85 | { | 70 | { |
| @@ -99,9 +84,6 @@ char *__fortify_strncat(char *__restrict dest, const char *__restrict src, size_ | |||
| 99 | return strncat(dest, src, n); | 84 | return strncat(dest, src, n); |
| 100 | } | 85 | } |
| 101 | 86 | ||
| 102 | #undef strncat | ||
| 103 | #define strncat(dest, src, n) __fortify_strcat(dest, src, n) | ||
| 104 | |||
| 105 | static inline __attribute__ ((always_inline)) | 87 | static inline __attribute__ ((always_inline)) |
| 106 | char *__fortify_strncpy(char *__restrict dest, const char *__restrict src, size_t n) | 88 | char *__fortify_strncpy(char *__restrict dest, const char *__restrict src, size_t n) |
| 107 | { | 89 | { |
| @@ -114,9 +96,6 @@ char *__fortify_strncpy(char *__restrict dest, const char *__restrict src, size_ | |||
| 114 | return strncpy(dest, src, n); | 96 | return strncpy(dest, src, n); |
| 115 | } | 97 | } |
| 116 | 98 | ||
| 117 | #undef strncpy | ||
| 118 | #define strncpy(dest, src, n) __fortify_strcpy(dest, src, n) | ||
| 119 | |||
| 120 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | 99 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) |
| 121 | static inline __attribute__ ((always_inline)) | 100 | static inline __attribute__ ((always_inline)) |
| 122 | size_t __fortify_strlcat(char *__restrict dest, const char *__restrict src, size_t n) | 101 | size_t __fortify_strlcat(char *__restrict dest, const char *__restrict src, size_t n) |
| @@ -130,9 +109,6 @@ size_t __fortify_strlcat(char *__restrict dest, const char *__restrict src, size | |||
| 130 | return strlcat(dest, src, n); | 109 | return strlcat(dest, src, n); |
| 131 | } | 110 | } |
| 132 | 111 | ||
| 133 | #undef strlcat | ||
| 134 | #define strlcat(dest, src, n) __fortify_strlcat(dest, src, n) | ||
| 135 | |||
| 136 | static inline __attribute__ ((always_inline)) | 112 | static inline __attribute__ ((always_inline)) |
| 137 | size_t __fortify_strlcpy(char *__restrict dest, const char *__restrict src, size_t n) | 113 | size_t __fortify_strlcpy(char *__restrict dest, const char *__restrict src, size_t n) |
| 138 | { | 114 | { |
| @@ -144,10 +120,30 @@ size_t __fortify_strlcpy(char *__restrict dest, const char *__restrict src, size | |||
| 144 | __builtin_trap(); | 120 | __builtin_trap(); |
| 145 | return strlcpy(dest, src, n); | 121 | return strlcpy(dest, src, n); |
| 146 | } | 122 | } |
| 123 | #endif | ||
| 124 | |||
| 125 | #undef memcpy | ||
| 126 | #define memcpy(dest, src, n) __fortify_memcpy(dest, src, n) | ||
| 127 | #undef memmove | ||
| 128 | #define memmove(dest, src, n) __fortify_memmove(dest, src, n) | ||
| 129 | #undef memset | ||
| 130 | #define memset(dest, src, n) __fortify_memset(dest, src, n) | ||
| 131 | #undef strcat | ||
| 132 | #define strcat(dest, src) __fortify_strcat(dest, src) | ||
| 133 | #undef strcpy | ||
| 134 | #define strcpy(dest, src) __fortify_strcpy(dest, src) | ||
| 135 | #undef strncat | ||
| 136 | #define strncat(dest, src, n) __fortify_strcat(dest, src, n) | ||
| 137 | #undef strncpy | ||
| 138 | #define strncpy(dest, src, n) __fortify_strcpy(dest, src, n) | ||
| 147 | 139 | ||
| 140 | #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) | ||
| 141 | #undef strlcat | ||
| 142 | #define strlcat(dest, src, n) __fortify_strlcat(dest, src, n) | ||
| 148 | #undef strlcpy | 143 | #undef strlcpy |
| 149 | #define strlcpy(dest, src, n) __fortify_strlcpy(dest, src, n) | 144 | #define strlcpy(dest, src, n) __fortify_strlcpy(dest, src, n) |
| 150 | #endif | 145 | #endif |
| 146 | |||
| 151 | #endif | 147 | #endif |
| 152 | 148 | ||
| 153 | #endif | 149 | #endif |
