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)
Feb 25 2024, 6:41 AM
Unknown Object (File)
Jan 23 2024, 2:26 AM
Unknown Object (File)
Jan 13 2024, 11:13 AM
Unknown Object (File)
Jan 5 2024, 5:34 AM
Unknown Object (File)
Dec 25 2023, 10:29 AM
Unknown Object (File)
Dec 22 2023, 10:23 PM
Unknown Object (File)
Nov 15 2023, 1:07 PM
Unknown Object (File)
Nov 7 2023, 4:13 PM
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.