deteect 64 bit

This commit is contained in:
Anthony Minessale 2012-12-12 14:09:39 -06:00
parent e89fe5a03b
commit ddea76280f
2 changed files with 42 additions and 6 deletions

View File

@ -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

View File

@ -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);