1 /* 2 * hdhomerun_os_windows.h 3 * 4 * Copyright © 2006-2017 Silicondust USA Inc. <www.silicondust.com>. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifdef _WINRT 22 #include <SDKDDKVer.h> 23 #endif 24 25 #ifndef _WIN32_WINNT 26 #define _WIN32_WINNT _WIN32_WINNT_VISTA 27 #endif 28 #ifndef _CRT_SECURE_NO_WARNINGS 29 #define _CRT_SECURE_NO_WARNINGS 30 #endif 31 #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS 32 #define _WINSOCK_DEPRECATED_NO_WARNINGS 33 #endif 34 35 #include <winsock2.h> 36 #include <windows.h> 37 #include <ws2tcpip.h> 38 #include <wspiapi.h> 39 #include <stdlib.h> 40 #include <stdio.h> 41 #include <stdarg.h> 42 #include <stdint.h> 43 #include <stdbool.h> 44 #include <string.h> 45 #include <signal.h> 46 #include <time.h> 47 #include <sys/types.h> 48 49 #ifdef LIBHDHOMERUN_DLLEXPORT 50 #define LIBHDHOMERUN_API __declspec(dllexport) 51 #endif 52 #ifdef LIBHDHOMERUN_DLLIMPORT 53 #define LIBHDHOMERUN_API __declspec(dllimport) 54 #endif 55 #ifndef LIBHDHOMERUN_API 56 #define LIBHDHOMERUN_API 57 #endif 58 59 #define LIBHDHOMERUN_PACKED(x) __pragma(pack(push, 1)) x __pragma( pack(pop)) 60 61 #if !defined(__unused) 62 #define __unused __pragma(warning(suppress: 4100 4101)) 63 #endif 64 65 #if !defined(alignas) && !defined(__cplusplus) 66 #define alignas(n) __declspec(align(n)) 67 #endif 68 69 typedef void (*sig_t)(int); 70 typedef void (*thread_task_func_t)(void *arg); 71 typedef HANDLE thread_task_t; 72 typedef HANDLE thread_mutex_t; 73 typedef HANDLE thread_cond_t; 74 75 #if !defined(va_copy) 76 #define va_copy(x, y) x = y 77 #endif 78 79 #define atoll _atoi64 80 #define strdup _strdup 81 #define strcasecmp _stricmp 82 #define strncasecmp _strnicmp 83 #define fseeko _fseeki64 84 #define ftello _ftelli64 85 86 #ifdef __cplusplus 87 extern "C" { 88 #endif 89 90 extern LIBHDHOMERUN_API uint32_t random_get32(void); 91 extern LIBHDHOMERUN_API uint64_t getcurrenttime(void); 92 extern LIBHDHOMERUN_API void msleep_approx(uint64_t ms); 93 extern LIBHDHOMERUN_API void msleep_minimum(uint64_t ms); 94 95 extern LIBHDHOMERUN_API bool thread_task_create(thread_task_t *tid, thread_task_func_t func, void *arg); 96 extern LIBHDHOMERUN_API void thread_task_join(thread_task_t tid); 97 98 extern LIBHDHOMERUN_API void thread_mutex_init(thread_mutex_t *mutex); 99 extern LIBHDHOMERUN_API void thread_mutex_dispose(thread_mutex_t *mutex); 100 extern LIBHDHOMERUN_API void thread_mutex_lock(thread_mutex_t *mutex); 101 extern LIBHDHOMERUN_API void thread_mutex_unlock(thread_mutex_t *mutex); 102 103 extern LIBHDHOMERUN_API void thread_cond_init(thread_cond_t *cond); 104 extern LIBHDHOMERUN_API void thread_cond_dispose(thread_cond_t *cond); 105 extern LIBHDHOMERUN_API void thread_cond_signal(thread_cond_t *cond); 106 extern LIBHDHOMERUN_API void thread_cond_wait(thread_cond_t *cond); 107 extern LIBHDHOMERUN_API void thread_cond_wait_with_timeout(thread_cond_t *cond, uint64_t max_wait_time); 108 109 extern LIBHDHOMERUN_API bool hdhomerun_vsprintf(char *buffer, char *end, const char *fmt, va_list ap); 110 extern LIBHDHOMERUN_API bool hdhomerun_sprintf(char *buffer, char *end, const char *fmt, ...); 111 112 #ifdef __cplusplus 113 } 114 #endif 115