Add header guards (#295)
* Add header guards. * Also add guarding to make sure this is not included in C++ compilation. If it is C++, still want to make sure the unchecked version of the header is included.
This commit is contained in:
Родитель
8ec52a19da
Коммит
98eca60d11
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __FENV_CHECKED_H
|
||||||
|
#define __FENV_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
int fesetexceptflag(const fexcept_t *flagp : itype(_Ptr<const fexcept_t>),
|
int fesetexceptflag(const fexcept_t *flagp : itype(_Ptr<const fexcept_t>),
|
||||||
|
@ -18,3 +22,6 @@ int fesetenv(const fenv_t *envp : itype(_Ptr<const fenv_t>));
|
||||||
int feupdateenv(const fenv_t *envp : itype(_Ptr<const fenv_t>));
|
int feupdateenv(const fenv_t *envp : itype(_Ptr<const fenv_t>));
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -9,6 +9,10 @@
|
||||||
#include <stddef.h> // define wchar_t for wcstoimax and wcstoumax
|
#include <stddef.h> // define wchar_t for wcstoimax and wcstoumax
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __INTTYPES_CHECKED_H
|
||||||
|
#define __INTTYPES_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
_Unchecked
|
_Unchecked
|
||||||
|
@ -39,3 +43,6 @@ uintmax_t wcstoumax(const wchar_t * restrict nptr :
|
||||||
int base);
|
int base);
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
|
#endif // no c++
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __MATH_CHECKED_H
|
||||||
|
#define __MATH_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
double frexp(double value, int *exp : itype(_Ptr<int>));
|
double frexp(double value, int *exp : itype(_Ptr<int>));
|
||||||
|
@ -28,3 +32,6 @@ float nanf(const char *t : itype(_Nt_array_ptr<const char>));
|
||||||
long double nanl(const char *t : itype(_Nt_array_ptr<const char>));
|
long double nanl(const char *t : itype(_Nt_array_ptr<const char>));
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif //guard
|
||||||
|
#endif // no c++
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __SIGNAL_CHECKED_H
|
||||||
|
#define __SIGNAL_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
_Unchecked
|
_Unchecked
|
||||||
|
@ -15,3 +19,6 @@ void (*signal(int sig,
|
||||||
)(int);
|
)(int);
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __STDIO_CHECKED_H
|
||||||
|
#define __STDIO_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
@ -183,3 +187,6 @@ void perror(const char *s : itype(_Nt_array_ptr<const char>));
|
||||||
#include "_builtin_stdio_checked.h"
|
#include "_builtin_stdio_checked.h"
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
|
#endif // no C++
|
||||||
|
|
|
@ -5,8 +5,15 @@
|
||||||
// These are listed in the same order that they occur in the C11 //
|
// These are listed in the same order that they occur in the C11 //
|
||||||
// specification. //
|
// specification. //
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __STDLIB_CHECKED_H
|
||||||
|
#define __STDLIB_CHECKED_H
|
||||||
|
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
double atof(const char *s : itype(_Nt_array_ptr<const char>));
|
double atof(const char *s : itype(_Nt_array_ptr<const char>));
|
||||||
|
@ -113,3 +120,6 @@ size_t wcstombs(char * restrict output : count(n),
|
||||||
size_t n);
|
size_t n);
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
|
#endif // no c++
|
||||||
|
|
|
@ -11,8 +11,14 @@
|
||||||
// TODO: Better Support for _FORTIFY_SOURCE > 0 //
|
// TODO: Better Support for _FORTIFY_SOURCE > 0 //
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
|
#ifndef __STRING_CHECKED_H
|
||||||
|
#define __STRING_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
// GCC has macros that it uses as part of its string implementation to optimize cases
|
// GCC has macros that it uses as part of its string implementation to optimize cases
|
||||||
|
@ -153,3 +159,6 @@ size_t strlen(const char *s : itype(_Nt_array_ptr<const char>));
|
||||||
#include "_builtin_string_checked.h"
|
#include "_builtin_string_checked.h"
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
|
#endif // no C++
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
// specification. //
|
// specification. //
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _CHECKEDC_MOCKUP_THREADS
|
#ifdef _CHECKEDC_MOCKUP_THREADS
|
||||||
// C implementations may not support the C11 threads package or even the
|
// C implementations may not support the C11 threads package or even the
|
||||||
// macro that says C11 threads are not supported. This mocks up
|
// macro that says C11 threads are not supported. This mocks up
|
||||||
|
@ -23,6 +25,10 @@ struct timespec;
|
||||||
#include <threads.h>
|
#include <threads.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __THREADS_CHECKED_H
|
||||||
|
#define __THREADS_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
void call_once(once_flag *flag : itype(_Ptr<once_flag>),
|
void call_once(once_flag *flag : itype(_Ptr<once_flag>),
|
||||||
|
@ -64,3 +70,6 @@ void *tss_get(tss_t key) : itype(_Ptr<void>);
|
||||||
int tss_set(tss_t key, void *value : itype(_Ptr<void>));
|
int tss_set(tss_t key, void *value : itype(_Ptr<void>));
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
|
#endif // no C++
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __TIME_CHECKED_H
|
||||||
|
#define __TIME_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
time_t mktime(struct tm *timeptr : itype(_Ptr<struct tm>));
|
time_t mktime(struct tm *timeptr : itype(_Ptr<struct tm>));
|
||||||
|
@ -34,3 +38,6 @@ size_t strftime(char * restrict output : count(maxsize),
|
||||||
itype(restrict _Ptr<const struct tm>));
|
itype(restrict _Ptr<const struct tm>));
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
|
@ -7,6 +7,10 @@
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#ifndef __UNISTD_CHECKED_H
|
||||||
|
#define __UNISTD_CHECKED_H
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE ON
|
#pragma CHECKED_SCOPE ON
|
||||||
|
|
||||||
#if _POSIX_VERSION >= 200112L
|
#if _POSIX_VERSION >= 200112L
|
||||||
|
@ -16,3 +20,6 @@ extern char ** environ : itype(_Nt_array_ptr<_Nt_array_ptr<char>>);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma CHECKED_SCOPE OFF
|
#pragma CHECKED_SCOPE OFF
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче