Bug 210319 - Including pthread_np.h should not imply including sys/queue.h
Summary: Including pthread_np.h should not imply including sys/queue.h
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: John Baldwin
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-06-16 12:51 UTC by Akinori MUSHA
Modified: 2016-07-24 00:32 UTC (History)
1 user (show)

See Also:
jhb: mfc-stable11+


Attachments
A patch for sys/sys/cpuset.h (371 bytes, patch)
2016-06-16 12:51 UTC, Akinori MUSHA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Akinori MUSHA freebsd_committer 2016-06-16 12:51:58 UTC
Created attachment 171481 [details]
A patch for sys/sys/cpuset.h

sys/cpuset.h is included by pthread_np.h, which is included by user applications.

sys/queue.h defines a lot of macros that should only be exposed to kernel sources, so the #include directive should be guarded with #ifdef _KERNEL, or just removed if all users are naturally expected to include sys/queue.h.

Ruby fails to build on 11-CURRENT due to a macro name clash of LIST_HEAD() between FreeBSD's sys/queue.h and CCAN's list module.

http://beefy4.nyi.freebsd.org/data/head-amd64-default/p414752_s299210/logs/ruby23-2.3.1,1.log

The #include directive was added in r299122, but I suspect the line was irrelevant to the rest of the commit.
Comment 1 Akinori MUSHA freebsd_committer 2016-07-07 06:50:43 UTC
What do you think?
Comment 2 John Baldwin freebsd_committer freebsd_triage 2016-07-07 11:43:13 UTC
Does this pass kernel builds?  I'm not sure why that ended up there myself and do not think it is needed.
Comment 3 Akinori MUSHA freebsd_committer 2016-07-07 16:57:46 UTC
Sorry to bother you, but I assigned you because you committed r299122.

With this patch applied buildworld/buildkernel/installkernel/installworld still pass, and then ruby builds successfully as it does on FreeBSD 10 and earlier.
Comment 4 John Baldwin freebsd_committer freebsd_triage 2016-07-14 23:13:09 UTC
It is needed to avoid the <sys/param.h> dependency for the kernel (so was definitely an intended part of the original change), but is not needed for userland.
Comment 5 commit-hook freebsd_committer 2016-07-14 23:14:44 UTC
A commit references this bug:

Author: jhb
Date: Thu Jul 14 23:14:10 UTC 2016
New revision: 302858
URL: https://svnweb.freebsd.org/changeset/base/302858

Log:
  Move nested include of <sys/queue.h> inside _KERNEL.

  This removes namespace pollution for userland brought in by r299122.

  PR:		210319
  Submitted by:	knu
  MFC after:	1 week

Changes:
  head/sys/sys/cpuset.h
Comment 6 commit-hook freebsd_committer 2016-07-23 17:38:44 UTC
A commit references this bug:

Author: jhb
Date: Sat Jul 23 17:37:59 UTC 2016
New revision: 303228
URL: https://svnweb.freebsd.org/changeset/base/303228

Log:
  MFC 302858: Move nested include of <sys/queue.h> inside _KERNEL.

  This removes namespace pollution for userland brought in by r299122.

  PR:		210319
  Approved by:	re (kib)

Changes:
_U  stable/11/
  stable/11/sys/sys/cpuset.h