Loading...
Searching...
No Matches
pthread_cleanup.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
17#ifndef PTHREAD_CLEANUP_H
18#define PTHREAD_CLEANUP_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
38
45
53
54/*
55 * Notice: `pthread_cleanup_*` has to be defined as a macro, because the cleanup
56 * stack needs extra data. The standard explicitly allows defining these
57 * functions as macros. The alternative would be malloc.
58 */
59
72#define pthread_cleanup_push(ROUTINE, ARG) \
73 do { \
74 __extension__ __pthread_cleanup_datum_t ____datum__ = { \
75 .__routine = (ROUTINE), \
76 .__arg = (ARG), \
77 }; \
78 __extension__ int ____execute__ = 1; \
79 __pthread_cleanup_push(&____datum__); \
80 do { \
81 do { } while (0)
82
88#define pthread_cleanup_pop(EXECUTE) \
89 ____execute__ = (EXECUTE); \
90 } while (0); \
91 __pthread_cleanup_pop(&____datum__, ____execute__); \
92 } while (0)
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif /* PTHREAD_CLEANUP_H */
99
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.