mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Merge pull request #1480 from matrix/osx_clock_gettime
Osx clock gettime
This commit is contained in:
commit
17f6324886
@ -47,6 +47,8 @@ typedef uint64_t u64;
|
||||
|
||||
#if defined (_WIN)
|
||||
typedef LARGE_INTEGER hc_timer_t;
|
||||
#elif defined(__APPLE__) && defined(MISSING_CLOCK_GETTIME)
|
||||
typedef struct timeval hc_timer_t;
|
||||
#else
|
||||
typedef struct timespec hc_timer_t;
|
||||
#endif
|
||||
|
@ -92,6 +92,7 @@ ifeq ($(UNAME),Darwin)
|
||||
CC := clang
|
||||
# the sed -i option of macOS requires a parameter for the backup file (we just use "")
|
||||
SED_IN_PLACE := -i ""
|
||||
PROD_VERS := $(shell sw_vers -productVersion | cut -d. -f2)
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME),FreeBSD)
|
||||
@ -215,6 +216,11 @@ endif # FreeBSD
|
||||
ifeq ($(UNAME),Darwin)
|
||||
export MACOSX_DEPLOYMENT_TARGET=10.9
|
||||
CFLAGS_NATIVE := $(CFLAGS)
|
||||
|
||||
ifeq ($(shell test $(PROD_VERS) -le 11; echo $$?), 0)
|
||||
CFLAGS_NATIVE += -DMISSING_CLOCK_GETTIME
|
||||
endif
|
||||
|
||||
LFLAGS_NATIVE := $(LFLAGS)
|
||||
LFLAGS_NATIVE += -framework OpenCL
|
||||
LFLAGS_NATIVE += -lpthread
|
||||
|
@ -33,7 +33,11 @@ inline double hc_timer_get (hc_timer_t a)
|
||||
|
||||
inline void hc_timer_set (hc_timer_t* a)
|
||||
{
|
||||
#if defined(__APPLE__) && defined(MISSING_CLOCK_GETTIME)
|
||||
gettimeofday (a, NULL);
|
||||
#else
|
||||
clock_gettime (CLOCK_MONOTONIC, a);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline double hc_timer_get (hc_timer_t a)
|
||||
@ -42,6 +46,9 @@ inline double hc_timer_get (hc_timer_t a)
|
||||
|
||||
hc_timer_set (&hr_tmp);
|
||||
|
||||
#if defined(__APPLE__) && defined(MISSING_CLOCK_GETTIME)
|
||||
return (double) (((hr_tmp.tv_sec - (a).tv_sec) * 1000) + ((double) (hr_tmp.tv_usec - (a).tv_usec) / 1000));
|
||||
#else
|
||||
hc_timer_t s;
|
||||
|
||||
s.tv_sec = hr_tmp.tv_sec - a.tv_sec;
|
||||
@ -56,6 +63,7 @@ inline double hc_timer_get (hc_timer_t a)
|
||||
double r = ((double) s.tv_sec * 1000) + ((double) s.tv_nsec / 1000000);
|
||||
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user