aboutsummaryrefslogtreecommitdiff
path: root/string/bits/string2.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-04-30 15:43:09 +0000
committerUlrich Drepper <drepper@redhat.com>1999-04-30 15:43:09 +0000
commit6c8f9de31cd7edb03bd46d431478408ef44d3ed3 (patch)
tree197c86fb417c920b76e5b05577c5f50e4e970a69 /string/bits/string2.h
parent1fafbbda1a49cf60e18b044d37ea2fc589c70786 (diff)
downloadglibc-6c8f9de31cd7edb03bd46d431478408ef44d3ed3.tar
glibc-6c8f9de31cd7edb03bd46d431478408ef44d3ed3.tar.gz
glibc-6c8f9de31cd7edb03bd46d431478408ef44d3ed3.tar.bz2
glibc-6c8f9de31cd7edb03bd46d431478408ef44d3ed3.zip
Fix bugs I introduced in last change.
Diffstat (limited to 'string/bits/string2.h')
-rw-r--r--string/bits/string2.h40
1 files changed, 21 insertions, 19 deletions
diff --git a/string/bits/string2.h b/string/bits/string2.h
index 391859a91b..3f7784ed38 100644
--- a/string/bits/string2.h
+++ b/string/bits/string2.h
@@ -97,59 +97,61 @@ __STRING2_COPY_TYPE (8);
(__extension__ (__builtin_constant_p (n) && (n) <= 16 \
? ((n) == 1 \
? __memset_1 (s, c) \
- : __memset_gc (s, (((__uint8_t) c) * 0x1010101), n)) \
+ : __memset_gc (s, c, n)) \
: (__builtin_constant_p (c) && (c) == '\0' \
? ({ void *__s = (s); __bzero (__s, n); __s; }) \
: memset (s, c, n))))
-#define __memset_1(s, c) ({ void *__s = (s); *((__uint8_t *) __s) = c; __s; })
+#define __memset_1(s, c) ({ void *__s = (s); \
+ *((__uint8_t *) __s) = (__uint8_t) c; __s; })
#define __memset_gc(s, c, n) \
({ void *__s = (s); \
__uint32_t *__ts = (__uint32_t *) __s; \
+ __uint8_t __c = (__uint8_t) (c); \
\
/* This `switch' statement will be removed at compile-time. */ \
switch (n) \
{ \
case 15: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 11: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 7: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 3: \
- *((__uint16_t *) __ts)++ = c; \
- *((__uint8_t *) __ts) = c; \
+ *((__uint16_t *) __ts)++ = __c * 0x0101; \
+ *((__uint8_t *) __ts) = __c; \
break; \
\
case 14: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 10: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 6: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 2: \
- *((__uint16_t *) __ts) = c; \
+ *((__uint16_t *) __ts) = __c * 0x0101; \
break; \
\
case 13: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 9: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 5: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 1: \
- *((__uint8_t *) __ts) = c; \
+ *((__uint8_t *) __ts) = __c; \
break; \
\
case 16: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 12: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 8: \
- *__ts++ = c; \
+ *__ts++ = __c * 0x01010101; \
case 4: \
- *__ts = c; \
+ *__ts = __c * 0x01010101; \
case 0: \
break; \
} \