2015-12-04 14:47:52 +00:00
|
|
|
/**
|
2016-02-16 15:42:08 +00:00
|
|
|
* Authors.....: Jens Steube <jens.steube@gmail.com>
|
|
|
|
* magnum <john.magnum@hushmail.com>
|
|
|
|
*
|
2015-12-04 14:47:52 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef COMMON_H
|
|
|
|
#define COMMON_H
|
|
|
|
|
|
|
|
#define _POSIX_SOURCE
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2016-01-12 17:56:26 +00:00
|
|
|
#include <stdbool.h>
|
2015-12-04 14:47:52 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <search.h>
|
2016-01-29 10:54:18 +00:00
|
|
|
#include <fcntl.h>
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#ifdef _POSIX
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <semaphore.h>
|
|
|
|
#include <dlfcn.h>
|
2015-12-13 11:21:36 +00:00
|
|
|
#include <pwd.h>
|
2015-12-04 14:47:52 +00:00
|
|
|
|
|
|
|
#ifdef LINUX
|
|
|
|
#include <termio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OSX
|
|
|
|
#include <termios.h>
|
|
|
|
#include <sys/ioctl.h>
|
2016-01-20 19:55:09 +00:00
|
|
|
#include <mach-o/dyld.h>
|
2016-02-06 17:00:04 +00:00
|
|
|
#include <mach/mach.h>
|
2015-12-04 14:47:52 +00:00
|
|
|
#endif
|
|
|
|
|
2016-01-26 20:40:49 +00:00
|
|
|
typedef void *OCL_LIB;
|
|
|
|
|
2016-01-20 19:55:09 +00:00
|
|
|
#ifdef HAVE_HWMON
|
2016-06-02 12:20:15 +00:00
|
|
|
typedef void *ADL_LIB;
|
|
|
|
typedef void *NVAPI_LIB;
|
|
|
|
typedef void *NVML_LIB;
|
2016-06-18 08:59:58 +00:00
|
|
|
typedef void *XNVCTRL_LIB;
|
2016-01-31 22:48:38 +00:00
|
|
|
#ifdef OSX
|
|
|
|
#define __stdcall
|
|
|
|
#endif
|
2015-12-04 14:47:52 +00:00
|
|
|
#endif
|
|
|
|
|
2016-01-20 19:55:09 +00:00
|
|
|
#endif // _POSIX
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
#ifdef _WIN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#include <process.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <psapi.h>
|
|
|
|
#include <io.h>
|
|
|
|
|
|
|
|
typedef UINT8 uint8_t;
|
|
|
|
typedef UINT16 uint16_t;
|
|
|
|
typedef UINT32 uint32_t;
|
|
|
|
typedef UINT64 uint64_t;
|
|
|
|
typedef INT8 int8_t;
|
|
|
|
typedef INT16 int16_t;
|
|
|
|
typedef INT32 int32_t;
|
|
|
|
typedef INT64 int64_t;
|
|
|
|
|
|
|
|
typedef UINT32 uint;
|
|
|
|
typedef UINT64 uint64_t;
|
|
|
|
|
2016-02-02 00:14:33 +00:00
|
|
|
typedef HINSTANCE OCL_LIB;
|
|
|
|
|
2016-01-20 19:55:09 +00:00
|
|
|
#ifdef HAVE_HWMON
|
2016-06-02 12:20:15 +00:00
|
|
|
typedef HINSTANCE ADL_LIB;
|
|
|
|
typedef HINSTANCE NVAPI_LIB;
|
|
|
|
typedef HINSTANCE NVML_LIB;
|
2016-06-18 08:59:58 +00:00
|
|
|
typedef HINSTANCE XNVCTRL_LIB;
|
2016-01-20 19:55:09 +00:00
|
|
|
#endif
|
2016-01-02 23:40:31 +00:00
|
|
|
|
|
|
|
#define mkdir(name,mode) mkdir (name)
|
|
|
|
|
2016-01-20 19:55:09 +00:00
|
|
|
#endif // _WIN
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-01-15 16:16:43 +00:00
|
|
|
typedef uint8_t u8;
|
|
|
|
typedef uint16_t u16;
|
|
|
|
typedef uint32_t u32;
|
|
|
|
typedef uint64_t u64;
|
|
|
|
|
|
|
|
typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
|
|
|
|
|
2016-03-26 09:37:59 +00:00
|
|
|
#define EXEC_CACHE 128
|
2016-02-11 08:54:50 +00:00
|
|
|
|
2016-03-26 09:37:59 +00:00
|
|
|
#define SPEED_CACHE 128
|
|
|
|
#define SPEED_MAXAGE 4096
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-04-18 16:40:13 +00:00
|
|
|
#define HCBUFSIZ 0x50000 // general large space buffer size in case the size is unknown at compile-time
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-06-14 08:18:42 +00:00
|
|
|
#define EXPECTED_ITERATIONS 10000
|
|
|
|
|
2015-12-04 14:47:52 +00:00
|
|
|
/**
|
|
|
|
* functions
|
|
|
|
*/
|
|
|
|
|
2016-06-19 10:55:03 +00:00
|
|
|
int log_out_nn (FILE *fp, const char *fmt, ...);
|
|
|
|
int log_info_nn (const char *fmt, ...);
|
|
|
|
int log_error_nn (const char *fmt, ...);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-06-19 10:55:03 +00:00
|
|
|
int log_out (FILE *fp, const char *fmt, ...);
|
|
|
|
int log_info (const char *fmt, ...);
|
|
|
|
int log_error (const char *fmt, ...);
|
2015-12-04 14:47:52 +00:00
|
|
|
|
2016-01-15 16:16:43 +00:00
|
|
|
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
|
|
|
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
2015-12-15 17:41:11 +00:00
|
|
|
|
2016-05-01 16:34:59 +00:00
|
|
|
#define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a)
|
|
|
|
|
2016-01-20 19:55:09 +00:00
|
|
|
#endif // COMMON_H
|