Page MenuHomeFreeBSD

Add Linux compatibility support for `SC_NPROCESSORS_{CONF,ONLN}` as `_SC_NPROCESSORS_{CONF,ONLN}`
ClosedPublic

Authored by ngie on Dec 23 2018, 11:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 1:03 PM
Unknown Object (File)
Nov 22 2024, 8:25 PM
Unknown Object (File)
Nov 3 2024, 4:40 PM
Unknown Object (File)
Oct 7 2024, 10:48 PM
Unknown Object (File)
Oct 3 2024, 11:03 PM
Unknown Object (File)
Sep 22 2024, 7:42 PM
Unknown Object (File)
Sep 13 2024, 3:37 AM
Unknown Object (File)
Sep 10 2024, 2:13 AM
Subscribers

Details

Summary

The goal of this change is to make it easier to use getconf to query
the number of available processors.

Sadly it's unclear per POSIX, which form (with a preceding _ or
lacking it) is correct. I will bring this up on the Austin Group list so
this point is clarified for implementors that might rely on this getconf
variable.

This is something I noticed when trying to import GoogleTest to FreeBSD
as one of the CI scripts uses this variable on Linux.

Test Plan

Setup:

$ make obj
$ make
$ cd $(make -V.OBJDIR)
  • Old form:
$ ./getconf _NPROCESSORS_ONLN
4
  • New (Linux compatible) form:
$ ./getconf NPROCESSORS_ONLN
4

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Did you bring it up on the Austin Group list?

I'm also unclear about this change - you add the _ form, but the non-_ form is Linux compatible and already exists? Or is the comment above backwards?

Did you bring it up on the Austin Group list?

I'm also unclear about this change - you add the _ form, but the non-_ form is Linux compatible and already exists? Or is the comment above backwards?

FreeBSD supports SC_NPROCESSORS_CONF/SC_NPROCESSORS_ONLN (no leading underscore) prior to this change and Linux supports _SC_NPROCESSORS_CONF/_SC_NPROCESSORS_ONLN (leading underscore). Not having the latter form (for Linux) makes it trivially more difficult when porting software to FreeBSD today in bourne shell scripts.

I'm adding code to support the Linux way to remove that minor barrier, so people will be able to port to FreeBSD for free when using the right idiom on Linux.

The comment about the Austin Group list was to cause the committee to officially comment on (and make a decision) as to whether or not FreeBSD/Linux needs to support SC_NPROCESSORS_CONF or _SC_NPROCESSORS_CONF, etc.

ngie retitled this revision from Add Linux compatibility support for `_NPROCESSORS_{CONF,ONLN}` as `NPROCESSORS_{CONF,ONLN}` to Add Linux compatibility support for `NPROCESSORS_{CONF,ONLN}` as `_NPROCESSORS_{CONF,ONLN}`.Jan 10 2019, 4:34 PM

@emaste: you're right though -- the summary was flip-flopped by accident :). Fixed!

ngie retitled this revision from Add Linux compatibility support for `NPROCESSORS_{CONF,ONLN}` as `_NPROCESSORS_{CONF,ONLN}` to Add Linux compatibility support for `SC_NPROCESSORS_{CONF,ONLN}` as `_SC_NPROCESSORS_{CONF,ONLN}`.Jan 10 2019, 4:35 PM

the summary was flip-flopped by accident

Ah, makes sense now.

As for Austin Group I was just wondering if you brought it up there already (and if there's any response from them).

As for Austin Group I was just wondering if you brought it up there already (and if there's any response from them).

I haven't yet. I will be starting that conversation this week/next week.

Regardless of what the group says, it seems like we'll probably want to support both for a transitional period. Given that, this change seems OK. @emaste , do you agree?

This revision is now accepted and ready to land.Jan 11 2019, 8:03 PM
This revision was automatically updated to reflect the committed changes.