Remove warnings. ST lib Hal configuration.
[lwext4.git] / demos / stm32f429_disco / syscalls.c
1 /*\r
2  * Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  *\r
9  * - Redistributions of source code must retain the above copyright\r
10  *   notice, this list of conditions and the following disclaimer.\r
11  * - Redistributions in binary form must reproduce the above copyright\r
12  *   notice, this list of conditions and the following disclaimer in the\r
13  *   documentation and/or other materials provided with the distribution.\r
14  * - The name of the author may not be used to endorse or promote products\r
15  *   derived from this software without specific prior written permission.\r
16  *\r
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
27  */\r
28 \r
29 #include <sys/stat.h>\r
30 #include <stdlib.h>\r
31 #include <errno.h>\r
32 #include <stdio.h>\r
33 #include <signal.h>\r
34 #include <time.h>\r
35 \r
36 #include <lcd_log.h>\r
37 \r
38 int _getpid(void)\r
39 {\r
40     return 1;\r
41 }\r
42 \r
43 int _kill(int pid, int sig)\r
44 {\r
45     errno = EINVAL;\r
46     return -1;\r
47 }\r
48 \r
49 void _exit (int status)\r
50 {\r
51     _kill(status, -1);\r
52     while (1) {}                /* Make sure we hang here */\r
53 }\r
54 \r
55 int _write(int file, char *ptr, int len)\r
56 {\r
57     int todo;\r
58 \r
59     for (todo = 0; todo < len; todo++)\r
60     {\r
61         __io_putchar( *ptr++ );\r
62     }\r
63 \r
64     /* Implement your write code here, this is used by puts and printf for example */\r
65     return len;\r
66 }\r
67 \r
68 caddr_t _sbrk(int incr)\r
69 {\r
70         extern char __heap_start;\r
71         extern char __heap_end;\r
72         static char *current_heap_end = &__heap_start;\r
73         char *previous_heap_end;\r
74 \r
75         previous_heap_end = current_heap_end;\r
76 \r
77         if (current_heap_end + incr > &__heap_end)\r
78         {\r
79                 errno = ENOMEM;\r
80                 return (caddr_t) -1;\r
81         }\r
82 \r
83         current_heap_end += incr;\r
84 \r
85         return (caddr_t)previous_heap_end;\r
86 }\r
87 \r
88 int _close(int file)\r
89 {\r
90     return -1;\r
91 }\r
92 \r
93 \r
94 int _fstat(int file, struct stat *st)\r
95 {\r
96     st->st_mode = S_IFCHR;\r
97     return 0;\r
98 }\r
99 \r
100 int _isatty(int file)\r
101 {\r
102     return 1;\r
103 }\r
104 \r
105 int _lseek(int file, int ptr, int dir)\r
106 {\r
107     return 0;\r
108 }\r
109 \r
110 int _read(int file, char *ptr, int len)\r
111 {\r
112     return 0;\r
113 }\r
114 \r
115 int _open(char *path, int flags, ...)\r
116 {\r
117     /* Pretend like we always fail */\r
118     return -1;\r
119 }\r
120 \r
121 int _wait(int *status)\r
122 {\r
123     errno = ECHILD;\r
124     return -1;\r
125 }\r
126 \r
127 int _unlink(char *name)\r
128 {\r
129     errno = ENOENT;\r
130     return -1;\r
131 }\r
132 \r
133 \r
134 int _stat(char *file, struct stat *st)\r
135 {\r
136     st->st_mode = S_IFCHR;\r
137     return 0;\r
138 }\r
139 \r
140 int _link(char *old, char *new)\r
141 {\r
142     errno = EMLINK;\r
143     return -1;\r
144 }\r
145 \r
146 int _fork(void)\r
147 {\r
148     errno = EAGAIN;\r
149     return -1;\r
150 }\r
151 \r
152 int _execve(char *name, char **argv, char **env)\r
153 {\r
154     errno = ENOMEM;\r
155     return -1;\r
156 }\r