Prepare for better autotuning capabilities
[hashcat.git] / include / common.h
1 /**
2 * Author......: Jens Steube <jens.steube@gmail.com>
3 * License.....: MIT
4 */
5
6 #ifndef COMMON_H
7 #define COMMON_H
8
9 #define _POSIX_SOURCE
10 #define _GNU_SOURCE
11 #define _FILE_OFFSET_BITS 64
12 #define _CRT_SECURE_NO_WARNINGS
13
14 #include <stdarg.h>
15 #include <stdint.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <stdbool.h>
19 #include <string.h>
20 #include <errno.h>
21 #include <getopt.h>
22 #include <math.h>
23 #include <ctype.h>
24 #include <dirent.h>
25 #include <time.h>
26 #include <unistd.h>
27 #include <signal.h>
28 #include <sys/stat.h>
29 #include <sys/types.h>
30 #include <search.h>
31 #include <fcntl.h>
32
33 #ifdef _POSIX
34 #include <sys/time.h>
35 #include <pthread.h>
36 #include <semaphore.h>
37 #include <dlfcn.h>
38 #include <pwd.h>
39
40 #ifdef LINUX
41 #include <termio.h>
42 #endif
43
44 #ifdef OSX
45 #include <termios.h>
46 #include <sys/ioctl.h>
47 #include <mach-o/dyld.h>
48 #include <mach/mach.h>
49 #endif
50
51 typedef void *OCL_LIB;
52
53 #ifdef HAVE_HWMON
54 typedef void *NV_LIB;
55 typedef void *AMD_LIB;
56 #ifdef OSX
57 #define __stdcall
58 #endif
59 #endif
60
61 #endif // _POSIX
62
63 #ifdef _WIN
64 #define WIN32_LEAN_AND_MEAN
65 #include <windows.h>
66 #include <process.h>
67 #include <conio.h>
68 #include <tchar.h>
69 #include <psapi.h>
70 #include <io.h>
71
72 typedef UINT8 uint8_t;
73 typedef UINT16 uint16_t;
74 typedef UINT32 uint32_t;
75 typedef UINT64 uint64_t;
76 typedef INT8 int8_t;
77 typedef INT16 int16_t;
78 typedef INT32 int32_t;
79 typedef INT64 int64_t;
80
81 typedef UINT32 uint;
82 typedef UINT64 uint64_t;
83
84 typedef HINSTANCE OCL_LIB;
85
86 #ifdef HAVE_HWMON
87 typedef HINSTANCE NV_LIB;
88 typedef HINSTANCE AMD_LIB;
89 #endif
90
91 #define mkdir(name,mode) mkdir (name)
92
93 #endif // _WIN
94
95 typedef uint8_t u8;
96 typedef uint16_t u16;
97 typedef uint32_t u32;
98 typedef uint64_t u64;
99
100 typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
101
102 #define EXEC_CACHE 128
103
104 #define SPEED_CACHE 128
105 #define SPEED_MAXAGE 4096
106
107 #undef BUFSIZ
108 #define BUFSIZ 8192
109
110 /**
111 * functions
112 */
113
114 void log_out_nn (FILE *fp, const char *fmt, ...);
115 void log_info_nn (const char *fmt, ...);
116 void log_error_nn (const char *fmt, ...);
117
118 void log_out (FILE *fp, const char *fmt, ...);
119 void log_info (const char *fmt, ...);
120 void log_error (const char *fmt, ...);
121
122 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
123 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
124
125 #endif // COMMON_H