Whamcloud - gitweb
LU-6245 libcfs: remove libcfsutil.h
[fs/lustre-release.git] / libcfs / include / libcfs / types.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
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
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 2014, Intel Corporation.
27  */
28 #ifndef _LIBCFS_TYPES_H
29 #define _LIBCFS_TYPES_H
30
31 #include <linux/types.h>
32
33 #ifndef __KERNEL__
34 # include <limits.h> /* LONG_MAX */
35 # include <stdbool.h> /* bool */
36 # include <stddef.h> /* size_t */
37 #endif /* !__KERNEL__ */
38
39 #if defined(_ASM_GENERIC_INT_L64_H)
40 # define LPF64 "l"
41 #elif defined(_ASM_GENERIC_INT_LL64_H)
42 # define LPF64 "ll"
43 #elif !defined(LPF64)
44 # error "cannot define LPF64"
45 #endif /* !LPF64 */
46
47 #define LPU64 "%"LPF64"u"
48 #define LPD64 "%"LPF64"d"
49 #define LPX64 "%#"LPF64"x"
50 #define LPX64i "%"LPF64"x"
51 #define LPO64 "%#"LPF64"o"
52
53 #define LPLU "%lu"
54 #define LPLD "%ld"
55 #define LPLX "%#lx"
56 #define LPPID "%d"
57
58 #ifndef BITS_PER_LONG
59 # if LONG_MAX == 9223372036854775807
60 #  define BITS_PER_LONG 64
61 # elif LONG_MAX == 2147483647
62 #  define BITS_PER_LONG 32
63 # else /* LONG_MAX == 2147483647 */
64 #  error "cannot define BITS_PER_LONG"
65 # endif /* LONG_MAX != 2147483647 */
66 #endif /* !BITS_PER_LONG */
67
68 #if BITS_PER_LONG == 64
69 # define LI_POISON ((int)0x5a5a5a5a5a5a5a5a)
70 # define LL_POISON ((long)0x5a5a5a5a5a5a5a5a)
71 # define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a)
72 #elif BITS_PER_LONG == 32
73 # define LI_POISON ((int)0x5a5a5a5a)
74 # define LL_POISON ((long)0x5a5a5a5a)
75 # define LP_POISON ((void *)(long)0x5a5a5a5a)
76 #else /* BITS_PER_LONG == 32 */
77 # error "cannot define L{I,L,P}_POISON"
78 #endif /* BITS_PER_LONG != 32 */
79
80 typedef unsigned long ulong_ptr_t;
81 typedef long long_ptr_t;
82
83 #ifndef __KERNEL__
84 /* Sparse annotation. */
85 #define __user
86 #endif
87
88 #endif /* _LIBCFS_TYPES_H */