From: nishi Date: Sat, 18 May 2024 09:16:30 +0000 (+0000) Subject: fix X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=1a2aaf267fdbad4f222100b1c9de6948ed09156f;p=dataworks.git fix git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@24 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/.clang-format b/.clang-format index 53f287c..a00b8c0 100644 --- a/.clang-format +++ b/.clang-format @@ -10,3 +10,5 @@ AllowShortIfStatementsOnASingleLine: Always AllowShortBlocksOnASingleLine: Never AllowShortLoopsOnASingleLine: true SpaceBeforeParens: Never +StatementMacros: + - __dw_big_endian diff --git a/Client/main.c b/Client/main.c index afb662b..589f41e 100644 --- a/Client/main.c +++ b/Client/main.c @@ -114,9 +114,7 @@ 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); + __dw_big_endian(123, double, ); int len = 0; char* buf = malloc(1); buf[0] = 0; diff --git a/Library/dw_util.h b/Library/dw_util.h index 2c3dd14..ad8c6fb 100644 --- a/Library/dw_util.h +++ b/Library/dw_util.h @@ -55,7 +55,8 @@ bool __dw_strcaseequ(const char* a, const char* b); type __converted; \ signed char* __converted_ptr = (signed char*)&__converted; \ int __i; \ - char __endian = dataworks_get_endian(); \ + int __endian_check = 1; \ + char __endian = (1 == *(volatile char*)&__endian_check) ? 'L' : 'B'; \ for(__i = 0; __i < sizeof(type); __i++){ \ if(__endian == 'L'){ \ __converted_ptr[sizeof(type) - __i - 1] = __ptr[__i]; \