diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c --- a/lib/libc/string/memset.c +++ b/lib/libc/string/memset.c @@ -42,7 +42,7 @@ #include -#define wsize sizeof(u_int) +#define wsize sizeof(u_long) #define wmask (wsize - 1) #ifdef BZERO @@ -67,7 +67,7 @@ { size_t t; #ifndef BZERO - u_int c; + u_long c; #endif u_char *dst; @@ -84,6 +84,9 @@ * * but we use a minimum of 3 here since the overhead of the code * to do word writes is substantial. + * + * TODO: This threshold might not be sensible for 64-bit u_long. + * We should benchmark and revisit this decision. */ if (length < 3 * wsize) { while (length != 0) { @@ -95,12 +98,12 @@ #ifndef BZERO if ((c = (u_char)c0) != 0) { /* Fill the word. */ - c = (c << 8) | c; /* u_int is 16 bits. */ -#if UINT_MAX > 0xffff - c = (c << 16) | c; /* u_int is 32 bits. */ + c = (c << 8) | c; /* u_long is 16 bits. */ +#if ULONG_MAX > 0xffff + c = (c << 16) | c; /* u_long is 32 bits. */ #endif -#if UINT_MAX > 0xffffffff - c = (c << 32) | c; /* u_int is 64 bits. */ +#if ULONG_MAX > 0xffffffff + c = (c << 32) | c; /* u_long is 64 bits. */ #endif } #endif @@ -116,7 +119,7 @@ /* Fill words. Length was >= 2*words so we know t >= 1 here. */ t = length / wsize; do { - *(u_int *)dst = WIDEVAL; + *(u_long *)(void *)dst = WIDEVAL; dst += wsize; } while (--t != 0);