Skip to content

Commit

Permalink
fixed build on linux
Browse files Browse the repository at this point in the history
__cdecl was undefined in several cases
  • Loading branch information
bloke committed May 1, 2018
1 parent 7366381 commit 2eebc8c
Show file tree
Hide file tree
Showing 26 changed files with 134 additions and 128 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CC=gcc
CPP=g++
WIN_DEFINES=WINVER=0x501
LINUX_DEFINES=_GNU_SOURCE
CFLAGS=-m32 -msse2 -mfpmath=sse -Wall -O0 -g -fno-omit-frame-pointer
CFLAGS=-m32 -msse2 -mfpmath=sse -Wall -O0 -g -fno-omit-frame-pointer -fmax-errors=15
WIN_LFLAGS=-m32 -g -Wl,--nxcompat,--stack,0x800000 -mwindows -static-libgcc -static -lm
WIN_LLIBS=tomcrypt mbedtls mbedcrypto mbedx509 ws2_32 wsock32 iphlpapi gdi32 winmm stdc++
LINUX_LFLAGS=-m32 -g -static-libgcc -rdynamic -Wl,-rpath=./
Expand Down
2 changes: 1 addition & 1 deletion src/bg_jump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "player.h"
#include "cvar.h"
#include "bg_local.h"
#include "q_math.h"
#include "q_shared.h"

#define PMF_JUMPING 0x4000
#define PMF_LADDER 0x8
Expand Down
2 changes: 1 addition & 1 deletion src/cm_debug.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "q_math.h"
#include "q_shared.h"
#include "cm_local.h"
#include "qcommon.h"
#include "cmd.h"
Expand Down
2 changes: 1 addition & 1 deletion src/cm_test.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "q_math.h"
#include "q_shared.h"
#include "cm_local.h"


Expand Down
2 changes: 1 addition & 1 deletion src/cmodel.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "q_math.h"
#include "q_shared.h"
#include "cm_local.h"

/*
Expand Down
2 changes: 1 addition & 1 deletion src/com_pack.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "com_pack.h"
#include "q_shared.h"
#include "q_math.h"
#include "q_shared.h"

extern "C"
{
Expand Down
2 changes: 1 addition & 1 deletion src/cvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef __CVAR_H__
#define __CVAR_H__

#include "q_math.h"
#include "q_shared.h"
#include "q_shared.h"

// nothing outside the Cvar_*() functions should modify these fields!
Expand Down
2 changes: 1 addition & 1 deletion src/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define __ENTITY_H__

#include "g_public_mp.h"
#include "q_math.h"
#include "q_shared.h"
#include "q_shared.h"
#include "game/surfaceflags.h"

Expand Down
2 changes: 1 addition & 1 deletion src/g_sv_movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@



#include "q_math.h"
#include "q_shared.h"
#include "q_shared.h"
#include "g_shared.h"
#include "entity.h"
Expand Down
2 changes: 1 addition & 1 deletion src/g_sv_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#ifndef __G_SV_SHARED_H__
#define __G_SV_SHARED_H__

#include "q_math.h"
#include "q_shared.h"
#include "q_shared.h"
#include "entity.h"
#include "cvar.h"
Expand Down
2 changes: 1 addition & 1 deletion src/g_weapon.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "q_shared.h"
#include "q_math.h"
#include "q_shared.h"
#include "g_shared.h"
#include "server.h"
#include "cscr_stringlist.h"
Expand Down
2 changes: 1 addition & 1 deletion src/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "q_shared.h"
#include "entity.h"
#include "q_math.h"
#include "q_shared.h"
#include "player.h"

#include <stdint.h>
Expand Down
2 changes: 1 addition & 1 deletion src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "g_public_mp.h"
#include "q_shared.h"
#include "q_math.h"
#include "q_shared.h"
#include "entity.h"

#define KEY_MASK_FORWARD 127
Expand Down
3 changes: 2 additions & 1 deletion src/q_math.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

#include "q_shared.h"
#include "q_shared.h"
#include "q_math.h"
#include <math.h>


Expand Down
1 change: 1 addition & 0 deletions src/q_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef __Q_MATH_H__
#define __Q_MATH_H__


/*
==============================================================
Expand Down
2 changes: 1 addition & 1 deletion src/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ typedef unsigned int clipHandle_t;
#endif

#include "q_platform.h"
#include "q_math.h"
#include "q_shared.h"
#include "sys_cod4defs.h"

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/scr_vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


#include "q_shared.h"
#include "q_math.h"
#include "q_shared.h"
#include "entity.h"
#include "player.h"
#include "g_hud.h"
Expand Down
2 changes: 1 addition & 1 deletion src/sv_bots.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "sv_bots.h"
#include "scr_vm.h"
#include "sys_main.h"
#include "q_math.h"
#include "q_shared.h"
#include "scr_vm_functions.h"
#include "misc.h"
#include "dobj_part_cache.h"
Expand Down
2 changes: 1 addition & 1 deletion src/sv_bots.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "player.h"
#include "sys_cod4defs.h"
#include "q_math.h"
#include "q_shared.h"

/* Should keep attribute and this field layout.
* Met situation where simple vector read into moveTo broke whole
Expand Down
2 changes: 1 addition & 1 deletion src/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "hl2rcon.h"
#include "crc.h"
#include "sv_bots.h"
#include "q_math.h"
#include "q_shared.h"
#include "math.h"
#include "httpftp.h"
#include "cscr_stringlist.h"
Expand Down
213 changes: 108 additions & 105 deletions src/sys_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,6 @@
===========================================================================
*/

#ifdef _WIN32
# include <winsock2.h>
# include <ws2tcpip.h>
# include <iphlpapi.h>
# if WINVER < 0x501
# ifdef __MINGW32__
// wspiapi.h isn't available on MinGW, so if it's
// present it's because the end user has added it
// and we should look for it in our tree
# include "wspiapi.h"
# else
# include <wspiapi.h>
# endif
# else
# include <ws2spi.h>
# endif

#include "qcommon_io.h"
#include "sys_net.h"
#include "cvar.h"
Expand All @@ -53,100 +36,120 @@
#include <ctype.h>
#include <stddef.h> /* for offsetof*/

typedef int socklen_t;
# ifdef ADDRESS_FAMILY
# define sa_family_t ADDRESS_FAMILY
# else
typedef unsigned short sa_family_t;
# endif
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#if WINVER < 0x501
#ifdef __MINGW32__
// wspiapi.h isn't available on MinGW, so if it's
// present it's because the end user has added it
// and we should look for it in our tree
#include "wspiapi.h"
#else
#include <wspiapi.h>
#endif
#else
#include <ws2spi.h>
#endif

/* no epipe yet */
#ifndef WSAEPIPE
#define WSAEPIPE -12345
#endif
# define EAGAIN WSAEWOULDBLOCK
# define EADDRNOTAVAIL WSAEADDRNOTAVAIL
# define EAFNOSUPPORT WSAEAFNOSUPPORT
# define ECONNRESET WSAECONNRESET
# define EINPROGRESS WSAEINPROGRESS
# define EINTR WSAEINTR
# define EPIPE WSAEPIPE
typedef u_long ioctlarg_t;
# define socketError WSAGetLastError( )

#define NET_NOSIGNAL 0x0

static WSADATA winsockdata;
static qboolean winsockInitialized = qfalse;

#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27 // Treat wildcard bind as AF_INET6-only.
#endif

int inet_pton(int af, const char *src, void *dst)
{
struct sockaddr_storage sin;
int addrSize = sizeof(sin);
char address[256];
strncpy(address, src, sizeof(address));


int rc = WSAStringToAddressA( address, af, NULL, (SOCKADDR*)&sin, &addrSize );
if(rc != 0)
{
return -1;
}
if(af == AF_INET)
{
*((struct in_addr *)dst) = ((struct sockaddr_in*)&sin)->sin_addr;
return 1;
}
if(af == AF_INET6)
{
*((struct in_addr6 *)dst) = ((struct sockaddr_in6*)&sin)->sin6_addr;
return 1;
typedef int socklen_t;
# ifdef ADDRESS_FAMILY
# define sa_family_t ADDRESS_FAMILY
# else
typedef unsigned short sa_family_t;
# endif

/* no epipe yet */
#ifndef WSAEPIPE
#define WSAEPIPE -12345
#endif
# define EAGAIN WSAEWOULDBLOCK
# define EADDRNOTAVAIL WSAEADDRNOTAVAIL
# define EAFNOSUPPORT WSAEAFNOSUPPORT
# define ECONNRESET WSAECONNRESET
# define EINPROGRESS WSAEINPROGRESS
# define EINTR WSAEINTR
# define EPIPE WSAEPIPE
typedef u_long ioctlarg_t;
# define socketError WSAGetLastError( )

#define NET_NOSIGNAL 0x0

static WSADATA winsockdata;
static qboolean winsockInitialized = qfalse;

#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 27 // Treat wildcard bind as AF_INET6-only.
#endif

int inet_pton(int af, const char *src, void *dst)
{
struct sockaddr_storage sin;
int addrSize = sizeof(sin);
char address[256];
strncpy(address, src, sizeof(address));

int rc = WSAStringToAddressA( address, af, NULL, (SOCKADDR*)&sin, &addrSize );
if(rc != 0)
{
return -1;
}
if(af == AF_INET)
{
*((struct in_addr *)dst) = ((struct sockaddr_in*)&sin)->sin_addr;
return 1;
}
if(af == AF_INET6)
{
*((struct in_addr6 *)dst) = ((struct sockaddr_in6*)&sin)->sin6_addr;
return 1;
}
return 0;
}
return 0;
}

#else

# if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
// needed for socklen_t on OSX 10.2
# define _BSD_SOCKLEN_T_
# endif

#ifdef MACOS_X
#define NET_NOSIGNAL SO_NOSIGPIPE
#else
#define NET_NOSIGNAL MSG_NOSIGNAL
#endif

# include <sys/socket.h>
# include <errno.h>
# include <netdb.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <net/if.h>
# include <sys/ioctl.h>
# include <sys/types.h>
# include <sys/time.h>
# include <unistd.h>
# if !defined(__sun) && !defined(__sgi)
# include <ifaddrs.h>
# endif

# ifdef __sun
# include <sys/filio.h>
# endif


# define INVALID_SOCKET -1
# define SOCKET_ERROR -1
# define closesocket close
# define ioctlsocket ioctl
typedef int ioctlarg_t;
# define socketError errno
typedef int SOCKET;
# if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
// needed for socklen_t on OSX 10.2
# define _BSD_SOCKLEN_T_
# endif

#ifdef MACOS_X
#define NET_NOSIGNAL SO_NOSIGPIPE
#else
#define NET_NOSIGNAL MSG_NOSIGNAL
#endif

#include <sys/socket.h>
#include <errno.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include "net_game.h"
#include <sys/time.h>
#include <unistd.h>
# if !defined(__sun) && !defined(__sgi)
# include <ifaddrs.h>
# endif

# ifdef __sun
# include <sys/filio.h>
# endif


# define INVALID_SOCKET -1
# define SOCKET_ERROR -1
# define closesocket close
# define ioctlsocket ioctl
typedef int ioctlarg_t;
# define socketError errno
typedef int SOCKET;
#endif


Expand Down
Loading

0 comments on commit 2eebc8c

Please sign in to comment.