fix Windows warnings: getpid, htole64, gettimeofday, socket_t mismatches, radix min
This commit is contained in:
1 parent
14dd90365a
commit
1be007f292
6 files changed
+10
-5
No files matched your search
@@ -28,6 +28,8 @@ extern "C" {
|
||||
#define be32toh(x) _byteswap_ulong(x)
|
||||
#define htobe64(x) _byteswap_uint64(x)
|
||||
#define be64toh(x) _byteswap_uint64(x)
|
||||
#define htole64(x) (x)
|
||||
#define le64toh(x) (x)
|
||||
#else
|
||||
#include <endian.h>
|
||||
#endif
|
||||
@@ -35,6 +37,7 @@ extern "C" {
|
||||
// POSIX functions missing on Windows
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define getpid() ((int)GetCurrentProcessId())
|
||||
|
||||
// memmem — not available on Windows
|
||||
#define memmem compat_memmem
|
||||
|
||||
+2
-1
@@ -38,7 +38,8 @@
|
||||
#include "debug_config.h"
|
||||
#include "radix.h"
|
||||
|
||||
#define min(a, b) ((a) < (b) ? (a) : (b))
|
||||
#undef min
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
static struct radix_node
|
||||
*rn_insert(void *, struct radix_head *, int *,
|
||||
|
||||
@@ -528,7 +528,7 @@ void dummynet_reset_stats(struct dummynet* dn, int direction) {
|
||||
}
|
||||
|
||||
/* Возвращает файловый дескриптор сокета */
|
||||
int dummynet_get_socket(struct dummynet* dn) {
|
||||
socket_t dummynet_get_socket(struct dummynet* dn) {
|
||||
if (!dn) return SOCKET_INVALID;
|
||||
return dn->sock;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ extern "C" {
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "../lib/socket_compat.h"
|
||||
|
||||
// Forward declarations
|
||||
struct UASYNC;
|
||||
@@ -127,7 +128,7 @@ void dummynet_reset_stats(struct dummynet* dn, int direction);
|
||||
* @param dn Контекст dummynet
|
||||
* @return socket_t или SOCKET_INVALID
|
||||
*/
|
||||
int dummynet_get_socket(struct dummynet* dn);
|
||||
socket_t dummynet_get_socket(struct dummynet* dn);
|
||||
|
||||
/**
|
||||
* @brief Возвращает listen_port
|
||||
|
||||
@@ -101,7 +101,7 @@ struct test_ctx {
|
||||
/* ===== Time helper ===== */
|
||||
static uint64_t now_us(void) {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
utun_gettimeofday(&tv, NULL);
|
||||
return (uint64_t)tv.tv_sec * 1000000ULL + tv.tv_usec;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ int main(void) {
|
||||
struct sockaddr_in ea = {.sin_family = AF_INET, .sin_addr = {.s_addr = inet_addr("127.0.0.1")}, .sin_port = htons(UDP_ECHO_PORT)};
|
||||
if (bind(g_echo_sock, (struct sockaddr*)&ea, sizeof(ea)) < 0) { printf("[FAIL] echo bind: %s\n", strerror(errno)); goto done; }
|
||||
socket_set_nonblocking(g_echo_sock);
|
||||
g_echo_id = uasync_add_socket(ua, g_echo_sock, udp_echo_cb, NULL, NULL, NULL);
|
||||
g_echo_id = uasync_add_socket_t(ua, g_echo_sock, udp_echo_cb, NULL, NULL, NULL);
|
||||
|
||||
g_to_id = uasync_set_timeout(ua, 100, NULL, monitor, "mon");
|
||||
void* to_id = uasync_set_timeout(ua, TEST_TIMEOUT_MS * 10, NULL, test_timeout, "to");
|
||||
|
||||
Reference in new issue
Block a user