Loading...
Searching...
No Matches
pthread_cleanup.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 René Kijewski <rene.kijewski@fu-berlin.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
34
41
49
50/*
51 * Notice: `pthread_cleanup_*` has to be defined as a macro, because the cleanup
52 * stack needs extra data. The standard explicitly allows defining these
53 * functions as macros. The alternative would be malloc.
54 */
55
68#define pthread_cleanup_push(ROUTINE, ARG) \
69 do { \
70 __extension__ __pthread_cleanup_datum_t ____datum__ = { \
71 .__routine = (ROUTINE), \
72 .__arg = (ARG), \
73 }; \
74 __extension__ int ____execute__ = 1; \
75 __pthread_cleanup_push(&____datum__); \
76 do { \
77 do { } while (0)
78
84#define pthread_cleanup_pop(EXECUTE) \
85 ____execute__ = (EXECUTE); \
86 } while (0); \
87 __pthread_cleanup_pop(&____datum__, ____execute__); \
88 } while (0)
89
90#ifdef __cplusplus
91}
92#endif
93
void __pthread_cleanup_push(__pthread_cleanup_datum_t *datum)
Internal function to be called by pthread_cleanup_push()
struct __pthread_cleanup_datum __pthread_cleanup_datum_t
Internal structure for pthread_cleanup_push()
void __pthread_cleanup_pop(__pthread_cleanup_datum_t *datum, int execute)
Internal function to be called by pthread_cleanup_push()
Internal structure for pthread_cleanup_push()
void(* __routine)(void *arg)
Cleanup routine to call.
void * __arg
Argument to supply.
struct __pthread_cleanup_datum * __next
Cleanup handler to call next.