Date: Fri, 24 Mar 1995 00:52:11 +0000 From: Ed Hudson <elh@p5.spnet.com> To: hackers@FreeBSD.org Cc: elh@p5.spnet.com Subject: is this reasonable? Message-ID: <199503240052.AAA15572@p5.spnet.com>
next in thread | raw e-mail | index | archive | help
sbrk called with an arg of 1 (eg, sbrk(1)) under fbsd2.x increments the brk by 1. under SunOS4.1.3, sbrk(1) increments the brk by 8, and returns a result always double-word (8byte) aligned. fbsd malloc, /usr/lib/src/libc/stdlib/malloc.c, only aligns sbrk on its first call. i'm hazy about whether or not fbsd requires malloc to have exclusive control of a programs brk values, but in my reading of the man pages and this code, it doesn't appear to be the case. if indeed malloc is supposed to be able to co-exist with other routines calling sbrk with >0 values, then i think that either malloc has a latent bug, or sbrk is broken in its behavior. clearly confused and seeking re-education... -elh #include <stdio.h> #include <unistd.h> #include <stdlib.h> int main(int argc, char **argv) { char *t; int i; for (i=0; i<8; i++) { fprintf(stderr,"sbrk(1)= 0x%08x\n",sbrk(1)); } return(0); } FreeBSD output FreeBSD p5 2.1.0-Development FreeBSD 2.1.0-Development #0: Mon Mar 20 17:43:36 1995 gcc version 2.6.3 sbrk(1)= 0x00002204 sbrk(1)= 0x00002205 sbrk(1)= 0x00002206 sbrk(1)= 0x00002207 sbrk(1)= 0x00002208 sbrk(1)= 0x00002209 sbrk(1)= 0x0000220a sbrk(1)= 0x0000220b sun4 (gcc), sunos4.1.3 output: SunOS maui 4.1.3 1 sun4c gcc version 2.6.0 sbrk(1)= 0x00007368 sbrk(1)= 0x00007370 sbrk(1)= 0x00007378 sbrk(1)= 0x00007380 sbrk(1)= 0x00007388 sbrk(1)= 0x00007390 sbrk(1)= 0x00007398 sbrk(1)= 0x000073a0
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199503240052.AAA15572>