#ifndef _INCLUDE_TLIB_NATIVE_UTILS_H_ #define _INCLUDE_TLIB_NATIVE_UTILS_H_ #include "mem-common.h" #include "primitives.h" #define _TOSTR_HELP(x) #x #define _TOSTR(x) _TOSTR_HELP(x) /* __TI_CURRENT_FUNCTION__ is re-defined for code-genned methods to a demangled name, but try to get one from the C compiler for native code */ #if defined(__GNUC__) || defined(__FUNCTION__) #define __TI_CURRENT_FUNCTION__ __FUNCTION__ #elif defined(HAVE_FUNC) /* __func__ should also work for ISO C99 compilers */ #define __TI_CURRENT_FUNCTION__ __func__ #else #define __TI_CURRENT_FUNCTION__ "" #endif extern char *build_loc_str(const char *funcname, const char *filename, int linenum); #define __current_loc build_loc_str(__TI_CURRENT_FUNCTION__,__FILE__,__LINE__) /* TI_IDENT() takes a unique identifier and a textual string and embeds the textual string in the executable file */ #define TI_PRAGMA(x) _Pragma ( #x ) #define _TI_IDENT(identName, identText) \ extern char volatile identName[]; \ char volatile identName[] = identText; \ extern char *_get_##identName() { return (char*)identName; } \ static int _dummy_##identName = sizeof(_dummy_##identName) #if defined(_CRAYC) #define TI_IDENT(identName, identText) \ TI_PRAGMA(_CRI ident identText); \ _TI_IDENT(identName, identText) #elif defined(__xlC__) /* #pragma comment(user,"text...") or _Pragma ( "comment (user,\"text...\")" ); are both supposed to work according to compiler docs, but both appear to be broken */ #define TI_IDENT(identName, identText) \ _TI_IDENT(identName, identText) #else #define TI_IDENT _TI_IDENT #endif #define CHECK_NULL_GLOBAL( object ) \ do { \ if (PREDICT_FALSE(isNull(object))) \ tossNullPointerException_str(__current_loc); \ } while(0) #define CHECK_NULL_LOCAL( object ) \ do { \ if (PREDICT_FALSE(!(object))) \ tossNullPointerException_str(__current_loc); \ } while(0) #ifdef COMM_GASNET #define TI_BEGIN_FUNCTION GASNET_BEGIN_FUNCTION(); #else #define TI_BEGIN_FUNCTION #endif void tossNullPointerException_str(char * const string) __attribute__((noreturn) ); void tossMonitorStateException_str(char * const string) __attribute__((noreturn)); void tossArrayStoreException_str(char * const string) __attribute__((noreturn)); void tossIllegalArgumentException_str(char * const string) __attribute__((noreturn)); #ifdef HAVE_DREM #define IEEEremainder drem #else #ifdef HAVE_REMAINDER #define IEEEremainder remainder #else #error Cannot locate IEEE remainder function. #endif #endif #endif