From e4bf86dcbef100c57fb6532c10fbc9227f940693 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 6 Sep 2016 18:44:05 +0200 Subject: [PATCH] Replace #pragma once with #ifndef #define #endif logic because #pragma once does not work cleanly on OSX --- include/bitops.h | 5 ++++- include/common.h | 6 ++++-- include/convert.h | 5 ++++- include/cpu_aes.h | 5 ++++- include/cpu_crc32.h | 4 +++- include/cpu_des.h | 5 ++++- include/cpu_md5.h | 5 ++++- include/cpu_sha1.h | 5 ++++- include/cpu_sha256.h | 5 ++++- include/data.h | 5 ++++- include/dynloader.h | 5 ++++- include/ext_ADL.h | 5 ++++- include/ext_OpenCL.h | 5 ++++- include/ext_nvapi.h | 5 ++++- include/ext_nvml.h | 5 ++++- include/ext_xnvctrl.h | 5 ++++- include/hwmon.h | 5 ++++- include/interface.h | 5 ++++- include/logfile.h | 5 ++++- include/logging.h | 5 ++++- include/memory.h | 5 ++++- include/mpsp.h | 5 ++++- include/rp_cpu.h | 5 ++++- include/rp_kernel_on_cpu.h | 5 ++++- include/shared.h | 5 ++++- include/terminal.h | 5 ++++- include/thread.h | 5 ++++- include/timer.h | 5 ++++- include/types.h | 5 ++++- include/types_int.h | 5 ++++- include/usage.h | 5 ++++- 31 files changed, 123 insertions(+), 32 deletions(-) diff --git a/include/bitops.h b/include/bitops.h index c7cd4dc55..b888f90fb 100644 --- a/include/bitops.h +++ b/include/bitops.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _BITOPS_H +#define _BITOPS_H u32 is_power_of_2 (const u32 v); @@ -14,3 +15,5 @@ u64 rotr64 (const u64 a, const u64 n); u32 byte_swap_32 (const u32 n); u64 byte_swap_64 (const u64 n); + +#endif // _BITOPS_H diff --git a/include/common.h b/include/common.h index 48a97ff96..153055fad 100644 --- a/include/common.h +++ b/include/common.h @@ -5,7 +5,8 @@ * License.....: MIT */ -#pragma once +#ifndef _COMMON_H +#define _COMMON_H #define _POSIX_SOURCE #define _GNU_SOURCE @@ -21,7 +22,6 @@ #define BLOCK_SIZE 64 - #define EXPECTED_ITERATIONS 10000 #define MIN(a,b) (((a) < (b)) ? (a) : (b)) @@ -38,3 +38,5 @@ #ifdef _WIN #define WIN32_LEAN_AND_MEAN #endif + +#endif // _COMMON_H diff --git a/include/convert.h b/include/convert.h index 2cf05d39c..6fdbd2976 100644 --- a/include/convert.h +++ b/include/convert.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _CONVERT_H +#define _CONVERT_H #include @@ -41,3 +42,5 @@ int base64_encode (u8 (*f) (const u8), const u8 *in_buf, int in_len, u8 *out_buf void lowercase (u8 *buf, int len); void uppercase (u8 *buf, int len); + +#endif // _CONVERT_H diff --git a/include/cpu_aes.h b/include/cpu_aes.h index 6cfdad4d2..77bd666cb 100644 --- a/include/cpu_aes.h +++ b/include/cpu_aes.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _CPU_AES_H +#define _CPU_AES_H /* AES context. */ typedef struct aes_context @@ -24,3 +25,5 @@ void AES_encrypt (AES_KEY *aes_key, const u8 *input, u8 *output); void AES_decrypt (AES_KEY *aes_key, const u8 *input, u8 *output); void AES128_decrypt_cbc (const u32 key[4], const u32 iv[4], const u32 in[16], u32 out[16]); + +#endif // _CPU_AES_H diff --git a/include/cpu_crc32.h b/include/cpu_crc32.h index 97775944f..1fb363ccc 100644 --- a/include/cpu_crc32.h +++ b/include/cpu_crc32.h @@ -3,10 +3,12 @@ * License.....: MIT */ -#pragma once +#ifndef _CPU_CRC32_H +#define _CPU_CRC32_H #include #include void cpu_crc32 (const char *filename, u8 keytab[64]); +#endif // _CPU_CRC32_H diff --git a/include/cpu_des.h b/include/cpu_des.h index 2e12a2d23..4687afb33 100644 --- a/include/cpu_des.h +++ b/include/cpu_des.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _CPU_DES_H +#define _CPU_DES_H #define PERM_OP(a,b,tt,n,m) \ { \ @@ -45,3 +46,5 @@ void _des_keysetup (u32 data[2], u32 Kc[16], u32 Kd[16]); void _des_encrypt (u32 data[2], u32 Kc[16], u32 Kd[16]); + +#endif // _CPU_DES_H diff --git a/include/cpu_md5.h b/include/cpu_md5.h index 136a2dfcf..abbdee5ab 100644 --- a/include/cpu_md5.h +++ b/include/cpu_md5.h @@ -3,9 +3,12 @@ * License.....: MIT */ -#pragma once +#ifndef _CPU_MD5_H +#define _CPU_MD5_H #include void md5_64 (uint block[16], uint digest[4]); void md5_complete_no_limit (uint digest[4], uint *plain, uint plain_len); + +#endif // _CPU_MD5_H diff --git a/include/cpu_sha1.h b/include/cpu_sha1.h index 2d217ce9f..675a5e4c3 100644 --- a/include/cpu_sha1.h +++ b/include/cpu_sha1.h @@ -3,6 +3,9 @@ * License.....: MIT */ -#pragma once +#ifndef _CPU_SHA1_H +#define _CPU_SHA1_H void sha1_64 (uint block[16], uint digest[5]); + +#endif // _CPU_SHA1_H diff --git a/include/cpu_sha256.h b/include/cpu_sha256.h index d5c4c50e5..1680446b8 100644 --- a/include/cpu_sha256.h +++ b/include/cpu_sha256.h @@ -3,6 +3,9 @@ * License.....: MIT */ -#pragma once +#ifndef _CPU_SHA256_H +#define _CPU_SHA256_H void sha256_64 (uint block[16], uint digest[8]); + +#endif // _CPU_SHA256_H diff --git a/include/data.h b/include/data.h index 699fbf76c..aff9a64f0 100644 --- a/include/data.h +++ b/include/data.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _DATA_H +#define _DATA_H typedef struct { @@ -252,3 +253,5 @@ typedef struct int (*parse_func) (char *, uint, hash_t *); } hc_global_data_t; + +#endif // _DATA_H diff --git a/include/dynloader.h b/include/dynloader.h index 0a87cbf62..f5463fd6a 100644 --- a/include/dynloader.h +++ b/include/dynloader.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _DYNLOADER_H +#define _DYNLOADER_H #include @@ -67,3 +68,5 @@ return -1; \ } \ } + +#endif // _DYNALOADER_H \ No newline at end of file diff --git a/include/ext_ADL.h b/include/ext_ADL.h index 4e289a564..d33052b70 100644 --- a/include/ext_ADL.h +++ b/include/ext_ADL.h @@ -6,7 +6,8 @@ * License.....: MIT */ -#pragma once +#ifndef _EXT_ADL_H +#define _EXT_ADL_H #include @@ -389,3 +390,5 @@ int hm_ADL_Overdrive6_PowerControl_Caps (ADL_PTR *adl, int iAdapterIndex, int *l int hm_ADL_Overdrive6_TargetTemperatureData_Get (ADL_PTR *adl, int iAdapterIndex, int *cur_temp, int *default_temp); int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo); int hm_ADL_Overdrive6_FanSpeed_Reset (ADL_PTR *adl, int iAdapterIndex); + +#endif // _EXT_ADL_H diff --git a/include/ext_OpenCL.h b/include/ext_OpenCL.h index e74a0615a..95180b018 100644 --- a/include/ext_OpenCL.h +++ b/include/ext_OpenCL.h @@ -5,7 +5,8 @@ * License.....: MIT */ -#pragma once +#ifndef _EXT_OPENCL_H +#define _EXT_OPENCL_H #define CL_PLATFORMS_MAX 16 @@ -168,3 +169,5 @@ cl_int hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem); cl_int hc_clReleaseProgram (OCL_PTR *ocl, cl_program program); cl_int hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value); cl_int hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list); + +#endif // _EXT_OPENCL_H diff --git a/include/ext_nvapi.h b/include/ext_nvapi.h index 51830c3b7..eebf0e70f 100644 --- a/include/ext_nvapi.h +++ b/include/ext_nvapi.h @@ -5,7 +5,8 @@ * License.....: MIT */ -#pragma once +#ifndef _EXT_NVAPI_H +#define _EXT_NVAPI_H /** * Declarations from nvapi.h and subheaders @@ -268,3 +269,5 @@ int hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhy int hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status); int hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels); int hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex); + +#endif // _EXT_NVAPI_H diff --git a/include/ext_nvml.h b/include/ext_nvml.h index a0697b67e..2cd50cc41 100644 --- a/include/ext_nvml.h +++ b/include/ext_nvml.h @@ -6,7 +6,8 @@ * License.....: MIT */ -#pragma once +#ifndef _NVML_H +#define _NVML_H /** * Declarations from nvml.h @@ -246,3 +247,5 @@ nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int, nvmlDev nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit); nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int limit); nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *limit); + +#endif // _NVML_H diff --git a/include/ext_xnvctrl.h b/include/ext_xnvctrl.h index b616809a3..e6b2fb5ef 100644 --- a/include/ext_xnvctrl.h +++ b/include/ext_xnvctrl.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _EXT_XNVCTRL_H +#define _EXT_XNVCTRL_H /** * Stuff from X11/Xlib.h @@ -85,3 +86,5 @@ int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val); int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val); int get_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int *val); int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val); + +#endif // _EXT_XNVCTRL_H diff --git a/include/hwmon.h b/include/hwmon.h index ed9c1b28f..6f5027259 100644 --- a/include/hwmon.h +++ b/include/hwmon.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _HWMON_H +#define _HWMON_H typedef struct { @@ -52,3 +53,5 @@ int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fa int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fanspeed); void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value); + +#endif // _HWMON_H diff --git a/include/interface.h b/include/interface.h index 7f8ff3286..6d1e02559 100644 --- a/include/interface.h +++ b/include/interface.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _INTERFACE_H +#define _INTERFACE_H #include #include @@ -1528,3 +1529,5 @@ void to_hccap_t (hccap_t *hccap, uint salt_pos, uint digest_pos); void truecrypt_crc32 (const char *filename, u8 keytab[64]); void ascii_digest (char *out_buf, uint salt_pos, uint digest_pos); + +#endif // _INTERFACE_H diff --git a/include/logfile.h b/include/logfile.h index 8f302994c..632506694 100644 --- a/include/logfile.h +++ b/include/logfile.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _LOGFILE_H +#define _LOGFILE_H #include #include @@ -14,3 +15,5 @@ char *logfile_generate_topid (void); char *logfile_generate_subid (void); void logfile_append (const char *fmt, ...); + +#endif // _LOGFILE_H diff --git a/include/logging.h b/include/logging.h index 6f2b931a6..5345a353b 100644 --- a/include/logging.h +++ b/include/logging.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _LOGGING_H +#define _LOGGING_H #include #include @@ -15,3 +16,5 @@ int log_error_nn (const char *fmt, ...); int log_out (FILE *fp, const char *fmt, ...); int log_info (const char *fmt, ...); int log_error (const char *fmt, ...); + +#endif // _LOGGING_H diff --git a/include/memory.h b/include/memory.h index 8514df105..8e35b21e1 100644 --- a/include/memory.h +++ b/include/memory.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _MEMORY_H +#define _MEMORY_H #include #include @@ -15,3 +16,5 @@ void myfree (void *ptr); void *mymalloc (size_t size); void *myrealloc (void *ptr, size_t oldsz, size_t add); char *mystrdup (const char *s); + +#endif // _MEMORY_H diff --git a/include/mpsp.h b/include/mpsp.h index 79df72484..57bdb763a 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _MPSP_H +#define _MPSP_H #include #include @@ -48,3 +49,5 @@ void sp_setup_tbl (const char *install_dir, char *hcstat, uint disable, uint cla void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint threshold, uint uniq_tbls[SP_PW_MAX][CHARSIZ]); void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out); void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out); + +#endif // _MPSP_H diff --git a/include/rp_cpu.h b/include/rp_cpu.h index cca52fd56..a1c3c6d31 100644 --- a/include/rp_cpu.h +++ b/include/rp_cpu.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _RP_CPU_H +#define _RP_CPU_H #include @@ -91,3 +92,5 @@ int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule); int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max); int _old_apply_rule (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE]); + +#endif // _RP_CPU_H diff --git a/include/rp_kernel_on_cpu.h b/include/rp_kernel_on_cpu.h index 49441c0c4..ebdd0a1de 100644 --- a/include/rp_kernel_on_cpu.h +++ b/include/rp_kernel_on_cpu.h @@ -3,9 +3,12 @@ * License.....: MIT */ -#pragma once +#ifndef _RP_KERNEL_ON_CPU_H +#define _RP_KERNEL_ON_CPU_H #define swap_workaround(n) __builtin_bswap32(n) u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len); u32 apply_rules (u32 *cmds, u32 buf0[4], u32 buf1[4], const u32 len); + +#endif // _RP_KERNEL_ON_CPU_H diff --git a/include/shared.h b/include/shared.h index d120ad085..fb5e44ca5 100644 --- a/include/shared.h +++ b/include/shared.h @@ -6,7 +6,8 @@ * License.....: MIT */ -#pragma once +#ifndef _SHARED_H +#define _SHARED_H #include #include @@ -241,3 +242,5 @@ void *thread_runtime (void *p); void status_display (void); void status_display_machine_readable (void); + +#endif // _SHARED_H diff --git a/include/terminal.h b/include/terminal.h index 8155fb8ff..7a6f3dac2 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _TERMINAL_H +#define _TERMINAL_H #include #include @@ -21,3 +22,5 @@ int tty_break(); int tty_getchar(); int tty_fix(); + +#endif // _TERMINAL_H diff --git a/include/thread.h b/include/thread.h index f2a36281a..08ce0c728 100644 --- a/include/thread.h +++ b/include/thread.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _THREAD_H +#define _THREAD_H #ifdef _POSIX #include @@ -44,3 +45,5 @@ typedef pthread_mutex_t hc_thread_mutex_t; #define hc_thread_mutex_delete(m) pthread_mutex_destroy (&m) #endif + +#endif // _THREAD_H diff --git a/include/timer.h b/include/timer.h index 4e5bf1578..2b7a38439 100644 --- a/include/timer.h +++ b/include/timer.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _TIMER_H +#define _TIMER_H #ifdef _POSIX #include @@ -27,3 +28,5 @@ typedef struct timeval hc_timer_t; #define hc_timer_set(a) { gettimeofday ((a), NULL); } #endif + +#endif // _TIMER_H diff --git a/include/types.h b/include/types.h index 6dafc564d..76f9a0879 100644 --- a/include/types.h +++ b/include/types.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _TYPES_H +#define _TYPES_H #include #include @@ -544,3 +545,5 @@ struct __hc_device_param }; typedef struct __hc_device_param hc_device_param_t; + +#endif // _TYPES_H diff --git a/include/types_int.h b/include/types_int.h index b5d0ce1a4..0b78b1889 100644 --- a/include/types_int.h +++ b/include/types_int.h @@ -3,7 +3,8 @@ * License.....: MIT */ -#pragma once +#ifndef _TYPES_INT_H +#define _TYPES_INT_H #include #include @@ -29,3 +30,5 @@ typedef uint32_t u32; typedef uint64_t u64; typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency + +#endif // _TYPES_INT_H diff --git a/include/usage.h b/include/usage.h index 901afa64b..4dc0d6526 100644 --- a/include/usage.h +++ b/include/usage.h @@ -3,7 +3,10 @@ * License.....: MIT */ -#pragma once +#ifndef _USAGE_H +#define _USAGE_H void usage_mini_print (const char *progname); void usage_big_print (const char *progname); + +#endif // _USAGE_H