19 #ifndef __TYPEDEFS_H__
20 #define __TYPEDEFS_H__
26 #define GENERATE_INPUTS
33 #define MAXGATES 32000000
39 #define two_pow(e) (((uint64_t) 1) << (e))
42 static int ceil_log2(
int bits) {
45 int targetlevel = 0, bitstemp = bits;
46 while (bitstemp >>= 1)
48 return targetlevel + ((1 << targetlevel) < bits);
51 static int ceil_log2_min1(
int bits) {
54 int targetlevel = 0, bitstemp = bits;
55 while (bitstemp >>= 1)
57 return targetlevel + ((1 << targetlevel) < bits);
60 static int ceil_log2_real(
int bits) {
63 int targetlevel = 0, bitstemp = bits;
64 while (bitstemp >>= 1)
66 return targetlevel + ((1 << targetlevel) < bits);
69 static int floor_log2(
int bits) {
90 typedef unsigned char BYTE;
91 typedef unsigned short USHORT;
92 typedef unsigned int UINT;
93 typedef unsigned long ULONG;
95 typedef USHORT UINT16_T;
96 typedef UINT UINT32_T;
97 typedef unsigned long long UINT64_T;
98 typedef long long SINT64_T;
101 typedef UINT64_T UGATE_T;
102 typedef UINT64_T REGISTER_SIZE;
104 #define GATE_T_BITS (sizeof(UGATE_T) * 8)
106 typedef REGISTER_SIZE REGSIZE;
107 #define LOG2_REGISTER_SIZE ceil_log2(sizeof(REGISTER_SIZE) << 3)
109 #define FILL_BYTES AES_BYTES
110 #define FILL_BITS AES_BITS
112 #define OT_WINDOW_SIZE (AES_BITS*4)
113 #define OT_WINDOW_SIZE_BYTES (AES_BYTES*4)
115 #define MAX_REPLY_BITS 65536 //at most 2^16 bits may be sent in one go
117 #define RETRY_CONNECT 1000
118 #define CONNECT_TIMEO_MILISEC 10000
122 #define OTEXT_BLOCK_SIZE_BITS AES_BITS
123 #define OTEXT_BLOCK_SIZE_BYTES AES_BYTES
125 #define VECTOR_INTERNAL_SIZE 8
131 #if (MAX_INT == 0xFFFFFFFF)
132 #define MACHINE_SIZE_32
133 #elif (MAX_INT == 0xFFFFFFFFFFFFFFFF)
134 #define MACHINE_SIZE_64
136 #define MACHINE_SIZE_16
141 return ((a) > 0) ? (a) % (b) : (a) % (b) + ((b) > 0 ? (b) : (b) * -1);
144 T sub(T a, T b, T m) {
145 return ((b) > (a)) ? (a) + (m) - (b) : (a) - (b);
154 #define MAX_BYTE 0xFF
155 #define MAX_UINT 0xFFFFFFFF
158 #include <WinSock2.h>
161 typedef unsigned short USHORT;
162 typedef int socklen_t;
163 #pragma comment(lib, "wsock32.lib")
165 #define SleepMiliSec(x) Sleep(x)
169 #include <sys/types.h>
170 #include <sys/socket.h>
172 #include <arpa/inet.h>
174 #include <netinet/in.h>
178 #include <netinet/tcp.h>
182 #define INVALID_SOCKET -1
184 #define SleepMiliSec(x) usleep((x)<<10)
187 #define ceil_divide(x, y) (( ((x) + (y)-1)/(y)))
189 #define PadToRegisterSize(x) (PadToMultiple(x, OTEXT_BLOCK_SIZE_BITS))
190 #define PadToMultiple(x, y) ( ceil_divide(x, y) * (y))
199 #endif //__TYPEDEFS_H__
Definition: typedefs.h:79