DIY Logging Volt/Ampmeter
syscalls.c
Go to the documentation of this file.
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  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
14  * All rights reserved.</center></h2>
15  *
16  * This software component is licensed by ST under BSD 3-Clause license,
17  * the "License"; You may not use this file except in compliance with the
18  * License. You may obtain a copy of the License at:
19  * opensource.org/licenses/BSD-3-Clause
20  *
21  ******************************************************************************
22  */
23 
24 /* Includes */
25 #include <sys/stat.h>
26 #include <stdlib.h>
27 #include <errno.h>
28 #include <stdio.h>
29 #include <signal.h>
30 #include <time.h>
31 #include <sys/time.h>
32 #include <sys/times.h>
33 
34 
35 /* Variables */
36 //#undef errno
37 extern int errno;
38 extern int __io_putchar(int ch) __attribute__((weak));
39 extern int __io_getchar(void) __attribute__((weak));
40 
41 register char * stack_ptr asm("sp");
42 
43 char *__env[1] = { 0 };
44 char **environ = __env;
45 
46 
47 /* Functions */
49 {
50 }
51 
52 int _getpid(void)
53 {
54  return 1;
55 }
56 
57 int _kill(int pid, int sig)
58 {
59  errno = EINVAL;
60  return -1;
61 }
62 
63 void _exit (int status)
64 {
65  _kill(status, -1);
66  while (1) {} /* Make sure we hang here */
67 }
68 
69 __attribute__((weak)) int _read(int file, char *ptr, int len)
70 {
71  int DataIdx;
72 
73  for (DataIdx = 0; DataIdx < len; DataIdx++)
74  {
75  *ptr++ = __io_getchar();
76  }
77 
78 return len;
79 }
80 
81 __attribute__((weak)) int _write(int file, char *ptr, int len)
82 {
83  int DataIdx;
84 
85  for (DataIdx = 0; DataIdx < len; DataIdx++)
86  {
87  __io_putchar(*ptr++);
88  }
89  return len;
90 }
91 
92 int _close(int file)
93 {
94  return -1;
95 }
96 
97 
98 int _fstat(int file, struct stat *st)
99 {
100  st->st_mode = S_IFCHR;
101  return 0;
102 }
103 
104 int _isatty(int file)
105 {
106  return 1;
107 }
108 
109 int _lseek(int file, int ptr, int dir)
110 {
111  return 0;
112 }
113 
114 int _open(char *path, int flags, ...)
115 {
116  /* Pretend like we always fail */
117  return -1;
118 }
119 
120 int _wait(int *status)
121 {
122  errno = ECHILD;
123  return -1;
124 }
125 
126 int _unlink(char *name)
127 {
128  errno = ENOENT;
129  return -1;
130 }
131 
132 int _times(struct tms *buf)
133 {
134  return -1;
135 }
136 
137 int _stat(char *file, struct stat *st)
138 {
139  st->st_mode = S_IFCHR;
140  return 0;
141 }
142 
143 int _link(char *old, char *new)
144 {
145  errno = EMLINK;
146  return -1;
147 }
148 
149 int _fork(void)
150 {
151  errno = EAGAIN;
152  return -1;
153 }
154 
155 int _execve(char *name, char **argv, char **env)
156 {
157  errno = ENOMEM;
158  return -1;
159 }
ptr
uint32_t volatile * ptr
Definition: cmsis_iccarm.h:558
_lseek
int _lseek(int file, int ptr, int dir)
Definition: syscalls.c:109
initialise_monitor_handles
void initialise_monitor_handles()
Definition: syscalls.c:48
_getpid
int _getpid(void)
Definition: syscalls.c:52
environ
char ** environ
Definition: syscalls.c:44
_close
int _close(int file)
Definition: syscalls.c:92
__io_putchar
int __io_putchar(int ch) __attribute__((weak))
_exit
void _exit(int status)
Definition: syscalls.c:63
_open
int _open(char *path, int flags,...)
Definition: syscalls.c:114
_kill
int _kill(int pid, int sig)
Definition: syscalls.c:57
__attribute__
__attribute__((weak))
Definition: syscalls.c:69
_link
int _link(char *old, char *new)
Definition: syscalls.c:143
_isatty
int _isatty(int file)
Definition: syscalls.c:104
__io_getchar
int __io_getchar(void)
Definition: syscalls.c:39
errno
int errno
_unlink
int _unlink(char *name)
Definition: syscalls.c:126
_fstat
int _fstat(int file, struct stat *st)
Definition: syscalls.c:98
_times
int _times(struct tms *buf)
Definition: syscalls.c:132
_wait
int _wait(int *status)
Definition: syscalls.c:120
_fork
int _fork(void)
Definition: syscalls.c:149
_execve
int _execve(char *name, char **argv, char **env)
Definition: syscalls.c:155
_stat
int _stat(char *file, struct stat *st)
Definition: syscalls.c:137