This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 1/4] Feature test macro overhaul



This is a lot of stuff which can have puzzeling side-effect.  I'd very
much appreciate at least another pair of eyes reviewing this patch.
Thanks in advance.


On Feb 22 21:24, Yaakov Selkowitz wrote:
> +/*
> + * Feature test macros control which symbols are exposed by the system
> + * headers.  Any of these must be defined before including any headers.
> + *
> + * __STRICT_ANSI__ (defined by gcc -ansi, -std=c90, -std=c99, or -std=c11)
> + *	ISO C
> + * _POSIX_SOURCE (deprecated by _POSIX_C_SOURCE=1)
> + * _POSIX_C_SOURCE >= 1
> + * 	POSIX.1-1990
> + * _POSIX_C_SOURCE >= 2
> + * 	POSIX.2-1992
> + * _POSIX_C_SOURCE >= 199309L
> + * 	POSIX.1b-1993 Real-time extensions
> + * _POSIX_C_SOURCE >= 199506L
> + * 	POSIX.1c-1995 Threads extensions
> + * _POSIX_C_SOURCE >= 200112L
> + * 	POSIX.1-2001 and C99
> + * _POSIX_C_SOURCE >= 200809L
> + * 	POSIX.1-2008
> + * _XOPEN_SOURCE
> + *	POSIX.1-1990 and XPG4

Per the linux feature_test_macros man page that should be POSIX.1-1990,
POSIX.2-1992, and XPG4.

> +#ifdef _GNU_SOURCE
> +#undef _ATFILE_SOURCE
> +#define _ATFILE_SOURCE		1
> +#undef _ISOC99_SOURCE
> +#define _ISOC99_SOURCE		1
> +#undef _ISOC11_SOURCE
> +#define _ISOC11_SOURCE		1
> +#undef _POSIX_SOURCE
> +#define _POSIX_SOURCE		1
> +#undef _POSIX_C_SOURCE
> +#define _POSIX_C_SOURCE		200809L
> +#undef _XOPEN_SOURCE
> +#define _XOPEN_SOURCE		700
> +#undef _XOPEN_SOURCE_EXTENDED
> +#define _XOPEN_SOURCE_EXTENDED	1
> +#undef _BSD_SOURCE
> +#define _BSD_SOURCE		1
> +#undef _SVID_SOURCE
> +#define _SVID_SOURCE		1
> +#endif /* _GNU_SOURCE */
> +
> +#if !defined(__STRICT_ANSI__) && !defined(_ANSI_SOURCE) && \
> +  !defined(_ISOC99_SOURCE) && !defined(_POSIX_SOURCE) && \
> +  !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) && \
> +  !defined(_BSD_SOURCE) && !defined(_SVID_SOURCE)
> +#define _BSD_SOURCE
> +#define _SVID_SOURCE
> +#endif

Can you please explain this expression?  Why is _BSD_SOURCE + _SVID_SOURCE
the default?  Is that derived from some BSD default setting?

The question is a bit dumb perhaps.  It's a result of me digging into
the Linux feature_test_macros man page which contains basically the
following information:

- _BSD_SOURCE is deprecated and has the same effect as _DEFAULT_SOURCE
- _SVID_SOURCE is deprecated and has the same effect as _DEFAULT_SOURCE
- _DEFAULT_SOURCE is effectively

    _BSD_SOURCE | _SVID_SOURCE | _POSIX_C_SOURCE=200809

> +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200809
> +#undef _ATFILE_SOURCE
> +#define _ATFILE_SOURCE
> +#endif

Maybe better

  #define _ATFILE_SOURCE 1

as in the `#ifdef _GNU_SOURCE code above?


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]