From ddea76280f0bc4b55ebcdde1f9c97914a950e40d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 12 Dec 2012 14:09:39 -0600 Subject: [PATCH] deteect 64 bit --- src/include/switch_platform.h | 5 ++++ src/include/switch_utils.h | 43 ++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index 1140aac8ba..030a7e2244 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -265,6 +265,11 @@ typedef intptr_t switch_ssize_t; #endif #endif + +#if UINTPTR_MAX == 0xffffffffffffffff +#define FS_64BIT 1 +#endif + #endif #define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index a3ffc4e546..4705069728 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -51,35 +51,66 @@ static inline uint32_t switch_toupper(uint32_t eax) return eax - ebx; } +#ifdef FS_64BIT + +static inline void switch_toupper_max(char *s) +{ + uint64_t *b,*p; + char *c; + size_t l; + + l = strlen(s); + + p = (uint64_t *) s; + + while (l > 8) { + b = p; + *b = (uint32_t) switch_toupper(*b); + b++; + p++; + l -= 8; + } + + c = (char *)p; + + while(l > 0) { + *c = (char) switch_toupper(*c); + c++; + l--; + } + +} + +#else static inline void switch_toupper_max(char *s) { uint32_t *b,*p; char *c; size_t l; - int div = 0, rem = 0; - int i; l = strlen(s); - div = (int) (l / 4); - rem = l % 4; p = (uint32_t *) s; - for (i = 0; i < div; i++) { + while (l > 4) { b = p; *b = (uint32_t) switch_toupper(*b); b++; p++; + l -= 4; } c = (char *)p; - for (i = 0; i < rem; i++) { + while(l > 0) { *c = (char) switch_toupper(*c); c++; + l--; } + } +#endif SWITCH_DECLARE(int) old_switch_toupper(int c);