µ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-posix.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(OS_USE_OS_APP_CONFIG_H)
14#include <cmsis-plus/os-app-config.h>
15#endif
16
17#if !defined(OS_USE_SEMIHOSTING_SYSCALLS)
18
19#include <cmsis-plus/rtos/os.h>
30
32
34
35#include <cstdarg>
36#include <cerrno>
37
38// ----------------------------------------------------------------------------
39
40#if defined(__clang__)
41#pragma clang diagnostic ignored "-Wc++98-compat"
42#endif
43
44// ----------------------------------------------------------------------------
45
46// Notes: Function prefix.
47//
48// To facilitate testing on POSIX platforms, and also to allow
49// integration on custom platforms, all function names are prefixed
50// with '__posix_'.
51// For embedded environments it is possible to also add aliases to the
52// standard, non-prefixed names, by adding the following preprocessor
53// definition: OS_INCLUDE_STANDARD_POSIX_FUNCTIONS
54
55// Notes: Reentrancy and 'errno'.
56//
57// The standard headers define errno as '*(__errno())';
58// If you use a multi-threaded environment, be sure you
59// redefine __errno() to return a thread specific pointer.
60
61// ----------------------------------------------------------------------------
62
63extern "C"
64{
65 void
67}
68
69// ----------------------------------------------------------------------------
70// ---- POSIX IO functions ----------------------------------------------------
71
72using namespace os;
73
74// ----------------------------------------------------------------------------
75
85int
86__posix_open (const char* path, int oflag, ...)
87{
88 va_list args;
89 va_start(args, oflag);
90 auto* const io = posix::vopen (path, oflag, args);
91 va_end(args);
92
93 if (io == nullptr)
94 {
95 // Return POSIX style error indicator.
96 return -1;
97 }
98
99 // Return non-negative POSIX file descriptor.
100 return io->file_descriptor ();
101}
102
103int
104__posix_close (int fildes)
105{
106 // The flow is identical for all POSIX functions: identify the C++
107 // object and call the corresponding C++ method.
108 auto* const io = posix::file_descriptors_manager::io (fildes);
109 if (io == nullptr)
110 {
111 errno = EBADF;
112 return -1;
113 }
114 return io->close ();
115}
116
117// ----------------------------------------------------------------------------
118
119ssize_t
120__posix_read (int fildes, void* buf, size_t nbyte)
121{
122 auto* const io = posix::file_descriptors_manager::io (fildes);
123 if (io == nullptr)
124 {
125 // STDIN
126 if (fildes == 0)
127 {
128 return 0; // Default empty input (EOF).
129 }
130 errno = EBADF;
131 return -1;
132 }
133 return io->read (buf, nbyte);
134}
135
136ssize_t
137__posix_write (int fildes, const void* buf, size_t nbyte)
138{
139 auto* const io = posix::file_descriptors_manager::io (fildes);
140 if (io == nullptr)
141 {
142 // STDOUT & STDERR
143 if (fildes == 1 || fildes == 2)
144 {
145 return trace_write (buf, nbyte); // Default output on trace.
146 }
147 errno = EBADF;
148 return -1;
149 }
150 return io->write (buf, nbyte);
151}
152
153ssize_t
154__posix_writev (int fildes, const /* struct */ iovec* iov, int iovcnt)
155{
156 auto* const io = posix::file_descriptors_manager::io (fildes);
157 if (io == nullptr)
158 {
159 errno = EBADF;
160 return -1;
161 }
162 return io->writev (iov, iovcnt);
163}
164
165int
166__posix_ioctl (int fildes, int request, ...)
167{
168 auto* const io = posix::file_descriptors_manager::io (fildes);
169 if (io == nullptr)
170 {
171 errno = EBADF;
172 return -1;
173 }
174
175 // Works only on STREAMS (CherDevices, in this implementation)
176 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::char_device)) == 0)
177 {
178 errno = ENOTTY; // Not a stream.
179 return -1;
180 }
181
182 va_list args;
183 va_start(args, request);
184 int ret = (static_cast<posix::char_device*> (io))->vioctl (request, args);
185 va_end(args);
186
187 return ret;
188}
189
190off_t
191__posix_lseek (int fildes, off_t offset, int whence)
192{
193 auto* const io = posix::file_descriptors_manager::io (fildes);
194 if (io == nullptr)
195 {
196 errno = EBADF; // Fildes is not an open file descriptor.
197 return -1;
198 }
199
200 // Works only on files (Does not work on sockets, pipes or FIFOs...)
201 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::file)) == 0)
202 {
203 errno = ESPIPE; // Not a file.
204 return -1;
205 }
206
207 return (static_cast<posix::file*> (io))->lseek (offset, whence);
208}
209
215int
216__posix_isatty (int fildes)
217{
218 auto* const io = posix::file_descriptors_manager::io (fildes);
219 if (io == nullptr)
220 {
221 if (fildes <= 2)
222 {
223 return true; // Default TTY for STDIN/OUT/ERR.
224 }
225 errno = EBADF;
226 return -1;
227 }
228 return io->isatty ();
229}
230
231int
232__posix_tcdrain (int fildes)
233{
234 auto* const io = posix::file_descriptors_manager::io (fildes);
235 if (io == nullptr)
236 {
237 errno = EBADF; // Fildes is not an open file descriptor.
238 return -1;
239 }
240
241 // Works only on tty...)
242 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::tty)) == 0)
243 {
244 errno = ESPIPE; // Not a tty.
245 return -1;
246 }
247
248 return (static_cast<posix::tty*> (io))->tcdrain ();
249}
250
251int
252__posix_tcgetattr (int fildes, /* struct */ termios *termios_p)
253{
254 auto* const io = posix::file_descriptors_manager::io (fildes);
255 if (io == nullptr)
256 {
257 errno = EBADF; // Fildes is not an open file descriptor.
258 return -1;
259 }
260
261 // Works only on tty...)
262 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::tty)) == 0)
263 {
264 errno = ESPIPE; // Not a tty.
265 return -1;
266 }
267
268 return (static_cast<posix::tty*> (io))->tcgetattr (termios_p);
269}
270
271int
272__posix_tcsetattr (int fildes, int optional_actions,
273 const /* struct */ termios *termios_p)
274{
275 auto* const io = posix::file_descriptors_manager::io (fildes);
276 if (io == nullptr)
277 {
278 errno = EBADF; // Fildes is not an open file descriptor.
279 return -1;
280 }
281
282 // Works only on tty...)
283 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::tty)) == 0)
284 {
285 errno = ESPIPE; // Not a tty.
286 return -1;
287 }
288
289 return (static_cast<posix::tty*> (io))->tcsetattr (optional_actions,
290 termios_p);
291}
292
293int
294__posix_tcflush (int fildes, int queue_selector)
295{
296 auto* const io = posix::file_descriptors_manager::io (fildes);
297 if (io == nullptr)
298 {
299 errno = EBADF; // Fildes is not an open file descriptor.
300 return -1;
301 }
302
303 // Works only on tty...)
304 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::tty)) == 0)
305 {
306 errno = ESPIPE; // Not a tty.
307 return -1;
308 }
309
310 return (static_cast<posix::tty*> (io))->tcflush (queue_selector);
311}
312
313int
314__posix_tcsendbreak (int fildes, int duration)
315{
316 auto* const io = posix::file_descriptors_manager::io (fildes);
317 if (io == nullptr)
318 {
319 errno = EBADF; // Fildes is not an open file descriptor.
320 return -1;
321 }
322
323 // Works only on tty...)
324 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::tty)) == 0)
325 {
326 errno = ESPIPE; // Not a tty.
327 return -1;
328 }
329
330 return (static_cast<posix::tty*> (io))->tcsendbreak (duration);
331}
332
333int
334__posix_fcntl (int fildes, int cmd, ...)
335{
336 auto* const io = posix::file_descriptors_manager::io (fildes);
337 if (io == nullptr)
338 {
339 errno = EBADF;
340 return -1;
341 }
342
343 va_list args;
344 va_start(args, cmd);
345 int ret = io->vfcntl (cmd, args);
346 va_end(args);
347
348 return ret;
349}
350
351int
352__posix_fstat (int fildes, struct stat* buf)
353{
354 auto* const io = posix::file_descriptors_manager::io (fildes);
355 if (io == nullptr)
356 {
357 errno = EBADF;
358 return -1;
359 }
360 return io->fstat (buf);
361}
362
363int
364__posix_fstatvfs (int fildes, struct statvfs* buf)
365{
366 auto* const io = posix::file_descriptors_manager::io (fildes);
367 if (io == nullptr)
368 {
369 errno = EBADF;
370 return -1;
371 }
372
373 // Works only on files (Does not work on sockets, pipes or FIFOs...)
374 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::file)) == 0)
375 {
376 errno = EINVAL; // Not a file.
377 return -1;
378 }
379
380 return (static_cast<posix::file*> (io))->fstatvfs (buf);
381}
382
383int
384__posix_ftruncate (int fildes, off_t length)
385{
386 auto* const io = posix::file_descriptors_manager::io (fildes);
387 if (io == nullptr)
388 {
389 errno = EBADF;
390 return -1;
391 }
392
393 // Works only on files (Does not work on sockets, pipes or FIFOs...)
394 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::file)) == 0)
395 {
396 errno = EINVAL; // Not a file.
397 return -1;
398 }
399
400 return (static_cast<posix::file*> (io))->ftruncate (length);
401}
402
403int
404__posix_fsync (int fildes)
405{
406 auto* const io = posix::file_descriptors_manager::io (fildes);
407 if (io == nullptr)
408 {
409 errno = EBADF;
410 return -1;
411 }
412
413 // Works only on files (Does not work on sockets, pipes or FIFOs...)
414 if ((io->get_type () & static_cast<posix::io::type_t>(posix::io::type::file)) == 0)
415 {
416 errno = EINVAL; // Not a file.
417 return -1;
418 }
419
420 return (static_cast<posix::file*> (io))->fsync ();
421}
422
423// ----------------------------------------------------------------------------
424// ----- POSIX file functions -----
425
426int
427__posix_chmod (const char* path, mode_t mode)
428{
429 return posix::chmod (path, mode);
430}
431
432int
433__posix_stat (const char* path, struct stat* buf)
434{
435 return posix::stat (path, buf);
436}
437
438int
439__posix_truncate (const char* path, off_t length)
440{
441 return posix::truncate (path, length);
442}
443
444int
445__posix_rename (const char* existing, const char* _new)
446{
447 return posix::rename (existing, _new);
448}
449
450int
451__posix_unlink (const char* path)
452{
453 return posix::unlink (path);
454}
455
456int
457__posix_utime (const char* path, const /* struct */ utimbuf* times)
458{
459 return posix::utime (path, times);
460}
461
462int
463__posix_statvfs (const char* path, struct statvfs* buf)
464{
465 return posix::statvfs (path, buf);
466}
467
468// ----------------------------------------------------------------------------
469// ----- POSIX file_system functions -----
470
471int
472__posix_mkdir (const char* path, mode_t mode)
473{
474 return posix::mkdir (path, mode);
475}
476
477int
478__posix_rmdir (const char* path)
479{
480 return posix::rmdir (path);
481}
482
483void
485{
486 return posix::sync ();
487}
488
489// ----------------------------------------------------------------------------
490// ----- Directories functions -----
491
492DIR*
493__posix_opendir (const char* dirpath)
494{
495 return reinterpret_cast<DIR*> (posix::opendir (dirpath));
496}
497
498/* struct */ dirent*
500{
501#pragma GCC diagnostic push
502#pragma GCC diagnostic ignored "-Wcast-align"
503 auto* const dir = reinterpret_cast<posix::directory*> (dirp);
504#pragma GCC diagnostic pop
505 if (dir == nullptr)
506 {
507 errno = ENOENT;
508 return nullptr;
509 }
510 return dir->read ();
511}
512
513#if 0
514int
515__posix_readdir_r (DIR* dirp, struct dirent* entry, struct dirent** result)
516 {
517 errno = ENOSYS; // Not implemented
518 return ((ssize_t) -1);
519 }
520#endif
521
522void
524{
525#pragma GCC diagnostic push
526#pragma GCC diagnostic ignored "-Wcast-align"
527 auto* const dir = reinterpret_cast<posix::directory*> (dirp);
528#pragma GCC diagnostic pop
529 if (dir == nullptr)
530 {
531 errno = ENOENT;
532 return;
533 }
534 return dir->rewind ();
535}
536
537int
539{
540#pragma GCC diagnostic push
541#pragma GCC diagnostic ignored "-Wcast-align"
542 auto* const dir = reinterpret_cast<posix::directory*> (dirp);
543#pragma GCC diagnostic pop
544 if (dir == nullptr)
545 {
546 errno = ENOENT;
547 return -1;
548 }
549 return dir->close ();
550}
551
552// ----------------------------------------------------------------------------
553// Socket functions
554
555#pragma GCC diagnostic push
556#if defined(__clang__)
557#elif defined(__GNUC__)
558#pragma GCC diagnostic ignored "-Wunused-parameter"
559#endif
560
561// socket() and socketpair() are the fuctions creating sockets.
562// The other are socket specific functions.
563
564// In addition, the following IO functions should work on sockets:
565// close(), read(), write(), writev(), ioctl(), fcntl(), select().
566
567int
568__posix_socket (int domain, int type, int protocol)
569{
570 auto* const sock = posix::socket (domain, type, protocol);
571 if (sock == nullptr)
572 {
573 errno = EBADF;
574 return -1;
575 }
576 return sock->file_descriptor ();
577}
578
579#if 0
580int
581__posix_socketpair (int domain, int type, int protocol, int socket_vector[2])
582 {
583 errno = ENOSYS; // Not implemented
584 return -1;
585 }
586#endif
587
588int
589__posix_accept (int socket, /* struct */ sockaddr* address, socklen_t* address_len)
590{
592 if (io == nullptr)
593 {
594 errno = EBADF;
595 return -1;
596 }
597 auto* const new_socket = io->accept (address, address_len);
598 return new_socket->file_descriptor ();
599}
600
601int
602__posix_bind (int socket, const /* struct */ sockaddr* address, socklen_t address_len)
603{
605 if (io == nullptr)
606 {
607 errno = EBADF;
608 return -1;
609 }
610 return io->bind (address, address_len);
611}
612
613int
614__posix_connect (int socket, const /* struct */ sockaddr* address,
615 socklen_t address_len)
616{
618 if (io == nullptr)
619 {
620 errno = EBADF;
621 return -1;
622 }
623 return io->connect (address, address_len);
624}
625
626int
627__posix_getpeername (int socket, /* struct */ sockaddr* address,
628 socklen_t* address_len)
629{
631 if (io == nullptr)
632 {
633 errno = EBADF;
634 return -1;
635 }
636 return io->getpeername (address, address_len);
637}
638
639int
640__posix_getsockname (int socket, /* struct */ sockaddr* address,
641 socklen_t* address_len)
642{
644 if (io == nullptr)
645 {
646 errno = EBADF;
647 return -1;
648 }
649 return io->getsockname (address, address_len);
650}
651
652int
653__posix_getsockopt (int socket, int level, int option_name, void* option_value,
654 socklen_t* option_len)
655{
657 if (io == nullptr)
658 {
659 errno = EBADF;
660 return -1;
661 }
662 return io->getsockopt (level, option_name, option_value, option_len);
663}
664
665int
666__posix_listen (int socket, int backlog)
667{
669 if (io == nullptr)
670 {
671 errno = EBADF;
672 return -1;
673 }
674 return io->listen (backlog);
675}
676
677ssize_t
678__posix_recv (int socket, void* buffer, size_t length, int flags)
679{
681 if (io == nullptr)
682 {
683 errno = EBADF;
684 return -1;
685 }
686 return io->recv (buffer, length, flags);
687}
688
689ssize_t
690__posix_recvfrom (int socket, void* buffer, size_t length, int flags,
691 /* struct */ sockaddr* address, socklen_t* address_len)
692{
694 if (io == nullptr)
695 {
696 errno = EBADF;
697 return -1;
698 }
699 return io->recvfrom (buffer, length, flags, address, address_len);
700}
701
702ssize_t
703__posix_recvmsg (int socket, /* struct */ msghdr* message, int flags)
704{
706 if (io == nullptr)
707 {
708 errno = EBADF;
709 return -1;
710 }
711 return io->recvmsg (message, flags);
712}
713
714ssize_t
715__posix_send (int socket, const void* buffer, size_t length, int flags)
716{
718 if (io == nullptr)
719 {
720 errno = EBADF;
721 return -1;
722 }
723 return io->send (buffer, length, flags);
724}
725
726ssize_t
727__posix_sendmsg (int socket, const /* struct */ msghdr* message, int flags)
728{
730 if (io == nullptr)
731 {
732 errno = EBADF;
733 return -1;
734 }
735 return io->sendmsg (message, flags);
736}
737
738ssize_t
739__posix_sendto (int socket, const void* message, size_t length, int flags,
740 const /* struct */ sockaddr* dest_addr, socklen_t dest_len)
741{
743 if (io == nullptr)
744 {
745 errno = EBADF;
746 return -1;
747 }
748 return io->sendto (message, length, flags, dest_addr, dest_len);
749}
750
751int
752__posix_setsockopt (int socket, int level, int option_name,
753 const void* option_value, socklen_t option_len)
754{
756 if (io == nullptr)
757 {
758 errno = EBADF;
759 return -1;
760 }
761 return io->setsockopt (level, option_name, option_value, option_len);
762}
763
764int
766{
768 if (io == nullptr)
769 {
770 errno = EBADF;
771 return -1;
772 }
773 return io->shutdown (how);
774}
775
776int
778{
780 if (io == nullptr)
781 {
782 errno = EBADF;
783 return -1;
784 }
785 return io->sockatmark ();
786}
787
788#pragma GCC diagnostic pop
789
790// ----------------------------------------------------------------------------
791
792// These functions are defined here to avoid linker errors in free
793// standing applications. They might be called in some error cases
794// from library code.
795//
796// If you detect other functions needed, just let us know
797// and we'll add them.
798
799// ----------------------------------------------------------------------------
800
801#pragma GCC diagnostic push
802#if defined(__clang__)
803#pragma clang diagnostic ignored "-Wunused-parameter"
804#elif defined(__GNUC__)
805#pragma GCC diagnostic ignored "-Wunused-parameter"
806#endif
807
808// ----------------------------------------------------------------------------
809// Not yet implemented.
810
811int __attribute__((weak))
812__posix_readdir_r (DIR* dirp, /* struct */ dirent* entry, /* struct */ dirent** result)
813{
814 errno = ENOSYS; // Not implemented
815 return -1;
816}
817
818int __attribute__((weak))
819__posix_socketpair (int domain, int type, int protocol, int socket_vector[2])
820{
821 errno = ENOSYS; // Not implemented
822 return -1;
823}
824
825int
826__posix_gettimeofday (/* struct */ timeval* ptimeval, void* ptimezone)
827{
828 ptimeval->tv_sec = static_cast<time_t> (os::rtos::rtclock.now ());
829 ptimeval->tv_usec = 0;
830
831 return 0;
832}
833
834int
835__posix_select (int nfds, fd_set* readfds, fd_set* writefds, fd_set* errorfds,
836 /* struct */ timeval* timeout)
837{
838 errno = ENOSYS; // Not implemented
839 return -1;
840}
841
842clock_t
843__posix_times (/* struct */ tms* buf)
844{
845 errno = ENOSYS; // Not implemented
846 return static_cast<clock_t> (-1);
847}
848
849int
850__posix_chdir (const char* path)
851{
852 errno = ENOSYS; // Not implemented
853 return -1;
854}
855
856char*
857__posix_getcwd (char* buf, size_t size)
858{
859 errno = ENOSYS; // Not implemented
860 return nullptr;
861}
862
863// ----------------------------------------------------------------------------
864// Unavailable in non-Unix embedded environments.
865
866clock_t
868{
869 errno = ENOSYS; // Not implemented
870 return static_cast<clock_t> (-1);
871}
872
873int
874__posix_execve (const char* path, char* const argv[], char* const envp[])
875{
876 errno = ENOSYS; // Not implemented
877 return -1;
878}
879
880pid_t
882{
883 errno = ENOSYS; // Not implemented
884
885#pragma GCC diagnostic push
886#if defined(__clang__)
887#elif defined(__GNUC__)
888#pragma GCC diagnostic ignored "-Wuseless-cast"
889#endif
890
891 return static_cast<pid_t> (-1);
892
893#pragma GCC diagnostic push
894}
895
896pid_t
898{
899 errno = ENOSYS; // Not implemented
900
901#pragma GCC diagnostic push
902#if defined(__clang__)
903#elif defined(__GNUC__)
904#pragma GCC diagnostic ignored "-Wuseless-cast"
905#endif
906
907 return static_cast<pid_t> (-1);
908
909#pragma GCC diagnostic pop
910}
911
912int
913__posix_kill (pid_t pid, int sig)
914{
915 errno = ENOSYS; // Not implemented
916 return -1;
917}
918
919int
921{
922 errno = ENOSYS; // Not implemented
923 return -1;
924}
925
926int
927__posix_system (const char *command)
928{
929 errno = ENOSYS; // Not implemented
930 return -1;
931}
932
933pid_t
934__posix_wait (int* stat_loc)
935{
936 errno = ENOSYS; // Not implemented
937
938#pragma GCC diagnostic push
939#if defined(__clang__)
940#elif defined(__GNUC__)
941#pragma GCC diagnostic ignored "-Wuseless-cast"
942#endif
943
944 return static_cast<pid_t> (-1);
945
946#pragma GCC diagnostic pop
947}
948
949int
950__posix_chown (const char* path, uid_t owner, gid_t group)
951{
952 errno = ENOSYS; // Not implemented
953 return -1;
954}
955
956int
957__posix_link (const char* existing, const char* _new)
958{
959 errno = ENOSYS; // Not implemented
960 return -1;
961}
962
963int
964__posix_symlink (const char* existing, const char* _new)
965{
966 errno = ENOSYS; // Not implemented
967 return -1;
968}
969
970ssize_t
971__posix_readlink (const char* path, char* buf, size_t bufsize)
972{
973 errno = ENOSYS; // Not implemented
974 return static_cast<ssize_t> (-1);
975}
976
977#pragma GCC diagnostic pop
978
979// `initialise_monitor_handles()` is a newlib libgloss function used to prepare
980// the stdio files when using semihosting. Better keep the name the same.
981
982void
984{
985 // Default STDIN, STDOUT, STDERR not required, the __posix_write()
986 // implementation defaults STDOUT/ERR to trace_write().
987}
988
989// ----------------------------------------------------------------------------
990
991#if defined(__ARM_EABI__) && (__STDC_HOSTED__ != 0)
992
993// The aliases must be in the same compilation unit as the names
994// they alias.
995
996#if defined(OS_INCLUDE_NEWLIB_POSIX_FUNCTIONS)
997
998// For special embedded environment that use POSIX system calls
999// with the newlib reentrant code, redefine
1000// some functions with _name(), others directly with name().
1001
1003
1004#else
1005
1006// For regular embedded environment that use POSIX system calls,
1007// redefine **all** functions without the '__posix_' prefix.
1008
1010
1011#endif
1012
1013#endif /* defined(__ARM_EABI__) && (__STDC_HOSTED__ != 0) */
1014
1015#endif /* !defined(OS_USE_SEMIHOSTING_SYSCALLS) */
1016
1017// ----------------------------------------------------------------------------
1018
int __posix_statvfs(const char *path, struct statvfs *buf)
void __posix_sync(void)
pid_t __posix_getpid(void)
int __posix_tcsetattr(int fildes, int optional_actions, const termios *termios_p)
pid_t __posix_fork(void)
clock_t __posix_clock(void)
int __posix_tcflush(int fildes, int queue_selector)
int __posix_fstatvfs(int fildes, struct statvfs *buf)
int __posix_tcdrain(int fildes)
void initialise_monitor_handles(void)
int __posix_tcgetattr(int fildes, termios *termios_p)
int __posix_tcsendbreak(int fildes, int duration)
Char device class.
Definition char-device.h:53
Directory class.
Definition directory.h:76
virtual int close(void)
Definition directory.cpp:86
virtual dirent * read(void)
Definition directory.cpp:52
virtual void rewind(void)
Definition directory.cpp:70
static class socket * socket(int fildes)
File class.
Definition file.h:65
unsigned int type_t
Definition io.h:127
Network socket.
virtual timestamp_t now(void) override
Tell the current time adjusted for epoch.
int stat(const char *path, struct stat *buf)
clock_t times(struct tms *buf)
int socket(int domain, int type, int protocol)
int utime(const char *path, const utimbuf *times)
int unlink(const char *path)
io * vopen(const char *path, int oflag, std::va_list args)
Definition io.cpp:67
int rmdir(const char *path)
int statvfs(const char *path, struct statvfs *buf)
int rename(const char *existing, const char *_new)
int stat(const char *path, struct stat *buf)
int chmod(const char *path, mode_t mode)
int truncate(const char *path, off_t length)
void sync(void)
directory * opendir(const char *dirname)
Open directory.
int mkdir(const char *path, mode_t mode)
clock_rtc rtclock
The real time clock object instance.
System namespace.
Single file µOS++ RTOS definitions.
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_stat
#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_gettimeofday
#define __posix_ioctl
#define __posix_setsockopt
#define __posix_socketpair
#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_accept
#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_execve
#define __posix_sendmsg
Definition dirent.h:57
Definition uio.h:41
ssize_t trace_write(const void *buf, size_t nbyte)