File indexing completed on 2024-12-22 04:17:22
0001 /*************************************************************************** 0002 * * 0003 * This program is free software; you can redistribute it and/or modify * 0004 * it under the terms of the GNU General Public License as published by * 0005 * the Free Software Foundation; either version 2 of the License, or * 0006 * (at your option) any later version. * 0007 * * 0008 * This file is from the procps project at http://procps.sourceforge.net/ * 0009 * Copyright 1998-2003 Albert Cahalan <albert@users.sf.net> * 0010 * * 0011 ***************************************************************************/ 0012 0013 #ifndef PROCPS_PROC_PROCPS_H 0014 #define PROCPS_PROC_PROCPS_H 0015 0016 #ifdef __cplusplus 0017 #define EXTERN_C_BEGIN extern "C" { 0018 #define EXTERN_C_END } 0019 #else 0020 #define EXTERN_C_BEGIN 0021 #define EXTERN_C_END 0022 #endif 0023 0024 /* Some ports make the mistake of running a 32-bit userspace */ 0025 /* on a 64-bit kernel. Shame on them. It's not at all OK to */ 0026 /* make everything "long long", since that causes unneeded */ 0027 /* slowness on 32-bit hardware. */ 0028 /* */ 0029 /* SPARC: 32-bit kernel is an ex-penguin, so use "long long". */ 0030 /* */ 0031 /* MIPS: Used for embedded systems and obsolete hardware. */ 0032 /* Oh, there's a 64-bit version? SGI is headed toward IA-64, */ 0033 /* so don't worry about 64-bit MIPS. */ 0034 /* */ 0035 /* PowerPC: Big ugly problem! Macs are popular. :-/ */ 0036 /* */ 0037 /* Unknown: PA-RISC, zSeries, and x86-64 */ 0038 /* */ 0039 #if defined(k64test) || defined(__sparc__) /* || defined(__mips__) || defined(__powerpc__) */ 0040 #define KLONG long long /* not typedef; want "unsigned KLONG" to work */ 0041 #define KLF "L" 0042 #define STRTOUKL strtoull 0043 #else 0044 #define KLONG long 0045 #define KLF "l" 0046 #define STRTOUKL strtoul 0047 #endif 0048 0049 /* since gcc-2.5 */ 0050 #define NORETURN __attribute__((__noreturn__)) 0051 #define FUNCTION __attribute__((__const__)) /* no access to global mem, even via ptr, and no side effect */ 0052 0053 #ifndef __STDC_VERSION__ 0054 #define __STDC_VERSION__ 0 0055 #endif 0056 0057 #if !defined(restrict) && __STDC_VERSION__ < 199901 0058 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 92 0059 #define restrict __restrict__ 0060 #else 0061 #warning No restrict keyword? 0062 #define restrict 0063 #endif 0064 #endif 0065 0066 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 96 0067 /* won't alias anything, and aligned enough for anything */ 0068 #define MALLOC __attribute__ ((__malloc__)) 0069 /* no side effect, may read globals */ 0070 #define PURE __attribute__ ((__pure__)) 0071 /* tell gcc what to expect: if(unlikely(err)) die(err); */ 0072 #define likely(x) __builtin_expect(!!(x),1) 0073 #define unlikely(x) __builtin_expect(!!(x),0) 0074 #define expected(x,y) __builtin_expect((x),(y)) 0075 #else 0076 #define MALLOC 0077 #define PURE 0078 #define likely(x) (x) 0079 #define unlikely(x) (x) 0080 #define expected(x,y) (x) 0081 #endif 0082 0083 #if defined(SHARED) && SHARED == 1 && (__GNUC__ > 2 || __GNUC_MINOR__ >= 96) 0084 #define LABEL_OFFSET 0085 #endif 0086 0087 #define STRINGIFY_ARG(a) #a 0088 #define STRINGIFY(a) STRINGIFY_ARG(a) 0089 0090 /* marks old junk, to warn non-procps library users */ 0091 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3 0092 #define OBSOLETE __attribute__((deprecated)) 0093 #else 0094 #define OBSOLETE 0095 #endif 0096 0097 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 1 ) || __GNUC__ > 3 0098 /* Tells gcc that function is library-internal; */ 0099 /* so no need to do dynamic linking at run-time. */ 0100 /* This might work with slightly older compilers too. */ 0101 #define HIDDEN __attribute__((visibility("hidden"))) 0102 /* Tell g++ that a function won't throw exceptions. */ 0103 #define NOTHROW __attribute__((__nothrow__)) 0104 #else 0105 #define HIDDEN 0106 #define NOTHROW 0107 #endif 0108 0109 /* Like HIDDEN, but for an alias that gets created. */ 0110 /* In gcc-3.2 there is an alias+hidden conflict. */ 0111 /* Many will have patched this bug, but oh well. */ 0112 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 2 ) || __GNUC__ > 3 0113 #define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x),visibility("hidden"))) 0114 #else 0115 #define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x))) 0116 #endif 0117 0118 #endif