dyntypes.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #if !defined(DYNTYPES_H)
00032 #define DYNTYPES_H
00033
00034 #if defined(_MSC_VER)
00035 #define WIN32_LEAN_AND_MEAN
00036 #include <windows.h>
00037 #include <winsock2.h>
00038 #endif
00039
00040 #ifndef FILE__
00041 #define FILE__ strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__
00042 #endif
00043
00044 #if defined(_POWER) && !defined(__GNUC__)
00045 #define XLC
00046 #endif
00047
00048 #if defined (_MSC_VER)
00049
00050 #include <hash_map>
00051 #define dyn_hash_map stdext::hash_map
00052 #define dyn_hash_set std::hash_set
00053 #define DECLTHROW(x)
00054 #elif defined(__GNUC__)
00055 #include <functional>
00056 #define DECLTHROW(x) throw(x)
00057
00058 #if (__GNUC__ > 4) || \
00059 (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
00060
00061 #include <tr1/unordered_set>
00062 #include <tr1/unordered_map>
00063 #define cap_tr1
00064 #define dyn_hash_set std::tr1::unordered_set
00065 #define dyn_hash_map std::tr1::unordered_map
00066 #else
00067
00068 #include <ext/hash_map>
00069 #include <ext/hash_set>
00070 #include <string>
00071 #define dyn_hash_set __gnu_cxx::hash_set
00072 #define dyn_hash_map __gnu_cxx::hash_map
00073 namespace Dyninst {
00074 unsigned ptrHash(void * addr);
00075 }
00076 using namespace __gnu_cxx;
00077 namespace __gnu_cxx {
00078
00079 template<> struct hash<std::string> {
00080 hash<char*> h;
00081 unsigned operator()(const std::string &s) const
00082 {
00083 const char *cstr = s.c_str();
00084 return h(cstr);
00085 };
00086 };
00087
00088 template<> struct hash<void *> {
00089 unsigned operator()(void *v) const
00090 {
00091 return Dyninst::ptrHash(v);
00092 };
00093 };
00094
00095 }
00096 #endif
00097 #elif defined(XLC)
00098 #define __IBMCPP_TR1__ 1
00099
00100 #include <functional>
00101 #include <unordered_set>
00102 #include <unordered_map>
00103 #define dyn_hash_set std::tr1::unordered_set
00104 #define dyn_hash_map std::tr1::unordered_map
00105 #define DECLTHROW(x)
00106 #else
00107 #error Unknown compiler
00108 #endif
00109
00110
00111 namespace Dyninst
00112 {
00113 typedef unsigned long Address;
00114 typedef unsigned long Offset;
00115
00116 #if defined(_MSC_VER)
00117 typedef int PID;
00118 typedef HANDLE PROC_HANDLE;
00119 typedef HANDLE LWP;
00120 typedef HANDLE THR_ID;
00121 typedef DWORD psaddr_t;
00122
00123 #define NULL_PID -1
00124 #define NULL_LWP INVALID_HANDLE_VALUE
00125 #define NULL_THR_ID INVALID_HANDLE_VALUE
00126 #define DYNINST_SINGLETHREADED INVALID_HANDLE_VALUE
00127 #else
00128 typedef int PID;
00129 typedef int PROC_HANDLE;
00130 typedef int LWP;
00131 typedef long THR_ID;
00132
00133 #define NULL_PID -1
00134 #define NULL_LWP -1
00135 #define NULL_THR_ID -1
00136 #ifndef INVALID_HANDLE_VALUE
00137 #define INVALID_HANDLE_VALUE -1
00138 #endif
00139 #endif
00140
00141 int ThrIDToTid(Dyninst::THR_ID id);
00142 }
00143
00144 namespace Dyninst
00145 {
00146 typedef enum {
00147 OSNone,
00148 Linux,
00149 FreeBSD,
00150 Windows,
00151 VxWorks,
00152 BlueGeneL,
00153 BlueGeneP,
00154 BlueGeneQ
00155 } OSType;
00156 }
00157
00158 #include "dyn_regs.h"
00159 #endif