Replace all #ifdef with #if defined (...) for convention

This commit is contained in:
jsteube
2016-09-07 22:29:57 +02:00
parent eb00cd959f
commit 9eb47153d4
37 changed files with 182 additions and 170 deletions

View File

@@ -9,21 +9,21 @@
#include <stdlib.h>
#include <stdarg.h>
#ifdef _POSIX
#if defined (_POSIX)
#include <pthread.h>
#include <sys/sysctl.h>
#endif // _POSIX
#ifdef __APPLE__
#if defined (__APPLE__)
#include <mach-o/dyld.h>
#include <mach/mach.h>
#endif // __APPLE__
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#endif // _WIN
#ifdef __APPLE__
#if defined (__APPLE__)
typedef struct cpu_set
{
uint32_t count;

View File

@@ -8,6 +8,18 @@
#ifndef _COMMON_H
#define _COMMON_H
#if defined (__linux__)
#define _POSIX
#elif defined (__APPLE__)
#define _POSIX
#elif defined (__FreeBSD__)
#define _POSIX
#elif defined (_WIN32) || defined (_WIN64)
#define _WIN
#else
#error Your Operating System is not supported or detected
#endif
#define _GNU_SOURCE
#define _FILE_OFFSET_BITS 64
@@ -32,11 +44,11 @@
#define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a)
#ifdef __APPLE__
#if defined (__APPLE__)
#define __stdcall
#endif
#ifdef _WIN
#if defined (_WIN)
#define WIN32_LEAN_AND_MEAN
#endif

View File

@@ -71,7 +71,7 @@ typedef struct
* hardware watchdog
*/
#ifdef HAVE_HWMON
#if defined (HAVE_HWMON)
void *hm_adl;
void *hm_nvml;
void *hm_nvapi;
@@ -192,7 +192,7 @@ typedef struct
uint dgst_pos2;
uint dgst_pos3;
#ifdef HAVE_HWMON
#if defined (HAVE_HWMON)
uint gpu_temp_disable;
uint gpu_temp_abort;
uint gpu_temp_retain;

View File

@@ -8,18 +8,18 @@
#include <stdlib.h>
#ifdef _POSIX
#if defined (_POSIX)
#include <dlfcn.h>
#ifdef __APPLE__
#if defined (__APPLE__)
#include <mach-o/dyld.h>
#endif // __APPLE__
#endif // _POSIX
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#endif // _WIN
#ifdef _WIN
#if defined (_WIN)
#define hc_dlopen LoadLibrary
#define hc_dlclose FreeLibrary
#define hc_dlsym GetProcAddress

View File

@@ -304,7 +304,7 @@ typedef int (ADL_API_CALL *ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET) (int, int *
typedef int (ADL_API_CALL *ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET) (int, ADLOD6ParameterRange *);
typedef int (ADL_API_CALL *ADL_OVERDRIVE6_FANSPEED_RESET) (int);
#ifdef _POSIX
#if defined (_POSIX)
typedef void *ADL_LIB;
#else
typedef HINSTANCE ADL_LIB;

View File

@@ -11,19 +11,19 @@
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
#ifdef __APPLE__
#if defined (__APPLE__)
#include <OpenCL/cl.h>
#endif
#ifdef _WIN
#if defined (_WIN)
#include <CL/cl.h>
#endif
#ifdef __linux__
#if defined (__linux__)
#include <CL/cl.h>
#endif
#ifdef __FreeBSD__
#if defined (__FreeBSD__)
#include <CL/cl.h>
#endif
@@ -62,7 +62,7 @@ typedef cl_int (CL_API_CALL *OCL_CLRELEASEPROGRAM) (cl_progra
typedef cl_int (CL_API_CALL *OCL_CLSETKERNELARG) (cl_kernel, cl_uint, size_t, const void *);
typedef cl_int (CL_API_CALL *OCL_CLWAITFOREVENTS) (cl_uint, const cl_event *);
#ifdef _POSIX
#if defined (_POSIX)
typedef void *OCL_LIB;
#else
typedef HINSTANCE OCL_LIB;

View File

@@ -233,7 +233,7 @@ typedef int (*NVAPI_API_CALL NVAPI_GPU_GETPERFPOLICIESSTATUS) (NvPhysicalGpuHand
typedef int (*NVAPI_API_CALL NVAPI_GPU_SETCOOLERLEVELS) (NvPhysicalGpuHandle, NvU32, NV_GPU_COOLER_LEVELS *);
typedef int (*NVAPI_API_CALL NVAPI_GPU_RESTORECOOLERSETTINGS) (NvPhysicalGpuHandle, NvU32);
#ifdef _POSIX
#if defined (_POSIX)
typedef void *NVAPI_LIB;
#else
typedef HINSTANCE NVAPI_LIB;

View File

@@ -189,7 +189,7 @@ typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_POWERMANAGEMENTLIMITCONSTRA
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_SET_POWERMANAGEMENTLIMIT) (nvmlDevice_t, unsigned int);
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_POWERMANAGEMENTLIMIT) (nvmlDevice_t, unsigned int *);
#ifdef _POSIX
#if defined (_POSIX)
typedef void *NVML_LIB;
#else
typedef HINSTANCE NVML_LIB;

View File

@@ -49,7 +49,7 @@ typedef int HM_ADAPTER_XNVCTRL;
typedef int (*XNVCTRL_API_CALL XNVCTRLQUERYTARGETATTRIBUTE) (void *, int, int, unsigned int, unsigned int, int *);
typedef void (*XNVCTRL_API_CALL XNVCTRLSETTARGETATTRIBUTE) (void *, int, int, unsigned int, unsigned int, int);
#ifdef _POSIX
#if defined (_POSIX)
typedef void *XNVCTRL_LIB;
#else
typedef HINSTANCE XNVCTRL_LIB;

View File

@@ -10,14 +10,14 @@
#include <dirent.h>
#include <unistd.h>
#ifdef _POSIX
#if defined (_POSIX)
#include <sys/types.h>
#ifdef __APPLE__
#if defined (__APPLE__)
#include <mach-o/dyld.h>
#endif // __APPLE__
#endif // _POSIX
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#endif

View File

@@ -13,7 +13,7 @@
#include <errno.h>
#include <fcntl.h>
#ifdef F_SETLKW
#if defined (F_SETLKW)
void lock_file (FILE *fp);
void unlock_file (FILE *fp);

View File

@@ -10,12 +10,12 @@
#include <unistd.h>
#include <errno.h>
#ifdef _POSIX
#if defined (_POSIX)
#include <sys/types.h>
#include <sys/stat.h>
#endif // _POSIX
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#include <psapi.h>
#endif // _WIN

View File

@@ -20,13 +20,13 @@
* OS specific includes
*/
#ifdef _POSIX
#if defined (_POSIX)
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/sysctl.h>
#endif // _POSIX
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#endif // _WIN
@@ -37,9 +37,9 @@
#ifdef _WIN
#if defined (_WIN)
#define hc_sleep(x) Sleep ((x) * 1000);
#elif _POSIX
#elif defined (_POSIX)
#define hc_sleep(x) sleep ((x));
#endif
@@ -136,7 +136,7 @@ void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_cha
void check_checkpoint (void);
#ifdef _WIN
#if defined (_WIN)
BOOL WINAPI sigHandler_default (DWORD sig);
BOOL WINAPI sigHandler_benchmark (DWORD sig);

View File

@@ -13,14 +13,14 @@
#include <sys/types.h>
#include <unistd.h>
#ifdef _POSIX
#if defined (_POSIX)
#include <termios.h>
#ifdef __APPLE__
#if defined (__APPLE__)
#include <sys/ioctl.h>
#endif // __APPLE__
#endif // _POSIX
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#endif // _WIN

View File

@@ -6,23 +6,23 @@
#ifndef _THREAD_H
#define _THREAD_H
#ifdef _POSIX
#if defined (_POSIX)
#include <pthread.h>
#include <semaphore.h>
#endif // _POSIX
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#endif // _WIN
#ifdef _WIN
#if defined (_WIN)
typedef HANDLE hc_thread_t;
typedef CRITICAL_SECTION hc_thread_mutex_t;
#elif _POSIX
#elif defined (_POSIX)
typedef pthread_t hc_thread_t;
typedef pthread_mutex_t hc_thread_mutex_t;
#endif
#ifdef _WIN
#if defined (_WIN)
#define hc_thread_create(t,f,a) t = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) &f, a, 0, NULL)
#define hc_thread_wait(n,a) for (uint i = 0; i < n; i++) WaitForSingleObject ((a)[i], INFINITE)
@@ -33,7 +33,7 @@ typedef pthread_mutex_t hc_thread_mutex_t;
#define hc_thread_mutex_init(m) InitializeCriticalSection (&m)
#define hc_thread_mutex_delete(m) DeleteCriticalSection (&m)
#elif _POSIX
#elif defined (_POSIX)
#define hc_thread_create(t,f,a) pthread_create (&t, NULL, f, a)
#define hc_thread_wait(n,a) for (uint i = 0; i < n; i++) pthread_join ((a)[i], NULL)

View File

@@ -6,23 +6,23 @@
#ifndef _TIMER_H
#define _TIMER_H
#ifdef _POSIX
#if defined (_POSIX)
#include <sys/time.h>
#else
#endif
#ifdef _WIN
#if defined (_WIN)
typedef LARGE_INTEGER hc_timer_t;
#elif _POSIX
#elif defined (_POSIX)
typedef struct timeval hc_timer_t;
#endif
#ifdef _WIN
#if defined (_WIN)
#define hc_timer_get(a,r) { hc_timer_t hr_freq; QueryPerformanceFrequency (&hr_freq); hc_timer_t hr_tmp; hc_timer_set (&hr_tmp); (r) = (double) ((double) (hr_tmp.QuadPart - (a).QuadPart) / (double) (hr_freq.QuadPart / 1000)); }
#define hc_timer_set(a) { QueryPerformanceCounter ((a)); }
#elif _POSIX
#elif defined (_POSIX)
#define hc_timer_get(a,r) { hc_timer_t hr_tmp; hc_timer_set (&hr_tmp); (r) = (double) (((hr_tmp.tv_sec - (a).tv_sec) * 1000) + ((double) (hr_tmp.tv_usec - (a).tv_usec) / 1000)); }
#define hc_timer_set(a) { gettimeofday ((a), NULL); }

View File

@@ -13,7 +13,7 @@
#include <sys/stat.h>
#include <string.h>
#ifdef _WIN
#if defined (_WIN)
#define EOL "\r\n"
#else
#define EOL "\n"
@@ -210,11 +210,11 @@ typedef struct
{
u64 cnt;
#ifdef _POSIX
#if defined (_POSIX)
struct stat stat;
#endif
#ifdef _WIN
#if defined (_WIN)
struct __stat64 stat;
#endif

View File

@@ -9,9 +9,9 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef _WIN
#if defined (_WIN)
#include <windows.h>
#ifdef _BASETSD_H
#if defined (_BASETSD_H)
#else
typedef UINT8 uint8_t;
typedef UINT16 uint16_t;