unistd.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #ifdef __M2__
  20. #if __i386__
  21. #include <x86/linux/unistd.c>
  22. #elif __x86_64__
  23. #include <amd64/linux/unistd.c>
  24. #elif __arm__
  25. #include <armv7l/linux/unistd.c>
  26. #elif __aarch64__
  27. #include <aarch64/linux/unistd.c>
  28. #elif __riscv && __riscv_xlen==32
  29. #include <riscv32/linux/unistd.c>
  30. #elif __riscv && __riscv_xlen==64
  31. #include <riscv64/linux/unistd.c>
  32. #else
  33. #error arch not supported
  34. #endif
  35. #else
  36. #define NULL 0
  37. #define __PATH_MAX 4096
  38. void* malloc(unsigned size);
  39. int access(char* pathname, int mode);
  40. int chdir(char* path);
  41. int fchdir(int fd);
  42. void _exit(int value);
  43. int fork();
  44. int waitpid (int pid, int* status_ptr, int options);
  45. int execve(char* file_name, char** argv, char** envp);
  46. int read(int fd, char* buf, unsigned count);
  47. int write(int fd, char* buf, unsigned count);
  48. int lseek(int fd, int offset, int whence);
  49. int close(int fd);
  50. int unlink (char *filename);
  51. int _getcwd(char* buf, int size);
  52. char* getcwd(char* buf, unsigned size);
  53. char* getwd(char* buf);
  54. char* get_current_dir_name();
  55. int brk(void *addr);
  56. struct utsname
  57. {
  58. char sysname[65]; /* Operating system name (e.g., "Linux") */
  59. char nodename[65]; /* Name within "some implementation-defined network" */
  60. char release[65]; /* Operating system release (e.g., "2.6.28") */
  61. char version[65]; /* Operating system version */
  62. char machine[65]; /* Hardware identifier */
  63. };
  64. int uname(struct utsname* unameData);
  65. #endif
  66. #endif