Types.h

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 /************************************************************************
00032  * $Id: Types.h,v 1.38 2008/08/29 21:45:10 legendre Exp $
00033  * Types.h: commonly used types (used by runtime libs and other modules)
00034 ************************************************************************/
00035 
00036 #if !defined(_Types_h_)
00037 #define _Types_h_
00038 
00039 /* Sets up 64 and 32 bit
00040    types:
00041       int64_t      uint64_t      int32_t       uint32_t
00042    constant macros:
00043       I64_C(x)     UI64_C(x)
00044    limits:
00045       I64_MAX      I64_MIN       UI64_MAX
00046       I32_MAX      I32_MIN       UI32_MAX
00047 
00048    note: needs to be included before anything that includes inttypes.h
00049          (eg. stdio on some systems)
00050 */
00051 
00052 /* Set up the 32 AND 64 BIT TYPES ===================================== */
00053 /*
00054    --- inttypes.h ---
00055              int32_t  uint32_t  int64_t uint64_t 32B lmts 64Blmts 64BlitMacros#
00056 Sol5.6       yes      yes       yes     yes      yes      no*     yes   
00057 Sol5.7       yes      yes       yes     yes      yes      no*     yes   
00058 Linux        yes      yes       yes     yes      yes      yes     yes
00059 Irix         yes      yes       yes     yes      yes      yes     yes
00060 Osf4.0       nonexistant
00061 Osf5.0       ?
00062 Aix4.2       nonexistant
00063 Aix4.3       yes      yes       yes     yes      yes      no*     yes
00064 WindowsNT    nonexistant
00065 
00066   * the 64bit limits on solaris and aix are defined, but they are not defined
00067     properly to include the numeric literal postfix (eg. LL), so we need to
00068     explicitly define these
00069   # we rename all of the 64 bit literal macros to our shortened name
00070 */
00071 
00072 #if defined(os_windows)
00073    typedef signed __int64 int64_t;
00074    typedef signed __int32 int32_t;
00075    typedef signed __int16 int16_t;
00076    typedef signed __int8 int8_t;
00077    typedef unsigned __int64 uint64_t;
00078    typedef unsigned __int32 uint32_t;
00079    typedef unsigned __int16 uint16_t;
00080    typedef unsigned __int8 uint8_t;
00081 
00082 #elif defined(os_aix)  
00083 #if defined (arch_power)
00084 #  if defined(rs6000_ibm_aix64)
00085 #       define TYPE64BIT
00086 #  endif
00087 #  ifndef _ALL_SOURCE
00088 #     define _ALL_SOURCE
00089 #  endif
00090 #  include <sys/types.h>     /* if aix4.3, this will include inttypes.h */
00091 #  ifndef _H_INTTYPES        /* for aix4.2 */
00092      typedef int int32_t;
00093      typedef unsigned int uint32_t;
00094 #    if defined(rs6000_ibm_aix64)
00095         typedef long int64_t;
00096         typedef unsigned long uint64_t;
00097 #    else
00098         typedef long long int64_t;
00099         typedef unsigned long long uint64_t;
00100 #    endif
00101 #  endif
00102 #  endif /* defined (arch_power) */
00103 
00104 #elif defined(arch_alpha)
00105 #define TYPE64BIT
00106 #  ifndef _H_INTTYPES
00107    typedef int int32_t;
00108    typedef long int64_t;
00109    typedef unsigned int uint32_t;
00110    typedef unsigned long uint64_t;
00111 #  endif
00112 
00113 #elif defined(os_linux)
00114 #if !defined(__STDC_CONSTANT_MACROS)
00115 #define __STDC_CONSTANT_MACROS
00116 #endif
00117 #if !defined(__STDC_LIMIT_MACROS)
00118 #define __STDC_LIMIT_MACROS
00119 #endif
00120 #include <stdint.h>
00121 #if defined(arch_x86_64) || defined(arch_64bit)
00122 #define TYPE64BIT
00123 #endif
00124 typedef long double double128_t;
00125 
00126 #elif defined(os_bg)
00127 #if !defined(__STDC_CONSTANT_MACROS)
00128 #define __STDC_CONSTANT_MACROS
00129 #endif
00130 #if !defined(__STDC_LIMIT_MACROS)
00131 #define __STDC_LIMIT_MACROS
00132 #endif
00133 #include <stdint.h>
00134 
00135 #elif defined(os_freebsd)
00136 #if !defined(__STDC_CONSTANT_MACROS)
00137 #define __STDC_CONSTANT_MACROS
00138 #endif
00139 #if !defined(__STDC_LIMIT_MACROS)
00140 #define __STDC_LIMIT_MACROS
00141 #endif
00142 #include <stdint.h>
00143 typedef long double double128_t;
00144 
00145 /* FreeBSD doesn't define this */
00146 typedef int64_t off64_t;
00147 
00148 #elif defined(os_vxworks)
00149 #if !defined(__STDC_CONSTANT_MACROS)
00150 #define __STDC_CONSTANT_MACROS
00151 #endif
00152 #if !defined(__STDC_LIMIT_MACROS)
00153 #define __STDC_LIMIT_MACROS
00154 #endif
00155 #ifndef __RTLIB__
00156 #include <stdint.h>
00157 #endif
00158 #include <limits.h>
00159 #if !defined(INT64_C)
00160 #define INT64_C(c) ((signed long long) (c))
00161 #endif
00162 #if !defined(UINT64_C)
00163 #define UINT64_C(c) ((unsigned long long) (c))
00164 #endif
00165 
00166 #else
00167 #error Unknown architecture
00168 #endif
00169 
00170 
00171 /* Set up the 64 BIT LITERAL MACROS =================================== */
00172 #if defined(os_aix) && !defined(_H_INTTYPES)  /* aix4.2 ---- */
00173 #define I64_C(x)  (x##ll)
00174 #define UI64_C(x) (x##ull)
00175 #elif defined(os_osf)     /* osf ---------------------------- */
00176 #define I64_C(x)  (x##l)
00177 #define UI64_C(x) (x##ul)
00178 #elif defined(os_windows)
00179                    /* nt ----------------------------- */
00180 #define I64_C(x)  (x##i64)
00181 #define UI64_C(x) (x##ui64)
00182 #elif defined(os_bg)
00183 #define I64_C(x) (x##ll)
00184 #define U64_C(x) (x##ull)
00185 #else                               /* linux, solaris, irix, aix4.3 --- */
00186 #define I64_C(x)  INT64_C(x)
00187 #define UI64_C(x) UINT64_C(x)
00188 #endif
00189 
00190 /* Set up the 32 and 64 BIT LIMITS for those not already set up ======= */
00191 #if defined(os_osf)  || (defined(os_aix) && !defined(_H_INTTYPES))
00192 #define INT32_MAX  (2147483647)
00193 #define UINT32_MAX (4294967295U)
00194 #define INT32_MIN  (-2147483647-1)
00195 #endif
00196 
00197                                    /* solaris, aix4.{23}, osf -------- */
00198 #if defined(os_aix)
00199 /* see note (*) above */
00200 #define I32_MAX    INT32_MAX
00201 #define UI32_MAX   UINT32_MAX
00202 #define I32_MIN    INT32_MIN
00203 #define I64_MAX    I64_C(9223372036854775807)
00204 #define UI64_MAX   UI64_C(18446744073709551615)
00205 /* The GNU compilers on solaris and aix have what seems like a bug where a
00206    warning is printed when the ...808 int64 minimum is used, so we'll get the
00207    value with some trickery */
00208 #define I64_MIN    (-I64_MAX-1)
00209 
00210 #elif defined(os_windows)
00211              /* nt ----------------------------- */
00212 #include <limits.h>
00213 #define I64_MAX  _I64_MAX
00214 #define UI64_MAX _UI64_MAX
00215 #define I64_MIN  _I64_MIN
00216 #define I32_MAX  _I32_MAX
00217 #define I32_MIN  _I32_MIN
00218 #define UI32_MAX  _UI32_MAX
00219 #else                              /* linux, irix -------------------- */
00220 #define I64_MAX  INT64_MAX
00221 #define UI64_MAX UINT64_MAX
00222 #define I64_MIN  INT64_MIN
00223 #define I32_MAX  INT32_MAX
00224 #define I32_MIN  INT32_MIN
00225 #define UI32_MAX UINT32_MAX
00226 #endif
00227 
00228    /*
00229 typedef int64_t time64;
00230 */
00231 
00232 #if defined(__cplusplus)
00233 #include "dynutil/h/dyntypes.h"
00234 using namespace Dyninst;
00235 static const Address ADDR_NULL = (Address)(0);
00236 #else
00237 #define ADDR_NULL (0)
00238 typedef unsigned long Address;
00239 #endif
00240 /* Note the inherent assumption that the size of a "long" integer matches
00241    that of an address (void*) on every supported Paradyn/Dyninst system!
00242    (This can be checked with Address_chk().)
00243 */
00244 
00245 typedef unsigned int Word;
00246 
00247 typedef long int RegValue;      /* register content */
00248 /* This needs to be an int since it is sometimes used to pass offsets
00249    to the code generator (i.e. if-statement) - jkh 5/24/99 */
00250 typedef unsigned int Register;  /* a register number, e.g., [0..31]  */
00251 static const Register Null_Register = (Register)(-1);   /* '255' */
00252 /* Easily noticeable name... */
00253 static const Register REG_NULL = (Register)(-1);
00254 
00255 // Virtual Memory Map -- shared between platforms
00256 #define PREMS_PRIVATE (1 << 4)
00257 #define PREMS_SHARED  (1 << 3)
00258 #define PREMS_READ    (1 << 2)
00259 #define PREMS_WRITE   (1 << 1)
00260 #define PREMS_EXEC    (1 << 0)
00261 
00262 #define MAPENTRIES_PATH_SIZE 512
00263 #define MAPENTRIES_PATH_SIZE_STR "512"
00264 typedef struct maps_entries {
00265    Address start;
00266    Address end;
00267    unsigned prems;
00268    Address offset;
00269    int dev_major;
00270    int dev_minor;
00271    int inode;
00272    char path[MAPENTRIES_PATH_SIZE];
00273 } map_entries;
00274 
00275 #ifdef __cplusplus
00276 
00277 #include "dynutil/h/util.h"
00278 
00279 COMMON_EXPORT void Address_chk ();
00280 COMMON_EXPORT char *Address_str (Address addr);
00281 
00282 // NB: this is probably inappropriate for 64-bit addresses!
00283 inline unsigned hash_address(const Address& addr) {
00284    return (unsigned) ((addr >> 2) & 0xffffffff);
00285 }
00286 #endif /* __cplusplus */
00287 
00288 #endif /* !defined(_Types_h_) */
00289 
00290 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1