home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / i386 / __brk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-30  |  584 b   |  31 lines

  1. #include <unistd.h>
  2. #include <sys/syscall.h>
  3. #include <errno.h>
  4.  
  5. void * ___brk_addr = 0;
  6.  
  7. int __brk(void * end_data_seg)
  8. {
  9. #if defined(__PIC__) || defined (__pic__)
  10.     __asm__ volatile ("pushl %%ebx\n\t"
  11.               "movl %%ecx,%%ebx\n\t"
  12.               "int $0x80\n\t"
  13.               "popl %%ebx"
  14.         :"=a" (___brk_addr)
  15.         :"0" (SYS_brk),"c" (end_data_seg));
  16. #else
  17.     __asm__ volatile ("int $0x80"
  18.         :"=a" (___brk_addr)
  19.         :"0" (SYS_brk),"b" (end_data_seg));
  20. #endif
  21.     if (___brk_addr == end_data_seg)
  22.         return 0;
  23.     errno = ENOMEM;
  24.     return -1;
  25. }
  26.  
  27. #include <gnu-stabs.h>
  28. #ifdef weak_alias
  29. weak_alias (__brk, brk);
  30. #endif
  31.