From 0e6427f3ff8c51d19644279c2a46c191e6acb1ea Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Sun, 6 Feb 2011 20:26:18 +0000 Subject: [PATCH] - Hopefully fix (#3984) compiler errors on Solaris while not introducing too many new ones on the other platforms - With _BSD_SOURCE now explicitly defined bring back strdup to vm_x86_64_assembler.c --- code/qcommon/net_ip.c | 6 ++++-- code/qcommon/q_shared.h | 8 ++++++++ code/qcommon/vm_x86_64_assembler.c | 7 ++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/code/qcommon/net_ip.c b/code/qcommon/net_ip.c index ba40f75b..fbb46486 100644 --- a/code/qcommon/net_ip.c +++ b/code/qcommon/net_ip.c @@ -50,6 +50,7 @@ typedef unsigned short sa_family_t; # define EADDRNOTAVAIL WSAEADDRNOTAVAIL # define EAFNOSUPPORT WSAEAFNOSUPPORT # define ECONNRESET WSAECONNRESET +typedef u_long ioctlarg_t; # define socketError WSAGetLastError( ) static WSADATA winsockdata; @@ -85,6 +86,7 @@ typedef int SOCKET; # define SOCKET_ERROR -1 # define closesocket close # define ioctlsocket ioctl +typedef int ioctlarg_t; # define socketError errno #endif @@ -831,7 +833,7 @@ NET_IPSocket int NET_IPSocket( char *net_interface, int port, int *err ) { SOCKET newsocket; struct sockaddr_in address; - u_long _true = 1; + ioctlarg_t _true = 1; int i = 1; *err = 0; @@ -899,7 +901,7 @@ NET_IP6Socket int NET_IP6Socket( char *net_interface, int port, struct sockaddr_in6 *bindto, int *err ) { SOCKET newsocket; struct sockaddr_in6 address; - u_long _true = 1; + ioctlarg_t _true = 1; *err = 0; diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 56734dce..df4d8def 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -23,6 +23,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __Q_SHARED_H #define __Q_SHARED_H +#ifndef _BSD_SOURCE + #define _BSD_SOURCE +#endif + +#ifndef _POSIX_C_SOURCE + #define _POSIX_C_SOURCE 200112L +#endif + // q_shared.h -- included first by ALL program modules. // A user mod should never modify this file diff --git a/code/qcommon/vm_x86_64_assembler.c b/code/qcommon/vm_x86_64_assembler.c index 9c6c5c69..b5e79f98 100644 --- a/code/qcommon/vm_x86_64_assembler.c +++ b/code/qcommon/vm_x86_64_assembler.c @@ -241,15 +241,12 @@ static void hash_add_label(const char* label, unsigned address) { struct hashentry* h; unsigned i = hashkey(label, -1U); - int labellen; i %= sizeof(labelhash)/sizeof(labelhash[0]); h = malloc(sizeof(struct hashentry)); - labellen = strlen(label) + 1; - h->label = malloc(labellen); - memcpy(h->label, label, labellen); - + h->label = strdup(label); + h->address = address; h->next = labelhash[i]; labelhash[i] = h;