]> granicus.if.org Git - strace/blob - string_to_uint.h
tests: workaround systemd-nspawn habit of disabling unimplemented syscalls
[strace] / string_to_uint.h
1 /*
2  * Copyright (c) 2001-2018 The strace developers.
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  */
7
8 #ifndef STRACE_STRING_TO_UINT_H
9 # define STRACE_STRING_TO_UINT_H
10
11 # include <limits.h>
12
13 # include "kernel_types.h"
14
15 extern long long
16 string_to_uint_ex(const char *str, char **endptr,
17                   unsigned long long max_val, const char *accepted_ending);
18
19 static inline long long
20 string_to_uint_upto(const char *const str, const unsigned long long max_val)
21 {
22         return string_to_uint_ex(str, NULL, max_val, NULL);
23 }
24
25 static inline int
26 string_to_uint(const char *str)
27 {
28         return string_to_uint_upto(str, INT_MAX);
29 }
30
31 static inline long
32 string_to_ulong(const char *str)
33 {
34         return string_to_uint_upto(str, LONG_MAX);
35 }
36
37 static inline kernel_long_t
38 string_to_kulong(const char *str)
39 {
40         return string_to_uint_upto(str, ((kernel_ulong_t) -1ULL) >> 1);
41 }
42
43 static inline long long
44 string_to_ulonglong(const char *str)
45 {
46         return string_to_uint_upto(str, LLONG_MAX);
47 }
48
49 #endif /* !STRACE_STRING_TO_UINT_H */