]>
Commit | Line | Data |
---|---|---|
224c7076 | 1 | /* |
1f2f436a | 2 | * Copyright (c) 2007, 2010 Apple Inc. All rights reserved. |
224c7076 A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | #ifndef _STDIO_H_ | |
25 | #error error "Never use <secure/_stdio.h> directly; include <stdio.h> instead." | |
26 | #endif | |
27 | ||
28 | #ifndef _SECURE__STDIO_H_ | |
29 | #define _SECURE__STDIO_H_ | |
30 | ||
31 | #include <secure/_common.h> | |
32 | ||
33 | #if _USE_FORTIFY_LEVEL > 0 | |
34 | ||
6465356a A |
35 | #ifndef __has_builtin |
36 | #define _undef__has_builtin | |
37 | #define __has_builtin(x) 0 | |
1f2f436a | 38 | #endif |
224c7076 | 39 | |
507116e3 | 40 | #ifndef UNIFDEF_DRIVERKIT |
224c7076 | 41 | /* sprintf, vsprintf, snprintf, vsnprintf */ |
6465356a | 42 | #if __has_builtin(__builtin___sprintf_chk) || defined(__GNUC__) |
224c7076 | 43 | extern int __sprintf_chk (char * __restrict, int, size_t, |
ad3c9f2a | 44 | const char * __restrict, ...); |
224c7076 | 45 | |
6465356a | 46 | #undef sprintf |
224c7076 A |
47 | #define sprintf(str, ...) \ |
48 | __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__) | |
6465356a | 49 | #endif |
507116e3 | 50 | #endif /* UNIFDEF_DRIVERKIT */ |
224c7076 | 51 | |
6465356a A |
52 | #if __DARWIN_C_LEVEL >= 200112L |
53 | #if __has_builtin(__builtin___snprintf_chk) || defined(__GNUC__) | |
224c7076 | 54 | extern int __snprintf_chk (char * __restrict, size_t, int, size_t, |
ad3c9f2a | 55 | const char * __restrict, ...); |
224c7076 | 56 | |
6465356a | 57 | #undef snprintf |
224c7076 A |
58 | #define snprintf(str, len, ...) \ |
59 | __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__) | |
6465356a | 60 | #endif |
224c7076 | 61 | |
507116e3 | 62 | #ifndef UNIFDEF_DRIVERKIT |
6465356a | 63 | #if __has_builtin(__builtin___vsprintf_chk) || defined(__GNUC__) |
224c7076 | 64 | extern int __vsprintf_chk (char * __restrict, int, size_t, |
ad3c9f2a | 65 | const char * __restrict, va_list); |
224c7076 | 66 | |
6465356a | 67 | #undef vsprintf |
224c7076 A |
68 | #define vsprintf(str, format, ap) \ |
69 | __builtin___vsprintf_chk (str, 0, __darwin_obsz(str), format, ap) | |
6465356a | 70 | #endif |
507116e3 | 71 | #endif /* UNIFDEF_DRIVERKIT */ |
224c7076 | 72 | |
6465356a | 73 | #if __has_builtin(__builtin___vsnprintf_chk) || defined(__GNUC__) |
224c7076 | 74 | extern int __vsnprintf_chk (char * __restrict, size_t, int, size_t, |
ad3c9f2a | 75 | const char * __restrict, va_list); |
224c7076 | 76 | |
6465356a | 77 | #undef vsnprintf |
224c7076 A |
78 | #define vsnprintf(str, len, format, ap) \ |
79 | __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap) | |
1f2f436a | 80 | #endif |
224c7076 | 81 | |
6465356a | 82 | #endif /* __DARWIN_C_LEVEL >= 200112L */ |
224c7076 | 83 | |
6465356a A |
84 | #ifdef _undef__has_builtin |
85 | #undef _undef__has_builtin | |
86 | #undef __has_builtin | |
224c7076 | 87 | #endif |
6465356a A |
88 | |
89 | #endif /* _USE_FORTIFY_LEVEL > 0 */ | |
90 | #endif /* _SECURE__STDIO_H_ */ |