sys/sem.h declares union semun imporpertly. According to the POSIX manpage, it should be declared by the application if required: > The semctl() function provides a variety of semaphore control operations as > specified by cmd. The fourth argument is optional and depends upon the > operation requested. If required, it is of type union semun, which the > application shall explicitly declare: > > union semun { > int val; > struct semid_ds *buf; > unsigned short *array; > } arg; union semun is used in the kernel so the declaration should be moved under an #ifdef _KERNEL and an exprun should be performed. It looks like configure scripts commonly handle this case so it may change code, but shouldn't break much.
It's also used in libc; would you propose something like #if defined(_KERNEL) || defined(_WANT_SEMUN) and use that to make the definition available to lib/libc/gen/semctl.c?
That would be a reasonable approach. In the patch I'm working on for an exp-run I've simply redeclared it.
A commit references this bug: Author: brooks Date: Fri Mar 2 22:32:54 UTC 2018 New revision: 330299 URL: https://svnweb.freebsd.org/changeset/base/330299 Log: Don't declare union semun in userspace unless _WANT_SEMUN is defined. POSIX explicitly states that the application must declare union semun. This makes no sense, but it is what it is. This brings us into line with Linux, MacOS/Darwin, and NetBSD. In a ports exp-run a moderate number of ports fail due to a lack of approprate autotools-like discovery mechanisms or local patches. A commit to address them will follow shortly. PR: 224300, 224443 (exp-run) Reviewed by: emaste, jhb, kib Exp-run by: antoine Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14492 Changes: head/contrib/sendmail/include/sm/os/sm_os_freebsd.h head/lib/libc/gen/semctl.c head/lib/libc/sys/semctl.2 head/sys/sys/param.h head/sys/sys/sem.h head/usr.bin/svn/lib/libapr/apr.h
A commit references this bug: Author: brooks Date: Fri Mar 2 22:34:56 UTC 2018 New revision: 463452 URL: https://svnweb.freebsd.org/changeset/ports/463452 Log: Work around the lack of definition of union semun per POSIX. When feasible do this by adding -D_WANT_SEMUN to CFLAGS or CXXFLAGS. Where this fails due to ports not honoring C*FLAGS, patch using __FreeBSD_version to enable the definition. PR: 224300, 224443 (exp-run) Approved by: portmgr (antoine) Exp-run: antoine Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14137 Changes: head/audio/alsa-lib/Makefile head/audio/gramofile/Makefile head/audio/wavplay/Makefile head/audio/xmcd/Makefile head/audio/zinf/Makefile head/benchmarks/super-smack/Makefile head/databases/fastdb/Makefile head/deskutils/fusenshi/Makefile head/devel/ace/Makefile head/devel/libmba/Makefile head/devel/libshbuf/Makefile head/devel/nspr/Makefile head/devel/poco-ssl/Makefile head/devel/shmap/Makefile head/emulators/qemu-sbruno/Makefile head/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_nsprpub_pr_src_pthreads_ptsynch.c head/ftp/gftp/Makefile head/lang/cint/files/patch-cint_lib_ipc_ipcif.h head/lang/ferite/Makefile head/lang/rexx-regutil/Makefile head/mail/batv-milter/Makefile head/mail/batv-milter/files/patch-include_sm_os_sm__os__freebsd.h head/mail/dk-milter/files/patch-include_sm_os_sm__os__freebsd.h head/mail/sendmail/files/patch-include_sm_os_sm__os__freebsd.h head/mail/sid-milter/files/patch-include_sm_os_sm__os__freebsd.h head/misc/buffer/Makefile head/multimedia/py-kaa-base/Makefile head/net-mgmt/sdig/Makefile head/net-p2p/monero-cli/Makefile head/sysutils/freeipmi/Makefile head/sysutils/symon/Makefile head/www/mod_cband/files/patch-src_mod__cband.c