diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-04 07:51:17 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-04 07:51:17 +0000 |
commit | beaf2ace87dee90c1afcaf624335a54a5019f745 (patch) | |
tree | 348d7e3ca22b584760dcad0b3423563acaa7368f /string.c | |
parent | fa26bdc6012565e848c7626e9b10b79e5c2ad1df (diff) | |
download | ruby-beaf2ace87dee90c1afcaf624335a54a5019f745.tar.gz |
ULL suffix is a C99ism
Don't assume long long == 8 bytes.
If you can assume C99, there are macros named UINT64_C and
such for appropriate integer literal suffixes.
If you can't, no way but do a bitwise or.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -440,10 +440,21 @@ static inline const char * search_nonascii(const char *p, const char *e) { const uintptr_t *s, *t; -#if SIZEOF_VOIDP == 8 -# define NONASCII_MASK 0x8080808080808080ULL -#elif SIZEOF_VOIDP == 4 -# define NONASCII_MASK 0x80808080UL + +#if defined(__STDC_VERSION) && (__STDC_VERSION__ >= 199901L) +# if SIZEOF_UINTPTR_T == 8 +# define NONASCII_MASK UINT64_C(0x8080808080808080) +# elif SIZEOF_UINTPTR_T == 4 +# define NONASCII_MASK UINT32_C(0x80808080) +# endif +#else +# if SIZEOF_UINTPTR_T == 8 +# define NONASCII_MASK ((uintptr_t)0x80808080UL << 32 | (uintptr_t)0x80808080UL) +# elif SIZEOF_UINTPTR_T == 4 +# define NONASCII_MASK 0x80808080UL /* or...? */ +# else +# error "don't know what to do." +# endif #endif if (UNALIGNED_WORD_ACCESS || e - p >= SIZEOF_VOIDP) { |