Type of brk(2) return value

guy at rlgvax.UUCP guy at rlgvax.UUCP
Wed May 30 15:05:06 AEST 1984


> 	I think you would find that brk() really returns an
> int and not a char * (I've looked at the code for 4.1 BSD,
> 2.8 BSD and Bell V7).  This is because of the way the entries
> are defined in the sysent[] table (as pointers to functions 
> which return int).  Therefore all system calls return int.

Look at the "time(2)" system call page.  Then tell me all system calls
return "int".  The declaration of the routines in the sysent[] table
is irrelevant; values are returned from a system call in the kernel to
user-mode code by filling in the return value in the U page; this value
is then stuffed into the appropriate register(s), so a system call can
return whatever it pleases, except for a structure.  Furthermore, the
user-mode routine that issues the system call need not have the same
behavior as the actual trap; check out the "signal" call for an example.

However, "brk" does, indeed, return an "int" and "sbrk" does, indeed, return
a "char *".  The S5 manual (which is the one sitting in front of me at this
instant) states it correctly, and probably other versions of the manual do
so as well.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list