[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] patches from pkgsrc: SConstruct
From: |
Greg Troxel |
Subject: |
Re: [gpsd-dev] patches from pkgsrc: SConstruct |
Date: |
Thu, 20 Jun 2019 18:49:59 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (berkeley-unix) |
> For example: _BSD_SOURCE is certainly not Linux only. It is glibx.
Good catch, thanks.
> Please use TODO instead of \todo. That is a keyword that triggers
> some tools we use.
OK - I'll try to remember that. I didn't realize the local convention.
> I just re-verified. This is not true:
>
> + # required because _XOPEN_SOURCE above restricts visibility of
> + # all things not defined by XOPEN
>
> Easy to confirm on netbad:
>
> fgrep XOPEN_SOURCE /usr/include -r
I've attached sys/featuretest.h. The issue of these visibility
definitions removing things that are beyond the standard has come up in
other places. You can see that defining _XOPEN_SOURCE removes the
implied definition of _NETBSD_SOURCE. This matches my understanding of
how this entire visibility scheme is supposed to work.
I wrote a test program (below) that trivially uses strlcpy. This
function exists in NetBSD, but it's only available if _NETBSD_SOURCE is
defined (explicitly or implicitly) because it is not specified by POSIX.
The test program as appended fails to build (with -Werror, because of
not seeing a strlcpy prototype). Without _XOPEN_SOURCE, or with
_NETBSD_SOURCE also, it builds without warnings.
This is what I was trying to say: by defining _XOPEN_SOURCE, one is not
only requesting that all functions defined by that XOPEN version be
visible, but also requesting that functions not defined by that version
be hidden.
Overall, I suspect that gpsd would be better off not defining *any*
visibility functions unless shown to be necessary, and then on those
platforms figuring out how to ask for all definitions.
----------------------------------------
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <string.h>
int main(int arg, char **argv)
{
char dst[10], *src;
size_t r;
src = "A wicked long string more than 10 bytes.";
r = strlcpy(dst, src, sizeof(dst));
printf("retval %d string <%s>\n", r, dst);
return 0;
}
---------------------------------------
/* $NetBSD: featuretest.h,v 1.10 2013/04/26 18:29:06 christos Exp $
*/
/*
* Written by Klaus Klein <address@hidden>, February 2, 1998.
* Public domain.
*
* NOTE: Do not protect this header against multiple inclusion. Doing
* so can have subtle side-effects due to header file inclusion order
* and testing of e.g. _POSIX_SOURCE vs. _POSIX_C_SOURCE. Instead,
* protect each CPP macro that we want to supply.
*/
/*
* Feature-test macros are defined by several standards, and allow an
* application to specify what symbols they want the system headers to
* expose, and hence what standard they want them to conform to.
* There are two classes of feature-test macros. The first class
* specify complete standards, and if one of these is defined, header
* files will try to conform to the relevant standard. They are:
*
* ANSI macros:
* _ANSI_SOURCE ANSI C89
*
* POSIX macros:
* _POSIX_SOURCE == 1 IEEE Std 1003.1 (version?)
* _POSIX_C_SOURCE == 1 IEEE Std 1003.1-1990
* _POSIX_C_SOURCE == 2 IEEE Std 1003.2-1992
* _POSIX_C_SOURCE == 199309L IEEE Std 1003.1b-1993
* _POSIX_C_SOURCE == 199506L ISO/IEC 9945-1:1996
* _POSIX_C_SOURCE == 200112L IEEE Std 1003.1-2001
* _POSIX_C_SOURCE == 200809L IEEE Std 1003.1-2008
*
* X/Open macros:
* _XOPEN_SOURCE System Interfaces and Headers, Issue 4, Ver 2
* _XOPEN_SOURCE_EXTENDED == 1 XSH4.2 UNIX extensions
* _XOPEN_SOURCE == 500 System Interfaces and Headers, Issue 5
* _XOPEN_SOURCE == 520 Networking Services (XNS), Issue 5.2
* _XOPEN_SOURCE == 600 IEEE Std 1003.1-2001, XSI option
* _XOPEN_SOURCE == 700 IEEE Std 1003.1-2008, XSI option
*
* NetBSD macros:
* _NETBSD_SOURCE == 1 Make all NetBSD features available.
*
* If more than one of these "major" feature-test macros is defined,
* then the set of facilities provided (and namespace used) is the
* union of that specified by the relevant standards, and in case of
* conflict, the earlier standard in the above list has precedence (so
* if both _POSIX_C_SOURCE and _NETBSD_SOURCE are defined, the version
* of rename() that's used is the POSIX one). If none of the "major"
* feature-test macros is defined, _NETBSD_SOURCE is assumed.
*
* There are also "minor" feature-test macros, which enable extra
* functionality in addition to some base standard. They should be
* defined along with one of the "major" macros. The "minor" macros
* are:
*
* _REENTRANT
* _ISOC99_SOURCE
* _ISOC11_SOURCE
* _LARGEFILE_SOURCE Large File Support
* <http://ftp.sas.com/standards/large.file/x_open.20Mar96.html>
*/
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 1L
#endif
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
!defined(_XOPEN_SOURCE) && !defined(_NETBSD_SOURCE)
#define _NETBSD_SOURCE 1
#endif
#if ((_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500) && \
!defined(_REENTRANT)
#define _REENTRANT
#endif
Re: [gpsd-dev] patches from pkgsrc: SConstruct, Greg Troxel, 2019/06/20
- Re: [gpsd-dev] patches from pkgsrc: SConstruct, Gary E. Miller, 2019/06/20
- Re: [gpsd-dev] patches from pkgsrc: SConstruct,
Greg Troxel <=
- [gpsd-dev] featuretest macros, Greg Troxel, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Gary E. Miller, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Greg Troxel, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Hal Murray, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Gary E. Miller, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Greg Troxel, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Gary E. Miller, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Greg Troxel, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Gary E. Miller, 2019/06/21
- Re: [gpsd-dev] featuretest macros, Greg Troxel, 2019/06/21