Browse Source

more 64bit fixes

OPENBSD_2_1
niklas 28 years ago
parent
commit
4dbdb68e0e
1 changed files with 12 additions and 10 deletions
  1. +12
    -10
      src/lib/libc/stdlib/malloc.c

+ 12
- 10
src/lib/libc/stdlib/malloc.c View File

@ -8,7 +8,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$OpenBSD: malloc.c,v 1.18 1996/11/23 19:10:26 niklas Exp $";
static char rcsid[] = "$OpenBSD: malloc.c,v 1.19 1996/11/24 00:41:30 niklas Exp $";
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
/* /*
@ -396,7 +396,7 @@ map_pages(pages)
malloc_brk = tail; malloc_brk = tail;
if ((last_index+1) >= malloc_ninfo && !extend_pgdir(last_index)) if ((last_index+1) >= malloc_ninfo && !extend_pgdir(last_index))
return 0;;
return 0;
return result; return result;
} }
@ -410,7 +410,7 @@ set_bit(pi, bit)
struct pginfo *pi; struct pginfo *pi;
int bit; int bit;
{ {
pi->bits[bit/MALLOC_BITS] |= 1<<(bit%MALLOC_BITS);
pi->bits[bit/MALLOC_BITS] |= 1UL<<(bit%MALLOC_BITS);
} }
#endif /* set_bit */ #endif /* set_bit */
@ -423,7 +423,7 @@ clr_bit(pi, bit)
struct pginfo *pi; struct pginfo *pi;
int bit; int bit;
{ {
pi->bits[bit/MALLOC_BITS] &= ~(1<<(bit%MALLOC_BITS));
pi->bits[bit/MALLOC_BITS] &= ~(1UL<<(bit%MALLOC_BITS));
} }
#endif /* clr_bit */ #endif /* clr_bit */
@ -436,7 +436,7 @@ tst_bit(pi, bit)
struct pginfo *pi; struct pginfo *pi;
int bit; int bit;
{ {
return pi->bits[bit/MALLOC_BITS] & (1<<(bit%MALLOC_BITS));
return pi->bits[bit/MALLOC_BITS] & (1UL<<(bit%MALLOC_BITS));
} }
#endif /* tst_bit */ #endif /* tst_bit */
@ -446,7 +446,7 @@ tst_bit(pi, bit)
#ifndef fls #ifndef fls
static __inline int static __inline int
fls(size) fls(size)
int size;
size_t size;
{ {
int i = 1; int i = 1;
while (size >>= 1) while (size >>= 1)
@ -455,7 +455,7 @@ fls(size)
} }
#endif /* fls */ #endif /* fls */
#if LONG_BITS == WORD_BITS
#if LONG_BIT == WORD_BIT
#define ffs_ul ffs #define ffs_ul ffs
#else #else
static __inline int static __inline int
@ -474,6 +474,7 @@ ffs_ul(u_long ul)
} }
if (k) if (k)
k += i * sizeof (u_int) * 8; k += i * sizeof (u_int) * 8;
return k;
} }
#endif #endif
@ -485,7 +486,8 @@ extend_pgdir(index)
u_long index; u_long index;
{ {
struct pginfo **new, **old; struct pginfo **new, **old;
int i, oldlen;
int i;
size_t oldlen;
/* Make it this many pages */ /* Make it this many pages */
i = index * sizeof *page_dir; i = index * sizeof *page_dir;
@ -788,7 +790,7 @@ malloc_make_chunks(bits)
(((malloc_pagesize >> bits)+MALLOC_BITS-1) / MALLOC_BITS); (((malloc_pagesize >> bits)+MALLOC_BITS-1) / MALLOC_BITS);
/* Don't waste more than two chunks on this */ /* Don't waste more than two chunks on this */
if ((1<<(bits)) <= l+l) {
if ((1UL<<(bits)) <= l+l) {
bp = (struct pginfo *)pp; bp = (struct pginfo *)pp;
} else { } else {
bp = (struct pginfo *)imalloc(l); bp = (struct pginfo *)imalloc(l);
@ -796,7 +798,7 @@ malloc_make_chunks(bits)
return 0; return 0;
} }
bp->size = (1<<bits);
bp->size = (1UL<<bits);
bp->shift = bits; bp->shift = bits;
bp->total = bp->free = malloc_pagesize >> bits; bp->total = bp->free = malloc_pagesize >> bits;
bp->page = pp; bp->page = pp;


Loading…
Cancel
Save