mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
run-time validate endianness, numeric sizes
This commit is contained in:
parent
1ea11e7073
commit
26b1e8f6cd
@ -30,6 +30,7 @@
|
||||
#include "virtualFileMountSystem.h"
|
||||
#include "virtualFileSimple.h"
|
||||
#include "pandaSystem.h"
|
||||
#include "numeric_types.h"
|
||||
|
||||
#include "dconfig.h"
|
||||
|
||||
@ -163,10 +164,28 @@ init_libexpress() {
|
||||
init_system_type_handles();
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
{
|
||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||
ps->add_system("zlib");
|
||||
}
|
||||
{
|
||||
PandaSystem *ps = PandaSystem::get_global_ptr();
|
||||
ps->add_system("zlib");
|
||||
}
|
||||
#endif
|
||||
|
||||
// This is a fine place to ensure that the numeric types have been
|
||||
// chosen correctly.
|
||||
nassertv(sizeof(PN_int8) == 1 && sizeof(PN_uint8) == 1);
|
||||
nassertv(sizeof(PN_int16) == 2 && sizeof(PN_uint16) == 2);
|
||||
nassertv(sizeof(PN_int32) == 4 && sizeof(PN_uint32) == 4);
|
||||
nassertv(sizeof(PN_int64) == 8 && sizeof(PN_uint64) == 8);
|
||||
nassertv(sizeof(PN_float32) == 4);
|
||||
nassertv(sizeof(PN_float64) == 8);
|
||||
|
||||
// Also, ensure that we have the right endianness.
|
||||
PN_uint32 word;
|
||||
memcpy(&word, "\1\2\3\4", 4);
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
nassertv(word == 0x01020304);
|
||||
#else
|
||||
nassertv(word == 0x04030201);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user