"static inline" fix for build with VS2013

"static inline" doesn't build on VS2013:

https://msdn.microsoft.com/en-us/library/z8y1yy88.aspx
This commit is contained in:
Remo E 2015-04-03 11:55:57 +02:00
parent 524a1f9498
commit 776a8c64f6
1 changed files with 10 additions and 4 deletions

View File

@ -44,7 +44,13 @@
define inline functions for those function so that we don't have define inline functions for those function so that we don't have
dependeny on that lib. */ dependeny on that lib. */
static inline uint32_t htonl(uint32_t hostlong) { #ifdef _MSC_VER
#define STIN static __inline
#else
#define STIN static inline
#endif
STIN uint32_t htonl(uint32_t hostlong) {
uint32_t res; uint32_t res;
unsigned char *p = (unsigned char *)&res; unsigned char *p = (unsigned char *)&res;
*p++ = hostlong >> 24; *p++ = hostlong >> 24;
@ -54,7 +60,7 @@ static inline uint32_t htonl(uint32_t hostlong) {
return res; return res;
} }
static inline uint16_t htons(uint16_t hostshort) { STIN uint16_t htons(uint16_t hostshort) {
uint16_t res; uint16_t res;
unsigned char *p = (unsigned char *)&res; unsigned char *p = (unsigned char *)&res;
*p++ = hostshort >> 8; *p++ = hostshort >> 8;
@ -62,7 +68,7 @@ static inline uint16_t htons(uint16_t hostshort) {
return res; return res;
} }
static inline uint32_t ntohl(uint32_t netlong) { STIN uint32_t ntohl(uint32_t netlong) {
uint32_t res; uint32_t res;
unsigned char *p = (unsigned char *)&netlong; unsigned char *p = (unsigned char *)&netlong;
res = *p++ << 24; res = *p++ << 24;
@ -72,7 +78,7 @@ static inline uint32_t ntohl(uint32_t netlong) {
return res; return res;
} }
static inline uint16_t ntohs(uint16_t netshort) { STIN uint16_t ntohs(uint16_t netshort) {
uint16_t res; uint16_t res;
unsigned char *p = (unsigned char *)&netshort; unsigned char *p = (unsigned char *)&netshort;
res = *p++ << 8; res = *p++ << 8;