You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
608 B

5 years ago
  1. #define _GNU_SOURCE
  2. #include <fcntl.h>
  3. #include <unistd.h>
  4. static
  5. int
  6. sys_get_pagesize_(void)
  7. {
  8. #ifdef _SC_PAGESIZE
  9. return sysconf(_SC_PAGESIZE);
  10. #else
  11. return getpagesize();
  12. #endif
  13. }
  14. int
  15. sys_get_pagesize(void)
  16. {
  17. static int pagesize = 0;
  18. if(pagesize == 0)
  19. pagesize = sys_get_pagesize_();
  20. return pagesize;
  21. }
  22. int
  23. sys_alloc_pipe(int pipe_[2],
  24. int bufsize_)
  25. {
  26. #ifdef F_SETPIPE_SZ
  27. int rv;
  28. rv = pipe(pipe_);
  29. if(rv == -1)
  30. return -1;
  31. rv = fcntl(pipe_[0],F_SETPIPE_SZ,bufsize_);
  32. if(rv == -1)
  33. return -1;
  34. return rv;
  35. #else
  36. errno = ENOSYS;
  37. return -1;
  38. #endif
  39. }