µ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-2023 Liviu Ionescu. All rights reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software
7 * for any purpose is hereby granted, under the terms of the MIT license.
8 *
9 * If a copy of the license was not distributed with this file, it can
10 * be obtained from https://opensource.org/licenses/mit/.
11 */
12
13#if defined(__clang__)
14#pragma clang diagnostic ignored "-Wempty-translation-unit"
15#endif
16
17// ----------------------------------------------------------------------------
18
19#if defined(__ARM_EABI__)
20
21// ----------------------------------------------------------------------------
22
24
25// ----------------------------------------------------------------------------
26
27extern "C"
28{
29
30 // Many newlib functions call the reentrant versions right away,
31 // and these call the _name() implementations. To avoid this, the
32 // shortcut is to simply skip the reentrant code (ignore the pointer)
33 // and directly call the posix implementation.
34
35#pragma GCC diagnostic push
36#if defined(__clang__)
37#elif defined(__GNUC__)
38#pragma GCC diagnostic ignored "-Wmissing-declarations"
39#pragma GCC diagnostic ignored "-Wunused-parameter"
40#endif
41
42 int __attribute__((weak))
43 _close_r (void* ptr, int fildes)
44 {
45 return __posix_close (fildes);
46 }
47
48 int __attribute__((weak))
49 _execve_r (void* ptr, const char* path, char* const argv[],
50 char* const envp[])
51 {
52 return __posix_execve (path, argv, envp);
53 }
54
55 int __attribute__((weak))
56 _fcntl_r (void* ptr, int fildes, int cmd, int arg)
57 {
58 return __posix_fcntl (fildes, cmd, arg);
59 }
60
61 pid_t __attribute__((weak))
62 _fork_r (void* ptr)
63 {
64 return __posix_fork ();
65 }
66
67#pragma GCC diagnostic push
68#if defined(__clang__)
69#elif defined(__GNUC__)
70#pragma GCC diagnostic ignored "-Wredundant-tags"
71#endif
72 int __attribute__((weak))
73 _fstat_r (void* ptr, int fildes, struct stat* buf)
74 {
75 return __posix_fstat (fildes, buf);
76 }
77#pragma GCC diagnostic pop
78
79 pid_t __attribute__((weak))
80 _getpid_r (void* ptr)
81 {
82 return __posix_getpid ();
83 }
84
85 int __attribute__((weak))
86 _gettimeofday_r (void* ptr, /* struct */ timeval* ptimeval, void* ptimezone)
87 {
88 return __posix_gettimeofday (ptimeval, ptimezone);
89 }
90
91 int __attribute__((weak))
92 _isatty_r (void* ptr, int fildes)
93 {
94 return __posix_isatty (fildes);
95 }
96
97 int __attribute__((weak))
98 _kill_r (void* ptr, pid_t pid, int sig)
99 {
100 return __posix_kill (pid, sig);
101 }
102
103 int __attribute__((weak))
104 _link_r (void* ptr, const char* existing, const char* _new)
105 {
106 return __posix_link (existing, _new);
107 }
108
109 off_t __attribute__((weak))
110 _lseek_r (void* ptr, int fildes, off_t offset, int whence)
111 {
112 return __posix_lseek (fildes, offset, whence);
113 }
114
115 int __attribute__((weak))
116 _mkdir_r (void* ptr, const char* path, mode_t mode)
117 {
118 return __posix_mkdir (path, mode);
119 }
120
121 int __attribute__((weak))
122 _open_r (void* ptr, const char* path, int oflag, int mode)
123 {
124 return __posix_open (path, oflag, mode);
125 }
126
127 ssize_t __attribute__((weak))
128 _read_r (void* ptr, int fildes, void* buf, size_t nbyte)
129 {
130 return __posix_read (fildes, buf, nbyte);
131 }
132
133 int __attribute__((weak))
134 _rename_r (void* ptr, const char* oldfn, const char* newfn)
135 {
136 return __posix_rename (oldfn, newfn);
137 }
138
139#pragma GCC diagnostic push
140#if defined(__clang__)
141#elif defined(__GNUC__)
142#pragma GCC diagnostic ignored "-Wredundant-tags"
143#endif
144 int __attribute__((weak))
145 _stat_r (void* ptr, const char* path, struct stat* buf)
146 {
147 return __posix_stat (path, buf);
148 }
149#pragma GCC diagnostic pop
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)
clock_t _times_r(void *ptr, tms *buf)
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 _stat_r(void *ptr, const char *path, struct stat *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 _gettimeofday_r(void *ptr, timeval *ptimeval, void *ptimezone)
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