From: Vladimir Mezentsev Date: Fri, 17 Mar 2023 00:19:23 +0000 (-0700) Subject: gprofng: Use prototype to call libc functions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=de8e70596896cc9f85498a9981196ebc4465172e;p=binutils-gdb.git gprofng: Use prototype to call libc functions libcollector may not link against libC. We use dlsym() to get a function from libc. In some files, pointers to these functions do not have prototypes. I also moved the shared definitions to libcollector/collect.h. gprofng/ChangeLog 2023-03-15 Vladimir Mezentsev libcollector/collector.c: Add prototypes. libcollector/dispatcher.c: Likewise. libcollector/heaptrace.c: Likewise. libcollector/iotrace.c: Likewise. libcollector/linetrace.c: Likewise. libcollector/mmaptrace.c: Likewise. libcollector/synctrace.c: Likewise. libcollector/collector.h: Add CALL_REAL(), NULL_PTR(), and DBG_LT. --- diff --git a/gprofng/libcollector/collector.c b/gprofng/libcollector/collector.c index 55c52548b4e..df493658df9 100644 --- a/gprofng/libcollector/collector.c +++ b/gprofng/libcollector/collector.c @@ -37,12 +37,6 @@ #include "cc_libcollector.h" #include "tsd.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 - typedef unsigned long ulong_t; extern char **environ; @@ -2455,11 +2449,8 @@ __collector_dlog (int tflag, int level, char *format, ...) */ /*------------------------------------------------------------- _exit */ -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) - -static void *__real__exit = NULL; /* libc only: _exit */ -static void *__real__Exit = NULL; /* libc only: _Exit */ +static void (*__real__exit) (int status) = NULL; /* libc only: _exit */ +static void (*__real__Exit) (int status) = NULL; /* libc only: _Exit */ void _exit () __attribute__ ((weak, alias ("__collector_exit"))); void _Exit () __attribute__ ((weak, alias ("__collector_Exit"))); diff --git a/gprofng/libcollector/collector.h b/gprofng/libcollector/collector.h index d771cf1d07a..77957ec537d 100644 --- a/gprofng/libcollector/collector.h +++ b/gprofng/libcollector/collector.h @@ -29,6 +29,8 @@ #include "collector_module.h" #define GETRELTIME() (__collector_gethrtime() - __collector_start_time) +#define CALL_REAL(x) (__real_##x) +#define NULL_PTR(x) (__real_##x == NULL) #if defined(__MUSL_LIBC) #define dlvsym(f, nm, v) dlsym (f, nm) @@ -171,6 +173,17 @@ enum SP_DUMP_STACK = 32, }; +/* TprintfT(,...) definitions. Adjust per module as needed */ +enum +{ + DBG_LT0 = 0, // for high-level configuration, unexpected errors/warnings + DBG_LTT = 0, // for interposition on GLIBC functions + DBG_LT1 = 1, // for configuration details, warnings + DBG_LT2 = 2, + DBG_LT3 = 3, + DBG_LT4 = 4 +}; + #ifndef DEBUG #define DprintfT(flag, ...) #define tprintf(...) diff --git a/gprofng/libcollector/dispatcher.c b/gprofng/libcollector/dispatcher.c index 0075f232cc8..5c5a06ec1b4 100644 --- a/gprofng/libcollector/dispatcher.c +++ b/gprofng/libcollector/dispatcher.c @@ -41,18 +41,10 @@ #include "collector_module.h" #include "tsd.h" #include "hwcdrv.h" - - -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 +#include "memmgr.h" static void collector_sigprof_dispatcher (int, siginfo_t*, void*); static int init_interposition_intf (); -#include "memmgr.h" static int collector_timer_create (timer_t * ptimerid); static int collector_timer_settime (int period, timer_t timerid); static int collector_timer_gettime (timer_t timerid); @@ -61,20 +53,28 @@ static timer_t collector_master_thread_timerid = NULL; static collector_mutex_t collector_clone_libc_lock = COLLECTOR_MUTEX_INITIALIZER; static unsigned dispatcher_key = COLLECTOR_TSD_INVALID_KEY; -static void *__real_clone = NULL; -static void *__real_timer_create = NULL; -static void *__real_timer_settime = NULL; -static void *__real_timer_delete = NULL; -static void *__real_timer_gettime = NULL; +static int (*__real_clone) (int (*fn)(void *), void *child_stack, int flags, + void *arg, ...) = NULL; +static int (*__real_timer_create) (clockid_t clockid, + struct sigevent *sevp, timer_t *timerid) = NULL; +static int (*__real_timer_settime) (timer_t timerid, int flags, + const struct itimerspec *new_value, + struct itimerspec *old_value) = NULL; +static int (*__real_timer_delete) (timer_t timerid) = NULL; +static int (*__real_timer_gettime) (timer_t timerid, + struct itimerspec *curr_value) = NULL; #if ARCH(Intel) && WSIZE(32) -static void *__real_pthread_create_2_1 = NULL; -static void *__real_pthread_create_2_0 = NULL; +static int (*__real_pthread_create_2_1) (pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), void *arg) = NULL; +static int (*__real_pthread_create_2_0) (pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), void *arg) = NULL; #elif ARCH(Intel) && WSIZE(64) -static void *__real_timer_create_2_3_3 = NULL; -static void *__real_timer_create_2_2_5 = NULL; -#elif ARCH(SPARC) && WSIZE(64) -static void *__real_timer_create_2_3_3 = NULL; -static void *__real_timer_create_2_2 = NULL; +static int (*__real_timer_create_2_3_3) (clockid_t clockid, + struct sigevent *sevp, timer_t *timerid) = NULL; +static int (*__real_timer_create_2_2_5) (clockid_t clockid, + struct sigevent *sevp, timer_t *timerid) = NULL; #endif /* Original SIGPROF handler which will be replaced with the dispatcher. Used @@ -93,16 +93,21 @@ static int dispatch_mode = DISPATCH_NYI; /* controls SIGPROF dispatching */ static int itimer_period_requested = 0; /* dispatcher itimer period */ static int itimer_period_actual = 0; /* actual dispatcher itimer period */ -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) - -static void *__real_sigaction = NULL; -static void *__real_setitimer = NULL; -static void *__real_libc_setitimer = NULL; -static void *__real_sigprocmask = NULL; -static void *__real_thr_sigsetmask = NULL; -static void *__real_pthread_sigmask = NULL; -static void *__real_pthread_create = NULL; +static int (*__real_sigaction) (int signum, const struct sigaction *act, + struct sigaction *oldact) = NULL; +static int (*__real_setitimer) (int which, const struct itimerval *new_value, + struct itimerval *old_value) = NULL; +static int (*__real_libc_setitimer) (int which, + const struct itimerval *new_value, struct itimerval *old_value) = NULL; +static int (*__real_sigprocmask) (int how, const sigset_t *set, + sigset_t *oldset) = NULL; +static int (*__real_thr_sigsetmask) (int how, const sigset_t *iset, + sigset_t *oset) = NULL; +static int (*__real_pthread_sigmask) (int how, const sigset_t *set, + sigset_t *oldset) = NULL; +static int (*__real_pthread_create) (pthread_t *thread, + const pthread_attr_t *attr, + void *(*start_routine) (void *), void *arg) = NULL; /* * void collector_sigprof_dispatcher() diff --git a/gprofng/libcollector/heaptrace.c b/gprofng/libcollector/heaptrace.c index 387d2a13c00..b51ab330ba6 100644 --- a/gprofng/libcollector/heaptrace.c +++ b/gprofng/libcollector/heaptrace.c @@ -26,18 +26,11 @@ #include #include "gp-defs.h" -#include "collector_module.h" +#include "collector.h" #include "gp-experiment.h" #include "data_pckts.h" #include "tsd.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 -#define DBG_LT4 4 - /* define the packets to be written out */ typedef struct Heap_packet { /* Malloc/free tracing packet */ @@ -73,18 +66,8 @@ static unsigned heap_key = COLLECTOR_TSD_INVALID_KEY; #define CHCK_REENTRANCE(x) ( !heap_mode || ((x) = collector_interface->getKey( heap_key )) == NULL || (*(x) != 0) ) #define PUSH_REENTRANCE(x) ((*(x))++) #define POP_REENTRANCE(x) ((*(x))--) -#define CALL_REAL(x) (__real_##x) -#define NULL_PTR(x) (__real_##x == NULL) #define gethrtime collector_interface->getHiResTime -#ifdef DEBUG -#define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ ) -#define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ ) -#else -#define Tprintf(...) -#define TprintfT(...) -#endif - static void *(*__real_malloc)(size_t) = NULL; static void (*__real_free)(void *); static void *(*__real_realloc)(void *, size_t); diff --git a/gprofng/libcollector/iotrace.c b/gprofng/libcollector/iotrace.c index d8439b02b3a..303e755df6e 100644 --- a/gprofng/libcollector/iotrace.c +++ b/gprofng/libcollector/iotrace.c @@ -39,12 +39,6 @@ #include "data_pckts.h" #include "tsd.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 /* define the packet that will be written out */ typedef struct IOTrace_packet @@ -88,19 +82,8 @@ static unsigned io_key = COLLECTOR_TSD_INVALID_KEY; #define RECHCK_REENTRANCE(x) (!io_mode || ((x) = collector_interface->getKey( io_key )) == NULL || (*(x) == 0)) #define PUSH_REENTRANCE(x) ((*(x))++) #define POP_REENTRANCE(x) ((*(x))--) - -#define CALL_REAL(x) (__real_##x) -#define NULL_PTR(x) (__real_##x == NULL) - #define gethrtime collector_interface->getHiResTime -#ifdef DEBUG -#define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ ) -#define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ ) -#else -#define Tprintf(...) -#define TprintfT(...) -#endif /* interposition function handles */ static int (*__real_open)(const char *path, int oflag, ...) = NULL; diff --git a/gprofng/libcollector/linetrace.c b/gprofng/libcollector/linetrace.c index 66241ac1f53..fd8e54a7973 100644 --- a/gprofng/libcollector/linetrace.c +++ b/gprofng/libcollector/linetrace.c @@ -30,17 +30,10 @@ #include #include #include - +#include #include "descendants.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 - #define LT_MAXNAMELEN 1024 #define LT_MAXPATHLEN 1024 @@ -63,51 +56,77 @@ static int line_initted = 0; static collector_mutex_t fork_lineage_lock = COLLECTOR_MUTEX_INITIALIZER; static collector_mutex_t clone_lineage_lock = COLLECTOR_MUTEX_INITIALIZER; -/* interposition */ -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define CALL_REALC(x) (*(char*(*)())__real_##x) -#define CALL_REALF(x) (*(FILE*(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) - // For a given Linux, which lib functions have more than one GLIBC version? Do this: // objdump -T `find /lib /lib64 -name "*.so*"` | grep GLIBC | grep text | grep \( -static void *__real_fork = NULL; -static void *__real_vfork = NULL; -static void *__real_execve = NULL; -static void *__real_execvp = NULL; -static void *__real_execv = NULL; -static void *__real_execle = NULL; -static void *__real_execlp = NULL; -static void *__real_execl = NULL; -static void *__real_clone = NULL; -static void *__real_grantpt = NULL; -static void *__real_ptsname = NULL; -static void *__real_popen = NULL; +static pid_t (*__real_fork) (void) = NULL; +static pid_t (*__real_vfork) (void) = NULL; +static int (*__real_execve) (const char *file, char *const argv[], + char *const envp[]) = NULL; +static int (*__real_execvp) (const char *file, char *const argv[]) = NULL; +static int (*__real_execv) (const char *file, char *const argv[]) = NULL; +static int (*__real_execle) (const char *path, const char *arg, ...) = NULL; +static int (*__real_execlp) (const char *file, const char *arg, ...) = NULL; +static int (*__real_execl) (const char *file, const char *arg, ...) = NULL; +static int (*__real_clone) (int (*fn) (void *), void *child_stack, + int flags, void *arg, ...) = NULL; +static int (*__real_grantpt) (int fd) = NULL; +static char *(*__real_ptsname) (int fd) = NULL; +static FILE *(*__real_popen) (const char *command, const char *type) = NULL; static int clone_linenum = 0; #if ARCH(Intel) #if WSIZE(32) -static void *__real_popen_2_1 = NULL; -static void *__real_popen_2_0 = NULL; -static void *__real_posix_spawn_2_15 = NULL; -static void *__real_posix_spawnp_2_15 = NULL; -static void *__real_posix_spawn_2_2 = NULL; -static void *__real_posix_spawnp_2_2 = NULL; +static FILE *(*__real_popen_2_1) (const char *command, const char *type) = NULL; +static FILE *(*__real_popen_2_0) (const char *command, const char *type) = NULL; +static int (*__real_posix_spawn_2_15) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawn_2_2) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_15) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_2) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; #elif WSIZE(64) -static void *__real_posix_spawn_2_15 = NULL; -static void *__real_posix_spawnp_2_15 = NULL; -static void *__real_posix_spawn_2_2_5 = NULL; -static void *__real_posix_spawnp_2_2_5 = NULL; +static int (*__real_posix_spawn_2_15) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawn_2_2_5) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_15) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp_2_2_5) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; #endif /* WSIZE() */ #endif /* ARCH(Intel) */ -static void *__real_system = NULL; -static void *__real_posix_spawn = NULL; -static void *__real_posix_spawnp = NULL; -static void *__real_setuid = NULL; -static void *__real_seteuid = NULL; -static void *__real_setreuid = NULL; -static void *__real_setgid = NULL; -static void *__real_setegid = NULL; -static void *__real_setregid = NULL; +static int (*__real_system) (const char *command) = NULL; +static int (*__real_posix_spawn) (pid_t *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_posix_spawnp) (pid_t *pid, const char *file, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, + char *const argv[], char *const envp[]) = NULL; +static int (*__real_setuid) (uid_t uid) = NULL; +static int (*__real_seteuid) (uid_t euid) = NULL; +static int (*__real_setreuid) (uid_t ruid, uid_t euid) = NULL; +static int (*__real_setgid) (gid_t gid) = NULL; +static int (*__real_setegid) (gid_t egid) = NULL; +static int (*__real_setregid) (gid_t rgid, gid_t egid)= NULL; static void linetrace_dormant (); static int check_follow_fork (); static int check_follow_exec (const char *execfile); @@ -1604,7 +1623,7 @@ __collector_popen_2_1 (const char *cmd, const char *mode) if (NULL_PTR (popen)) init_lineage_intf (); TprintfT (DBG_LTT, "linetrace: GLIBC: __collector_popen_2_1@%p\n", CALL_REAL (popen_2_1)); - return __collector_popen_symver (CALL_REALF (popen_2_1), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_1), cmd, mode); } SYMVER_ATTRIBUTE (__collector_popen_2_0, popen@GLIBC_2.0) @@ -1614,7 +1633,7 @@ __collector_popen_2_0 (const char *cmd, const char *mode) if (NULL_PTR (popen)) init_lineage_intf (); TprintfT (DBG_LTT, "linetrace: GLIBC: __collector_popen_2_0@%p\n", CALL_REAL (popen_2_0)); - return __collector_popen_symver (CALL_REALF (popen_2_0), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_0), cmd, mode); } SYMVER_ATTRIBUTE (__collector__popen_2_1, _popen@GLIBC_2.1) @@ -1624,7 +1643,7 @@ __collector__popen_2_1 (const char *cmd, const char *mode) if (NULL_PTR (popen)) init_lineage_intf (); TprintfT (DBG_LTT, "linetrace: GLIBC: __collector__popen_2_1@%p\n", CALL_REAL (popen_2_1)); - return __collector_popen_symver (CALL_REALF (popen_2_1), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_1), cmd, mode); } SYMVER_ATTRIBUTE (__collector__popen_2_0, _popen@GLIBC_2.0) @@ -1633,7 +1652,7 @@ __collector__popen_2_0 (const char *cmd, const char *mode) { if (NULL_PTR (popen)) init_lineage_intf (); - return __collector_popen_symver (CALL_REALF (popen_2_0), cmd, mode); + return __collector_popen_symver (CALL_REAL (popen_2_0), cmd, mode); } #else // WSIZE(64) FILE * popen () __attribute__ ((weak, alias ("__collector_popen"))); @@ -1662,7 +1681,7 @@ __collector_popen (const char *cmd, const char *mode) #if ARCH(Intel) && WSIZE(32) return (real_popen) (cmd, mode); #else - return CALL_REALF (popen)(cmd, mode); + return CALL_REAL (popen)(cmd, mode); #endif } int following_combo = 0; @@ -1671,7 +1690,7 @@ __collector_popen (const char *cmd, const char *mode) #if ARCH(Intel) && WSIZE(32) ret = (real_popen) (cmd, mode); #else - ret = CALL_REALF (popen)(cmd, mode); + ret = CALL_REAL (popen)(cmd, mode); #endif POP_REENTRANCE (guard); linetrace_ext_combo_epilogue ("popen", (ret == NULL) ? (-1) : 0, &following_combo); @@ -1718,11 +1737,11 @@ __collector_ptsname (const int fildes) if (line_mode == LM_TRACK_LINEAGE) INIT_REENTRANCE (guard); if (guard == NULL) - return CALL_REALC (ptsname)(fildes); + return CALL_REAL (ptsname)(fildes); int following_combo = 0; linetrace_ext_combo_prologue ("ptsname", "/usr/lib/pt_chmod", &following_combo); PUSH_REENTRANCE (guard); - char *ret = CALL_REALC (ptsname)(fildes); + char *ret = CALL_REAL (ptsname)(fildes); POP_REENTRANCE (guard); linetrace_ext_combo_epilogue ("ptsname", (ret == NULL) ? (-1) : 1, &following_combo); return ret; diff --git a/gprofng/libcollector/mmaptrace.c b/gprofng/libcollector/mmaptrace.c index 221b4e2d176..c46dac4e0aa 100644 --- a/gprofng/libcollector/mmaptrace.c +++ b/gprofng/libcollector/mmaptrace.c @@ -61,13 +61,6 @@ typedef struct prmap_t int pr_pagesize; /* pagesize (bytes) for this mapping */ } prmap_t; -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 -#define DBG_LT4 4 - #define SYS_MMAP_NAME "mmap" #define SYS_MMAP64_NAME "mmap64" #define SYS_MUNMAP_NAME "munmap" @@ -113,9 +106,6 @@ static int reentrance = 0; #define PUSH_REENTRANCE reentrance++ #define POP_REENTRANCE reentrance-- -#define CALL_REAL(x) (__real_##x) -#define NULL_PTR(x) (__real_##x == NULL) - /* interposition function handles */ static void *(*__real_mmap)(void* start, size_t length, int prot, int flags, int fd, off_t offset) = NULL; diff --git a/gprofng/libcollector/synctrace.c b/gprofng/libcollector/synctrace.c index cbe4e46533d..c50151bbd52 100644 --- a/gprofng/libcollector/synctrace.c +++ b/gprofng/libcollector/synctrace.c @@ -38,13 +38,6 @@ #include "tsd.h" #include "cc_libcollector.h" -/* TprintfT(,...) definitions. Adjust per module as needed */ -#define DBG_LT0 0 // for high-level configuration, unexpected errors/warnings -#define DBG_LTT 0 // for interposition on GLIBC functions -#define DBG_LT1 1 // for configuration details, warnings -#define DBG_LT2 2 -#define DBG_LT3 3 - /* define the packet that will be written out */ typedef struct Sync_packet { /* Synchronization delay tracing packet */ @@ -88,19 +81,8 @@ static int init_thread_intf_finished = 0; #define RECHCK_JREENTRANCE(x) (!sync_java || !sync_mode || ((x) = collector_interface->getKey( sync_key )) == NULL || (*(x) == 0)) #define PUSH_REENTRANCE(x) ((*(x))++) #define POP_REENTRANCE(x) ((*(x))--) - -#define CALL_REAL(x) (*(int(*)())__real_##x) -#define NULL_PTR(x) ( __real_##x == NULL ) #define gethrtime collector_interface->getHiResTime -#ifdef DEBUG -#define Tprintf(...) if (collector_interface) collector_interface->writeDebugInfo( 0, __VA_ARGS__ ) -#define TprintfT(...) if (collector_interface) collector_interface->writeDebugInfo( 1, __VA_ARGS__ ) -#else -#define Tprintf(...) -#define TprintfT(...) -#endif - /* * In most cases, the functions which require interposition are implemented as * weak symbols corresponding to an associated internal function named with a @@ -109,26 +91,36 @@ static int init_thread_intf_finished = 0; * is distinct from the internal version (used by system libraries), i.e., * cond_wait() is an alias for _cond_wait_cancel() rather than _cond_wait(). */ -static void *__real_strtol = NULL; -static void *__real_fprintf = NULL; -static void *__real___collector_jprofile_enable_synctrace = NULL; -static void *__real_pthread_mutex_lock = NULL; -static void *__real_pthread_mutex_unlock = NULL; /* not interposed, used in calibrate */ -static void *__real_pthread_cond_wait = NULL; -static void *__real_pthread_cond_timedwait = NULL; -static void *__real_pthread_join = NULL; -static void *__real_sem_wait = NULL; -static void *__real_pthread_cond_wait_2_3_2 = NULL; -static void *__real_pthread_cond_timedwait_2_3_2 = NULL; +static long int (*__real_strtol)(const char *nptr, char **endptr, int base) = NULL; +static int (*__real_fprintf) (FILE *stream, const char *format, ...) = NULL; +static void (*__real___collector_jprofile_enable_synctrace) (void) = NULL; +static int (*__real_pthread_mutex_lock) (pthread_mutex_t *mutex) = NULL; +static int (*__real_pthread_mutex_unlock) (pthread_mutex_t *mutex) = NULL; +static int (*__real_pthread_cond_wait) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; +static int (*__real_pthread_cond_timedwait) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) = NULL; +static int (*__real_pthread_join) (pthread_t thread, void **retval) = NULL; +static int (*__real_sem_wait) (sem_t *sem) = NULL; +static int (*__real_pthread_cond_wait_2_3_2) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; +static int (*__real_pthread_cond_timedwait_2_3_2) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) = NULL; #if WSIZE(32) -static void *__real_sem_wait_2_1 = NULL; -static void *__real_sem_wait_2_0 = NULL; -static void *__real_pthread_cond_wait_2_0 = NULL; -static void *__real_pthread_cond_timedwait_2_0 = NULL; +static int (*__real_sem_wait_2_1) (sem_t *sem) = NULL; +static int (*__real_sem_wait_2_0) (sem_t *sem) = NULL; +static int (*__real_pthread_cond_wait_2_0) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; +static int (*__real_pthread_cond_timedwait_2_0) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex, + const struct timespec *restrict abstime) = NULL; #elif WSIZE(64) #if ARCH(Intel) -static void *__real_pthread_cond_wait_2_2_5 = NULL; +static int (*__real_pthread_cond_wait_2_2_5) (pthread_cond_t *restrict cond, + pthread_mutex_t *restrict mutex) = NULL; static void *__real_pthread_cond_timedwait_2_2_5 = NULL; #elif ARCH(SPARC) static void *__real_pthread_cond_wait_2_2 = NULL;