brk.c 416 B

1234567891011121314151617181920212223
  1. /* From libc-5.3.12 */
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #include <sys/syscall.h>
  5. libc_hidden_proto(brk)
  6. extern void * ___brk_addr;
  7. extern int __init_brk (void);
  8. extern void *_brk(void *ptr);
  9. int brk(void * end_data_seg)
  10. {
  11. if (__init_brk () == 0)
  12. {
  13. ___brk_addr = _brk(end_data_seg);
  14. if (___brk_addr == end_data_seg)
  15. return 0;
  16. __set_errno(ENOMEM);
  17. }
  18. return -1;
  19. }
  20. libc_hidden_def(brk)