aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--doc/info/chap/introduction.texinfo96
-rw-r--r--include/slibc/features.h63
2 files changed, 158 insertions, 1 deletions
diff --git a/doc/info/chap/introduction.texinfo b/doc/info/chap/introduction.texinfo
index 5dcf7cb..43f4898 100644
--- a/doc/info/chap/introduction.texinfo
+++ b/doc/info/chap/introduction.texinfo
@@ -51,6 +51,8 @@ the C programming language.
@node Reserved Names
@section Reserved Names
+@cpindex Reserved names
+@cpindex Names, reserved
The names of all types, variables, functions and
macros, that comes from the @sc{ISO}@tie{}C standard
are reserved. Additionally, all names that are
@@ -242,3 +244,97 @@ Additionally, @command{slibc} specifies the
macro defined, all warnings @command{slibc}
defines for header files and functions are disabled.
+@command{slibc} also recognises feature-test
+macros defined by other projects.
+
+@table @code
+@item _ISOC90_SOURCE
+@cpindex @sc{ISO}@tie{}C
+@cpindex C90
+@lvindex _ISOC90_SOURCE
+Enables functionality from the @sc{ISO}@tie{}C90
+standard, even if the program is not compiled
+with C90.
+
+@item _ISOC99_SOURCE
+@cpindex @sc{ISO}@tie{}C
+@cpindex C99
+@lvindex _ISOC99_SOURCE
+Enables functionality from the @sc{ISO}@tie{}C99
+standard, even if the program is not compiled
+with C99.
+
+@item _ISOC11_SOURCE
+@cpindex @sc{ISO}@tie{}C
+@cpindex C11
+@lvindex _ISOC11_SOURCE
+Enables functionality from the @sc{ISO}@tie{}C11
+standard, even if the program is not compiled
+with C11.
+
+@item _POSIX_SOURCE
+@cpindex @sc{POSIX}
+@cpindex @sc{ISO}@tie{}C
+@lvindex _POSIX_SOURCE
+Enables functionality from the @sc{POSIX}.1
+standard (@sc{IEEE} Standard 1003.1) as well
+as @sc{ISO}@tie{}C. @code{_POSIX_SOURCE} is
+automatically enabled if @code{_POSIX_C_SOURCE}
+is defined and has a positive value.
+
+@item _POSIX_C_SOURCE >= 1L
+@cpindex @sc{POSIX}
+@lvindex _POSIX_C_SOURCE
+Enables functionality from the 1990 edition
+of the @sc{POSIX}.1 standard (@sc{IEEE}
+Standard 1003.1-1990).
+
+@item _POSIX_C_SOURCE >= 2L
+@cpindex @sc{POSIX}
+@lvindex _POSIX_C_SOURCE
+Enables functionality from the 1992 edition
+of the @sc{POSIX}.2 standard (@sc{IEEE}
+Standard 1003.2-1992).
+
+@item _POSIX_C_SOURCE >= 199309L
+@cpindex @sc{POSIX}
+@lvindex _POSIX_C_SOURCE
+Enables functionality from the 1993 edition
+of the @sc{POSIX}.1b standard (@sc{IEEE}
+Standard 1003.1b-1993).
+
+@item _POSIX_C_SOURCE >= 199506L
+@cpindex @sc{POSIX}
+@lvindex _POSIX_C_SOURCE
+Enables functionality from the 1996 edition
+of the @sc{POSIX}.1 standard (@sc{ISO}/@sc{IEC}
+9945-1: 1996).
+
+@item _BSD_SOURCE
+@cpindex @sc{BSD}
+@lvindex _BSD_SOURCE
+Enables functionality from @sc{BSD}, as well
+as @sc{ISO}@tie{}C, @sc{POSIX}.1, and @sc{POSIX}.2.
+Note that some @sc{BSD} function conflicts with
+@sc{POSIX}.1.
+
+@lvindex _BSD_COMPATIBLE_SOURCE
+@lvindex _POSIX_COMPATIBLE_SOURCE
+To enable the @sc{BSD} functionality that conflicts
+with @sc{POSIX}.1 functionality, also define
+@code{_BSD_COMPATIBLE_SOURCE}. If you however
+prefer to use the @sc{POSIX}.1 functionality, define
+@code{_POSIX_COMPATIBLE_SOURCE} to suppress warnings
+about conflicts. These two feature-test macros are
+specific to @command{slibc}.
+
+@item _SVID_SOURCE
+@cpindex @sc{SVID}
+@cpindex System V Interface Description
+@lvindex _SVID_SOURCE
+Enables functionality from @i{System V Interface
+Description} (@sc{SVID}), as well as @sc{ISO}@tie{}C,
+@sc{POSIX}.1, @sc{POSIX}.2, and X/Open.
+
+@end table
+
diff --git a/include/slibc/features.h b/include/slibc/features.h
index e6005f9..d223d76 100644
--- a/include/slibc/features.h
+++ b/include/slibc/features.h
@@ -40,7 +40,7 @@
/**
* Is C99, or newer, used?
*/
-#if __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L || defined(_ISOC99_SOURCE)
# define __C99__
#endif
@@ -54,6 +54,55 @@
/**
+ * _POSIX_SOURCE is implied if (_POSIX_C_SOURCE >= 1L).
+ */
+#if !defined(_POSIX_SOURCE) && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 1L)
+# define _POSIX_SOURCE 1
+#endif
+#if (!defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE <= 0)) && !defined(_POSIX_SOURCE)
+# define _POSIX_C_SOURCE 1L
+#endif
+
+/**
+ * _BSD_SOURCE || _SVID_SOURCE implies _POSIX_C_SOURCE = 2.
+ */
+#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
+# if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE < 1L)
+# undef _POSIX_C_SOURCE
+# endif
+# if !defined(_POSIX_C_SOURCE)
+# define _POSIX_C_SOURCE 2
+# endif
+#endif
+
+/**
+ * _SVID_SOURCE implies _XOPEN_SOURCE
+ */
+#if defined(_SVID_SOURCE) && !defined(_XOPEN_SOURCE)
+# define _XOPEN_SOURCE 1
+#endif
+
+/**
+ * _BSD_COMPATIBLE_SOURCE requires _BSD_SOURCE.
+ */
+#if defined(_BSD_COMPATIBLE_SOURCE) && !defined(_BSD_SOURCE)
+# if !defined(_SLIBC_SUPPRESS_WARNINGS)
+# warning "_BSD_COMPATIBLE_SOURCE is defined, but _BSD_SOURCE is undefined."
+# endif
+#endif
+
+/**
+ * _BSD_COMPATIBLE_SOURCE and _POSIX_COMPATIBLE_SOURCE
+ * are incompatible.
+ */
+#if defined(_BSD_COMPATIBLE_SOURCE) && defined(_POSIX_COMPATIBLE_SOURCE)
+# if !defined(_SLIBC_SUPPRESS_WARNINGS)
+# warning "You should not define both _BSD_COMPATIBLE_SOURCE and _POSIX_COMPATIBLE_SOURCE."
+# endif
+#endif
+
+
+/**
* Feature-test macros that also change that
* `_PORTABLE_SOURCE` and `_LIBRARY_HEADER`
* is not defined.
@@ -142,6 +191,18 @@
/**
+ * Functions that have a BSD-specification that is conficting
+ * with the POSIX-specification shall have this attribute.
+ */
+#if defined(_BSD_SOURCE) && !defined(_POSIX_COMPATIBLE_SOURCE) && !defined(_BSD_COMPATIBLE_SOURCE)
+# define __bsd_posix_conflict \
+ __warning("The BSD-version of this function is incompatible with the POSIX-version.")
+#else
+# define __bsd_posix_conflict /* ignore*/
+#endif
+
+
+/**
* Format for the `format` GCC function attribute,
* for `*printf` functions.
*/