00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #define _WINSOCKAPI_
00034 #if defined(USING_MINGW)
00035
00036 #define WINVER 0x0501
00037 #endif
00038 #include <windows.h>
00039 #include <winsock2.h>
00040 #include <ws2tcpip.h>
00041 #if !defined(USING_MINGW)
00042 #include <wspiapi.h>
00043 #endif
00044 #include <stdlib.h>
00045 #include <stdio.h>
00046 #include <stdarg.h>
00047 #include <string.h>
00048 #include <signal.h>
00049 #include <time.h>
00050 #include <sys/types.h>
00051 #include <sys/timeb.h>
00052
00053 #if defined(DLL_IMPORT)
00054 #define LIBTYPE __declspec( dllexport )
00055 #elif defined(DLL_EXPORT)
00056 #define LIBTYPE __declspec( dllimport )
00057 #else
00058 #define LIBTYPE
00059 #endif
00060
00061 typedef int bool_t;
00062 #if defined(USING_MINGW)
00063 #include <stdint.h>
00064 #include <pthread.h>
00065 #else
00066 typedef signed __int8 int8_t;
00067 typedef signed __int16 int16_t;
00068 typedef signed __int32 int32_t;
00069 typedef signed __int64 int64_t;
00070 typedef unsigned __int8 uint8_t;
00071 typedef unsigned __int16 uint16_t;
00072 typedef unsigned __int32 uint32_t;
00073 typedef unsigned __int64 uint64_t;
00074 typedef void (*sig_t)(int);
00075 typedef HANDLE pthread_t;
00076 typedef HANDLE pthread_mutex_t;
00077 #endif
00078
00079 #define va_copy(x, y) x = y
00080 #define atoll _atoi64
00081 #define strdup _strdup
00082 #define strcasecmp _stricmp
00083 #define snprintf _snprintf
00084 #define fseeko _fseeki64
00085 #define ftello _ftelli64
00086 #define THREAD_FUNC_PREFIX DWORD WINAPI
00087
00088 #ifdef __cplusplus
00089 extern "C" {
00090 #endif
00091
00092 extern LIBTYPE uint32_t random_get32(void);
00093 extern LIBTYPE uint64_t getcurrenttime(void);
00094 extern LIBTYPE void msleep_approx(uint64_t ms);
00095 extern LIBTYPE void msleep_minimum(uint64_t ms);
00096
00097 #if !defined(PTHREAD_H)
00098 extern LIBTYPE int pthread_create(pthread_t *tid, void *attr, LPTHREAD_START_ROUTINE start, void *arg);
00099 extern LIBTYPE int pthread_join(pthread_t tid, void **value_ptr);
00100 extern LIBTYPE void pthread_mutex_init(pthread_mutex_t *mutex, void *attr);
00101 extern LIBTYPE void pthread_mutex_lock(pthread_mutex_t *mutex);
00102 extern LIBTYPE void pthread_mutex_unlock(pthread_mutex_t *mutex);
00103 #endif
00104
00105
00106
00107
00108
00109
00110 extern LIBTYPE void console_vprintf(const char *fmt, va_list ap);
00111 extern LIBTYPE void console_printf(const char *fmt, ...);
00112
00113 #ifdef __cplusplus
00114 }
00115 #endif