1
0

brk.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * This file is part of Jehanne.
  3. *
  4. * Copyright (C) 2016 Giacomo Tesio <giacomo@tesio.it>
  5. *
  6. * Jehanne is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, version 2 of the License.
  9. *
  10. * Jehanne is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <u.h>
  19. #include <lib9.h>
  20. void
  21. main(void)
  22. {
  23. long b, b1;
  24. b = sys_create("#0/brk/set", -1, 16*1024*1024);
  25. if(b >= 0){
  26. print("FAIL: create returned fd %d.\n", b);
  27. exits("FAIL");
  28. }
  29. if(b == -1){
  30. print("FAIL: create: %r.\n");
  31. exits("FAIL");
  32. }
  33. b1 = brk((void*)b + 16*1024*1024);
  34. if(b1 == -1){
  35. print("FAIL: brk: %r.\n");
  36. exits("FAIL");
  37. }
  38. if(b >= b1){
  39. print("FAIL: b >= b1.\n");
  40. exits("FAIL");
  41. }
  42. print("PASS\n");
  43. exits("PASS");
  44. }