Date: Wed, 1 Jun 2016 19:31:51 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Ed Schouten <ed@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r301071 - head/sys/sys Message-ID: <20160601183101.X1028@besplex.bde.org> In-Reply-To: <201605311905.u4VJ5geL053766@repo.freebsd.org> References: <201605311905.u4VJ5geL053766@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 31 May 2016, Ed Schouten wrote: > Log: > Improve POSIX conformance of <signal.h>. > > - This header file has always depended on pthread_t, pthread_attr_t, > struct timespec, size_t and uid_t. Only as of POSIX 2008, these > dependencies have been states explicitly. They should now be defined. Not always. POSIX didn't have pthreads or timespecs before about 1993. > - In our implementation, struct sigevent::sigev_notify_attributes has > type "void *" instead of "pthread_attr_t *". My guess is that this was > done to prevent pulling in the pthread types, but this can easily be > avoided by using the underlying structure types. Not easily, since the tags of the underlying struct types are in the application namespace, at least up to POSIX 2001. > Modified: > head/sys/sys/signal.h > > Modified: head/sys/sys/signal.h > ============================================================================== > --- head/sys/sys/signal.h Tue May 31 18:45:52 2016 (r301070) > +++ head/sys/sys/signal.h Tue May 31 19:05:41 2016 (r301071) > @@ -45,6 +45,23 @@ > #include <machine/_limits.h> /* __MINSIGSTKSZ */ > #include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */ > > +#if __POSIX_VISIBLE >= 200809 > + > +#include <sys/_pthreadtypes.h> This gives the following pollution (which breaks almost everything since <sys/types.h> includes this header: - struct tag names pthread* - struct member names state and mutex POSIX could reasonably be unimproved by reserving pthread* but not ordinary identifiers like state and mutex. > ... > @@ -160,6 +177,9 @@ union sigval { > #endif > > #if __POSIX_VISIBLE >= 199309 > + > +struct pthread_attr; > + The 1993 version certainly doesn't reserve pthread*. The 1996 version has a nice table of reserved symbols for every header. For signal.h, they are just ones with a prefix of sa_, si_, sigev_ and sival_ (these shall not be declared or #defined by the application), and SIG_, SA_, SI_ and SIGEV_ (these may be used by the application iff they are #undef'ed before use). This doesn't proprtly separate optional things. A draft 2001 version as a not so nice table. The rules are now too tangled to present in a single table, so there are several tables that are hard to parse. The first table has sa_, uc_ (new), SIG[A-Z] (stronger), SIG_[A-Z] (weaker). Then it has ss_ (new) and sv_ (new) for XSI only. Then it has si_, SI_, sigev_, SIGEV_ and sival_ for RTS only. The second table has SA_, SIG_[0-9a-z_] (different/weaker), then massive pollution: BUS_, CLD_, FPE_, ILL_, POLL_, SEGV_, SI_ (now in both tables), SS_, SV_ and TRAP_. A draft 2007 version is like the 2001 version. It fixes the sorting of uc_ and makes RTS non-optional. In the second table, it moves SS_, SV_ and TRAP_ under XSI, and moves POLL_ under OBS XSR. I think pthread is not reserved since it is not in these tables. Later versions of POSIX were broken to allow <signal.h> to be pollutied with all the symbols in <time.h>, but I don't want to check what is in that now. <time.h> is slightly simpler in POSIX but much more polluted than <signal.h> in FreeBSD. > struct sigevent { > int sigev_notify; /* Notification type */ > int sigev_signo; /* Signal number */ > @@ -168,7 +188,7 @@ struct sigevent { > __lwpid_t _threadid; Names like _threadid are bogus. sigev is reserved for uses like this. Noy using a prefix makes the namespace random. > struct { > void (*_function)(union sigval); > - void *_attribute; /* pthread_attr_t * */ > + struct pthread_attr **_attribute; pthread is not reserved. pthread*_t is only reserved by the general rule that everything ending in _t is reserved. This also has indentation errors. > } _sigev_thread; > unsigned short _kevent_flags; Further bogus names. At least they use a prefix. > long __spare__[8]; A more bogus name. > @@ -190,6 +210,7 @@ struct sigevent { > #define SIGEV_KEVENT 3 /* Generate a kevent. */ > #define SIGEV_THREAD_ID 4 /* Send signal to a kernel thread. */ It is correct to used the reserved prefix for our extensions, but this style is inconsistent with old parts of the file. In the old parts, we ifdef out extensions to a fault. This makes the code hard to read but provides good documentation of what is portable. > #endif > + > #endif /* __POSIX_VISIBLE >= 199309 */ > > #if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE > Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160601183101.X1028>