From ddeeb5da0f58e4a5077ed3f55d0bad600a52c935 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 16 Apr 2024 23:41:37 -0700 Subject: [PATCH] pbot-vm: update de-optimization for gdb() function --- applets/pbot-vm/guest/include/prelude.h | 23 ++++++++++++----------- lib/PBot/VERSION.pm | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/applets/pbot-vm/guest/include/prelude.h b/applets/pbot-vm/guest/include/prelude.h index 0a0d6d5e..fffa6f5d 100644 --- a/applets/pbot-vm/guest/include/prelude.h +++ b/applets/pbot-vm/guest/include/prelude.h @@ -3,7 +3,7 @@ #include #include #include - + static int printf_binary_handler(FILE *s, const struct printf_info *info, const void *const *args) { const char *g = 0; @@ -14,9 +14,9 @@ static int printf_binary_handler(FILE *s, const struct printf_info *info, const info->is_char ? *(const unsigned char *) args[0] : info->is_short ? *(const unsigned short *) args[0] : *(const unsigned int *) args[0] ; - + char buf[sizeof value * CHAR_BIT], *p = buf; - + while(value) *p++ = '0' + (value & 1), value >>= 1; len = p - buf; digits = info->prec < 0 ? 1 : info->prec; @@ -47,31 +47,31 @@ static int printf_binary_handler(FILE *s, const struct printf_info *info, const } else { int j = (digits - arr) % g[-1]; if(!j) j = g[-1]; - + while(j--) fputc(digits-- > len ? '0' : *--p, s); while(digits > arr) { fputs(loc->thousands_sep, s); for(j = 0; j < g[-1]; ++j) fputc(digits-- > len ? '0' : *--p, s); } } - + while(digits) { int i = *--g; fputs(loc->thousands_sep, s); while(i--) fputc(digits-- > len ? '0' : *--p, s); } - + } else while(digits) fputc(digits-- > len ? '0' : *--p, s); - + while(info->left && info->width > total++) fputc(' ', s); return total - 1; } - + static int printf_binary_arginfo(const struct printf_info *info, size_t n, int *types, int *sizes) { if(n < 1) return -1; (void)sizes; - + types[0] = info->is_long_double ? PA_INT | PA_FLAG_LONG_LONG : info->is_long ? PA_INT | PA_FLAG_LONG : info->is_char ? PA_CHAR : @@ -79,7 +79,7 @@ static int printf_binary_arginfo(const struct printf_info *info, size_t n, int * PA_INT ; return 1; } - + __attribute__ (( constructor )) static void printf_binary_register(void) { setvbuf(stdout, NULL, _IONBF, 0); @@ -87,7 +87,8 @@ __attribute__ (( constructor )) static void printf_binary_register(void) register_printf_specifier('b', printf_binary_handler, printf_binary_arginfo); } -void gdb(char *cmd) { __asm__(""); } +__attribute__((optnone)) +void gdb(char *cmd) { asm volatile ("" : "+r" (cmd)); } #define dump(...) gdb("print " #__VA_ARGS__) #define print(...) gdb("print " #__VA_ARGS__) #define ptype(...) gdb("ptype " #__VA_ARGS__) diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index cedd533a..a8fab1d3 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4749, - BUILD_DATE => "2024-04-12", + BUILD_REVISION => 4750, + BUILD_DATE => "2024-04-16", }; sub initialize {}