mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge pull request #691 from benwaffle/master
fixed MSWindows detection in network.h
This commit is contained in:
commit
49d2d7f56e
@ -42,7 +42,7 @@
|
||||
#define SECOND_FLAG 0x2
|
||||
|
||||
/* ensure that we sleep in milliseconds */
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define c_sleep(x) Sleep(x)
|
||||
#else
|
||||
#define c_sleep(x) usleep(1000*x)
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "../toxcore/onion_announce.h"
|
||||
#include "../toxcore/util.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include "../toxcore/tox.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "../testing/misc_tools.c"
|
||||
|
||||
/* Sleep function (x = milliseconds) */
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include <string.h>
|
||||
|
||||
//Sleep function (x = milliseconds)
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "../toxcore/Lossless_UDP.h"
|
||||
#include "misc_tools.c"
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "misc_tools.c"
|
||||
|
||||
//Sleep function (x = milliseconds)
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include "../toxcore/Messenger.h"
|
||||
#include "misc_tools.c"
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#endif
|
||||
|
||||
// Hi-resolution timer
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#ifndef WINVER
|
||||
//Windows XP
|
||||
#define WINVER 0x0501
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "../../toxcore/group_chats.h"
|
||||
#define NUM_CHATS 8
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
#else
|
||||
#define c_sleep(x) usleep(1000*x)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "../../toxcore/group_chats.h"
|
||||
#define NUM_CHATS 8
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
#else
|
||||
#define c_sleep(x) usleep(1000*x)
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef __WIN32__
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define _WIN32_WINNT 0x501
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
@ -44,7 +44,7 @@
|
||||
#include <time.h>
|
||||
#include <locale.h>
|
||||
|
||||
#ifdef __WIN32__
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define c_sleep(x) Sleep(1*x)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#define IPV6_V6ONLY 27
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
|
||||
static const char *inet_ntop(sa_family_t family, void *addr, char *buf, size_t bufsize)
|
||||
{
|
||||
@ -112,7 +112,7 @@ static int inet_pton(sa_family_t family, const char *addrString, void *addrbuf)
|
||||
uint64_t current_time(void)
|
||||
{
|
||||
uint64_t time;
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
/* This probably works fine */
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
@ -228,7 +228,7 @@ static int receivepacket(sock_t sock, IP_Port *ip_port, uint8_t *data, uint32_t
|
||||
{
|
||||
memset(ip_port, 0, sizeof(IP_Port));
|
||||
struct sockaddr_storage addr;
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
int addrlen = sizeof(addr);
|
||||
#else
|
||||
socklen_t addrlen = sizeof(addr);
|
||||
@ -414,7 +414,7 @@ static int at_startup(void)
|
||||
sodium_init();
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
WSADATA wsaData;
|
||||
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != NO_ERROR)
|
||||
@ -431,7 +431,7 @@ static int at_startup(void)
|
||||
/* TODO: Put this somewhere
|
||||
static void at_shutdown(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
@ -471,7 +471,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
||||
temp->sock = socket(temp->family, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
||||
/* Check for socket error. */
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
|
||||
if (temp->sock == INVALID_SOCKET) { /* MSDN recommends this. */
|
||||
free(temp);
|
||||
@ -501,7 +501,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
||||
setsockopt(temp->sock, SOL_SOCKET, SO_BROADCAST, (char *)&broadcast, sizeof(broadcast));
|
||||
|
||||
/* Set socket nonblocking. */
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
/* I think this works for Windows. */
|
||||
u_long mode = 1;
|
||||
/* ioctl(sock, FIONBIO, &mode); */
|
||||
@ -662,7 +662,7 @@ Networking_Core *new_networking(IP ip, uint16_t port)
|
||||
/* Function to cleanup networking stuff. */
|
||||
void kill_networking(Networking_Core *net)
|
||||
{
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
closesocket(net->sock);
|
||||
#else
|
||||
close(net->sock);
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef WIN32 /* Put win32 includes here */
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) /* Put win32 includes here */
|
||||
#ifndef WINVER
|
||||
//Windows XP
|
||||
#define WINVER 0x0501
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#ifndef WINVER
|
||||
//Windows XP
|
||||
#define WINVER 0x0501
|
||||
|
@ -70,7 +70,7 @@
|
||||
#define DEFAULT_WEBCAM "/dev/video0"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
|
||||
#define VIDEO_DRIVER "vfwcap"
|
||||
#define DEFAULT_WEBCAM "0"
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user