Network headers and __BSD_VISIBLE

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Sep 8 07:01:36 UTC 2011


Hello,

if we do this

#include <sys/socket.h>

in RTEMS, then several features of the network stack are not visible since 
__BSD_VISIBLE is undefined.  This is in contrast to FreeBSD and Linux.  FreeBSD 
for example defines __BSD_VISIBLE in <sys/cdefs.h> depending on other defines. 
  The default is __BSD_VISIBLE defined to 1.  Linux does not use __BSD_VISIBLE 
and exports everything unconditionally.

We should do this similar to FreeBSD.  Here is the part that defines 
__BSD_VISIBLE in the current FreeBSD <sys/cdefs.h>:

http://svnweb.freebsd.org/base/head/sys/sys/cdefs.h?revision=218824&view=markup

/*
  * Deal with all versions of POSIX.  The ordering relative to the tests above is
  * important.
  */
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
#define	_POSIX_C_SOURCE		198808
#endif
#ifdef _POSIX_C_SOURCE
#if _POSIX_C_SOURCE >= 200809
#define	__POSIX_VISIBLE		200809
#define	__ISO_C_VISIBLE		1999
#elif _POSIX_C_SOURCE >= 200112
#define	__POSIX_VISIBLE		200112
#define	__ISO_C_VISIBLE		1999
#elif _POSIX_C_SOURCE >= 199506
#define	__POSIX_VISIBLE		199506
#define	__ISO_C_VISIBLE		1990
#elif _POSIX_C_SOURCE >= 199309
#define	__POSIX_VISIBLE		199309
#define	__ISO_C_VISIBLE		1990
#elif _POSIX_C_SOURCE >= 199209
#define	__POSIX_VISIBLE		199209
#define	__ISO_C_VISIBLE		1990
#elif _POSIX_C_SOURCE >= 199009
#define	__POSIX_VISIBLE		199009
#define	__ISO_C_VISIBLE		1990
#else
#define	__POSIX_VISIBLE		198808
#define	__ISO_C_VISIBLE		0
#endif /* _POSIX_C_SOURCE */
#else
/*-
  * Deal with _ANSI_SOURCE:
  * If it is defined, and no other compilation environment is explicitly
  * requested, then define our internal feature-test macros to zero.  This
  * makes no difference to the preprocessor (undefined symbols in preprocessing
  * expressions are defined to have value zero), but makes it more convenient for
  * a test program to print out the values.
  *
  * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
  * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
  * environment (and in fact we will never get here).
  */
#if defined(_ANSI_SOURCE)	/* Hide almost everything. */
#define	__POSIX_VISIBLE		0
#define	__XSI_VISIBLE		0
#define	__BSD_VISIBLE		0
#define	__ISO_C_VISIBLE		1990
#elif defined(_C99_SOURCE)	/* Localism to specify strict C99 env. */
#define	__POSIX_VISIBLE		0
#define	__XSI_VISIBLE		0
#define	__BSD_VISIBLE		0
#define	__ISO_C_VISIBLE		1999
#else				/* Default environment: show everything. */
#define	__POSIX_VISIBLE		200809
#define	__XSI_VISIBLE		700
#define	__BSD_VISIBLE		1
#define	__ISO_C_VISIBLE		1999
#endif
#endif

-- 
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list