syscalls.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include <string.h>
  15. #include <stdbool.h>
  16. #include <stdlib.h>
  17. #include <stdarg.h>
  18. #include <sys/types.h>
  19. #include <unistd.h>
  20. #include <errno.h>
  21. #include <reent.h>
  22. #include <sys/fcntl.h>
  23. int system(const char* str)
  24. {
  25. errno = ENOSYS;
  26. return -1;
  27. }
  28. int _system_r(struct _reent *r, const char *str)
  29. {
  30. __errno_r(r) = ENOSYS;
  31. return -1;
  32. }
  33. int raise(int sig)
  34. {
  35. abort();
  36. }
  37. int _raise_r(struct _reent *r, int sig)
  38. {
  39. abort();
  40. }
  41. void* _sbrk_r(struct _reent *r, ptrdiff_t sz)
  42. {
  43. abort();
  44. }
  45. int _getpid_r(struct _reent *r)
  46. {
  47. __errno_r(r) = ENOSYS;
  48. return -1;
  49. }
  50. int _kill_r(struct _reent *r, int pid, int sig)
  51. {
  52. __errno_r(r) = ENOSYS;
  53. return -1;
  54. }
  55. void _exit(int __status)
  56. {
  57. abort();
  58. }
  59. /* Replaces newlib fcntl, which has been compiled without HAVE_FCNTL */
  60. int fcntl(int fd, int cmd, ...)
  61. {
  62. va_list args;
  63. va_start(args, cmd);
  64. int arg = va_arg(args, int);
  65. va_end(args);
  66. struct _reent* r = __getreent();
  67. return _fcntl_r(r, fd, cmd, arg);
  68. }
  69. /* No-op function, used to force linking this file,
  70. instead of the syscalls implementation from libgloss.
  71. */
  72. void newlib_include_syscalls_impl()
  73. {
  74. }