mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-26 13:51:50 +01:00
Make frontend endian-aware.
In many parts the DMD frontend assumes a little endian CPU. In some parts there are checks for endianess but they are incomplete and the used definition is wrong. (Test for endianess will be removed in dmd 2.062.) In this commit I add the required #if's and also add a CMake test for endianess because there is no single compiler definition to check for.
This commit is contained in:
@@ -990,7 +990,16 @@ Expression *ctfeCat(Type *type, Expression *e1, Expression *e2)
|
||||
if (es2e->op != TOKint64)
|
||||
return EXP_CANT_INTERPRET;
|
||||
dinteger_t v = es2e->toInteger();
|
||||
#if IN_LLVM
|
||||
#if __LITTLE_ENDIAN__
|
||||
memcpy((unsigned char *)s + i * sz, &v, sz);
|
||||
#else
|
||||
memcpy((unsigned char *)s + i * sz,
|
||||
(unsigned char *)&v + (sizeof(dinteger_t) - sz), sz);
|
||||
#endif
|
||||
#else
|
||||
memcpy((unsigned char *)s + i * sz, &v, sz);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Add terminating 0
|
||||
@@ -1020,7 +1029,16 @@ Expression *ctfeCat(Type *type, Expression *e1, Expression *e2)
|
||||
if (es2e->op != TOKint64)
|
||||
return EXP_CANT_INTERPRET;
|
||||
dinteger_t v = es2e->toInteger();
|
||||
#if IN_LLVM
|
||||
#if __LITTLE_ENDIAN__
|
||||
memcpy((unsigned char *)s + (es1->len + i) * sz, &v, sz);
|
||||
#else
|
||||
memcpy((unsigned char *)s + (es1->len + i) * sz,
|
||||
(unsigned char *) &v + (sizeof(dinteger_t) - sz), sz);
|
||||
#endif
|
||||
#else
|
||||
memcpy((unsigned char *)s + (es1->len + i) * sz, &v, sz);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Add terminating 0
|
||||
|
||||
Reference in New Issue
Block a user