diff options
| author | jvoisin | 2023-10-01 22:00:21 +0200 |
|---|---|---|
| committer | jvoisin | 2023-10-01 22:00:21 +0200 |
| commit | 6a801d8a749da3889ec57030cee09d1d60b4663e (patch) | |
| tree | edad6a0f885992d3c6214e9b44a6526936876ee2 /include/stdio.h | |
| parent | 76fef96b2b29fc90cdfea3e595ab98d267c6b965 (diff) | |
Add `fprintf`
Diffstat (limited to 'include/stdio.h')
| -rw-r--r-- | include/stdio.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/include/stdio.h b/include/stdio.h index 9415f83..3bbee38 100644 --- a/include/stdio.h +++ b/include/stdio.h | |||
| @@ -36,8 +36,6 @@ extern "C" { | |||
| 36 | #undef fread | 36 | #undef fread |
| 37 | #undef fwrite | 37 | #undef fwrite |
| 38 | #undef popen | 38 | #undef popen |
| 39 | #undef printf | ||
| 40 | #undef vprintf | ||
| 41 | #undef vsnprintf | 39 | #undef vsnprintf |
| 42 | #undef vsprintf | 40 | #undef vsprintf |
| 43 | 41 | ||
| @@ -185,6 +183,7 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f, | |||
| 185 | } | 183 | } |
| 186 | 184 | ||
| 187 | #ifndef __clang__ /* FIXME */ | 185 | #ifndef __clang__ /* FIXME */ |
| 186 | #undef vprintf | ||
| 188 | __access(read_only, 1) | 187 | __access(read_only, 1) |
| 189 | __format(printf, 1, 0) | 188 | __format(printf, 1, 0) |
| 190 | #if __has_builtin(__builtin_vprintf) | 189 | #if __has_builtin(__builtin_vprintf) |
| @@ -198,7 +197,7 @@ _FORTIFY_FN(vprintf) int vprintf(const char *__f, __builtin_va_list __v) | |||
| 198 | return __orig_vprintf(__f, __v); | 197 | return __orig_vprintf(__f, __v); |
| 199 | #endif | 198 | #endif |
| 200 | } | 199 | } |
| 201 | #endif | 200 | #endif // __clang__ |
| 202 | 201 | ||
| 203 | 202 | ||
| 204 | #if __has_builtin(__builtin_va_arg_pack) | 203 | #if __has_builtin(__builtin_va_arg_pack) |
| @@ -219,6 +218,8 @@ _FORTIFY_FN(vprintf) int vprintf(const char *__f, __builtin_va_list __v) | |||
| 219 | 218 | ||
| 220 | #undef snprintf | 219 | #undef snprintf |
| 221 | #undef sprintf | 220 | #undef sprintf |
| 221 | #undef printf | ||
| 222 | #undef fprintf | ||
| 222 | 223 | ||
| 223 | __access(read_write, 1, 2) | 224 | __access(read_write, 1, 2) |
| 224 | __access(read_only, 3) | 225 | __access(read_only, 3) |
| @@ -270,6 +271,20 @@ _FORTIFY_FN(printf) int printf(const char *__f, ...) | |||
| 270 | #endif | 271 | #endif |
| 271 | } | 272 | } |
| 272 | 273 | ||
| 274 | __access(read_only, 2) | ||
| 275 | __format(printf, 2, 0) | ||
| 276 | #if __has_builtin(__builtin_fprintf) | ||
| 277 | __diagnose_as_builtin(__builtin_fprintf, 2, 3) | ||
| 278 | #endif | ||
| 279 | _FORTIFY_FN(fprintf) int fprintf(FILE *__s, const char *__f, ...) | ||
| 280 | { | ||
| 281 | #if __has_builtin(__builtin___fprintf_chk) && USE_NATIVE_CHK | ||
| 282 | return __builtin___fprintf_chk(_FORTIFY_SOURCE, __s, __f, __builtin_va_arg_pack()); | ||
| 283 | #else | ||
| 284 | return __orig_fprintf(__s, __f, __builtin_va_arg_pack()); | ||
| 285 | #endif | ||
| 286 | } | ||
| 287 | |||
| 273 | #endif /* __has_builtin(__builtin_va_arg_pack) */ | 288 | #endif /* __has_builtin(__builtin_va_arg_pack) */ |
| 274 | 289 | ||
| 275 | #ifdef __cplusplus | 290 | #ifdef __cplusplus |
