1
0

segbrk 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. .TH SEGBRK 2
  2. .SH NAME
  3. segbrk \- change memory allocation
  4. .SH SYNOPSIS
  5. .B #include <u.h>
  6. .br
  7. .B #include <libc.h>
  8. .PP
  9. .ta \w'\fLvoid* 'u
  10. .B
  11. void* segbrk(void *saddr, void *addr)
  12. .PP
  13. .SH DESCRIPTION
  14. .I Segbrk
  15. sets the system's idea of the lowest unused location of a segment
  16. to
  17. .I addr
  18. rounded up to the next multiple of a page size, typically 4096 bytes.
  19. The segment is identified by
  20. .I saddr
  21. which may be any valid address within the segment.
  22. .PP
  23. A call to
  24. .I segbrk
  25. with a zero
  26. .I addr
  27. argument returns the address
  28. of the top of bss.
  29. .PP
  30. The system will prevent segments from overlapping and will not allow the
  31. length of the
  32. text, data, or stack segment to be altered.
  33. .SH SOURCE
  34. .B /sys/src/libc/9syscall
  35. .SH SEE ALSO
  36. .IR brk (2),
  37. .IR segattach (2),
  38. .IR segflush (2)
  39. .br
  40. .BR /proc/*/segment
  41. .SH DIAGNOSTICS
  42. Sets
  43. .IR errstr .
  44. .I Segbrk
  45. returns
  46. .B (void*)-1
  47. on error.
  48. .SH BUGS
  49. .I Segbrk
  50. is not fully defined or implemented.
  51. In particular,
  52. it cannot always return the top of bss
  53. when called with a zero
  54. .I addr
  55. argument.
  56. The
  57. .I segbrk
  58. system call may go away or be re-implemented
  59. to give more general segment control,
  60. subsuming the functions of
  61. .IR brk (2),
  62. .IR segflush (2)
  63. and
  64. .I segfree
  65. in
  66. .IR segattach (2).