1 /*************************************************************************** 2 * * 3 * This program is free software; you can redistribute it and/or modify * 4 * it under the terms of the GNU General Public License as published by * 5 * the Free Software Foundation; either version 2 of the License, or * 6 * (at your option) any later version. * 7 * * 8 * This file is from the procps project at http://procps.sourceforge.net/ * 9 * Copyright 1998-2003 Albert Cahalan <albert@users.sf.net> * 10 * * 11 ***************************************************************************/ 12 13 #ifndef PROCPS_PROC_PROCPS_H 14 #define PROCPS_PROC_PROCPS_H 15 16 #ifdef __cplusplus 17 #define EXTERN_C_BEGIN extern "C" { 18 #define EXTERN_C_END } 19 #else 20 #define EXTERN_C_BEGIN 21 #define EXTERN_C_END 22 #endif 23 24 /* Some ports make the mistake of running a 32-bit userspace */ 25 /* on a 64-bit kernel. Shame on them. It's not at all OK to */ 26 /* make everything "long long", since that causes unneeded */ 27 /* slowness on 32-bit hardware. */ 28 /* */ 29 /* SPARC: 32-bit kernel is an ex-penguin, so use "long long". */ 30 /* */ 31 /* MIPS: Used for embedded systems and obsolete hardware. */ 32 /* Oh, there's a 64-bit version? SGI is headed toward IA-64, */ 33 /* so don't worry about 64-bit MIPS. */ 34 /* */ 35 /* PowerPC: Big ugly problem! Macs are popular. :-/ */ 36 /* */ 37 /* Unknown: PA-RISC, zSeries, and x86-64 */ 38 /* */ 39 #if defined(k64test) || defined(__sparc__) /* || defined(__mips__) || defined(__powerpc__) */ 40 #define KLONG long long /* not typedef; want "unsigned KLONG" to work */ 41 #define KLF "L" 42 #define STRTOUKL strtoull 43 #else 44 #define KLONG long 45 #define KLF "l" 46 #define STRTOUKL strtoul 47 #endif 48 49 /* since gcc-2.5 */ 50 #define NORETURN __attribute__((__noreturn__)) 51 #define FUNCTION __attribute__((__const__)) /* no access to global mem, even via ptr, and no side effect */ 52 53 #ifndef __STDC_VERSION__ 54 #define __STDC_VERSION__ 0 55 #endif 56 57 #if !defined(restrict) && __STDC_VERSION__ < 199901 58 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 92 59 #define restrict __restrict__ 60 #else 61 #warning No restrict keyword? 62 #define restrict 63 #endif 64 #endif 65 66 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96 67 /* won't alias anything, and aligned enough for anything */ 68 #define MALLOC __attribute__ ((__malloc__)) 69 /* no side effect, may read globals */ 70 #define PURE __attribute__ ((__pure__)) 71 /* tell gcc what to expect: if(unlikely(err)) die(err); */ 72 #define likely(x) __builtin_expect(!!(x),1) 73 #define unlikely(x) __builtin_expect(!!(x),0) 74 #define expected(x,y) __builtin_expect((x),(y)) 75 #else 76 #define MALLOC 77 #define PURE 78 #define likely(x) (x) 79 #define unlikely(x) (x) 80 #define expected(x,y) (x) 81 #endif 82 83 #if defined(SHARED) && SHARED == 1 && (__GNUC__ > 2 || __GNUC_MINOR__ >= 96) 84 #define LABEL_OFFSET 85 #endif 86 87 #define STRINGIFY_ARG(a) #a 88 #define STRINGIFY(a) STRINGIFY_ARG(a) 89 90 /* marks old junk, to warn non-procps library users */ 91 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3 92 #define OBSOLETE __attribute__((deprecated)) 93 #else 94 #define OBSOLETE 95 #endif 96 97 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 1 ) || __GNUC__ > 3 98 /* Tells gcc that function is library-internal; */ 99 /* so no need to do dynamic linking at run-time. */ 100 /* This might work with slightly older compilers too. */ 101 #define HIDDEN __attribute__((visibility("hidden"))) 102 /* Tell g++ that a function won't throw exceptions. */ 103 #define NOTHROW __attribute__((__nothrow__)) 104 #else 105 #define HIDDEN 106 #define NOTHROW 107 #endif 108 109 /* Like HIDDEN, but for an alias that gets created. */ 110 /* In gcc-3.2 there is an alias+hidden conflict. */ 111 /* Many will have patched this bug, but oh well. */ 112 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 2 ) || __GNUC__ > 3 113 #define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x),visibility("hidden"))) 114 #else 115 #define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x))) 116 #endif 117 118 #endif 119