commit d242b7e1169f44d9ece58ea5f4777aa4321e9cf2 Author: Peter Avalos Date: Tue Dec 14 15:14:23 2010 -1000 Fix libstand to have sbrk() and write() match standards. diff --git a/lib/libstand/sbrk.c b/lib/libstand/sbrk.c index e0f64bc..10b4eb6 100644 --- a/lib/libstand/sbrk.c +++ b/lib/libstand/sbrk.c @@ -45,18 +45,18 @@ setheap(void *base, void *top) maxheap = top - heapbase; } -char * -sbrk(int incr) +void * +sbrk(intptr_t incr) { - char *ret; + void *ret; - if ((heapsize + incr) <= maxheap) { + if ((heapsize + *(int *)incr) <= maxheap) { ret = heapbase + heapsize; - bzero(ret, incr); - heapsize += incr; + bzero(ret, *(int *)incr); + heapsize += *(int *)incr; return(ret); } errno = ENOMEM; - return((char *)-1); + return((void *)-1); } diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h index 1b86eea..e368ddb 100644 --- a/lib/libstand/stand.h +++ b/lib/libstand/stand.h @@ -236,7 +236,7 @@ tolower(int c) /* sbrk emulation */ extern void setheap(void *, void *); -extern char *sbrk(int); +extern void *sbrk(intptr_t); /* Matt Dillon's zalloc/zmalloc */ extern void *malloc(size_t); @@ -273,7 +273,7 @@ extern int open(const char *, int); extern int close(int); extern void closeall(void); extern ssize_t read(int, void *, size_t); -extern ssize_t write(int, void *, size_t); +extern ssize_t write(int, const void *, size_t); extern struct dirent *readdirfd(int); extern void srandom(u_long); diff --git a/lib/libstand/write.c b/lib/libstand/write.c index 6885a63..8372671 100644 --- a/lib/libstand/write.c +++ b/lib/libstand/write.c @@ -69,7 +69,7 @@ #include "stand.h" ssize_t -write(int fd, void *dest, size_t bcount) +write(int fd, const void *dest, size_t bcount) { struct open_file *f = &files[fd]; size_t resid; @@ -81,14 +81,14 @@ write(int fd, void *dest, size_t bcount) if (f->f_flags & F_RAW) { twiddle(); errno = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE, - btodb(f->f_offset), bcount, dest, &resid); + btodb(f->f_offset), bcount, __DECONST(void *, dest), &resid); if (errno) return (-1); f->f_offset += resid; return (resid); } resid = bcount; - if ((errno = (f->f_ops->fo_write)(f, dest, bcount, &resid))) + if ((errno = (f->f_ops->fo_write)(f, __DECONST(void *, dest), bcount, &resid))) return (-1); return (0); } diff --git a/lib/libstand/zalloc_malloc.c b/lib/libstand/zalloc_malloc.c index b3f1ac9..68a611c 100644 --- a/lib/libstand/zalloc_malloc.c +++ b/lib/libstand/zalloc_malloc.c @@ -65,7 +65,7 @@ malloc(size_t bytes) int incr = (bytes + BLKEXTENDMASK) & ~BLKEXTENDMASK; char *base; - if ((base = sbrk(incr)) == (char *)-1) + if ((base = sbrk((intptr_t)&incr)) == (void *)-1) return(NULL); zextendPool(&MallocPool, base, incr); zfree(&MallocPool, base, incr);