Commit Graph

13 Commits

Author SHA1 Message Date
Yaakov Selkowitz 6ba26630e0 Feature test macros overhaul: sys/features.h
This is the complete rework of the feature tests macros for better
compatibility with GNU libc, primarily based on the Linux man pages
documentation:

http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

The previous implementation was flawed in its approach that macros were
often used to hide symbols if defined (e.g. !defined __STRICT_ANSI__ or
!defined _POSIX_SOURCE), whereas the approach of glibc is that these macros
make symbols available when defined (e.g. defined _BSD_SOURCE, or as used
internally, #if __BSD_VISIBLE).  As much open-source software is written
with glibc in mind, this necessitated patching numerous packages just to
compile.

In particular, __STRICT_ANSI__ (which is defined by gcc -ansi or -std=c*)
was given too much importance.  This implementation limits the influence
of __STRICT_ANSI__ to controlling the default when no other feature test
macros are defined, and to the inclusion of <alloca.h> in <stdlib.h> as
documented.  These are the only places where __STRICT_ANSI__ should be
tested.

The following macros are now accepted: _ATFILE_SOURCE, _BSD_SOURCE,
_DEFAULT_SOURCE, _ISOC99_SOURCE, _ISOC11_SOURCE, _LARGEFILE_SOURCE,
_SVID_SOURCE, _XOPEN_SOURCE_EXTENDED.

The existing __*_VISIBLE internal macros have been kept mostly
compatible with the original BSD implementation, with some changes to
the criteria which controls them.  Several more macros in this style
have been added where needed for concision or accuracy.

Enabling C++11 or newer in the compiler also enables C99 and C11
functions.  Doing so should help move away from the need to define
_GNU_SOURCE in g++ for _GLIBCXX_USE_C99 support as on Linux:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51749

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:06:40 -05:00
Jeff Johnston ecee0b0607 Synchronize with FreeBSD.
* libc/include/sys/cdefs.h: Synchronize with latest FreeBSD
        version.
2015-10-13 17:50:30 -04:00
Jeff Johnston 443467d752 Add FreeBSD style changes to sys/cdefs.h
* libc/include/sys/cdefs.h: Add style changes of latest FreeBSD
        version.
2015-10-13 17:46:47 -04:00
Jon TURNEY 67d150ca14 * libc/include/sys/cdefs.h (_GNU_SOURCE): Move check so it has an
effect when _XOPEN_SOURCE is also defined.
2015-02-25 15:58:41 +00:00
Corinna Vinschen 9bd3bcc642 * libc/include/machine/_default_types.h: Move extern "C" after
header includes.  Include <sys/features.h> for
	__GNUC_PREREQ__().
	(__u?int.*_t): Define via GCC provided __U?INT.*_TYPE__ if
	available.
	(__intptr_t): Define.
	(__uintptr_t): Likewise.
	* libc/include/stdint.h: Include <machine/_default_types.h>
	instead of <_ansi.h>.
	(u?int.*_t): Define via __u?int.*_t provided by
	<machine/_default_types.h>.
	(u?int_fast.*_t): Define via GCC provided
	__U?INT_FAST.*_TYPE__ if available.
	(U?INT.*(MIN|MAX)): Define via GCC provided __U?INT.*(MIN|MAX)__
	if available.
	(U?INT.*_C): Define via GCC provided __U?INT.*_C if available.
	* libc/include/sys/cdefs.h: Use <machine/_default_types.h>
	instead of <stdint.h>.
	* libc/sys/rtems/sys/cpuset.h: Likewise.
	* libc/sys/rtems/machine/_types.h: Include <stdint.h> for
	FreeBSD compatibility.
2013-12-03 16:04:41 +00:00
Joel Sherrill 62c28b76ac 2013-11-29 Jennifer Averett <jennifer.averett@oarcorp.com>
* libc/include/pthread.h (pthread_attr_setaffinity_np):
	Add pthread SMP affinity attributes to methods to RTEMS for
	compatibility with GNU/Linux.
	(pthread_attr_getaffinity_np): Likewise.
	(pthread_setaffinity_np): Likewise.
	(pthread_getaffinity_np): Likewise.
	(pthread_getattr_np): Add for GNU/Linux compatibility.
	* libc/include/sys/types.h: Add cpuset to pthread_attr_t for RTEMS.
	* libc/include/sys/cdefs.h (_GNU_SOURCE): Defining _GNU_SOURCE
	turns on all _XXX_VISBLE feature flags.
2013-11-29 23:14:57 +00:00
Jeff Johnston 44d6d53977 2013-09-12 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/include/sys/cdefs.h: Synchronize with latest FreeBSD
        version.
        * libc/include/stdatomic.h: Likewise.
2013-09-12 22:05:43 +00:00
Corinna Vinschen af9f65e0c4 * libc/include/cdefs.h (__has_extension): New define.
(__has_feature): Likewise.
	(__has_include): Likewise.
	(__has_builtin): Likewise.
	* libc/include/stdatomic.h: New.
2013-06-07 09:14:39 +00:00
Corinna Vinschen 742fb38c56 * libc/include/sys/cdefs.h (_Static_assert): Accommodate gcc >= 4.6. 2013-05-22 17:53:07 +00:00
Corinna Vinschen 9770af188f * libc/include/sys/cdefs.h: Align with latest FreeBSD file header.
* libc/include/sys/features.h (__GNUC_PREREQ__): Define.
2013-04-22 10:28:05 +00:00
Corinna Vinschen 7eb805f68d * libc/sys/rtems/sys/queue.h: Delete file.
* libc/include/sys/cdefs.h (__containerof): New define.
	(__DEQUALIFY): Likewise.
	* libc/include/sys/queue.h (TRACEBUF_INITIALIZER): Likewise.
	(TRACEBUF): Likewise.
	(LIST_FOREACH_SAFE): Likewise.
	(LIST_PREV): Likewise.
	(LIST_SWAP): Likewise.
	(QMD_LIST_CHECK_HEAD): Likewise.
	(QMD_LIST_CHECK_NEXT): Likewise.
	(QMD_LIST_CHECK_PREV): Likewise.
	(QMD_SAVELINK): Likewise.
	(QMD_TAILQ_CHECK_HEAD): Likewise.
	(QMD_TAILQ_CHECK_NEXT): Likewise.
	(QMD_TAILQ_CHECK_PREV): Likewise.
	(QMD_TAILQ_CHECK_TAIL): Likewise.
	(QMD_TRACE_ELEM): Likewise.
	(QMD_TRACE_HEAD): Likewise.
	(SLIST_FOREACH_PREVPTR): Likewise.
	(SLIST_FOREACH_SAFE): Likewise.
	(SLIST_REMOVE_AFTER): Likewise.
	(SLIST_SWAP): Likewise.
	(STAILQ_FOREACH_SAFE): Likewise.
	(STAILQ_REMOVE_AFTER): Likewise.
	(STAILQ_SWAP): Likewise.
	(TAILQ_FOREACH_REVERSE_SAFE): Likewise.
	(TAILQ_FOREACH_SAFE): Likewise.
	(TAILQ_SWAP): Likewise.
	(TRASHIT): Likewise.
	(SLIST_REMOVE): Use SLIST_REMOVE_AFTER().
	(STAILQ_LAST): Use __containerof().
	(STAILQ_REMOVE): Use STAILQ_REMOVE_AFTER().
2013-04-16 10:25:16 +00:00
Corinna Vinschen 977cd4175e * libc/include/sys/cdefs.h (__CONCAT1): Define.
(__CONCAT): Define.
	(__STRING): Define.
	(__XSTRING): Define.
	(__ASMNAME): Define.
	* libc/include/string.h (strerror_r): Use __ASMNAME to take target
	specific label prefixes into account.
2011-03-03 10:37:09 +00:00
Thomas Fitzsimmons a7b23a8f11 * Makefile.am (LIB_OBJECTLISTS): Add
libc/search/objectlist.awk.in.
	* libc/Makefile.am (SUBDIRS): Add search.
	(SUBLIBS): Add search/libsearch.la.
	* libc/configure.in (AC_OUTPUT): Add search/Makefile.
	* libc/search: New directory.
	* libc/search/Makefile.am: New file.
	* libc/search/extern.h: New file.
	* libc/search/hash.c: New file.
	* libc/search/hash.h: New file.
	* libc/search/hash_bigkey.c: New file.
	* libc/search/hash_buf.c: New file.
	* libc/search/hash_func.c: New file.
	* libc/search/hash_log2.c: New file.
	* libc/search/hash_page.c: New file.
	* libc/search/hcreate.3: New file.
	* libc/search/hcreate.c: New file.
	* libc/search/hcreate.c~: New file.
	* libc/search/hcreate_r.c: New file.
	* libc/search/ndbm.c: New file.
	* libc/search/page.h: New file.
	* libc/search/tdelete.c: New file.
	* libc/search/tdestroy.c: New file.
	* libc/search/tfind.c: New file.
	* libc/search/tsearch.3: New file.
	* libc/search/tsearch.c: New file.
	* libc/search/twalk.c: New file.
	* libc/include/db.h: New file.
	* libc/include/ndbm.h: New file.
	* libc/include/search.h: New file.
	* libc/include/sys/queue.h: New file.
	* libc/include/sys/cdefs.h: New file.
	* libc/include/sys/param.h
	[__IEEE_LITTLE_ENDIAN,__IEEE_BIG_ENDIAN]: Set BYTE_ORDER to
	LITTLE_ENDIAN or BIG_ENDIAN.
	* libc/include/sys/errno.h (EFTYPE): New macro.
	* libc/search/bsearch.c: Move from libc/stdlib.
	* libc/search/qsort.c: Likewise.
	* libc/stdlib/Makefile.am (LIB_SOURCES): Remove bsearch.c and
	qsort.c.
	(CHEWOUT_FILES): Remove bsearch.def and qsort.def.
	* libc/stdlib/stdlib.tex: Remove references to bsearch and qsort.
2002-06-20 19:51:40 +00:00