Automatic date update in version.in
[binutils-gdb.git] / gprofng / libcollector / tsd.h
blobe76ddef4af81130067ce600f481187fe1a636155
1 /* Copyright (C) 2021-2023 Free Software Foundation, Inc.
2 Contributed by Oracle.
4 This file is part of GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 /* Thread-specific data */
23 #ifndef _TSD_H
24 #define _TSD_H
26 #include <sys/types.h>
28 int __collector_tsd_init ();
29 /* Function: Init tsd module. Call once before using other functions.
30 MT-Level: Unsafe
31 Return: 0 if successful
34 void __collector_tsd_fini ();
35 /* Function: Shutdown tsd module.
36 MT-Level: Unsafe
37 Return: None
40 void __collector_tsd_fork_child_cleanup ();
41 /* Function: Reset tsd module. Call immediately after fork() in child process.
42 MT-Level: Unsafe
43 Return: None
46 int __collector_tsd_allocate ();
47 /* Function: Allocate thread info.
48 Call from threads before using tsd_get_by_key().
49 Call from main thread should be made before calls from other threads.
50 MT-Level: First call is unsafe. Safe afterwards.
51 Return: 0 if successful
54 void __collector_tsd_release ();
55 /* Function: Free thread info.
56 Call from threads just before thread termination.
57 MT-Level: Safe
58 Return: None
61 #define COLLECTOR_TSD_INVALID_KEY ((unsigned)-1)
62 unsigned __collector_tsd_create_key (size_t memsize, void (*init)(void*), void (*fini)(void*));
63 /* Function: Reserve TDS memory.
64 MT-Level: Unsafe
65 Inputs: <memsize>: number of bytes to reserve
66 <init>: key memory initialization. Must be callable even if
67 the associated thread has not yet been created.
68 <fini>: key memory finalization. Must be callable even if
69 the associated thread has been terminated.
70 Return: key or COLLECTOR_TSD_INVALID_KEY if not successful.
73 void *__collector_tsd_get_by_key (unsigned key);
74 /* Function: Get TSD memory.
75 Call from threads after calling tsd_allocate().
76 MT-Level: Safe
77 Inputs: <key>: return value from tsd_create_key()
78 Return: memory if successful, NULL otherwise
80 #endif /* _TSD_H */