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