Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
81 user(s) are online (63 user(s) are browsing Forums)

Members: 0
Guests: 81

more...

Support us!

Headlines

Report message:*
 

Re: MineCraft (MineTest) work in progress help need it

Subject: Re: MineCraft (MineTest) work in progress help need it
by kas1e on 2021/1/7 20:06:07

@all
Started from failed test in TestSerialisation's testStreamRead() firstly:

https://github.com/minetest/minetest/b ... st_serialization.cpp#L216

Everything which comes from line 233 is a fail (all the calls till the end). All those functions are there:

https://github.com/minetest/minetest/b ... ster/src/util/serialize.h

Strangely, that this file have endian-aware code, and i am surely check that i "#if HAVE_ENDIAN_H" code. But still all the tests fail.

For example that one : UASSERT(readF1000(is) == 53.534f);

It is :

inline f32 readF1000(const u8 *data)
{
    return (
f32)readS32(data) / FIXEDPOINT_FACTOR;
}

inline s32 readS32(const u8 *data)
{
    return (
s32)readU32(data);
}

inline u32 readU32(const u8 *data)
{
    
u32 val;
    
memcpy(&valdata4);
    return 
be32toh(val);
}



and i have in my "endian.h" for big endian: #define be32toh(x) (x)

There is my updated endian.h file I use for a build that game (sadly our SDK miss half of this):

#ifndef __MACHINE_ENDIAN_H__

/* Swap bytes in 16 bit value.  */
#ifdef __GNUC__
# define __bswap_16(x) 
    
(__extension__                                  
     
({ unsigned short int __bsx = (x);                          
        ((((
__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }))
#else
static __inline unsigned short int
__bswap_16 
(unsigned short int __bsx)
{
  return ((((
__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
}
#endif

/* Swap bytes in 32 bit value.  */
#ifdef __GNUC__
# define __bswap_32(x) 
    
(__extension__                                  
     
({ unsigned int __bsx = (x);                          
        ((((
__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |    
     (((
__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24)); }))
#else
static __inline unsigned int
__bswap_32 
(unsigned int __bsx)
{
  return ((((
__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |
      (((
__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24));
}
#endif

#if defined __GNUC__ && __GNUC__ >= 2
/* Swap bytes in 64 bit value.  */
# define __bswap_constant_64(x) 
     
((((x) & 0xff00000000000000ull) >> 56)                      
      | (((
x) & 0x00ff000000000000ull) >> 40)                      
      | (((
x) & 0x0000ff0000000000ull) >> 24)                      
      | (((
x) & 0x000000ff00000000ull) >> 8)                      
      | (((
x) & 0x00000000ff000000ull) << 8)                      
      | (((
x) & 0x0000000000ff0000ull) << 24)                      
      | (((
x) & 0x000000000000ff00ull) << 40)                      
      | (((
x) & 0x00000000000000ffull) << 56))

# define __bswap_64(x) 
     
(__extension__                                  
      
({ union __extension__ unsigned long long int __ll;              
         
unsigned int __l[2]; } __w__r;                  
         if (
__builtin_constant_p (x))                          
       
__r.__ll __bswap_constant_64 (x);                      
     else                                      
       {                                      
         
__w.__ll = (x);                              
         
__r.__l[0] = __bswap_32 (__w.__l[1]);                  
         
__r.__l[1] = __bswap_32 (__w.__l[0]);                  
       }                                      
     
__r.__ll; }))
#endif



#include <sys/config.h>

#ifndef BIG_ENDIAN
#define BIG_ENDIAN 4321
#endif
#ifndef LITTLE_ENDIAN
#define LITTLE_ENDIAN 1234
#endif

#ifndef BYTE_ORDER
#ifdef __IEEE_LITTLE_ENDIAN
#define BYTE_ORDER LITTLE_ENDIAN
#else
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif

#ifndef ntohl
   #define ntohl(x) (x)
#endif
#ifndef ntohs
   #define ntohs(x) (x)
#endif
#ifndef htonl
   #define htonl(x) (x)
#endif
#ifndef htons
   #define htons(x) (x)
#endif

#ifndef NTOHL
   #define NTOHL(x) (x)
#endif
#ifndef NTOHS
   #define NTOHS(x) (x)
#endif
#ifndef HTONL
   #define HTONL(x) (x)
#endif
#ifndef HTONS
   #define HTONS(x) (x)
#endif


#if __BYTE_ORDER == __LITTLE_ENDIAN

#define htobe16(x) __bswap_16(x)
#define htobe32(x) __bswap_32(x)
#define htobe64(x) __bswap_64(x)

#define be16toh(x) __bswap_16(x)
#define be32toh(x) __bswap_32(x)
#define be64toh(x) __bswap_64(x)

#define htole16(x) (x)
#define htole32(x) (x)
#define htole64(x) (x)

#define le16toh(x) (x)
#define le32toh(x) (x)
#define le64toh(x) (x)

#endif /*__BYTE_ORDER == __LITTLE_ENDIAN*/

#if __BYTE_ORDER == __BIG_ENDIAN

#define htobe16(x) (x)
#define htobe32(x) (x)
#define htobe64(x) (x)

#define be16toh(x) (x)
#define be32toh(x) (x)
#define be64toh(x) (x)

#define htole16(x) __bswap_16(x)
#define htole32(x) __bswap_32(x)
#define htole64(x) __bswap_64(x)

#define le16toh(x) __bswap_16(x)
#define le32toh(x) __bswap_32(x)
#define le64toh(x) __bswap_64(x)

#endif /*__BYTE_ORDER == __BIG_ENDIAN*/



#endif /* __MACHINE_ENDIAN_H__ */


So, wtf ?:)

Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project