a9a1b13a59c284b9f43935ab508e0fd020f00912
[strongswan.git] / src / libstrongswan / utils / compat / android.h
1 /*
2 * Copyright (C) 2010-2015 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup android android
18 * @{ @ingroup compat
19 */
20
21 #ifndef ANDROID_H_
22 #define ANDROID_H_
23
24 #include <android/api-level.h>
25
26 /* stuff defined in AndroidConfig.h, which is included using the -include
27 * command-line option, thus cannot be undefined using -U CFLAGS options.
28 * the reason we have to undefine these flags in the first place, is that
29 * AndroidConfig.h defines them as 0, which in turn means that they are
30 * actually defined. */
31 #undef HAVE_BACKTRACE
32
33 /* sigwaitinfo() is not defined up to this API level, provide a fallback */
34 #if __ANDROID_API__ <= 21
35 #include <errno.h>
36 #include <signal.h>
37
38 static inline int sigwaitinfo(const sigset_t *set, void *info)
39 {
40 int sig, err;
41
42 if (info)
43 { /* we don't replicate siginfo_t, which we don't use */
44 errno = EINVAL;
45 return -1;
46 }
47 err = sigwait(set, &sig);
48 if (err != 0)
49 {
50 errno = err;
51 sig = -1;
52 }
53 return sig;
54 }
55 #else
56 #error Check availability of sigwaitinfo() in this API level
57 #endif
58
59 #endif /** ANDROID_H_ @}*/