read_error = true ;
}
if ( sgIsBigEndian() ) {
- sgEndianSwap( (uint64*)var);
+ sgEndianSwap( (uint64_t*)var);
}
}
void sgWriteDouble ( gzFile fd, const double var )
{
if ( sgIsBigEndian() ) {
- sgEndianSwap( (uint64*)&var);
+ sgEndianSwap( (uint64_t*)&var);
}
if ( gzwrite ( fd, (void *)(&var), sizeof(double) ) != sizeof(double) ) {
write_error = true ;
}
-void sgReadLong ( gzFile fd, long int *var )
+void sgReadLong ( gzFile fd, int32_t *var )
{
- if ( gzread ( fd, var, sizeof(long int) ) != sizeof(long int) ) {
+ if ( gzread ( fd, var, sizeof(int32_t) ) != sizeof(int32_t) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
}
-void sgWriteLong ( gzFile fd, const long int var )
+void sgWriteLong ( gzFile fd, const int32_t var )
{
if ( sgIsBigEndian() ) {
sgEndianSwap( (unsigned int*)&var);
}
- if ( gzwrite ( fd, (void *)(&var), sizeof(long int) )
- != sizeof(long int) )
+ if ( gzwrite ( fd, (void *)(&var), sizeof(int32_t) )
+ != sizeof(int32_t) )
{
write_error = true ;
}
}
-void sgReadLongLong ( gzFile fd, int64 *var )
+void sgReadLongLong ( gzFile fd, int64_t *var )
{
- if ( gzread ( fd, var, sizeof(int64) ) != sizeof(int64) ) {
+ if ( gzread ( fd, var, sizeof(int64_t) ) != sizeof(int64_t) ) {
read_error = true ;
}
if ( sgIsBigEndian() ) {
- sgEndianSwap( (uint64*)var);
+ sgEndianSwap( (uint64_t*)var);
}
}
-void sgWriteLongLong ( gzFile fd, const int64 var )
+void sgWriteLongLong ( gzFile fd, const int64_t var )
{
if ( sgIsBigEndian() ) {
- sgEndianSwap( (uint64*)&var);
+ sgEndianSwap( (uint64_t*)&var);
}
- if ( gzwrite ( fd, (void *)(&var), sizeof(int64) )
- != sizeof(int64) )
+ if ( gzwrite ( fd, (void *)(&var), sizeof(int64_t) )
+ != sizeof(int64_t) )
{
write_error = true ;
}
}
if ( sgIsBigEndian() ) {
for ( unsigned int i = 0; i < n; ++i ) {
- sgEndianSwap( (uint64*)var++);
+ sgEndianSwap( (uint64_t*)var++);
}
}
}
double *ptr = swab;
memcpy( swab, var, sizeof(double) * n );
for ( unsigned int i = 0; i < n; ++i ) {
- sgEndianSwap( (uint64*)ptr++);
+ sgEndianSwap( (uint64_t*)ptr++);
}
var = swab;
}
#include <stdio.h>
+#include <inttypes.h>
#include <zlib.h>
#include <plib/sg.h>
-#ifdef _MSC_VER
-typedef __int64 int64;
-typedef __int64 uint64;
-#else
-typedef long long int64;
-typedef unsigned long long uint64;
-#endif
+#include <simgear/compiler.h>
// Note that output is written in little endian form (and converted as
// necessary for big endian machines)
void sgWriteUInt ( gzFile fd, const unsigned int var ) ;
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, int64 *var ) ;
-void sgWriteLongLong ( gzFile fd, const int64 var ) ;
+void sgReadLong ( gzFile fd, int32_t *var ) ;
+void sgWriteLong ( gzFile fd, const int32_t var ) ;
+void sgReadLongLong ( gzFile fd, int64_t *var ) ;
+void sgWriteLongLong ( gzFile fd, const int64_t 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(uint64 *x) {
+inline void sgEndianSwap(uint64_t *x) {
#ifndef _MSC_VER
*x =
(( *x >> 56 ) & 0x00000000000000FFULL ) |
double *dptr = (double *)ptr;
if ( sgIsBigEndian() ) {
- sgEndianSwap( (uint64 *)&(dptr[0]) );
- sgEndianSwap( (uint64 *)&(dptr[1]) );
- sgEndianSwap( (uint64 *)&(dptr[2]) );
+ sgEndianSwap( (uint64_t *)&(dptr[0]) );
+ sgEndianSwap( (uint64_t *)&(dptr[1]) );
+ sgEndianSwap( (uint64_t *)&(dptr[2]) );
}
gbs_center = Point3D( dptr[0], dptr[1], dptr[2] );
// cout << "Center = " << gbs_center << endl;
// write header magic
sgWriteUInt( fp, SG_FILE_MAGIC_NUMBER );
time_t calendar_time = time(NULL);
- sgWriteLong( fp, (long int)calendar_time );
+ sgWriteLong( fp, (int32_t)calendar_time );
// calculate and write number of top level objects
string material;