Commit e4614618 authored by Nirbheek Chauhan's avatar Nirbheek Chauhan Committed by Olivier Crête

Fix build with MSVC

Tested inside Cerbero with VS 2017
parent 3685e3d3
...@@ -21,6 +21,7 @@ endif ...@@ -21,6 +21,7 @@ endif
libnice = library('nice', libnice = library('nice',
link_whole: [libagent, libsocket, libstun, librandom], link_whole: [libagent, libsocket, libstun, librandom],
dependencies: nice_deps,
version : libversion, version : libversion,
soversion : soversion, soversion : soversion,
vs_module_defs: libnice_def, vs_module_defs: libnice_def,
...@@ -62,5 +63,6 @@ pkg.generate(libnice, ...@@ -62,5 +63,6 @@ pkg.generate(libnice,
subdirs: 'nice', subdirs: 'nice',
description: 'ICE library', description: 'ICE library',
requires: glib_dep, requires: glib_dep,
requires_private: [gthread_dep, gupnp_igd_dep, crypto_dep, syslibs], requires_private: [gthread_dep, gupnp_igd_dep, crypto_dep],
libraries_private: syslibs,
variables: ['upnp_enabled=@0@'.format(upnp_enabled_string)]) variables: ['upnp_enabled=@0@'.format(upnp_enabled_string)])
...@@ -43,19 +43,20 @@ ...@@ -43,19 +43,20 @@
#include "random-glib.h" #include "random-glib.h"
#define TEST_RNGSIZE 256
int int
main (void) main (void)
{ {
NiceRNG *rng; NiceRNG *rng;
const int rngsize = 256; gchar buf[TEST_RNGSIZE];
gchar buf[rngsize];
buf[rngsize - 1] = '\0'; buf[TEST_RNGSIZE - 1] = '\0';
nice_rng_set_new_func (nice_rng_glib_new_predictable); nice_rng_set_new_func (nice_rng_glib_new_predictable);
rng = nice_rng_new (); rng = nice_rng_new ();
nice_rng_generate_bytes_print (rng, rngsize - 1, buf); nice_rng_generate_bytes_print (rng, TEST_RNGSIZE - 1, buf);
/* g_debug ("%s", buf); */ /* g_debug ("%s", buf); */
g_assert (0 == strcmp (buf, "sv1AD7DnJTVykXGYYM6BmnXuYRlZNIJUzQzF+PvASjYxzdTTOngBJ5/gfK0Xj+Ly3ciAAk1Fmo0RPEpq6f4BBnp5jm3LuSbAOj1M5qULEGEv/0DMk0oOPUj6XPN1VwxFpjAfFeAxykiwdDiqNwnVJ/AKyr6/X7C5i+je7DSujURybOp6BkKWroLCzQg2AmTuqz48oNeY9CDeirNwoITfIaC40Ds9OgEDtL8WN5tL4QYdVuZQ85219Thogk775GV")); g_assert (0 == strcmp (buf, "sv1AD7DnJTVykXGYYM6BmnXuYRlZNIJUzQzF+PvASjYxzdTTOngBJ5/gfK0Xj+Ly3ciAAk1Fmo0RPEpq6f4BBnp5jm3LuSbAOj1M5qULEGEv/0DMk0oOPUj6XPN1VwxFpjAfFeAxykiwdDiqNwnVJ/AKyr6/X7C5i+je7DSujURybOp6BkKWroLCzQg2AmTuqz48oNeY9CDeirNwoITfIaC40Ds9OgEDtL8WN5tL4QYdVuZQ85219Thogk775GV"));
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
/* FIXME: This should be defined in gio/gnetworking.h, which we should include; /* FIXME: This should be defined in gio/gnetworking.h, which we should include;
* but we cannot do that without refactoring. * but we cannot do that without refactoring.
* (See: https://phabricator.freedesktop.org/D230). */ * (See: https://phabricator.freedesktop.org/D230). */
#undef TCP_NODELAY
#define TCP_NODELAY 1 #define TCP_NODELAY 1
typedef struct { typedef struct {
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
/* FIXME: This should be defined in gio/gnetworking.h, which we should include; /* FIXME: This should be defined in gio/gnetworking.h, which we should include;
* but we cannot do that without refactoring. * but we cannot do that without refactoring.
* (See: https://phabricator.freedesktop.org/D230). */ * (See: https://phabricator.freedesktop.org/D230). */
#undef TCP_NODELAY
#define TCP_NODELAY 1 #define TCP_NODELAY 1
static GMutex mutex; static GMutex mutex;
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
/* FIXME: This should be defined in gio/gnetworking.h, which we should include; /* FIXME: This should be defined in gio/gnetworking.h, which we should include;
* but we cannot do that without refactoring. * but we cannot do that without refactoring.
* (See: https://phabricator.freedesktop.org/D230). */ * (See: https://phabricator.freedesktop.org/D230). */
#undef TCP_NODELAY
#define TCP_NODELAY 1 #define TCP_NODELAY 1
typedef struct { typedef struct {
......
...@@ -57,10 +57,9 @@ ...@@ -57,10 +57,9 @@
#include "win32_common.h" #include "win32_common.h"
#else #else
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#endif #endif
#include <stdbool.h>
#include <sys/types.h> #include <sys/types.h>
/** /**
......
...@@ -43,9 +43,9 @@ ...@@ -43,9 +43,9 @@
#include "win32_common.h" #include "win32_common.h"
#else #else
#include <stdint.h> #include <stdint.h>
#include <stdbool.h>
#endif #endif
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
typedef struct { typedef struct {
......
...@@ -44,7 +44,10 @@ ...@@ -44,7 +44,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
......
...@@ -69,15 +69,7 @@ typedef unsigned uint32_t; ...@@ -69,15 +69,7 @@ typedef unsigned uint32_t;
typedef long long int64_t; typedef long long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
/* size_t and ssize_t are not defined on Windows */ /* ssize_t is not defined on Windows */
#ifndef size_t
# if defined(_WIN64)
typedef unsigned __int64 size_t;
# else
typedef unsigned long size_t;
# endif
#endif /* !size_t */
#ifndef ssize_t #ifndef ssize_t
# if defined(_WIN64) # if defined(_WIN64)
typedef signed __int64 ssize_t; typedef signed __int64 ssize_t;
...@@ -86,4 +78,8 @@ typedef signed long ssize_t; ...@@ -86,4 +78,8 @@ typedef signed long ssize_t;
# endif # endif
#endif /* !ssize_t */ #endif /* !ssize_t */
/* Windows v10.0.16232 SDK defines MSG_ERRQUEUE, but doesn't support it with
* recvmsg, and also uses a different msghdr struct */
#undef MSG_ERRQUEUE
#endif /* _WIN32_COMMON_H */ #endif /* _WIN32_COMMON_H */
nice_tests = [ nice_tests = [
'test-pseudotcp', 'test-pseudotcp',
'test-pseudotcp-fin',
'test-pseudotcp-fuzzy', 'test-pseudotcp-fuzzy',
'test-bsd', 'test-bsd',
'test', 'test',
...@@ -22,7 +21,6 @@ nice_tests = [ ...@@ -22,7 +21,6 @@ nice_tests = [
'test-fallback', 'test-fallback',
'test-thread', 'test-thread',
'test-dribble', 'test-dribble',
'test-new-dribble',
'test-tcp', 'test-tcp',
'test-icetcp', 'test-icetcp',
'test-credentials', 'test-credentials',
...@@ -31,6 +29,13 @@ nice_tests = [ ...@@ -31,6 +29,13 @@ nice_tests = [
'test-nomination', 'test-nomination',
] ]
if cc.has_header('arpa/inet.h')
nice_tests += [
'test-pseudotcp-fin',
'test-new-dribble',
]
endif
tenv = environment() tenv = environment()
tenv.set('BUILT_WITH_MESON', '1') tenv.set('BUILT_WITH_MESON', '1')
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "agent-priv.h" #include "agent-priv.h"
#include "socket.h" #include "socket.h"
static GRand *rand; static GRand *randg;
static GSList * static GSList *
generate_test_messages(void) generate_test_messages(void)
...@@ -45,7 +45,7 @@ generate_test_messages(void) ...@@ -45,7 +45,7 @@ generate_test_messages(void)
for (i = 0; i != 100; ++i) { for (i = 0; i != 100; ++i) {
GInputVector *msg_data = g_new (GInputVector, 1); GInputVector *msg_data = g_new (GInputVector, 1);
gsize msg_size = g_rand_int_range (rand, 0, G_MAXUINT16); gsize msg_size = g_rand_int_range (randg, 0, G_MAXUINT16);
gsize j; gsize j;
msg_data->size = msg_size + sizeof (guint16); msg_data->size = msg_size + sizeof (guint16);
...@@ -53,7 +53,7 @@ generate_test_messages(void) ...@@ -53,7 +53,7 @@ generate_test_messages(void)
*(guint16 *)(msg_data->buffer) = htons (msg_size); *(guint16 *)(msg_data->buffer) = htons (msg_size);
for (j = 2; j != msg_data->size; ++j) { for (j = 2; j != msg_data->size; ++j) {
((guint8 *)msg_data->buffer)[j] = g_rand_int(rand); ((guint8 *)msg_data->buffer)[j] = g_rand_int(randg);
} }
result = g_slist_append(result, msg_data); result = g_slist_append(result, msg_data);
...@@ -76,7 +76,7 @@ test_socket_recv_messages (NiceSocket *sock, NiceInputMessage *recv_messages, ...@@ -76,7 +76,7 @@ test_socket_recv_messages (NiceSocket *sock, NiceInputMessage *recv_messages,
guint i; guint i;
for (i = 0; priv->current_msg && i != n_recv_messages; ++i) { for (i = 0; priv->current_msg && i != n_recv_messages; ++i) {
gsize msg_size = g_rand_int_range (rand, 0, G_MAXUINT16) + sizeof (guint16); gsize msg_size = g_rand_int_range (randg, 0, G_MAXUINT16) + sizeof (guint16);
gsize j; gsize j;
j = sizeof (guint16); j = sizeof (guint16);
...@@ -132,6 +132,8 @@ test_socket_new (GSList *msg_data) ...@@ -132,6 +132,8 @@ test_socket_new (GSList *msg_data)
return sock; return sock;
} }
#define N_RECV_MESSAGES 7
static void static void
tcp_turn_fragmentation (void) tcp_turn_fragmentation (void)
{ {
...@@ -143,17 +145,16 @@ tcp_turn_fragmentation (void) ...@@ -143,17 +145,16 @@ tcp_turn_fragmentation (void)
NiceAddress addr; NiceAddress addr;
NiceSocket *turnsock; NiceSocket *turnsock;
guint n_recv_messages = 7; NiceInputMessage recv_messages[N_RECV_MESSAGES];
NiceInputMessage recv_messages[n_recv_messages]; GInputVector recv_vectors[N_RECV_MESSAGES];
GInputVector recv_vectors[n_recv_messages]; NiceAddress recv_addr[N_RECV_MESSAGES];
NiceAddress recv_addr[n_recv_messages]; guint8 recv_buffers[N_RECV_MESSAGES][G_MAXUINT16 + sizeof (guint16)];
guint8 recv_buffers[n_recv_messages][G_MAXUINT16 + sizeof (guint16)];
gint n_messages; gint n_messages;
guint i; guint i;
GSList *li; GSList *li;
for (i = 0; i != n_recv_messages; ++i) { for (i = 0; i != N_RECV_MESSAGES; ++i) {
recv_messages[i].buffers = &recv_vectors[i]; recv_messages[i].buffers = &recv_vectors[i];
recv_messages[i].from = &recv_addr[i]; recv_messages[i].from = &recv_addr[i];
recv_messages[i].n_buffers = 1; recv_messages[i].n_buffers = 1;
...@@ -171,7 +172,7 @@ tcp_turn_fragmentation (void) ...@@ -171,7 +172,7 @@ tcp_turn_fragmentation (void)
li = test_messages; li = test_messages;
while (li) { while (li) {
n_messages = nice_socket_recv_messages (turnsock, recv_messages, n_messages = nice_socket_recv_messages (turnsock, recv_messages,
n_recv_messages); N_RECV_MESSAGES);
for (i = 0; i != (guint)n_messages; ++i) { for (i = 0; i != (guint)n_messages; ++i) {
NiceInputMessage *message = &recv_messages[i]; NiceInputMessage *message = &recv_messages[i];
...@@ -202,7 +203,7 @@ main (int argc, char *argv[]) ...@@ -202,7 +203,7 @@ main (int argc, char *argv[])
{ {
GMainLoop *mainloop; GMainLoop *mainloop;
rand = g_rand_new(); randg = g_rand_new();
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
mainloop = g_main_loop_new (NULL, TRUE); mainloop = g_main_loop_new (NULL, TRUE);
...@@ -211,7 +212,7 @@ main (int argc, char *argv[]) ...@@ -211,7 +212,7 @@ main (int argc, char *argv[])
g_test_run (); g_test_run ();
g_rand_free(rand); g_rand_free(randg);
g_main_loop_unref (mainloop); g_main_loop_unref (mainloop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment