Skip to content

[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

Closed
wants to merge 3 commits into from

Conversation

ycsin
Copy link
Member

@ycsin ycsin commented Jul 5, 2023

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

@ycsin ycsin added the DNM This PR should not be merged (Do Not Merge) label Jul 5, 2023
@ycsin ycsin requested a review from cfriedt as a code owner July 5, 2023 16:23
@ycsin ycsin changed the title posix: signal: posix: signal: empty + fill + set Jul 5, 2023
@zephyrbot zephyrbot added the area: POSIX POSIX API Library label Jul 5, 2023
@ycsin ycsin requested a review from keith-packard July 5, 2023 16:25
@ycsin ycsin force-pushed the pr/posix-sigaddset branch from 9782dda to 15c8cb5 Compare July 5, 2023 16:32
@ycsin ycsin changed the title posix: signal: empty + fill + set [RFC] posix: signal: empty + fill + set Jul 5, 2023
};

/* Signal set management definitions and macros. */
#define MIN_SIGNO 1 /* Lowest valid signal number */
Copy link
Member Author

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

Copy link
Collaborator

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.

Copy link
Member Author

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..

Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally though, #defines would give you more compile-time constness which is A Good Thing™️ for size.

ycsin added 3 commits July 6, 2023 00:53
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]>
@ycsin ycsin force-pushed the pr/posix-sigaddset branch from 15c8cb5 to b47a5b4 Compare July 5, 2023 16:54
#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 */
Copy link
Member

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.

Copy link
Member Author

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)
Copy link
Member

@cfriedt cfriedt Jul 5, 2023

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.

Copy link
Member Author

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

@ycsin
Copy link
Member Author

ycsin commented Jul 6, 2023

closed, see #60083

@ycsin ycsin closed this Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: POSIX POSIX API Library DNM This PR should not be merged (Do Not Merge)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

posix: implement sigfillset() posix: implement sigemptyset() posix: implement sigaddset()
4 participants