Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
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
21
extern
"C"
{
22
#endif
23
27
typedef
struct
__pthread_cleanup_datum
28
{
30
struct
__pthread_cleanup_datum
*
__next
;
31
33
void (*
__routine
)(
void
*arg);
34
36
void
*
__arg
;
37
}
__pthread_cleanup_datum_t
;
38
44
void
__pthread_cleanup_push
(
__pthread_cleanup_datum_t
*datum);
45
52
void
__pthread_cleanup_pop
(
__pthread_cleanup_datum_t
*datum,
int
execute);
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
__pthread_cleanup_datum::__arg
void * __arg
Argument to supply.
Definition:
pthread_cleanup.h:36
__pthread_cleanup_pop
void __pthread_cleanup_pop(__pthread_cleanup_datum_t *datum, int execute)
Internal function to be called by pthread_cleanup_push()
__pthread_cleanup_datum_t
struct __pthread_cleanup_datum __pthread_cleanup_datum_t
Internal structure for pthread_cleanup_push()
__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
__pthread_cleanup_push
void __pthread_cleanup_push(__pthread_cleanup_datum_t *datum)
Internal function to be called by pthread_cleanup_push()
__pthread_cleanup_datum::__next
struct __pthread_cleanup_datum * __next
Cleanup handler to call next.
Definition:
pthread_cleanup.h:30
Generated on Tue Nov 24 2020 19:46:52 by
1.8.17