From 96783ed7a3aed9407187b8bcfd1096c1b6873e04 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 29 Nov 2016 13:39:22 -0800 Subject: [PATCH] Fix compilation for native Cygwin --- include/affinity.h | 2 ++ include/common.h | 4 ++-- include/ext_ADL.h | 2 +- include/ext_OpenCL.h | 4 ++++ include/ext_nvapi.h | 2 +- include/ext_nvml.h | 2 +- include/ext_xnvctrl.h | 2 +- include/sort_r.h | 2 +- src/affinity.c | 6 +++++- src/dictstat.c | 2 +- src/folder.c | 4 ++-- src/opencl.c | 2 ++ src/terminal.c | 2 +- 13 files changed, 24 insertions(+), 12 deletions(-) diff --git a/include/affinity.h b/include/affinity.h index ff88f85a3..ff3dd860a 100644 --- a/include/affinity.h +++ b/include/affinity.h @@ -11,7 +11,9 @@ #if defined (_POSIX) #include +#if defined (__linux__) #include +#endif // __linux__ #endif // _POSIX #if defined (__APPLE__) diff --git a/include/common.h b/include/common.h index fc87b012c..a747acbd2 100644 --- a/include/common.h +++ b/include/common.h @@ -8,7 +8,7 @@ #define PROGNAME "hashcat" -#if defined (__linux__) +#if defined (__linux__) || defined (__CYGWIN__) #define _POSIX #elif defined (__APPLE__) #define _POSIX @@ -38,7 +38,7 @@ #if defined (__MSC_VER) #define HC_API_CALL __cdecl -#elif defined (_WIN32) || defined (__WIN32__) || defined (__CYGWIN__) +#elif defined (_WIN32) || defined (__WIN32__) #define HC_API_CALL __stdcall #else #define HC_API_CALL diff --git a/include/ext_ADL.h b/include/ext_ADL.h index 656238b6d..76fe6bcf5 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -252,7 +252,7 @@ typedef struct ADLOD6PowerControlInfo #if defined (__MSC_VER) #define ADL_API_CALL __cdecl -#elif defined (_WIN32) || defined (__WIN32__) || defined (__CYGWIN__) +#elif defined (_WIN32) || defined (__WIN32__) #define ADL_API_CALL __stdcall #else #define ADL_API_CALL diff --git a/include/ext_OpenCL.h b/include/ext_OpenCL.h index efbf6efb6..adaf313f2 100644 --- a/include/ext_OpenCL.h +++ b/include/ext_OpenCL.h @@ -25,6 +25,10 @@ #include #endif +#if defined (__CYGWIN__) +#include +#endif + // NVIDIA extras #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h index 98e94a6e4..2a7b667c8 100644 --- a/include/ext_nvapi.h +++ b/include/ext_nvapi.h @@ -215,7 +215,7 @@ NVAPI_INTERFACE NvAPI_GPU_RestoreCoolerSettings (NvPhysicalGpuHandle hPhysicalGp typedef NvPhysicalGpuHandle HM_ADAPTER_NVAPI; -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__WIN32__) #define NVAPI_API_CALL __stdcall #else #define NVAPI_API_CALL diff --git a/include/ext_nvml.h b/include/ext_nvml.h index 9342b4e6e..622552674 100644 --- a/include/ext_nvml.h +++ b/include/ext_nvml.h @@ -159,7 +159,7 @@ typedef enum nvmlGom_enum typedef nvmlDevice_t HM_ADAPTER_NVML; -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__WIN32__) #define NVML_API_CALL __stdcall #else #define NVML_API_CALL diff --git a/include/ext_xnvctrl.h b/include/ext_xnvctrl.h index 1ae36dfcf..263ec9033 100644 --- a/include/ext_xnvctrl.h +++ b/include/ext_xnvctrl.h @@ -40,7 +40,7 @@ typedef int (*XCLOSEDISPLAY) (void *); typedef int HM_ADAPTER_XNVCTRL; -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +#if defined(_WIN32) || defined(__WIN32__) #define XNVCTRL_API_CALL __stdcall #else #define XNVCTRL_API_CALL diff --git a/include/sort_r.h b/include/sort_r.h index 638401ccf..f8bdf50ff 100644 --- a/include/sort_r.h +++ b/include/sort_r.h @@ -28,7 +28,7 @@ Slightly modified to work with hashcat to no falsly detect _SORT_R_LINUX with mi defined __FreeBSD__ || defined __DragonFly__) # define _SORT_R_BSD # define _SORT_R_INLINE inline -#elif (defined __linux__) +#elif (defined __linux__) || defined (__CYGWIN__) # define _SORT_R_LINUX # define _SORT_R_INLINE inline #elif (defined _WIN32 || defined _WIN64 || defined __WINDOWS__) diff --git a/src/affinity.c b/src/affinity.c index d0163a95c..c8b82b070 100644 --- a/src/affinity.c +++ b/src/affinity.c @@ -45,8 +45,11 @@ static int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t typedef cpuset_t cpu_set_t; #endif -int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) +int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) { +#if defined (__CYGWIN__) + return 0; +#else const user_options_t *user_options = hashcat_ctx->user_options; if (user_options->cpu_affinity == NULL) return 0; @@ -121,4 +124,5 @@ int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx) #endif return 0; +#endif } diff --git a/src/dictstat.c b/src/dictstat.c index 4c347f6a3..1f942eb57 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -15,7 +15,7 @@ int sort_by_dictstat (const void *s1, const void *s2) dictstat_t *d1 = (dictstat_t *) s1; dictstat_t *d2 = (dictstat_t *) s2; - #if defined (__linux__) + #if defined (__linux__) || defined (__CYGWIN__) d2->stat.st_atim = d1->stat.st_atim; #else d2->stat.st_atime = d1->stat.st_atime; diff --git a/src/folder.c b/src/folder.c index d7d504baa..05fc22a63 100644 --- a/src/folder.c +++ b/src/folder.c @@ -24,7 +24,7 @@ int sort_by_stringptr (const void *p1, const void *p2) static int get_exec_path (char *exec_path, const size_t exec_path_sz) { - #if defined (__linux__) + #if defined (__linux__) || defined (__CYGWIN__) char tmp[32] = { 0 }; @@ -302,7 +302,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins return -1; } - #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) + #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined (__CYGWIN__) static const char SLASH[] = "/"; diff --git a/src/opencl.c b/src/opencl.c index ccdb0a5e6..9b4fda09e 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -369,6 +369,8 @@ int ocl_init (hashcat_ctx_t *hashcat_ctx) ocl->lib = hc_dlopen ("OpenCL"); #elif defined(__APPLE__) ocl->lib = hc_dlopen ("/System/Library/Frameworks/OpenCL.framework/OpenCL", RTLD_NOW); + #elif defined (__CYGWIN__) + ocl->lib = hc_dlopen ("cygOpenCL-1.dll", RTLD_NOW); #else ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW); diff --git a/src/terminal.c b/src/terminal.c index a8f451d0e..15c1c3639 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -294,7 +294,7 @@ void SetConsoleWindowSize (const int x) } #endif -#if defined (__linux__) +#if defined (__linux__) || defined (__CYGWIN__) static struct termios savemodes; static int havemodes = 0;