From e68d860dbaa6b1bcf8104463cd3001ae946b7d4e Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 23 Jan 2014 16:51:56 +0100 Subject: [PATCH] Compatibility fixes for NetBSD and Solaris - Fixed some warnings in NetBSD (5.x and 6.x) and Solaris (11) Signed-off-by: Haru --- src/common/cbasetypes.h | 5 +++++ src/map/clif.c | 4 ++++ src/map/npc.c | 4 ++-- src/map/packets_struct.h | 4 ++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index 120f4f86134..97789750643 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -42,6 +42,11 @@ #define __DARWIN__ #endif +// Necessary for __NetBSD_Version__ (defined as VVRR00PP00) on NetBSD +#ifdef __NETBSD__ +#include +#endif // __NETBSD__ + // 64bit OS #if defined(_M_IA64) || defined(_M_X64) || defined(_WIN64) || defined(_LP64) || defined(_ILP64) || defined(__LP64__) || defined(__ppc64__) #define __64BIT__ diff --git a/src/map/clif.c b/src/map/clif.c index 5f835a8ab82..fe3e7cfe998 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -12959,14 +12959,18 @@ bool clif_validate_emblem(const uint8 *emblem, unsigned long emblem_len) { BITMAP_WIDTH = 24, BITMAP_HEIGHT = 24, }; +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(push, 1) +#endif // not NetBSD < 6 / Solaris struct s_bitmaptripple { //uint8 b; //uint8 g; //uint8 r; unsigned int rgb:24; } __attribute__((packed)); +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) +#endif // not NetBSD < 6 / Solaris uint8 buf[1800]; // no well-formed emblem bitmap is larger than 1782 (24 bit) / 1654 (8 bit) bytes unsigned long buf_len = sizeof(buf); int header = 0, bitmap = 0, offbits = 0, palettesize = 0, i = 0; diff --git a/src/map/npc.c b/src/map/npc.c index 722e5199c1e..458fc52ed9d 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2432,7 +2432,7 @@ int npc_parseview(const char* w4, const char* start, const char* buffer, const c // Extract view ID / constant while (w4[i] != '\0') { - if (isspace(w4[i]) || w4[i] == '/' || w4[i] == ',') + if (ISSPACE(w4[i]) || w4[i] == '/' || w4[i] == ',') break; i++; @@ -2464,7 +2464,7 @@ bool npc_viewisid(const char * viewid) { // Loop through view, looking for non-numeric character. while (*viewid) { - if (isdigit(*viewid++) == 0) return false; + if (ISDIGIT(*viewid++) == 0) return false; } } diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index 8f0989f3d32..1156f446539 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -205,7 +205,9 @@ enum packet_headers { npcmarketopenType = 0x9d5, }; +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(push, 1) +#endif // not NetBSD < 6 / Solaris /** * structs for data @@ -939,6 +941,8 @@ struct packet_npc_market_open { } list[1000];/* TODO: whats the actual max of this? */ } __attribute__((packed)); +#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute #pragma pack(pop) +#endif // not NetBSD < 6 / Solaris #endif /* _PACKETS_STRUCT_H_ */