From c72a4e5dd7aa33fc04c0c2fb4bf6564f179966aa Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 31 Aug 2015 22:36:29 +0200 Subject: add _LIBRARY_HEADER MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/alloca.h | 3 ++- include/assert.h | 4 +--- include/bits/types.h | 2 +- include/ctype.h | 4 +--- include/err.h | 4 ++-- include/errno.h | 4 ++-- include/error.h | 4 ++-- include/iso646.h | 1 + include/malloc.h | 10 ++++------ include/obstack.h | 4 +--- include/slibc-alloc.h | 3 ++- include/slibc-error.h | 4 ++-- include/slibc/features.h | 8 ++++++++ include/stdalign.h | 2 -- include/stdarg.h | 1 + include/stdbool.h | 1 + include/stddef.h | 1 + include/stdint.h | 3 ++- include/stdlib.h | 2 +- include/stdnoreturn.h | 2 -- include/string.h | 18 ++++++++---------- include/strings.h | 4 +--- include/unistd.h | 2 -- include/wchar.h | 20 +++++++++----------- 24 files changed, 53 insertions(+), 58 deletions(-) (limited to 'include') diff --git a/include/alloca.h b/include/alloca.h index 3ef962b..68e50bf 100644 --- a/include/alloca.h +++ b/include/alloca.h @@ -17,8 +17,9 @@ */ #ifndef _ALLOCA_H #define _ALLOCA_H -#ifndef _PORTABLE_SOURCE #include +#include +#ifndef __PORTABLE diff --git a/include/assert.h b/include/assert.h index 1e351bd..6315ae1 100644 --- a/include/assert.h +++ b/include/assert.h @@ -18,8 +18,6 @@ #ifndef _ASSERT_H #define _ASSERT_H #include - - #include @@ -58,7 +56,7 @@ #define static_assert _Static_assert -#ifndef _PORTABLE_SOURCE +#ifndef __PORTABLE /** * Unless `NDEBUG` is defined, print an error message * and abort the process, if `errnum` is non-zero. diff --git a/include/bits/types.h b/include/bits/types.h index 58c6064..e594e44 100644 --- a/include/bits/types.h +++ b/include/bits/types.h @@ -54,7 +54,7 @@ typedef unsigned long int uptrdiff_t; #endif -#ifndef _PORTABLE_SOURCE +#ifndef __PORTABLE /** * Integer type which can represent any character. * May not be greater than the with of type long. diff --git a/include/ctype.h b/include/ctype.h index 9d4addc..f01ad57 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -18,6 +18,7 @@ #ifndef _CTYPE_H #define _CTYPE_H #include +#include #ifndef _SLIBC_SUPPRESS_WARNINGS # warning "Functions in , 'isascii' and 'toascii', only support ASCII." @@ -25,9 +26,6 @@ #endif -#include - - /** * Check whether a character is an alphabetical diff --git a/include/err.h b/include/err.h index 9c28533..6e9b828 100644 --- a/include/err.h +++ b/include/err.h @@ -17,15 +17,15 @@ */ #ifndef _ERR_H #define _ERR_H -#ifndef _PORTABLE_SOURCE #include +#include +#ifndef __PORTABLE #ifndef _SLIBC_SUPPRESS_WARNINGS # warning "Please consider not using ." #endif -#include #include diff --git a/include/errno.h b/include/errno.h index a1cc191..9344a8a 100644 --- a/include/errno.h +++ b/include/errno.h @@ -18,9 +18,9 @@ #ifndef _ERRNO_H #define _ERRNO_H #include +#include -#include /* TODO include error definitions */ @@ -41,7 +41,7 @@ volatile int* __errno(void) __GCC_ONLY(__attribute__((const))); /* TODO not implemented */ -#ifndef _PORTABLE_SOURCE +#ifndef __PORTABLE /** * This is the name that was used to invoke the program * running in the current process. This is the value diff --git a/include/error.h b/include/error.h index 36cdacc..f38ee44 100644 --- a/include/error.h +++ b/include/error.h @@ -17,8 +17,9 @@ */ #ifndef _ERROR_H #define _ERROR_H -#ifndef _PORTABLE_SOURCE #include +#include +#ifndef __PORTABLE #ifndef _SLIBC_SUPPRESS_WARNINGS # warning "Please consider not using ." @@ -26,7 +27,6 @@ #include -#include diff --git a/include/iso646.h b/include/iso646.h index 557b0a8..c0c7a51 100644 --- a/include/iso646.h +++ b/include/iso646.h @@ -18,6 +18,7 @@ #ifndef _ISO646_H #define _ISO646_H #include +#include #ifndef _SLIBC_SUPPRESS_WARNINGS # warning "Please consider not using , is really not good for readability." diff --git a/include/malloc.h b/include/malloc.h index ab8e0a9..56a6174 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -18,8 +18,6 @@ #ifndef _MALLOC_H #define _MALLOC_H #include - - #include @@ -112,13 +110,13 @@ void free(void*) * beginning of a memory allocation on the heap. * However, if it is `NULL`, nothing will happen. */ -#ifndef _PORTABLE_SOURCE +#ifndef __PORTABLE void cfree(void*, ...) __deprecated("'cfree' is deprecated and not portable, use 'free' instead."); #endif -#ifndef _PORTABLE_SOURCE +#ifndef __PORTABLE /** * Variant of `malloc` that returns an address with a * specified alignment. @@ -169,7 +167,7 @@ void* memalign(size_t, size_t) int posix_memalign(void**, size_t, size_t) __GCC_ONLY(__attribute__((nonnull))); -#ifndef _PORTABLE_SOURCE +#ifndef __PORTABLE /** * `valloc(n)` is equivalent to `memalign(sysconf(_SC_PAGESIZE), n)`. * @@ -241,7 +239,7 @@ void* aligned_alloc(size_t, size_t) #endif -#if defined(_GNU_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_GNU_SOURCE) && !defined(__PORTABLE) /** * This function returns the allocation size of * a memory segment. diff --git a/include/obstack.h b/include/obstack.h index 947e991..da1acc3 100644 --- a/include/obstack.h +++ b/include/obstack.h @@ -17,11 +17,9 @@ */ #ifndef _OBSTACK_H #define _OBSTACK_H -#ifndef _PORTABLE_SOURCE #include - - #include +#ifndef __PORTABLE diff --git a/include/slibc-alloc.h b/include/slibc-alloc.h index b230f16..d792ebc 100644 --- a/include/slibc-alloc.h +++ b/include/slibc-alloc.h @@ -17,8 +17,9 @@ */ #ifndef _SLIBC_ALLOC_H #define _SLIBC_ALLOC_H -#ifndef _PORTABLE_SOURCE #include +#include +#ifndef __PORTABLE diff --git a/include/slibc-error.h b/include/slibc-error.h index 6232aab..086ad31 100644 --- a/include/slibc-error.h +++ b/include/slibc-error.h @@ -17,11 +17,11 @@ */ #ifndef _SLIBC_ERROR_H #define _SLIBC_ERROR_H -#ifndef _PORTABLE_SOURCE #include +#include +#ifndef __PORTABLE -#include #include #include diff --git a/include/slibc/features.h b/include/slibc/features.h index ba91975..7363215 100644 --- a/include/slibc/features.h +++ b/include/slibc/features.h @@ -22,6 +22,14 @@ /* These definitions are only to be used in slibc header-files. */ +/** + * Macro that is defined if portability shall be ensured. + */ +#if defined(_PORTABLE_SOURCE) || defined(_LIBRARY_HEADER) +# define __PORTABLE +#endif + + /** * Is C11, or newer, used? */ diff --git a/include/stdalign.h b/include/stdalign.h index b247b2c..905b963 100644 --- a/include/stdalign.h +++ b/include/stdalign.h @@ -18,8 +18,6 @@ #ifndef _STDALIGN_H #define _STDALIGN_H #include - - #include diff --git a/include/stdarg.h b/include/stdarg.h index 577f26a..84bc840 100644 --- a/include/stdarg.h +++ b/include/stdarg.h @@ -18,6 +18,7 @@ #ifndef _STDARG_H #define _STDARG_H #include +#include #include diff --git a/include/stdbool.h b/include/stdbool.h index 3025899..794be99 100644 --- a/include/stdbool.h +++ b/include/stdbool.h @@ -18,6 +18,7 @@ #ifndef _STDBOOL_H #define _STDBOOL_H #include +#include diff --git a/include/stddef.h b/include/stddef.h index 0e10989..26286f5 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -18,6 +18,7 @@ #ifndef _STDDEF_H #define _STDDEF_H #include +#include diff --git a/include/stdint.h b/include/stdint.h index a8cb426..d9e0dcd 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -18,6 +18,7 @@ #ifndef _STDINT_H #define _STDINT_H #include +#include @@ -376,7 +377,7 @@ #define SSIZE_MIN INTPTR_MIN -#ifndef _PORTABLE_SOURCE +#ifndef __PORTABLE /** * Maximum value of `wchar_t`. */ diff --git a/include/stdlib.h b/include/stdlib.h index 5ac4e7c..3151947 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -18,9 +18,9 @@ #ifndef _STDLIB_H #define _STDLIB_H #include +#include -#include #include diff --git a/include/stdnoreturn.h b/include/stdnoreturn.h index 19c6016..3260cf2 100644 --- a/include/stdnoreturn.h +++ b/include/stdnoreturn.h @@ -18,8 +18,6 @@ #ifndef _STDNORETURN_H #define _STDNORETURN_H #include - - #include diff --git a/include/string.h b/include/string.h index 09bdc5e..5891dbb 100644 --- a/include/string.h +++ b/include/string.h @@ -18,8 +18,6 @@ #ifndef _STRING_H #define _STRING_H #include - - #include @@ -73,7 +71,7 @@ char* strerror_l(int, locale_t) __GCC_ONLY(__attribute__((warn_unused_result))); -#if !defined(_PORTABLE_SOURCE) && !defined(_SLIBC_SOURCE) +#if !defined(__PORTABLE) && !defined(_SLIBC_SOURCE) /** * Reenterant variant of `strerror`. * @@ -131,7 +129,7 @@ size_t strlen(const char*) #if (defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || \ defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || \ - defined(_BSD_SOURCE)) && !defined(_PORTABLE_SOURCE) + defined(_BSD_SOURCE)) && !defined(__PORTABLE) /** * Variant of `strlen` that only inspects the * beginning of s string. @@ -167,7 +165,7 @@ void* memset(void*, int, size_t); */ void* memcpy(void* restrict, const void* restrict, size_t); -#if defined(_GNU_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_GNU_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment. * @@ -222,7 +220,7 @@ void* mempmove(void*, const void*, size_t); */ void* memccpy(void* restrict, const void* restrict, int, size_t); -#if defined(_SLIBC_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, possibly overlapping, segment, * but stop if a specific byte is encountered. @@ -264,7 +262,7 @@ char* strcpy(char* restrict, const char* restrict) char* stpcpy(char* restrict, const char* restrict) __GCC_ONLY(__attribute__((returns_nonnull, nonnull))); -#if defined(_SLIBC_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment, * stop when a NUL byte or a specified byte is encountered. @@ -321,7 +319,7 @@ char* strstrcpy(char* restrict, const char* restrict, const char* restrict) char* strncpy(char* restrict, const char* restrict, size_t) __GCC_ONLY(__attribute__((returns_nonnull, nonnull))); -#if defined(_GNU_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_GNU_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment, * stop when a NUL byte is encountered. @@ -397,7 +395,7 @@ char* strstrncpy(char* restrict, const char* restrict, const char* restrict, siz # endif #endif -#if defined(_SLIBC_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, possibly overlapping, segment, * stop when a NUL byte is encountered. @@ -604,7 +602,7 @@ char* strncat(char* restrict, const char* restrict, size_t) char* strdup(const char*) __GCC_ONLY(__attribute__((malloc, nonnull, warn_unused_result))); -#if !defined(_PORTABLE_SOURCE) +#if !defined(__PORTABLE) # if defined(_GNU_SOURCE) /** * Duplicate a string. diff --git a/include/strings.h b/include/strings.h index 505e8ec..0a4bc5e 100644 --- a/include/strings.h +++ b/include/strings.h @@ -18,8 +18,6 @@ #ifndef _STRINGS_H #define _STRINGS_H #include - - #include @@ -39,7 +37,7 @@ void bzero(void*, size_t) __deprecated("Use 'memset', 'explicit_bzero' or 'secure_free' instead."); -#if !defined(_PORTABLE_SOURCE) && (defined(_SLIBC_SOURCE) || defined(_BSD_SOURCE)) +#if !defined(__PORTABLE) && (defined(_SLIBC_SOURCE) || defined(_BSD_SOURCE)) /** * Override a memory segment with zeroes. * diff --git a/include/unistd.h b/include/unistd.h index cbc6b2d..b2831f5 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -18,8 +18,6 @@ #ifndef _UNISTD_H #define _UNISTD_H #include - - #include diff --git a/include/wchar.h b/include/wchar.h index d00056e..34c066e 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -17,11 +17,9 @@ */ #ifndef _WCHAR_H #define _WCHAR_H -#ifndef _PORTABLE_SOURCE /* `wchar_t` is not portable. */ #include - - #include +#ifndef __PORTABLE /* `wchar_t` is not portable. */ @@ -43,7 +41,7 @@ size_t wcslen(const wchar_t*) #if (defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) || \ defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || \ - defined(_BSD_SOURCE)) && !defined(_PORTABLE_SOURCE) + defined(_BSD_SOURCE)) && !defined(__PORTABLE) /** * `wchar_t` version of `strnlen`. * @@ -79,7 +77,7 @@ wchar_t* wmemset(wchar_t*, wchar_t, size_t); */ wchar_t* wmemcpy(wchar_t* restrict, const wchar_t* restrict, size_t); -#if defined(_GNU_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_GNU_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment. * @@ -120,7 +118,7 @@ wchar_t* wmempmove(wchar_t*, const wchar_t*, size_t); # endif #endif -#if defined(_SLIBC_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment, * but stop if a specific character is encountered. @@ -169,7 +167,7 @@ wchar_t* wmemcmove(wchar_t*, const wchar_t*, wchar_t, size_t); wchar_t* wcscpy(wchar_t* restrict, const wchar_t* restrict) __GCC_ONLY(__attribute__((returns_nonnull, nonnull))); -#if (defined(_SLIBC_SOURCE) || defined(_GNU_SOURCE)) && !defined(_PORTABLE_SOURCE) +#if (defined(_SLIBC_SOURCE) || defined(_GNU_SOURCE)) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment, * stop when a NUL wide character is encountered. @@ -184,7 +182,7 @@ wchar_t* wcpcpy(wchar_t* restrict, const wchar_t* restrict) __GCC_ONLY(__attribute__((returns_nonnull, nonnull))); #endif -#if defined(_SLIBC_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment, * stop when a NUL wide character or a specified wide character @@ -242,7 +240,7 @@ wchar_t* wcswcscpy(wchar_t* restrict, const wchar_t* restrict, const wchar_t* re wchar_t* wcsncpy(wchar_t* restrict, const wchar_t* restrict, size_t) __GCC_ONLY(__attribute__((returns_nonnull, nonnull))); -#if defined(_GNU_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_GNU_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, non-overlapping, segment, * stop when a NUL wide character is encountered. @@ -319,7 +317,7 @@ wchar_t* wcswcsncpy(wchar_t* restrict, const wchar_t* restrict, const wchar_t* r # endif #endif -#if defined(_SLIBC_SOURCE) && !defined(_PORTABLE_SOURCE) +#if defined(_SLIBC_SOURCE) && !defined(__PORTABLE) /** * Copy a memory segment to another, possibly overlapping, segment, * stop when a NUL wide character is encountered. @@ -516,7 +514,7 @@ wchar_t* wcsncat(wchar_t* restrict whither, const wchar_t* restrict whence, size /* wcpncat does not exsits because use of it would be very inefficient. */ -#if !defined(_PORTABLE_SOURCE) +#if !defined(__PORTABLE) /** * Duplicate a string. * -- cgit v1.2.3-70-g09d2