µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
c-newlib-reent.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ distribution.
3 * (https://github.com/micro-os-plus)
4 * Copyright (c) 2015 Liviu Ionescu.
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#if defined(__clang__)
29#pragma clang diagnostic ignored "-Wempty-translation-unit"
30#endif
31
32// ----------------------------------------------------------------------------
33
34#if defined(__ARM_EABI__)
35
36// ----------------------------------------------------------------------------
37
39
40// ----------------------------------------------------------------------------
41
42extern "C"
43{
44
45 // Many newlib functions call the reentrant versions right away,
46 // and these call the _name() implementations. To avoid this, the
47 // shortcut is to simply skip the reentrant code (ignore the pointer)
48 // and directly call the posix implementation.
49
50#pragma GCC diagnostic push
51#pragma GCC diagnostic ignored "-Wmissing-declarations"
52#pragma GCC diagnostic ignored "-Wunused-parameter"
53
54 int __attribute__((weak))
55 _close_r (void* ptr, int fildes)
56 {
57 return __posix_close (fildes);
58 }
59
60 int __attribute__((weak))
61 _execve_r (void* ptr, const char* path, char* const argv[],
62 char* const envp[])
63 {
64 return __posix_execve (path, argv, envp);
65 }
66
67 int __attribute__((weak))
68 _fcntl_r (void* ptr, int fildes, int cmd, int arg)
69 {
70 return __posix_fcntl (fildes, cmd, arg);
71 }
72
73 pid_t __attribute__((weak))
74 _fork_r (void* ptr)
75 {
76 return __posix_fork ();
77 }
78
79 int __attribute__((weak))
80 _fstat_r (void* ptr, int fildes, struct stat* buf)
81 {
82 return __posix_fstat (fildes, buf);
83 }
84
85 pid_t __attribute__((weak))
86 _getpid_r (void* ptr)
87 {
88 return __posix_getpid ();
89 }
90
91 int __attribute__((weak))
92 _gettimeofday_r (void* ptr, struct timeval* ptimeval, void* ptimezone)
93 {
94 return __posix_gettimeofday (ptimeval, ptimezone);
95 }
96
97 int __attribute__((weak))
98 _isatty_r (void* ptr, int fildes)
99 {
100 return __posix_isatty (fildes);
101 }
102
103 int __attribute__((weak))
104 _kill_r (void* ptr, pid_t pid, int sig)
105 {
106 return __posix_kill (pid, sig);
107 }
108
109 int __attribute__((weak))
110 _link_r (void* ptr, const char* existing, const char* _new)
111 {
112 return __posix_link (existing, _new);
113 }
114
115 off_t __attribute__((weak))
116 _lseek_r (void* ptr, int fildes, off_t offset, int whence)
117 {
118 return __posix_lseek (fildes, offset, whence);
119 }
120
121 int __attribute__((weak))
122 _mkdir_r (void* ptr, const char* path, mode_t mode)
123 {
124 return __posix_mkdir (path, mode);
125 }
126
127 int __attribute__((weak))
128 _open_r (void* ptr, const char* path, int oflag, int mode)
129 {
130 return __posix_open (path, oflag, mode);
131 }
132
133 ssize_t __attribute__((weak))
134 _read_r (void* ptr, int fildes, void* buf, size_t nbyte)
135 {
136 return __posix_read (fildes, buf, nbyte);
137 }
138
139 int __attribute__((weak))
140 _rename_r (void* ptr, const char* oldfn, const char* newfn)
141 {
142 return __posix_rename (oldfn, newfn);
143 }
144
145 int __attribute__((weak))
146 _stat_r (void* ptr, const char* path, struct stat* buf)
147 {
148 return __posix_stat (path, buf);
149 }
150
151 clock_t __attribute__((weak))
152 _times_r (void* ptr, struct tms* buf)
153 {
154 return __posix_times (buf);
155 }
156
157 int __attribute__((weak))
158 _unlink_r (void* ptr, const char* name)
159 {
160 return __posix_unlink (name);
161 }
162
163 pid_t __attribute__((weak))
164 _wait_r (void* ptr, int* stat_loc)
165 {
166 return __posix_wait (stat_loc);
167 }
168
169 ssize_t __attribute__((weak))
170 _write_r (void* ptr, int fildes, const void* buf, size_t nbyte)
171 {
172 return __posix_write (fildes, buf, nbyte);
173 }
174
175 // --------------------------------------------------------------------------
176
177#pragma GCC diagnostic pop
178
179}
180
181// ----------------------------------------------------------------------------
182
183#endif /* defined(__ARM_EABI__) */
pid_t _fork_r(void *ptr)
int _isatty_r(void *ptr, int fildes)
off_t _lseek_r(void *ptr, int fildes, off_t offset, int whence)
int _unlink_r(void *ptr, const char *name)
pid_t _wait_r(void *ptr, int *stat_loc)
int _open_r(void *ptr, const char *path, int oflag, int mode)
int _gettimeofday_r(void *ptr, struct timeval *ptimeval, void *ptimezone)
int _stat_r(void *ptr, const char *path, struct stat *buf)
clock_t _times_r(void *ptr, struct tms *buf)
ssize_t _read_r(void *ptr, int fildes, void *buf, size_t nbyte)
int _execve_r(void *ptr, const char *path, char *const argv[], char *const envp[])
ssize_t _write_r(void *ptr, int fildes, const void *buf, size_t nbyte)
pid_t _getpid_r(void *ptr)
int _fstat_r(void *ptr, int fildes, struct stat *buf)
int _close_r(void *ptr, int fildes)
int _kill_r(void *ptr, pid_t pid, int sig)
int _link_r(void *ptr, const char *existing, const char *_new)
int _rename_r(void *ptr, const char *oldfn, const char *newfn)
int _mkdir_r(void *ptr, const char *path, mode_t mode)
int _fcntl_r(void *ptr, int fildes, int cmd, int arg)
int stat(const char *path, struct stat *buf)
#define __posix_wait
#define __posix_kill
#define __posix_lseek
#define __posix_fstat
#define __posix_stat
#define __posix_close
#define __posix_link
#define __posix_read
#define __posix_fcntl
#define __posix_gettimeofday
#define __posix_times
#define __posix_write
#define __posix_open
#define __posix_mkdir
#define __posix_rename
#define __posix_isatty
#define __posix_unlink
#define __posix_getpid
#define __posix_fork
#define __posix_execve