unistd.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Copyright (C) 2020 Jeremiah Orians
  2. * This file is part of M2-Planet.
  3. *
  4. * M2-Planet is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * M2-Planet is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef _UNISTD_H
  18. #define _UNISTD_H
  19. #include <sys/utsname.h>
  20. #ifdef __M2__
  21. #if __uefi__
  22. #include <uefi/unistd.c>
  23. #elif __i386__
  24. #include <x86/linux/unistd.c>
  25. #elif __x86_64__
  26. #include <amd64/linux/unistd.c>
  27. #elif __arm__
  28. #include <armv7l/linux/unistd.c>
  29. #elif __aarch64__
  30. #include <aarch64/linux/unistd.c>
  31. #elif __riscv && __riscv_xlen==32
  32. #include <riscv32/linux/unistd.c>
  33. #elif __riscv && __riscv_xlen==64
  34. #include <riscv64/linux/unistd.c>
  35. #else
  36. #error arch not supported
  37. #endif
  38. #else
  39. #define NULL 0
  40. #define __PATH_MAX 4096
  41. void* malloc(unsigned size);
  42. int access(char* pathname, int mode);
  43. int chdir(char* path);
  44. int fchdir(int fd);
  45. void _exit(int value);
  46. int fork();
  47. int waitpid (int pid, int* status_ptr, int options);
  48. int execve(char* file_name, char** argv, char** envp);
  49. int read(int fd, char* buf, unsigned count);
  50. int write(int fd, char* buf, unsigned count);
  51. int lseek(int fd, int offset, int whence);
  52. int close(int fd);
  53. int unlink (char *filename);
  54. int _getcwd(char* buf, int size);
  55. char* getcwd(char* buf, unsigned size);
  56. char* getwd(char* buf);
  57. char* get_current_dir_name();
  58. int brk(void *addr);
  59. int uname(struct utsname* unameData);
  60. int unshare(int flags);
  61. int geteuid();
  62. int getegid();
  63. int chroot(char const *path);
  64. int mount(char const *source, char const *target, char const *filesystemtype, SCM mountflags, void const *data);
  65. #endif
  66. #endif