unistd: handle required _SC* values in sysconf - #520
Conversation
There was a problem hiding this comment.
Code Review
This pull request expands the sysconf implementation by defining and adding support for numerous POSIX system configuration constants (_SC_*). It also updates _SC_OPEN_MAX to return -1 for POSIX compliance. The review feedback highlights several areas for improvement: ensuring that limits associated with unsupported options also return -1 to comply with POSIX standards, returning defined limits like NGROUPS_MAX and PTHREAD_DESTRUCTOR_ITERATIONS instead of their POSIX minimums, and adding the missing _SC_CLK_TCK case to the sysconf switch statement.
27ef143 to
8f85816
Compare
Fixes: phoenix-rtos/phoenix-rtos-project#1458 TASK: RTOS-1438
Set to _POSIX_NGROUPS_MAX for now. TASK: RTOS-1438
8f85816 to
d81d4f7
Compare
6a9bd18 to
24ae168
Compare
Unit Test Results (nightly) 1 files 3 182 suites 6h 8m 27s ⏱️ Results for commit 24ae168. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request expands POSIX compliance by defining numerous _SC_* configuration constants in include/unistd.h and implementing their handling in sysconf within unistd/conf.c. Additionally, _SC_OPEN_MAX now returns -1 to remain POSIX-compliant. The review feedback suggests improving sysconf by returning the defined PTHREAD_DESTRUCTOR_ITERATIONS and NGROUPS_MAX constants instead of returning -1 or fallback values, respectively.
| case _SC_THREAD_DESTRUCTOR_ITERATIONS: | ||
| case _SC_THREAD_KEYS_MAX: | ||
| case _SC_THREAD_STACK_MIN: | ||
| case _SC_THREAD_THREADS_MAX: | ||
| /* The POSIX Threads option is not fully supported. */ | ||
| return -1; |
There was a problem hiding this comment.
Since PTHREAD_DESTRUCTOR_ITERATIONS is defined in <limits.h> (via <posix/limits.h>), sysconf(_SC_THREAD_DESTRUCTOR_ITERATIONS) should return its value instead of -1 to be POSIX-compliant.
| case _SC_THREAD_DESTRUCTOR_ITERATIONS: | |
| case _SC_THREAD_KEYS_MAX: | |
| case _SC_THREAD_STACK_MIN: | |
| case _SC_THREAD_THREADS_MAX: | |
| /* The POSIX Threads option is not fully supported. */ | |
| return -1; | |
| case _SC_THREAD_DESTRUCTOR_ITERATIONS: | |
| return PTHREAD_DESTRUCTOR_ITERATIONS; | |
| case _SC_THREAD_KEYS_MAX: | |
| case _SC_THREAD_STACK_MIN: | |
| case _SC_THREAD_THREADS_MAX: | |
| /* The POSIX Threads option is not fully supported. */ | |
| return -1; |
| case _SC_NGROUPS_MAX: | ||
| return _POSIX_NGROUPS_MAX; |
There was a problem hiding this comment.
Since NGROUPS_MAX is defined in <limits.h>, sysconf(_SC_NGROUPS_MAX) should return NGROUPS_MAX instead of the POSIX minimum fallback _POSIX_NGROUPS_MAX. This ensures that any future changes to NGROUPS_MAX are automatically reflected in sysconf.
| case _SC_NGROUPS_MAX: | |
| return _POSIX_NGROUPS_MAX; | |
| case _SC_NGROUPS_MAX: | |
| return NGROUPS_MAX; |
Fixes: phoenix-rtos/phoenix-rtos-project#1458
Description
Motivation and Context
Types of changes
How Has This Been Tested?
Checklist:
Special treatment