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
libnice = library('nice',
link_whole: [libagent, libsocket, libstun, librandom],
dependencies: nice_deps,
version : libversion,
soversion : soversion,
vs_module_defs: libnice_def,
......@@ -62,5 +63,6 @@ pkg.generate(libnice,
subdirs: 'nice',
description: 'ICE library',
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)])
......@@ -43,19 +43,20 @@
#include "random-glib.h"
#define TEST_RNGSIZE 256
int
main (void)
{
NiceRNG *rng;
const int rngsize = 256;
gchar buf[rngsize];
gchar buf[TEST_RNGSIZE];
buf[rngsize - 1] = '\0';
buf[TEST_RNGSIZE - 1] = '\0';
nice_rng_set_new_func (nice_rng_glib_new_predictable);
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_assert (0 == strcmp (buf, "sv1AD7DnJTVykXGYYM6BmnXuYRlZNIJUzQzF+PvASjYxzdTTOngBJ5/gfK0Xj+Ly3ciAAk1Fmo0RPEpq6f4BBnp5jm3LuSbAOj1M5qULEGEv/0DMk0oOPUj6XPN1VwxFpjAfFeAxykiwdDiqNwnVJ/AKyr6/X7C5i+je7DSujURybOp6BkKWroLCzQg2AmTuqz48oNeY9CDeirNwoITfIaC40Ds9OgEDtL8WN5tL4QYdVuZQ85219Thogk775GV"));
......
......@@ -53,6 +53,7 @@
/* FIXME: This should be defined in gio/gnetworking.h, which we should include;
* but we cannot do that without refactoring.
* (See: https://phabricator.freedesktop.org/D230). */
#undef TCP_NODELAY
#define TCP_NODELAY 1
typedef struct {
......
......@@ -59,6 +59,7 @@
/* FIXME: This should be defined in gio/gnetworking.h, which we should include;
* but we cannot do that without refactoring.
* (See: https://phabricator.freedesktop.org/D230). */
#undef TCP_NODELAY
#define TCP_NODELAY 1
static GMutex mutex;
......
......@@ -53,6 +53,7 @@
/* FIXME: This should be defined in gio/gnetworking.h, which we should include;
* but we cannot do that without refactoring.
* (See: https://phabricator.freedesktop.org/D230). */
#undef TCP_NODELAY
#define TCP_NODELAY 1
typedef struct {
......
......@@ -57,10 +57,9 @@
#include "win32_common.h"
#else
#include <stdint.h>
#include <stdbool.h>
#endif
#include <stdbool.h>
#include <sys/types.h>
/**
......
......@@ -43,9 +43,9 @@
#include "win32_common.h"
#else
#include <stdint.h>
#include <stdbool.h>
#endif
#include <stdbool.h>
#include <stdlib.h>
typedef struct {
......
......@@ -44,7 +44,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <winsock2.h>
......
......@@ -69,15 +69,7 @@ typedef unsigned uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
/* size_t and ssize_t are 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 */
/* ssize_t is not defined on Windows */
#ifndef ssize_t
# if defined(_WIN64)
typedef signed __int64 ssize_t;
......@@ -86,4 +78,8 @@ typedef signed long ssize_t;
# endif
#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 */
nice_tests = [
'test-pseudotcp',
'test-pseudotcp-fin',
'test-pseudotcp-fuzzy',
'test-bsd',
'test',
......@@ -22,7 +21,6 @@ nice_tests = [
'test-fallback',
'test-thread',
'test-dribble',
'test-new-dribble',
'test-tcp',
'test-icetcp',
'test-credentials',
......@@ -31,6 +29,13 @@ nice_tests = [
'test-nomination',
]
if cc.has_header('arpa/inet.h')
nice_tests += [
'test-pseudotcp-fin',
'test-new-dribble',
]
endif
tenv = environment()
tenv.set('BUILT_WITH_MESON', '1')
......
......@@ -35,7 +35,7 @@
#include "agent-priv.h"
#include "socket.h"
static GRand *rand;
static GRand *randg;
static GSList *
generate_test_messages(void)
......@@ -45,7 +45,7 @@ generate_test_messages(void)
for (i = 0; i != 100; ++i) {
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;
msg_data->size = msg_size + sizeof (guint16);
......@@ -53,7 +53,7 @@ generate_test_messages(void)
*(guint16 *)(msg_data->buffer) = htons (msg_size);
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);
......@@ -76,7 +76,7 @@ test_socket_recv_messages (NiceSocket *sock, NiceInputMessage *recv_messages,
guint 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;
j = sizeof (guint16);
......@@ -132,6 +132,8 @@ test_socket_new (GSList *msg_data)
return sock;
}
#define N_RECV_MESSAGES 7
static void
tcp_turn_fragmentation (void)
{
......@@ -143,17 +145,16 @@ tcp_turn_fragmentation (void)
NiceAddress addr;
NiceSocket *turnsock;
guint n_recv_messages = 7;
NiceInputMessage recv_messages[n_recv_messages];
GInputVector recv_vectors[n_recv_messages];
NiceAddress recv_addr[n_recv_messages];
guint8 recv_buffers[n_recv_messages][G_MAXUINT16 + sizeof (guint16)];
NiceInputMessage recv_messages[N_RECV_MESSAGES];
GInputVector recv_vectors[N_RECV_MESSAGES];
NiceAddress recv_addr[N_RECV_MESSAGES];
guint8 recv_buffers[N_RECV_MESSAGES][G_MAXUINT16 + sizeof (guint16)];
gint n_messages;
guint i;
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].from = &recv_addr[i];
recv_messages[i].n_buffers = 1;
......@@ -171,7 +172,7 @@ tcp_turn_fragmentation (void)
li = test_messages;
while (li) {
n_messages = nice_socket_recv_messages (turnsock, recv_messages,
n_recv_messages);
N_RECV_MESSAGES);
for (i = 0; i != (guint)n_messages; ++i) {
NiceInputMessage *message = &recv_messages[i];
......@@ -202,7 +203,7 @@ main (int argc, char *argv[])
{
GMainLoop *mainloop;
rand = g_rand_new();
randg = g_rand_new();
g_test_init (&argc, &argv, NULL);
mainloop = g_main_loop_new (NULL, TRUE);
......@@ -211,7 +212,7 @@ main (int argc, char *argv[])
g_test_run ();
g_rand_free(rand);
g_rand_free(randg);
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