µ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-syscalls-aliases-newlib.h
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#ifndef CMSIS_PLUS_POSIX_IO_C_POSIX_SYSCALLS_ALIASES_NEWLIB_H_
14#define CMSIS_PLUS_POSIX_IO_C_POSIX_SYSCALLS_ALIASES_NEWLIB_H_
15
16// ----------------------------------------------------------------------------
17
18#ifdef __cplusplus
19extern "C"
20{
21#endif
22
23 // --------------------------------------------------------------------------
24
29 // For embedded environment that use POSIX system calls, redefine
30 // some functions with _name(), some directly with name().
31 int __attribute__((weak, alias ("__posix_accept")))
32 accept (int socket, struct sockaddr* address, socklen_t* address_len);
33
34 int __attribute__((weak, alias ("__posix_bind")))
35 bind (int socket, const struct sockaddr* address, socklen_t address_len);
36
37 int __attribute__((weak, alias ("__posix_chdir")))
38 chdir (const char* path);
39
40 int __attribute__((weak, alias ("__posix_chmod")))
41 chmod (const char* path, mode_t mode);
42
43 int __attribute__((weak, alias ("__posix_chown")))
44 _chown (const char* path, uid_t owner, gid_t group);
45
46 clock_t __attribute__((weak, alias ("__posix_clock")))
47 _clock (void);
48
49 int __attribute__((weak, alias ("__posix_close")))
50 _close (int fildes);
51
52 int __attribute__((weak, alias ("__posix_closedir")))
53 closedir (DIR* dirp);
54
55 int __attribute__((weak, alias ("__posix_connect")))
56 connect (int socket, const struct sockaddr* address, socklen_t address_len);
57
58 int __attribute__((weak, alias ("__posix_execve")))
59 _execve (const char* path, char* const argv[], char* const envp[]);
60
61 int __attribute__((weak, alias ("__posix_fcntl")))
62 fcntl (int fildes, int cmd, ...);
63
64 pid_t __attribute__((weak, alias ("__posix_fork")))
65 _fork (void);
66
67 int __attribute__((weak, alias ("__posix_fstat")))
68 _fstat (int fildes, struct stat* buf);
69
70 int __attribute__((weak), alias ("__posix_fstatvfs"))
71 fstatvfs (int fildes, struct statvfs* buf);
72
73 int __attribute__((weak, alias ("__posix_ftruncate")))
74 ftruncate (int fildes, off_t length);
75
76 int __attribute__((weak, alias ("__posix_fsync")))
77 fsync (int fildes);
78
79 char*
80 __attribute__((weak, alias ("__posix_getcwd")))
81 getcwd (char* buf, size_t size);
82
83 int __attribute__((weak, alias ("__posix_getpeername")))
84 getpeername (int socket, struct sockaddr* address, socklen_t* address_len);
85
86 pid_t __attribute__((weak, alias ("__posix_getpid")))
87 _getpid (void);
88
89 int __attribute__((weak, alias ("__posix_getsockname")))
90 getsockname (int socket, struct sockaddr* address, socklen_t* address_len);
91
92 int __attribute__((weak, alias ("__posix_getsockopt")))
93 getsockopt (int socket, int level, int option_name, void* option_value,
94 socklen_t* option_len);
95
96 int __attribute__((weak, alias ("__posix_gettimeofday")))
97 _gettimeofday (struct timeval* ptimeval, void* ptimezone);
98
99 int __attribute__((weak, alias ("__posix_ioctl")))
100 ioctl (int fildes, int request, ...);
101
102 int __attribute__((weak, alias ("__posix_isatty")))
103 _isatty (int fildes);
104
105 int __attribute__((weak, alias ("__posix_kill")))
106 _kill (pid_t pid, int sig);
107
108 int __attribute__((weak, alias ("__posix_link")))
109 _link (const char* existing, const char* _new);
110
111 int __attribute__((weak, alias ("__posix_listen")))
112 listen (int socket, int backlog);
113
114 off_t __attribute__((weak, alias ("__posix_lseek")))
115 _lseek (int fildes, off_t offset, int whence);
116
117 int __attribute__((weak, alias ("__posix_mkdir")))
118 mkdir (const char* path, mode_t mode);
119
120 int __attribute__((weak, alias ("__posix_open")))
121 _open (const char* path, int oflag, ...);
122
123 DIR*
124 __attribute__((weak, alias ("__posix_opendir")))
125 opendir (const char* dirname);
126
127 int __attribute__((weak, alias ("__posix_raise")))
128 raise (int sig);
129
130 ssize_t __attribute__((weak, alias ("__posix_read")))
131 _read (int fildes, void* buf, size_t nbyte);
132
133 struct dirent*
134 __attribute__((weak, alias ("__posix_readdir")))
135 readdir (DIR* dirp);
136
137 int __attribute__((weak, alias ("__posix_readdir_r")))
138 readdir_r (DIR* dirp, struct dirent* entry, struct dirent** result);
139
140 ssize_t __attribute__((weak, alias ("__posix_readlink")))
141 _readlink (const char* path, char* buf, size_t bufsize);
142
143 ssize_t __attribute__((weak, alias ("__posix_recv")))
144 recv (int socket, void* buffer, size_t length, int flags);
145
146 ssize_t __attribute__((weak, alias ("__posix_recvfrom")))
147 recvfrom (int socket, void* buffer, size_t length, int flags,
148 struct sockaddr* address, socklen_t* address_len);
149
150 ssize_t __attribute__((weak, alias ("__posix_recvmsg")))
151 recvmsg (int socket, struct msghdr* message, int flags);
152
153 int __attribute__((weak, alias ("__posix_rename")))
154 rename (const char* oldfn, const char* newfn);
155
156 void __attribute__((weak, alias ("__posix_rewinddir")))
157 rewinddir (DIR* dirp);
158
159 int __attribute__((weak, alias ("__posix_rmdir")))
160 rmdir (const char* path);
161
162 int __attribute__((weak, alias ("__posix_select")))
163 select (int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds,
164 struct timeval* timeout);
165
166 ssize_t __attribute__((weak, alias ("__posix_send")))
167 send (int socket, const void* buffer, size_t length, int flags);
168
169 ssize_t __attribute__((weak, alias ("__posix_sendmsg")))
170 sendmsg (int socket, const struct msghdr* message, int flags);
171
172 ssize_t __attribute__((weak, alias ("__posix_sendto")))
173 sendto (int socket, const void* message, size_t length, int flags,
174 const struct sockaddr* dest_addr, socklen_t dest_len);
175
176 int __attribute__((weak, alias ("__posix_setsockopt")))
177 setsockopt (int socket, int level, int option_name, const void* option_value,
178 socklen_t option_len);
179
180 int __attribute__((weak, alias ("__posix_shutdown")))
181 shutdown (int socket, int how);
182
183 int __attribute__((weak, alias ("__posix_sockatmark")))
184 sockatmark (int socket);
185
186 int __attribute__((weak, alias ("__posix_socket")))
187 socket (int domain, int type, int protocol);
188
189#if 0
190 int __attribute__((weak, alias ("__posix_socketpair")))
191 socketpair (int domain, int type, int protocol, int socket_vector[2]);
192#endif
193
194 int __attribute__((weak, alias ("__posix_stat")))
195 _stat (const char* path, struct stat* buf);
196
197#pragma GCC diagnostic push
198#if defined(__clang__)
199#elif defined(__GNUC__)
200#pragma GCC diagnostic ignored "-Wshadow"
201#endif
202
203 int __attribute__((weak, alias ("__posix_statvfs")))
204 statvfs (const char* path, struct statvfs* buf);
205
206#pragma GCC diagnostic pop
207
208 void __attribute__((weak, alias ("__posix_sync")))
209 sync (void);
210
211 int __attribute__((weak, alias ("__posix_symlink")))
212 _symlink (const char* existing, const char* _new);
213
214 int __attribute__((weak, alias ("__posix_system")))
215 system (const char *command);
216
217 int __attribute__((weak, alias ("__posix_symlink")))
218 tcdrain (int fildes);
219
220 int __attribute__((weak, alias ("__posix_tcflush")))
221 tcflush (int fildes, int queue_selector);
222
223 int __attribute__((weak, alias ("__posix_tcgetattr")))
224 tcgetattr (int fildes, struct termios *termios_p);
225
226 int __attribute__((weak, alias ("__posix_tcsendbreak")))
227 tcsendbreak (int fildes, int duration);
228
229 int __attribute__((weak, alias ("__posix_tcsetattr")))
230 tcsetattr (int fildes, int optional_actions, const struct termios *termios_p);
231
232 clock_t __attribute__((weak, alias ("__posix_times")))
233 _times (struct tms* buf);
234
235 int __attribute__((weak, alias ("__posix_truncate")))
236 truncate (const char* path, off_t length);
237
238 int __attribute__((weak, alias ("__posix_unlink")))
239 _unlink (const char* name);
240
241 int __attribute__((weak, alias ("__posix_utime")))
242 utime (const char* path, const struct utimbuf* times);
243
244 pid_t __attribute__((weak, alias ("__posix_wait")))
245 _wait (int* stat_loc);
246
247 ssize_t __attribute__((weak, alias ("__posix_write")))
248 _write (int fildes, const void* buf, size_t nbyte);
249
250 ssize_t __attribute__((weak, alias ("__posix_writev")))
251 writev (int fildes, const struct iovec* iov, int iovcnt);
252
257// --------------------------------------------------------------------------
258#ifdef __cplusplus
259}
260#endif
261
262#endif /* CMSIS_PLUS_POSIX_IO_C_POSIX_SYSCALLS_ALIASES_NEWLIB_H_ */
263
264// ----------------------------------------------------------------------------
int shutdown(int socket, int how)
int chdir(const char *path)
int rename(const char *oldfn, const char *newfn)
int system(const char *command)
int tcdrain(int fildes)
int raise(int sig)
ssize_t recv(int socket, void *buffer, size_t length, int flags)
int tcsendbreak(int fildes, int duration)
int ioctl(int fildes, int request,...)
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
int accept(int socket, struct sockaddr *address, socklen_t *address_len)
int ftruncate(int fildes, off_t length)
ssize_t recvmsg(int socket, struct msghdr *message, int flags)
ssize_t sendmsg(int socket, const struct msghdr *message, int flags)
int stat(const char *path, struct stat *buf)
int sockatmark(int socket)
int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
int mkdir(const char *path, mode_t mode)
int bind(int socket, const struct sockaddr *address, socklen_t address_len)
int fsync(int fildes)
int tcsetattr(int fildes, int optional_actions, const struct termios *termios_p)
int tcgetattr(int fildes, struct termios *termios_p)
int getpeername(int socket, struct sockaddr *address, socklen_t *address_len)
clock_t times(struct tms *buf)
ssize_t send(int socket, const void *buffer, size_t length, int flags)
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout)
struct dirent * readdir(DIR *dirp)
int truncate(const char *path, off_t length)
int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len)
int closedir(DIR *dirp)
ssize_t sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len)
int listen(int socket, int backlog)
int rmdir(const char *path)
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt)
ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
int chmod(const char *path, mode_t mode)
void sync(void)
char * getcwd(char *buf, size_t size)
int fcntl(int fildes, int cmd,...)
int fstatvfs(int fildes, struct statvfs *buf)
void rewinddir(DIR *dirp)
DIR * opendir(const char *dirname)
int utime(const char *path, const struct utimbuf *times)
int tcflush(int fildes, int queue_selector)
int getsockname(int socket, struct sockaddr *address, socklen_t *address_len)
int connect(int socket, const struct sockaddr *address, socklen_t address_len)
int socket(int domain, int type, int protocol)
int socketpair(int domain, int type, int protocol, int socket_vector[2])
uint32_t socklen_t
#define __posix_select
#define __posix_sockatmark
#define __posix_wait
#define __posix_getsockopt
#define __posix_rewinddir
#define __posix_kill
#define __posix_lseek
#define __posix_chmod
#define __posix_chown
#define __posix_raise
#define __posix_shutdown
#define __posix_readlink
#define __posix_writev
#define __posix_truncate
#define __posix_fstat
#define __posix_recvfrom
#define __posix_getcwd
#define __posix_readdir_r
#define __posix_close
#define __posix_recv
#define __posix_link
#define __posix_read
#define __posix_fcntl
#define __posix_sendto
#define __posix_symlink
#define __posix_getsockname
#define __posix_clock
#define __posix_gettimeofday
#define __posix_ioctl
#define __posix_setsockopt
#define __posix_send
#define __posix_rmdir
#define __posix_times
#define __posix_readdir
#define __posix_closedir
#define __posix_write
#define __posix_listen
#define __posix_open
#define __posix_mkdir
#define __posix_rename
#define __posix_socket
#define __posix_isatty
#define __posix_unlink
#define __posix_recvmsg
#define __posix_ftruncate
#define __posix_getpid
#define __posix_utime
#define __posix_bind
#define __posix_opendir
#define __posix_fsync
#define __posix_connect
#define __posix_getpeername
#define __posix_system
#define __posix_chdir
#define __posix_fork
#define __posix_execve
#define __posix_sendmsg
Definition dirent.h:57
Definition uio.h:41
int __posix_tcgetattr(int fildes, struct termios *termios_p)
int __posix_tcflush(int fildes, int queue_selector)
int __posix_fstatvfs(int fildes, struct statvfs *buf)
int __posix_tcsetattr(int fildes, int optional_actions, const struct termios *termios_p)
int __posix_tcsendbreak(int fildes, int duration)