linuxsystem-callsbrk

why do the argument of function brk() is void* and not int type?


I was looking at the documentation of the function int brk() in the Linux guide:

SYNOPSIS
   #include <unistd.h>

   int brk(void *addr);

   void *sbrk(intptr_t increment);



Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

   brk(), sbrk():
       Since glibc 2.19:
           _DEFAULT_SOURCE ||
               (_XOPEN_SOURCE >= 500) &&
               ! (_POSIX_C_SOURCE >= 200112L)
       From glibc 2.12 to 2.19:
           _BSD_SOURCE || _SVID_SOURCE ||
               (_XOPEN_SOURCE >= 500) &&
               ! (_POSIX_C_SOURCE >= 200112L)
       Before glibc 2.12:
           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500

DESCRIPTION      
       brk() and sbrk() change the location of the program break, which
       defines the end of the process's data segment (i.e., the program
       break is the first location after the end of the uninitialized data
       segment).  Increasing the program break has the effect of allocating
       memory to the process; decreasing the break deallocates memory.

   brk() sets the end of the data segment to the value specified by
   addr, when that value is reasonable, the system has enough memory,
   and the process does not exceed its maximum data size (see
   setrlimit(2)).

RETURN VALUE    
       On success, brk() returns zero.  On error, -1 is returned, and errno
       is set to ENOMEM.

and there's something I don't understand: if brk() only sets the end of the data segment to the value specified by addr, then why does it's argument is void* and not int type?

Thank you for your help!


Solution

  • I suppose, since the "break is the address of the first location beyond the current end of the data region" (Wikipedia), you cannot and should not know what data lies there, and hence the pointer cannot be any other type than void.