X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fio%2Flowlevel.hxx;h=fc8398f54d2b74d38b689cbad85dee8b8e49055f;hb=dc09a50472890ac706d3c76d8af34cc3682ada0c;hp=dfc38162b0c99114f2e51599d89a23c5e9dd9bd1;hpb=12620b615281eb0567ce13b350222bb7003bdce2;p=simgear.git diff --git a/simgear/io/lowlevel.hxx b/simgear/io/lowlevel.hxx index dfc38162..fc8398f5 100644 --- a/simgear/io/lowlevel.hxx +++ b/simgear/io/lowlevel.hxx @@ -4,7 +4,7 @@ // Shamelessly adapted from plib January 2001 // // Original version Copyright (C) 2000 the plib team -// Local changes Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org +// Local changes Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -29,15 +29,17 @@ #include - -#ifdef HAVE_ZLIB -# include -#else -# include -#endif +#include #include +#ifdef _MSC_VER +typedef __int64 int64; +typedef __int64 uint64; +#else +typedef long long int64; +typedef unsigned long long uint64; +#endif // Note that output is written in little endian form (and converted as // necessary for big endian machines) @@ -54,8 +56,8 @@ void sgReadInt ( gzFile fd, int *var ) ; void sgWriteInt ( gzFile fd, const int var ) ; void sgReadLong ( gzFile fd, long int *var ) ; void sgWriteLong ( gzFile fd, const long int var ) ; -void sgReadLongLong ( gzFile fd, long long int *var ) ; -void sgWriteLongLong ( gzFile fd, const long long int var ) ; +void sgReadLongLong ( gzFile fd, int64 *var ) ; +void sgWriteLongLong ( gzFile fd, const int64 var ) ; void sgReadUShort ( gzFile fd, unsigned short *var ) ; void sgWriteUShort ( gzFile fd, const unsigned short var ) ; void sgReadShort ( gzFile fd, short *var ) ; @@ -143,7 +145,8 @@ inline void sgEndianSwap(unsigned int *x) { (( *x << 24 ) & 0xFF000000 ) ; } -inline void sgEndianSwap(unsigned long long *x) { +inline void sgEndianSwap(uint64 *x) { +#ifndef _MSC_VER *x = (( *x >> 56 ) & 0x00000000000000FFULL ) | (( *x >> 40 ) & 0x000000000000FF00ULL ) | @@ -153,7 +156,17 @@ inline void sgEndianSwap(unsigned long long *x) { (( *x << 24 ) & 0x0000FF0000000000ULL ) | (( *x << 40 ) & 0x00FF000000000000ULL ) | (( *x << 56 ) & 0xFF00000000000000ULL ) ; +#else + *x = + (( *x >> 56 ) & 0x00000000000000FF ) | + (( *x >> 40 ) & 0x000000000000FF00 ) | + (( *x >> 24 ) & 0x0000000000FF0000 ) | + (( *x >> 8 ) & 0x00000000FF000000 ) | + (( *x << 8 ) & 0x000000FF00000000 ) | + (( *x << 24 ) & 0x0000FF0000000000 ) | + (( *x << 40 ) & 0x00FF000000000000 ) | + (( *x << 56 ) & 0xFF00000000000000 ) ; +#endif } - #endif // _SG_LOWLEVEL_HXX