read_error = true ;
}
if ( sgIsBigEndian() ) {
- sgEndianSwap( (unsigned long long*)var);
+ sgEndianSwap( (uint64*)var);
}
}
void sgWriteDouble ( gzFile fd, const double var )
{
if ( sgIsBigEndian() ) {
- sgEndianSwap( (unsigned long long*)&var);
+ sgEndianSwap( (uint64*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(double) ) != sizeof(double) ) {
write_error = true ;
}
-void sgReadLongLong ( gzFile fd, long long int *var )
+void sgReadLongLong ( gzFile fd, int64 *var )
{
- if ( gzread ( fd, var, sizeof(long long int) ) != sizeof(long long int) ) {
+ if ( gzread ( fd, var, sizeof(int64) ) != sizeof(int64) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
- sgEndianSwap( (unsigned long long int*)var);
+ sgEndianSwap( (uint64*)var);
}
}
-void sgWriteLongLong ( gzFile fd, const long long int var )
+void sgWriteLongLong ( gzFile fd, const int64 var )
{
if ( sgIsBigEndian() ) {
- sgEndianSwap( (unsigned long long*)&var);
+ sgEndianSwap( (uint64*)&var);
}
- if ( gzwrite ( fd, (void *)(&var), sizeof(long long int) )
- != sizeof(long long int) )
+ if ( gzwrite ( fd, (void *)(&var), sizeof(int64) )
+ != sizeof(int64) )
{
write_error = true ;
}
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
- sgEndianSwap( (unsigned long long*)var++);
+ sgEndianSwap( (uint64*)var++);
}
}
}
double *ptr = swab;
memcpy( swab, var, sizeof(double) * n );
for ( unsigned int i = 0; i < n; ++i ) {
- sgEndianSwap( (unsigned long long*)ptr++);
+ sgEndianSwap( (uint64*)ptr++);
}
var = swab;
}
#include <plib/sg.h>
+#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)
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 ) ;
(( *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 ) |
(( *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
double *dptr = (double *)ptr;
if ( sgIsBigEndian() ) {
- sgEndianSwap( (unsigned long long *)&(dptr[0]) );
- sgEndianSwap( (unsigned long long *)&(dptr[1]) );
- sgEndianSwap( (unsigned long long *)&(dptr[2]) );
+ sgEndianSwap( (uint64 *)&(dptr[0]) );
+ sgEndianSwap( (uint64 *)&(dptr[1]) );
+ sgEndianSwap( (uint64 *)&(dptr[2]) );
}
gbs_center = Point3D( dptr[0], dptr[1], dptr[2] );
// cout << "Center = " << gbs_center << endl;