]> git.mxchange.org Git - flightgear.git/commitdiff
Use our own stdint.hxx implementation.
authorehofman <ehofman>
Thu, 22 Sep 2005 11:47:58 +0000 (11:47 +0000)
committerehofman <ehofman>
Thu, 22 Sep 2005 11:47:58 +0000 (11:47 +0000)
src/MultiPlayer/Makefile.am
src/MultiPlayer/swap_test.cpp [deleted file]
src/MultiPlayer/tiny_xdr.cpp
src/MultiPlayer/tiny_xdr.hpp
src/Network/net_ctrls.hxx
src/Network/net_fdm.hxx
src/Network/net_fdm_mini.hxx
src/Network/net_gui.hxx

index 0ad23d80a7942550d09d2b3d28d62ad95ffc05f3..9057a991c4d3239f95e530d9681bc5cc03e5454f 100644 (file)
@@ -1,7 +1,3 @@
-noinst_PROGRAMS = swap_test
-
-swap_test_SOURCES = swap_test.cpp
-
 noinst_LIBRARIES = libMultiPlayer.a
 
 libMultiPlayer_a_SOURCES = multiplayrxmgr.cxx multiplayrxmgr.hxx multiplaytxmgr.cxx multiplaytxmgr.hxx mpplayer.cxx mpplayer.hxx mpmessages.hxx tiny_xdr.cpp tiny_xdr.hpp
diff --git a/src/MultiPlayer/swap_test.cpp b/src/MultiPlayer/swap_test.cpp
deleted file mode 100644 (file)
index 5df58f8..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#include <stdio.h>
-#include <stdint.h>
-#include "tiny_xdr.hpp"
-
-int main() 
-{
-   uint32_t ui32 = 0x01234567;
-   uint64_t ui64 = 0x0123456789ABCDEFLL;
-
-   printf("UI32: (normal) %x\nUI32: (swapped) %x\n\n", ui32, bswap_32(ui32) );
-   printf("UI64: (normal) %llx\nUI64: (swapped) %llx\n\n", ui64, bswap_64(ui64) );
-
-   return 0;
-}
index d1182af858679ed511f37d7040c3b435303586e1..ff994e3936feb65666c6f08ac79b4a44c5e30cee 100644 (file)
 
 /* XDR 8bit integers */
 xdr_data_t
-XDR_encode_int8 ( int8_t  n_Val )
+XDR_encode_int8 ( const int8_t & n_Val )
 {
     return (SWAP32(static_cast<xdr_data_t> (n_Val)));
 }
 
 xdr_data_t
-XDR_encode_uint8 ( uint8_t n_Val )
+XDR_encode_uint8 ( const uint8_t & n_Val )
 {
     return (SWAP32(static_cast<xdr_data_t> (n_Val)));
 }
 
 int8_t
-XDR_decode_int8 ( xdr_data_t n_Val )
+XDR_decode_int8 ( const xdr_data_t & n_Val )
 {
     return (static_cast<int8_t> (SWAP32(n_Val)));
 }
 
 uint8_t
-XDR_decode_uint8 ( xdr_data_t n_Val )
+XDR_decode_uint8 ( const xdr_data_t & n_Val )
 {
     return (static_cast<uint8_t> (SWAP32(n_Val)));
 }
 
 /* XDR 16bit integers */
 xdr_data_t
-XDR_encode_int16 ( int16_t  n_Val )
+XDR_encode_int16 ( const int16_t & n_Val )
 {
     return (SWAP32(static_cast<xdr_data_t> (n_Val)));
 }
 
 xdr_data_t
-XDR_encode_uint16 ( uint16_t n_Val )
+XDR_encode_uint16 ( const uint16_t & n_Val )
 {
     return (SWAP32(static_cast<xdr_data_t> (n_Val)));
 }
 
 int16_t
-XDR_decode_int16 ( xdr_data_t  n_Val )
+XDR_decode_int16 ( const xdr_data_t & n_Val )
 {
     return (static_cast<int16_t> (SWAP32(n_Val)));
 }
 
 uint16_t
-XDR_decode_uint16 ( xdr_data_t  n_Val )
+XDR_decode_uint16 ( const xdr_data_t & n_Val )
 {
     return (static_cast<uint16_t> (SWAP32(n_Val)));
 }
@@ -68,25 +68,25 @@ XDR_decode_uint16 ( xdr_data_t  n_Val )
 
 /* XDR 32bit integers */
 xdr_data_t
-XDR_encode_int32 ( int32_t  n_Val )
+XDR_encode_int32 ( const int32_t & n_Val )
 {
     return (SWAP32(static_cast<xdr_data_t> (n_Val)));
 }
 
 xdr_data_t
-XDR_encode_uint32 ( uint32_t n_Val )
+XDR_encode_uint32 ( const uint32_t & n_Val )
 {
     return (SWAP32(static_cast<xdr_data_t> (n_Val)));
 }
 
 int32_t
-XDR_decode_int32 ( xdr_data_t  n_Val )
+XDR_decode_int32 ( const xdr_data_t & n_Val )
 {
     return (static_cast<int32_t> (SWAP32(n_Val)));
 }
 
 uint32_t
-XDR_decode_uint32 ( xdr_data_t  n_Val )
+XDR_decode_uint32 ( const xdr_data_t & n_Val )
 {
     return (static_cast<uint32_t> (SWAP32(n_Val)));
 }
@@ -94,25 +94,25 @@ XDR_decode_uint32 ( xdr_data_t  n_Val )
 
 /* XDR 64bit integers */
 xdr_data2_t
-XDR_encode_int64 ( int64_t n_Val )
+XDR_encode_int64 ( const int64_t & n_Val )
 {
     return (SWAP64(static_cast<xdr_data2_t> (n_Val)));
 }
 
 xdr_data2_t
-XDR_encode_uint64 ( uint64_t n_Val )
+XDR_encode_uint64 ( const uint64_t & n_Val )
 {
     return (SWAP64(static_cast<xdr_data2_t> (n_Val)));
 }
 
 int64_t
-XDR_decode_int64 ( xdr_data2_t n_Val )
+XDR_decode_int64 ( const xdr_data2_t & n_Val )
 {
     return (static_cast<int64_t> (SWAP64(n_Val)));
 }
 
 uint64_t
-XDR_decode_uint64 ( xdr_data2_t n_Val )
+XDR_decode_uint64 ( const xdr_data2_t & n_Val )
 {
     return (static_cast<uint64_t> (SWAP64(n_Val)));
 }
@@ -120,7 +120,7 @@ XDR_decode_uint64 ( xdr_data2_t n_Val )
 
 /* float */
 xdr_data_t
-XDR_encode_float ( float f_Val )
+XDR_encode_float ( const float & f_Val )
 {
     xdr_data_t* tmp;
 
@@ -129,7 +129,7 @@ XDR_encode_float ( float f_Val )
 }
 
 float
-XDR_decode_float ( xdr_data_t f_Val )
+XDR_decode_float ( const xdr_data_t & f_Val )
 {
     float* tmp;
     xdr_data_t dummy;
@@ -141,7 +141,7 @@ XDR_decode_float ( xdr_data_t f_Val )
 
 /* double */
 xdr_data2_t
-XDR_encode_double ( double d_Val )
+XDR_encode_double ( const double & d_Val )
 {
     xdr_data2_t* tmp;
 
@@ -150,7 +150,7 @@ XDR_encode_double ( double d_Val )
 }
 
 double
-XDR_decode_double ( xdr_data2_t d_Val )
+XDR_decode_double ( const xdr_data2_t & d_Val )
 {
     double* tmp;
     xdr_data2_t dummy;
index 4db48604b6d762410d6a38f4e44957648aaf746e..befe73e765ab2ab88743d20f7a5e81dee9f88a33 100644 (file)
 #   include <config.h>
 #endif
 
-#include <simgear/compiler.h>
-#if defined HAVE_STDINT_H
-#   include <stdint.h>
-#endif
-
-#include <plib/ul.h>
+#include <simgear/misc/stdint.hxx>
 
-//////////////////////////////////////////////////////////////////////
-//
-//  There are many sick systems out there:
-//
-//  check for sizeof(float) and sizeof(double)
-//  if sizeof(float) != 4 this code must be patched
-//  if sizeof(double) != 8 this code must be patched
-//
-//  Those are comments I fetched out of glibc source:
-//  - s390 is big-endian
-//  - Sparc is big-endian, but v9 supports endian conversion
-//    on loads/stores and GCC supports such a mode.  Be prepared.  
-//  - The MIPS architecture has selectable endianness.
-//  - x86_64 is little-endian.
-//  - CRIS is little-endian.
-//  - m68k is big-endian.
-//  - Alpha is little-endian.
-//  - PowerPC can be little or big endian.
-//  - SH is bi-endian but with a big-endian FPU.
-//  - hppa1.1 big-endian. 
-//  - ARM is (usually) little-endian but with a big-endian FPU. 
-//
-//////////////////////////////////////////////////////////////////////
-inline uint32_t bswap_32(unsigned int b) {
-    unsigned x = b;
-    ulEndianSwap(&x);
-    return x;
-}
-
-#if (SIZEOF_LONG_INT == 8)
-inline uint64_t bswap_64(unsigned long int b) {
-    uint64_t x = b;
-    x = ((x >>  8) & 0x00FF00FF00FF00FFLL) | ((x <<  8) & 0xFF00FF00FF00FF00LL);
-    x = ((x >> 16) & 0x0000FFFF0000FFFFLL) | ((x << 16) & 0xFFFF0000FFFF0000LL);
-    x = (x >> 32) | (x << 32);
-    return x;
-}
-#else
-inline uint64_t bswap_64(unsigned long long int b) {
-    union { 
-         uint64_t ll;
-         uint32_t l[2]; 
-     } w, r;
-     w.ll = b;
-     r.l[0] = bswap_32 (w.l[1]);
-     r.l[1] = bswap_32 (w.l[0]);
-     return r.ll;
-}
-#endif
 
 #if BYTE_ORDER == BIG_ENDIAN
 #   define SWAP32(arg) arg
@@ -83,8 +29,8 @@ inline uint64_t bswap_64(unsigned long long int b) {
 #   define LOW  0
 #   define HIGH 1
 #else
-#   define SWAP32(arg) bswap_32(arg)
-#   define SWAP64(arg) bswap_64(arg)
+#   define SWAP32(arg) sg_bswap_32(arg)
+#   define SWAP64(arg) sg_bswap_64(arg)
 #   define LOW  1
 #   define HIGH 0
 #endif
@@ -95,28 +41,28 @@ typedef uint32_t    xdr_data_t;      /* 4 Bytes */
 typedef uint64_t    xdr_data2_t;     /* 8 Bytes */
 
 /* XDR 8bit integers */
-xdr_data_t      XDR_encode_int8     ( int8_t  n_Val );
-xdr_data_t      XDR_encode_uint8    ( uint8_t n_Val );
-int8_t          XDR_decode_int8     ( xdr_data_t n_Val );
-uint8_t         XDR_decode_uint8    ( xdr_data_t n_Val );
+xdr_data_t      XDR_encode_int8     ( const int8_t &  n_Val );
+xdr_data_t      XDR_encode_uint8    ( const uint8_t & n_Val );
+int8_t          XDR_decode_int8     ( const xdr_data_t & n_Val );
+uint8_t         XDR_decode_uint8    ( const xdr_data_t & n_Val );
 
 /* XDR 16bit integers */
-xdr_data_t      XDR_encode_int16    ( int16_t  n_Val );
-xdr_data_t      XDR_encode_uint16   ( uint16_t n_Val );
-int16_t         XDR_decode_int16    ( xdr_data_t n_Val );
-uint16_t        XDR_decode_uint16   ( xdr_data_t n_Val );
+xdr_data_t      XDR_encode_int16    ( const int16_t & n_Val );
+xdr_data_t      XDR_encode_uint16   ( const uint16_t & n_Val );
+int16_t         XDR_decode_int16    ( const xdr_data_t & n_Val );
+uint16_t        XDR_decode_uint16   ( const xdr_data_t & n_Val );
 
 /* XDR 32bit integers */
-xdr_data_t      XDR_encode_int32    ( int32_t  n_Val );
-xdr_data_t      XDR_encode_uint32   ( const uint32_t n_Val );
-int32_t         XDR_decode_int32    ( xdr_data_t n_Val );
-uint32_t        XDR_decode_uint32   ( const xdr_data_t n_Val );
+xdr_data_t      XDR_encode_int32    ( const int32_t & n_Val );
+xdr_data_t      XDR_encode_uint32   ( const uint32_t n_Val );
+int32_t         XDR_decode_int32    ( const xdr_data_t & n_Val );
+uint32_t        XDR_decode_uint32   ( const xdr_data_t n_Val );
 
 /* XDR 64bit integers */
-xdr_data2_t     XDR_encode_int64    ( int64_t n_Val );
-xdr_data2_t     XDR_encode_uint64   ( uint64_t n_Val );
-int64_t         XDR_decode_int64    ( xdr_data2_t n_Val );
-uint64_t        XDR_decode_uint64   ( xdr_data2_t n_Val );
+xdr_data2_t     XDR_encode_int64    ( const int64_t & n_Val );
+xdr_data2_t     XDR_encode_uint64   ( const uint64_t & n_Val );
+int64_t         XDR_decode_int64    ( const xdr_data2_t & n_Val );
+uint64_t        XDR_decode_uint64   ( const xdr_data2_t & n_Val );
 
 //////////////////////////////////////////////////
 //
@@ -131,11 +77,11 @@ uint64_t        XDR_decode_uint64   ( xdr_data2_t n_Val );
 //
 //////////////////////////////////////////////////
 /* float */
-xdr_data_t      XDR_encode_float    ( float f_Val );
-float           XDR_decode_float    ( xdr_data_t f_Val );
+xdr_data_t      XDR_encode_float    ( const float & f_Val );
+float           XDR_decode_float    ( const xdr_data_t & f_Val );
 
 /* double */
-xdr_data2_t     XDR_encode_double   ( double d_Val );
-double          XDR_decode_double   ( xdr_data2_t d_Val );
+xdr_data2_t     XDR_encode_double   ( const double & d_Val );
+double          XDR_decode_double   ( const xdr_data2_t & d_Val );
 
 #endif
index ba304379f810e33dc299c658d4d4aa08881d5da7..f09c0ade66ee93398a914a6676a6a60f7b59d548 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef _NET_CTRLS_HXX
 #define _NET_CTRLS_HXX
 
-#include <simgear/compiler.h>
+#include <simgear/misc/stdint.hxx>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
 // I am not aware of any platforms that don't use 4 bytes for float
 // and 8 bytes for double.
 
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
 const uint32_t FG_NET_CTRLS_VERSION = 26;
 
 
index 3392cf01aadd441d349763fb9a21d9fb36bc7658..3056bf83200072a79cd6f7adf1d29c2f442f54d8 100644 (file)
@@ -14,7 +14,7 @@
 
 
 #include <time.h> // time_t
-#include <simgear/compiler.h>
+#include <simgear/misc/stdint.hxx>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
 // I am not aware of any platforms that don't use 4 bytes for float
 // and 8 bytes for double.
 
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
 const uint32_t FG_NET_FDM_VERSION = 22;
 
 
index cf91b0c1b356369ed4fad736dc550114e1022f6c..e1243756c90bf812f92a853fdcc2fa17fcfcd7b5 100644 (file)
@@ -17,7 +17,7 @@
 # error This library requires C++
 #endif                                   
 
-#include <simgear/compiler.h>
+#include <simgear/misc/stdint.hxx>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
 // I am not aware of any platforms that don't use 4 bytes for float
 // and 8 bytes for double.
 
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
 
 const uint32_t FG_NET_FDM_MINI_VERSION = 2;
 
index 0c94d6ffc2c2feccc1c51180bf41b05c8cfb7791..1025d6acc07d603450a91fb092a625efcb129e94 100644 (file)
@@ -11,7 +11,7 @@
 #ifndef _NET_GUI_HXX
 #define _NET_GUI_HXX
 
-#include <simgear/compiler.h>
+#include <simgear/misc/stdint.hxx>
 
 // NOTE: this file defines an external interface structure.  Due to
 // variability between platforms and architectures, we only used fixed
@@ -19,9 +19,6 @@
 // I am not aware of any platforms that don't use 4 bytes for float
 // and 8 bytes for double.
 
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#endif
 
 const uint32_t FG_NET_GUI_VERSION = 7;