syscalls.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /**
  2. ******************************************************************************
  3. * @file syscalls.c
  4. * @author Auto-generated by STM32CubeIDE
  5. * @brief STM32CubeIDE Minimal System calls file
  6. *
  7. * For more information about which c-functions
  8. * need which of these lowlevel functions
  9. * please consult the Newlib libc-manual
  10. ******************************************************************************
  11. * @attention
  12. *
  13. * Copyright (c) 2021 STMicroelectronics.
  14. * All rights reserved.
  15. *
  16. * This software is licensed under terms that can be found in the LICENSE file
  17. * in the root directory of this software component.
  18. * If no LICENSE file comes with this software, it is provided AS-IS.
  19. *
  20. ******************************************************************************
  21. */
  22. /* Includes */
  23. #include <sys/stat.h>
  24. #include <stdlib.h>
  25. #include <errno.h>
  26. #include <stdio.h>
  27. #include <signal.h>
  28. #include <time.h>
  29. #include <sys/time.h>
  30. #include <sys/times.h>
  31. /* Variables */
  32. extern int __io_putchar(int ch) __attribute__((weak));
  33. extern int __io_getchar(void) __attribute__((weak));
  34. char *__env[1] = { 0 };
  35. char **environ = __env;
  36. /* Functions */
  37. void initialise_monitor_handles()
  38. {
  39. }
  40. int _getpid(void)
  41. {
  42. return 1;
  43. }
  44. int _kill(int pid, int sig)
  45. {
  46. errno = EINVAL;
  47. return -1;
  48. }
  49. void _exit (int status)
  50. {
  51. _kill(status, -1);
  52. while (1) {} /* Make sure we hang here */
  53. }
  54. __attribute__((weak)) int _read(int file, char *ptr, int len)
  55. {
  56. int DataIdx;
  57. for (DataIdx = 0; DataIdx < len; DataIdx++)
  58. {
  59. *ptr++ = __io_getchar();
  60. }
  61. return len;
  62. }
  63. __attribute__((weak)) int _write(int file, char *ptr, int len)
  64. {
  65. int DataIdx;
  66. for (DataIdx = 0; DataIdx < len; DataIdx++)
  67. {
  68. __io_putchar(*ptr++);
  69. }
  70. return len;
  71. }
  72. int _close(int file)
  73. {
  74. return -1;
  75. }
  76. int _fstat(int file, struct stat *st)
  77. {
  78. st->st_mode = S_IFCHR;
  79. return 0;
  80. }
  81. int _isatty(int file)
  82. {
  83. return 1;
  84. }
  85. int _lseek(int file, int ptr, int dir)
  86. {
  87. return 0;
  88. }
  89. int _open(char *path, int flags, ...)
  90. {
  91. /* Pretend like we always fail */
  92. return -1;
  93. }
  94. int _wait(int *status)
  95. {
  96. errno = ECHILD;
  97. return -1;
  98. }
  99. int _unlink(char *name)
  100. {
  101. errno = ENOENT;
  102. return -1;
  103. }
  104. int _times(struct tms *buf)
  105. {
  106. return -1;
  107. }
  108. int _stat(char *file, struct stat *st)
  109. {
  110. st->st_mode = S_IFCHR;
  111. return 0;
  112. }
  113. int _link(char *old, char *new)
  114. {
  115. errno = EMLINK;
  116. return -1;
  117. }
  118. int _fork(void)
  119. {
  120. errno = EAGAIN;
  121. return -1;
  122. }
  123. int _execve(char *name, char **argv, char **env)
  124. {
  125. errno = ENOMEM;
  126. return -1;
  127. }