diff --git a/ChangeLog b/ChangeLog index 0ac0807..2280d30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-21 Aleksey Demakov + + * include/jit/jit-walk.h (jit_get_next_frame_address): use + JIT_ARCH_GET_NEXT_FRAME if defined, use gcc syntax only if + defined __GNUC__. + 2008-05-12 Klaus Treichel * jit/jit-apply-x86-64.h: Include jit/jit-common.h instead of diff --git a/include/jit/jit-walk.h b/include/jit/jit-walk.h index 02db55c..cec87fd 100644 --- a/include/jit/jit-walk.h +++ b/include/jit/jit-walk.h @@ -33,10 +33,10 @@ extern "C" { */ void *_jit_get_frame_address(void *start, unsigned int n); #if defined(__GNUC__) -#define jit_get_frame_address(n) \ +# define jit_get_frame_address(n) \ (_jit_get_frame_address(jit_get_current_frame(), (n))) #else -#define jit_get_frame_address(n) (_jit_get_frame_address(0, (n))) +# define jit_get_frame_address(n) (_jit_get_frame_address(0, (n))) #endif /* @@ -47,66 +47,81 @@ void *_jit_get_frame_address(void *start, unsigned int n); * _JIT_ARCH_GET_CURRENT_FRAME() if available. */ #if defined(__GNUC__) -#if defined(_JIT_ARCH_GET_CURRENT_FRAME) -#define jit_get_current_frame() \ +# define JIT_FAST_GET_CURRENT_FRAME 1 +# if defined(_JIT_ARCH_GET_CURRENT_FRAME) +# define jit_get_current_frame() \ ({ \ void *address; \ _JIT_ARCH_GET_CURRENT_FRAME(address); \ address; \ }) +# else +# define jit_get_current_frame() (__builtin_frame_address(0)) +# endif #else -#define jit_get_current_frame() (__builtin_frame_address(0)) -#endif -#else -#define jit_get_current_frame() (jit_get_frame_address(0)) +# define JIT_FAST_GET_CURRENT_FRAME 0 +# define jit_get_current_frame() (jit_get_frame_address(0)) #endif /* * Get the next frame up the stack from a specified frame. * Returns NULL if it isn't possible to retrieve the next frame. */ -void *jit_get_next_frame_address(void *frame); +void *_jit_get_next_frame_address(void *frame); +#if defined(__GNUC__) && defined(_JIT_ARCH_GET_NEXT_FRAME) +# define jit_get_next_frame_address(frame) \ + ({ \ + void *address; \ + _JIT_ARCH_GET_NEXT_FRAME(address); \ + address; \ + }) +#else +# define jit_get_next_frame_address(frame) \ + (_jit_get_next_frame_address(frame)) +#endif /* * Get the return address for a specific frame. */ void *_jit_get_return_address(void *frame, void *frame0, void *return0); -#if defined(_JIT_ARCH_GET_RETURN_ADDRESS) -#define jit_get_return_address(frame) \ +#if defined(__GNUC__) +# if defined(_JIT_ARCH_GET_RETURN_ADDRESS) +# define jit_get_return_address(frame) \ ({ \ void *address; \ _JIT_ARCH_GET_RETURN_ADDRESS(address, (frame)); \ address; \ }) +# else +# define jit_get_return_address(frame) \ + (_jit_get_return_address \ + ((frame), \ + __builtin_frame_address(0), \ + __builtin_return_address(0))) +# endif #else -#if defined(__GNUC__) -#define jit_get_return_address(frame) \ - (_jit_get_return_address \ - ((frame), __builtin_frame_address(0), __builtin_return_address(0))) -#else -#define jit_get_return_address(frame) \ - (_jit_get_return_address((frame), 0, 0)) -#endif +# define jit_get_return_address(frame) \ + (_jit_get_return_address((frame), 0, 0)) #endif /* * Get the return address for the current frame. May be more efficient * than using "jit_get_return_address(0)". */ -#if defined(_JIT_ARCH_GET_CURRENT_RETURN) -#define jit_get_current_return() \ +#if defined(__GNUC__) +# if defined(_JIT_ARCH_GET_CURRENT_RETURN) +# define jit_get_current_return() \ ({ \ void *address; \ _JIT_ARCH_GET_CURRENT_RETURN(address); \ address; \ }) +# else +# define jit_get_current_return() (__builtin_return_address(0)) +# endif #else -#if defined(__GNUC__) -#define jit_get_current_return() (__builtin_return_address(0)) -#else -#define jit_get_current_return() \ - (jit_get_return_address(jit_get_current_frame())) -#endif +# define jit_get_current_return() \ + (jit_get_return_address(jit_get_current_frame())) #endif /* diff --git a/jit/jit-walk.c b/jit/jit-walk.c index 2e3143c..afeca6b 100644 --- a/jit/jit-walk.c +++ b/jit/jit-walk.c @@ -159,7 +159,7 @@ void *_jit_get_frame_address(void *start, unsigned int n) * the next frame up the stack. * @end deftypefun @*/ -void *jit_get_next_frame_address(void *frame) +void *_jit_get_next_frame_address(void *frame) { if(frame) {