diff --git a/Makefile b/Makefile index 67e6771..601e579 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,12 @@ ifeq ($m, 64) ARCH = -m64 endif -CFLAGS = $(ARCH) -O3 -std=gnu11 -Wall -mpclmul -march=core2 -mfpmath=sse -mssse3 -fno-strict-aliasing -fno-strict-overflow -fwrapv -DAES=1 -DCOMMIT=\"${COMMIT}\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -LDFLAGS = $(ARCH) -ggdb -rdynamic -lm -lrt -lcrypto -lz -lpthread -lcrypto +CFLAGS = $(ARCH) -O3 -std=gnu11 -Wall -mpclmul -march=core2 -mfpmath=sse -mssse3 -fcommon -fno-strict-aliasing -fno-strict-overflow -fwrapv -DAES=1 -DCOMMIT=\"${COMMIT}\" -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 +LDFLAGS = $(ARCH) -ggdb -rdynamic -lm -lrt -lz -lpthread -lcrypto +LIBEXECTEST = '\#include \nint main(){return backtrace(0,0);}' +ifeq ($(shell printf ${LIBEXECTEST} | gcc -x c -o /dev/null - -lexecinfo 2>/dev/null; echo $$?), 0) +LDFLAGS := ${LDFLAGS} -lexecinfo # For systems without glibc e.g. Alpine linux that uses musl libc. +endif LIB = ${OBJ}/lib CINCLUDE = -iquote common -iquote . diff --git a/jobs/jobs.c b/jobs/jobs.c index 68b7d53..db84a27 100644 --- a/jobs/jobs.c +++ b/jobs/jobs.c @@ -370,9 +370,7 @@ __thread job_t this_job; long int lrand48_j (void) { if (this_job_thread) { - long int t; - lrand48_r (&this_job_thread->rand_data, &t); - return t; + return nrand48 (this_job_thread->rand_data); } else { return lrand48 (); } @@ -380,9 +378,7 @@ long int lrand48_j (void) { long int mrand48_j (void) { if (this_job_thread) { - long int t; - mrand48_r (&this_job_thread->rand_data, &t); - return t; + return jrand48 (this_job_thread->rand_data); } else { return mrand48 (); } @@ -390,9 +386,7 @@ long int mrand48_j (void) { double drand48_j (void) { if (this_job_thread) { - double t; - drand48_r (&this_job_thread->rand_data, &t); - return t; + return erand48 (this_job_thread->rand_data); } else { return drand48 (); } @@ -463,8 +457,10 @@ int create_job_thread_ex (int thread_class, void *(*thread_work)(void *)) { JT->id = i; assert (JT->job_queue); - srand48_r (rdtsc () ^ lrand48 (), &JT->rand_data); - + long int seed = rdtsc () ^ lrand48 (); + JT->rand_data[0] = 0x330e; + JT->rand_data[1] = seed; + JT->rand_data[2] = seed >> 16; if (thread_class != JC_MAIN) { pthread_attr_t attr; diff --git a/jobs/jobs.h b/jobs/jobs.h index 56522e5..11e5b15 100644 --- a/jobs/jobs.h +++ b/jobs/jobs.h @@ -231,7 +231,7 @@ struct job_thread { long long jobs_created; long long jobs_active; int thread_system_id; - struct drand48_data rand_data; + unsigned short rand_data[3]; job_t timer_manager; double wakeup_time; struct job_class *job_class;