pthread_cleanup.h File Reference

Cleanup primitives for pthread threads. More...

Detailed Description

Cleanup primitives for pthread threads.

Note
Do not include this header file directly, but pthread.h.

Definition in file pthread_cleanup.h.

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  __pthread_cleanup_datum
 Internal structure for pthread_cleanup_push() More...
 
#define pthread_cleanup_push(ROUTINE, ARG)
 Open a cleanup frame. More...
 
#define pthread_cleanup_pop(EXECUTE)
 Closes a cleaup frame. More...
 
typedef struct __pthread_cleanup_datum __pthread_cleanup_datum_t
 Internal structure for pthread_cleanup_push()
 
void __pthread_cleanup_push (__pthread_cleanup_datum_t *datum)
 Internal function to be called by pthread_cleanup_push() More...
 
void __pthread_cleanup_pop (__pthread_cleanup_datum_t *datum, int execute)
 Internal function to be called by pthread_cleanup_push() More...
 

Macro Definition Documentation

◆ pthread_cleanup_pop

#define pthread_cleanup_pop (   EXECUTE)
Value:
____execute__ = (EXECUTE); \
} while (0); \
__pthread_cleanup_pop(&____datum__, ____execute__); \
} while (0)

Closes a cleaup frame.

Must be paired with pthread_cleanup_push().

Parameters
[in]EXECUTEIff != 0 call cleanup handler.

Definition at line 88 of file pthread_cleanup.h.

◆ pthread_cleanup_push

#define pthread_cleanup_push (   ROUTINE,
  ARG 
)
Value:
do { \
__extension__ __pthread_cleanup_datum_t ____datum__ = { \
.__routine = (ROUTINE), \
.__arg = (ARG), \
}; \
__extension__ int ____execute__ = 1; \
__pthread_cleanup_push(&____datum__); \
do { \
do { } while (0)

Open a cleanup frame.

This function must be paired with pthread_cleanup_pop().

The cleanup function is called if the current thread exists inside the frame by means of pthread_exit(), or if the thread was cancelled.

You must not return, continue, or break out of the cleanup frame.

The frame opens a scope. Variables declared inside this scope won't be visible outside.

Parameters
[in]ROUTINEFunction to call on cleanup.
[in]ARGArgument to supply to the cleanup handler.

Definition at line 72 of file pthread_cleanup.h.

Function Documentation

◆ __pthread_cleanup_pop()

void __pthread_cleanup_pop ( __pthread_cleanup_datum_t datum,
int  execute 
)

Internal function to be called by pthread_cleanup_push()

This function leaves the cleanup frame that was opened with __pthread_cleanup_push().

Parameters
[in]datumParameter that was supplied to __pthread_cleanup_push().
[in]executeIff != 0 call cleanup handler.

◆ __pthread_cleanup_push()

void __pthread_cleanup_push ( __pthread_cleanup_datum_t datum)

Internal function to be called by pthread_cleanup_push()

The previous top of the stack gets stored in datum->next.

Parameters
[in]datumAllocated in the stack, datum tells how to cleanup.
__pthread_cleanup_datum::__routine
void(* __routine)(void *arg)
Cleanup routine to call.
Definition: pthread_cleanup.h:33
__pthread_cleanup_datum
Internal structure for pthread_cleanup_push()
Definition: pthread_cleanup.h:27