diff options
author | niklas <> | 1996-11-23 19:10:26 +0000 |
---|---|---|
committer | niklas <> | 1996-11-23 19:10:26 +0000 |
commit | 05500d62e522ee16732503e0c78e0040855392ca (patch) | |
tree | 53f95c94df488ca7aa796575b6c84f54b2060e47 /src/lib | |
parent | 53263a3b349d4220f2b3acda159798b6ff3a9f3e (diff) | |
download | openbsd-05500d62e522ee16732503e0c78e0040855392ca.tar.gz openbsd-05500d62e522ee16732503e0c78e0040855392ca.tar.bz2 openbsd-05500d62e522ee16732503e0c78e0040855392ca.zip |
64 bit clean
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/stdlib/malloc.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 4e18a07994..9111b092c7 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #if defined(LIBC_SCCS) && !defined(lint) | 10 | #if defined(LIBC_SCCS) && !defined(lint) |
11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.17 1996/11/22 16:15:23 kstailey Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.18 1996/11/23 19:10:26 niklas Exp $"; |
12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ |
13 | 13 | ||
14 | /* | 14 | /* |
@@ -455,6 +455,28 @@ fls(size) | |||
455 | } | 455 | } |
456 | #endif /* fls */ | 456 | #endif /* fls */ |
457 | 457 | ||
458 | #if LONG_BITS == WORD_BITS | ||
459 | #define ffs_ul ffs | ||
460 | #else | ||
461 | static __inline int | ||
462 | ffs_ul(u_long ul) | ||
463 | { | ||
464 | u_int n; | ||
465 | int i; | ||
466 | int k; | ||
467 | |||
468 | for (i = 0; i < sizeof (u_long) / sizeof (u_int); i++) { | ||
469 | n = ul & UINT_MAX; | ||
470 | k = ffs (n); | ||
471 | if (k) | ||
472 | break; | ||
473 | ul >>= (sizeof (u_int) * 8); | ||
474 | } | ||
475 | if (k) | ||
476 | k += i * sizeof (u_int) * 8; | ||
477 | } | ||
478 | #endif | ||
479 | |||
458 | /* | 480 | /* |
459 | * Extend page directory | 481 | * Extend page directory |
460 | */ | 482 | */ |
@@ -838,8 +860,8 @@ malloc_bytes(size) | |||
838 | ; | 860 | ; |
839 | 861 | ||
840 | /* Find that bit, and tweak it */ | 862 | /* Find that bit, and tweak it */ |
841 | k = ffs((unsigned)*lp) - 1; | 863 | k = ffs_ul(*lp) - 1; |
842 | *lp ^= 1<<k; | 864 | *lp ^= 1UL<<k; |
843 | 865 | ||
844 | /* If there are no more free, remove from free-list */ | 866 | /* If there are no more free, remove from free-list */ |
845 | if (!--bp->free) { | 867 | if (!--bp->free) { |