Changeset a15586 in git
- Timestamp:
- Nov 9, 2011, 3:18:30 PM (12 years ago)
- Branches:
- (u'spielwiese', '91fdef05f09f54b8d58d92a472e9c4a43aa4656f')
- Children:
- 61b2e164cc25fb30ef24c1f947cb188d72824bb7
- Parents:
- 2cba98d996d3093dcc04573bc6024bb750518d4f
- git-author:
- Burcin Erocal <burcin@erocal.org>2011-11-09 15:18:30+01:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2011-11-09 20:32:41+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
omalloc/omReturn.h
r2cba98d ra15586 24 24 25 25 /* 26 * This file contains the definition of the SET_RET_ADDR macro which26 * This file contains the definition of the GET_RET_ADDR macro which 27 27 * is designed to contain the archecture/compiler specific hacks to 28 28 * determine the return-address from inside the malloc library. With … … 39 39 * __builtin_return_address(0); with gcc version 2+ should give you a 40 40 * good start on building a hack for your box. 41 * 42 * NOTE: the hacks mentioned above were removed in favor of the GCC macro 43 * __builtin_return_address(). Assumptions made in these hacks break for 44 * recent GCC versions. 41 45 */ 42 46 … … 44 48 #define __OM_RETURN_H__ 45 49 46 /*************************************/47 48 /* for Sun SparcStations with GCC */49 #if __sparc && __GNUC__ > 150 51 /*52 * NOTE: %i7 seems to be more reliable than the [%fp+4] used by53 * __builtin_return_address. [%fp+4] is on the stack however, meaning54 * it may be better -- less prone to be erased. However, it produces55 * some bogus data -- it seems to return the last return-address or56 * something like that.57 *58 * Alexandre Oliva <oliva@dcc.unicamp.br> recently advised to change59 * the "=g" to a "=m". If you are having problems, you may want to60 * return to the =g to see if it works.61 */62 #define GET_RET_ADDR(file) asm("st %%i7,%0" : \63 "=m" (file) : \64 /* no inputs */ )65 66 #if 067 68 /* this was the default however =g was recommended to be changed to =m */69 #define GET_RET_ADDR(file) asm("st %%i7,%0" : \70 "=g" (file) : \71 /* no inputs */ )72 73 /*74 * This was what the gcc __builtin_return_address returned. The above75 * versions worked better. It is here for reference purposes only.76 */77 #define GET_RET_ADDR(file) asm("ld [%%fp+4],%%o0; st %%o0,%0" : \78 "=g" (file) : \79 /* no inputs */ : \80 "o0")81 #endif82 83 #endif /* __sparc */84 85 /*************************************/86 87 /* for i[34]86 machines with GCC */88 #if __i386 && __GNUC__ > 189 90 #define GET_RET_ADDR(file) asm("movl 4(%%ebp),%%eax ; movl %%eax,%0" : \91 "=g" (file) : \92 /* no inputs */ : \93 "eax")94 95 #endif /* __i386 */96 97 /*************************************/98 99 /*100 * For DEC Mips machines running Ultrix101 */102 #if __mips103 104 /*105 * I have no idea how to get inline assembly with the default cc.106 * Anyone know how?107 */108 109 #if 0110 111 /*112 * NOTE: we assume here that file is global.113 *114 * $31 is the frame pointer. $2 looks to be the return address but maybe115 * not consistently.116 */117 #define GET_RET_ADDR(file) asm("sw $2, file")118 119 #endif120 121 #endif /* __mips */122 123 /******************************* contributions *******************************/124 125 /*126 * For DEC Alphas running OSF. from Dave Hill <ddhill@zk3.dec.com>127 * and Alexandre Oliva <oliva@dcc.unicamp.br>. Thanks guys.128 */129 #if __alpha130 131 #ifdef __GNUC__132 133 #define GET_RET_ADDR(file) asm("bis $26, $26, %0" : "=r" (file))134 135 #else /* __GNUC__ */136 137 #include <c_asm.h>138 139 #define GET_RET_ADDR(file) file = (char *)asm("bis %ra,%ra,%v0")140 141 #endif /* __GNUC__ */142 143 #endif /* __alpha */144 145 /*************************************/146 147 /*148 * For Data General workstations running DG/UX 5.4R3.00 from Joerg149 * Wunsch <joerg_wunsch@julia.tcd-dresden.de>.150 */151 #ifdef __m88k__152 153 /*154 * I have no ideas about the syntax of Motorola SVR[34] assemblers.155 * Also, there may be occasions where gcc does not set up a stack156 * frame for some function, so the returned value should be taken with157 * a grain of salt. For the ``average'' function calls it proved to be158 * correct anyway -- jw159 */160 #if !__DGUX__ || _DGUXCOFF_TARGET161 # define M88K_RET_ADDR "ld %0,r30,4"162 #else /* __DGUX__ && !_DGUXCOFF_TARGET: DG/UX ELF with version 3 assembler */163 # define M88K_RET_ADDR "ld %0,#r30,4"164 #endif165 166 #define GET_RET_ADDR(file) asm(M88K_RET_ADDR : \167 "=r" (file) : \168 /* no inputs */)169 170 #endif /* m88k */171 172 /*************************************/173 174 /*175 * SGI compilers implement a C level method of accessing the return176 * address by simply referencing the __return_address symbol. -- James177 * Bonfield <jkb@mrc-lmb.cam.ac.uk>178 */179 #if defined(__sgi)180 181 #define GET_RET_ADDR(file) file = (void *)__return_address182 183 #endif /* __sgi */184 185 /*************************************/186 187 /*188 * Stratus FTX system (UNIX_System_V 4.0 FTX release 2.3.1.1 XA/R189 * Model 310 Intel i860XP processor)190 *191 * I ended up with compiling according to full-ANSI rules (using the192 * -Xa compiler option). This I could only do after modifying the193 * "dmalloc.h.3" in such a way that the malloc/calloc/realloc/free194 * definitions would no longer cause the compiler to bark with195 * 'identifier redeclared' (I just put an #ifdef _STDLIB_H ... #endif196 * around those functions). -- Wim_van_Duuren@stratus.com197 */198 #if defined(_FTX) && defined(i860)199 200 /*201 * we first have the define the little assembly code function202 */203 asm void ASM_GET_RET_ADDR(file)204 {205 % reg file;206 mov %r1, file207 % mem file;208 st.l %r31,-40(%fp)209 orh file@ha, %r0, %r31210 st.l %r1, file@l(%r31)211 ld.l -40(%fp),%r31212 % error213 }214 #define GET_RET_ADDR(file) ASM_GET_RET_ADDR(file)215 216 #endif /* _FTX & i860 */217 218 /*************************************/219 220 /*221 * For HP-UX PA-RISC with gcc/g++ from Jack Perdue222 * <j-perdue@tamu.edu>.223 */224 #if __hpux && __hppa && __GNUC__ > 1225 226 /*227 * This is my very first line of PA-RISC assembly ever. I have no228 * idea if is correct, but it seems to work. Register 2 (%r2)229 * contains the return address. The code generated by x =230 * __builtin_return_address() was considerably longer and without a231 * PA-RISC Instruction Set guide available (not even on the web), I232 * just put togther little tidbits of knowledge I found while looking233 * for one to take a stab with this. Like I said, it seems to work on234 * my g++ code under HPUX11 on a HP V-class system. YMMV. -- Jack235 * Perdue (j-perdue@tamu.edu)236 */237 #define GET_RET_ADDR(file) asm("stw %%r2, %0" : "=m" (file) : );238 239 #endif240 241 /*************************************/242 243 /*244 * For Powerpc 603 based system running LynxOS 2.3.1 using gcc/gas.245 * From Shawn Carey <smc@questra.com>.246 */247 #if defined(__powerpc__) && defined(__GNUC__) && !defined(__OPTIMIZE__)248 249 /*250 * This won't compile if "-O2" is used, but it seems to work fine with251 * "-O0". I'm no assembler expert; I was happy enough to come up with252 * something that works at all... :-)253 */254 255 #define GET_RET_ADDR(file) \256 do { \257 asm("mflr 0"); \258 asm("stw 0,%0" : "=g" (file)); \259 } while(0)260 261 #endif /* __powerpc__ && __GNUC__ && !__OPTIMIZE__ */262 263 /*************************************/264 50 265 51 /********************************** default **********************************/ 266 267 /* for all others, do nothing */268 52 #ifndef GET_RET_ADDR 269 53
Note: See TracChangeset
for help on using the changeset viewer.