Skip to content
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

posix: implement pthread_cleanup_pop() #59940

Closed
Tracked by #51211
ycsin opened this issue Jul 3, 2023 · 0 comments · Fixed by #65700
Closed
Tracked by #51211

posix: implement pthread_cleanup_pop() #59940

ycsin opened this issue Jul 3, 2023 · 0 comments · Fixed by #65700
Labels
area: POSIX POSIX API Library Feature Request A request for a new feature Good first issue Good for a first time contributor to take

Comments

@ycsin
Copy link
Member

ycsin commented Jul 3, 2023

There are currently 20 missing POSIX functions with trivial implementations, pthread_cleanup_pop() is one of them.

pthread_cleanup_pop, pthread_cleanup_push - establish cancellation handlers

The pthread_cleanup_pop() function shall remove the routine at the top of the calling thread's cancellation cleanup stack and optionally invoke it (if execute is non-zero).

The pthread_cleanup_push() function shall push the specified cancellation cleanup handler routine onto the calling thread's cancellation cleanup stack. The cancellation cleanup handler shall be popped from the cancellation cleanup stack and invoked with the argument arg when:

The thread exits (that is, calls pthread_exit()).

The thread acts upon a cancellation request.

The thread calls pthread_cleanup_pop() with a non-zero execute argument.

It is unspecified whether pthread_cleanup_push() and pthread_cleanup_pop() are macros or functions. If a macro definition is suppressed in order to access an actual function, or a program defines an external identifier with any of these names, the behavior is undefined. The application shall ensure that they appear as statements, and in pairs within the same lexical scope (that is, the pthread_cleanup_push() macro may be thought to expand to a token list whose first token is '{' with pthread_cleanup_pop() expanding to a token list whose last token is the corresponding '}' ).

The effect of calling longjmp() or siglongjmp() is undefined if there have been any calls to pthread_cleanup_push() or pthread_cleanup_pop() made without the matching call since the jump buffer was filled. The effect of calling longjmp() or siglongjmp() from inside a cancellation cleanup handler is also undefined unless the jump buffer was also filled in the cancellation cleanup handler.

The effect of the use of return, break, continue, and goto to prematurely leave a code block described by a pair of pthread_cleanup_push() and pthread_cleanup_pop() functions calls is undefined.

See https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cleanup_pop.html

See RFC #51211 for more info.

@ycsin ycsin added Feature Request A request for a new feature Good first issue Good for a first time contributor to take area: POSIX POSIX API Library labels Jul 3, 2023
@ycsin ycsin moved this from To Do to LTS3 Goals in Release Plan Jul 3, 2023
@ycsin ycsin added this to the v3.5.0 milestone Jul 3, 2023
@cfriedt cfriedt assigned cfriedt and unassigned cfriedt Jul 4, 2023
@cfriedt cfriedt removed the status in Release Plan Sep 12, 2023
@nashif nashif removed this from Release Plan Sep 13, 2023
@cfriedt cfriedt removed this from the v3.5.0 milestone Oct 13, 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 Feature Request A request for a new feature Good first issue Good for a first time contributor to take
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants