-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[RFC] posix: signal: empty + fill + set #60057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
}; | ||
|
||
/* Signal set management definitions and macros. */ | ||
#define MIN_SIGNO 1 /* Lowest valid signal number */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might move some of these into the enum above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat concerned that using an ENUM will allow pre-processor defines to override these without generating a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I shouldn't be lazy and should have used defines instead..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think technically you can do both 😁 but some people might find that a bit too verbose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally though, #define
s would give you more compile-time constness which is A Good Thing™️ for size.
Implement POSIX signal API: sigemptyset. Add ztest. SIgned-off-by: Yong Cong Sin <[email protected]> Update signal.h
Implement POSIX signal API: sigfillset. Added ztest. SIgned-off-by: Yong Cong Sin <[email protected]>
Implement POSIX signal API: sigaddset Added ztest. SIgned-off-by: Yong Cong Sin <[email protected]>
#define SIGRTMIN (SIGSTDMAX + 1) /* First real time signal */ | ||
#define SIGRTMAX MAX_SIGNO /* Last real time signal */ | ||
#define _NSIG (MAX_SIGNO + 1) /* Biggest signal number + 1 */ | ||
#define NSIG _NSIG /* _NSIG variant commonly used */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are _NSIG
, NSIG
, MAX_SIGNO
, SIGSTDMAX
, SIGSTDMIN
, etc standard names? I haven't looked yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_NSIG
,NSIG
I can't find this in the standard, but pretty common in implementations to have these for calculation:
https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/signal.h#L7
/* sigset_t is represented as an array of 32-b unsigned integers. | ||
* _SIGSET_NELEM is the allocated size of the array | ||
*/ | ||
#define _SIGSET_NELEM ((_NSIG + 31) >> 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these standard symbols?
Normally underscore followed by capital letter is reserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really standard, different implementations seems to have different names for this, to calculate the uint32_t
array size to fit the number of signals, in nuttx its _SIGSET_NELEM
, in Linux its _NSIG_WORDS
closed, see #60083 |
Implementation for
sigemptyset
,sigfillset
,sigaddset
Heavily 'influenced' by nuttx's implementation
will probably finish off the remaining signal APIs tomorrow..
fixes #59927
fixes #59929
fixes #59931