summaryrefslogtreecommitdiffstats
path: root/lib/atfork.h
blob: 8c779ef9b9e5a6cf9f4fc9aa50765f9413afc7e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * Copyright (C) 2014 Red Hat
 *
 * Author: Nikos Mavrogiannopoulos
 *
 * This file is part of GnuTLS.
 *
 * The GnuTLS is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>
 *
 */

#ifndef GNUTLS_LIB_ATFORK_H
#define GNUTLS_LIB_ATFORK_H

#include <config.h>
#include "gnutls_int.h"

extern unsigned int _gnutls_forkid;

#if defined(HAVE___REGISTER_ATFORK)
# define HAVE_ATFORK
#endif

#ifndef _WIN32

/* API */
int _gnutls_register_fork_handler(void); /* global init */

# if defined(HAVE_ATFORK)
inline static int _gnutls_detect_fork(unsigned int forkid)
{
	if (forkid == _gnutls_forkid)
		return 0;
	return 1;
}

inline static unsigned int _gnutls_get_forkid(void)
{
	return _gnutls_forkid;
}
# else
int _gnutls_detect_fork(unsigned int forkid);
unsigned int _gnutls_get_forkid(void);
# endif

#else

# define _gnutls_detect_fork(x) 0
# define _gnutls_get_forkid() 0

#endif

#endif /* GNUTLS_LIB_ATFORK_H */