]> Nishi Git Mirror - dataworks.git/commitdiff
should work
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 09:08:39 +0000 (09:08 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sat, 18 May 2024 09:08:39 +0000 (09:08 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@23 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Client/main.c
Library/dw_util.h

index 582d893d27ede8df4bffce306b2fa2d4397de3ba..afb662b3ee543b1d4cf74606032a680c781bdb15 100644 (file)
@@ -114,6 +114,9 @@ int main(int argc, char** argv) {
        printf("\n");
        printf("Type a command (.help) for the help\n");
        printf("\n");
+       double val;
+       __dw_big_endian(123.3, double, val = __converted);
+       printf("%f\n", val);
        int len = 0;
        char* buf = malloc(1);
        buf[0] = 0;
index 0b5d6891cff1622cc8a313ccfb452c42422d820f..2c3dd1482d639598e1f6b57ecf54de04926e0a1f 100644 (file)
@@ -42,8 +42,30 @@ extern "C" {
 
 #include <stdbool.h>
 
+#include "dataworks.h"
+
 bool __dw_strcaseequ(const char* a, const char* b);
 
+#define __dw_xstr(x) #x
+#define __dw_str(x) __dw_xstr(x)
+
+#define __dw_big_endian(arg, type, exec) { \
+       type __original = arg; \
+       signed char* __ptr = (signed char*)&__original; \
+       type __converted; \
+       signed char* __converted_ptr = (signed char*)&__converted; \
+       int __i; \
+       char __endian = dataworks_get_endian(); \
+       for(__i = 0; __i < sizeof(type); __i++){ \
+               if(__endian == 'L'){ \
+                       __converted_ptr[sizeof(type) - __i - 1] = __ptr[__i]; \
+               }else{ \
+                       __converted_ptr[__i] = __ptr[__i]; \
+               } \
+       } \
+       exec; \
+}
+
 #ifdef __cplusplus
 }
 #endif