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