1 #ifndef PROCPS_PROC_PROCPS_H
2 #define PROCPS_PROC_PROCPS_H
5 #define EXTERN_C_BEGIN extern "C" {
12 // Some ports make the mistake of running a 32-bit userspace
13 // on a 64-bit kernel. Shame on them. It's not at all OK to
14 // make everything "long long", since that causes unneeded
15 // slowness on 32-bit hardware.
17 // SPARC: The 32-bit kernel was looking like an ex-penguin,
18 // but it lives! ("I'm not dead yet.") So, 64-bit users will
19 // just have to compile for 64-bit. Aw, the suffering.
21 // MIPS: Used 32-bit for embedded systems and obsolete hardware.
22 // The 64-bit systems use an n32 format executable, defining
23 // _ABIN32 to indicate this. Since n32 doesn't currently run on
24 // any 32-bit system, nobody get hurt if it's bloated. Not that
25 // this is sane of course, but it won't hurt the 32-bit users.
26 // __mips_eabi means eabi, which comes in both sizes, but isn't used.
28 // PowerPC: Big ugly problem! 32-bit Macs are still popular. :-/
30 // x86-64: So far, nobody has been dumb enough to go 32-bit.
32 // Unknown: PA-RISC and zSeries
34 #if defined(k64test) || (defined(_ABIN32) && _MIPS_SIM == _ABIN32)
35 #define KLONG long long // not typedef; want "unsigned KLONG" to work
37 #define STRTOUKL strtoull
41 #define STRTOUKL strtoul
45 #define NORETURN __attribute__((__noreturn__))
46 #define FUNCTION __attribute__((__const__)) // no access to global mem, even via ptr, and no side effect
48 #if !defined(restrict) && __STDC_VERSION__ < 199901
49 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 92
50 #define restrict __restrict__
52 #warning No restrict keyword?
57 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
58 // won't alias anything, and aligned enough for anything
59 #define MALLOC __attribute__ ((__malloc__))
60 // no side effect, may read globals
61 #define PURE __attribute__ ((__pure__))
62 // tell gcc what to expect: if(unlikely(err)) die(err);
63 #define likely(x) __builtin_expect(!!(x),1)
64 #define unlikely(x) __builtin_expect(!!(x),0)
65 #define expected(x,y) __builtin_expect((x),(y))
70 #define unlikely(x) (x)
71 #define expected(x,y) (x)
74 #if SHARED==1 && (__GNUC__ > 2 || __GNUC_MINOR__ >= 96)
78 #define STRINGIFY_ARG(a) #a
79 #define STRINGIFY(a) STRINGIFY_ARG(a)
81 // marks old junk, to warn non-procps library users
82 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
83 #define OBSOLETE __attribute__((deprecated))
88 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 1 ) || __GNUC__ > 3
89 // Tells gcc that function is library-internal;
90 // so no need to do dynamic linking at run-time.
91 // This might work with slightly older compilers too.
92 #define HIDDEN __attribute__((visibility("hidden")))
93 // The opposite, in case -fvisibility=hidden used
94 #define EXPORT __attribute__((visibility("default")))
95 // Tell g++ that a function won't throw exceptions.
96 #define NOTHROW __attribute__((__nothrow__))
103 // Like HIDDEN, but for an alias that gets created.
104 // In gcc-3.2 there is an alias+hidden conflict.
105 // Many will have patched this bug, but oh well.
106 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 2 ) || __GNUC__ > 3
107 #define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x),visibility("hidden")))
109 #define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x)))