µ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 File Reference

Go to the source code of this file.

Functions

int __posix_accept (int socket, sockaddr *address, socklen_t *address_len)
 
int __posix_bind (int socket, const sockaddr *address, socklen_t address_len)
 
int __posix_chdir (const char *path)
 
int __posix_chmod (const char *path, mode_t mode)
 
int __posix_chown (const char *path, uid_t owner, gid_t group)
 
clock_t __posix_clock (void)
 
int __posix_close (int fildes)
 
int __posix_closedir (DIR *dirp)
 
int __posix_connect (int socket, const sockaddr *address, socklen_t address_len)
 
int __posix_execve (const char *path, char *const argv[], char *const envp[])
 
int __posix_fcntl (int fildes, int cmd,...)
 
pid_t __posix_fork (void)
 
int __posix_fstat (int fildes, struct stat *buf)
 
int __posix_fstatvfs (int fildes, struct statvfs *buf)
 
int __posix_fsync (int fildes)
 
int __posix_ftruncate (int fildes, off_t length)
 
char * __posix_getcwd (char *buf, size_t size)
 
int __posix_getpeername (int socket, sockaddr *address, socklen_t *address_len)
 
pid_t __posix_getpid (void)
 
int __posix_getsockname (int socket, sockaddr *address, socklen_t *address_len)
 
int __posix_getsockopt (int socket, int level, int option_name, void *option_value, socklen_t *option_len)
 
int __posix_gettimeofday (timeval *ptimeval, void *ptimezone)
 
int __posix_ioctl (int fildes, int request,...)
 
int __posix_isatty (int fildes)
 Test for a terminal device.
 
int __posix_kill (pid_t pid, int sig)
 
int __posix_link (const char *existing, const char *_new)
 
int __posix_listen (int socket, int backlog)
 
off_t __posix_lseek (int fildes, off_t offset, int whence)
 
int __posix_mkdir (const char *path, mode_t mode)
 
int __posix_open (const char *path, int oflag,...)
 Open file relative to directory file descriptor.
 
DIR__posix_opendir (const char *dirpath)
 
int __posix_raise (int sig)
 
ssize_t __posix_read (int fildes, void *buf, size_t nbyte)
 
dirent__posix_readdir (DIR *dirp)
 
int __posix_readdir_r (DIR *dirp, dirent *entry, dirent **result)
 
ssize_t __posix_readlink (const char *path, char *buf, size_t bufsize)
 
ssize_t __posix_recv (int socket, void *buffer, size_t length, int flags)
 
ssize_t __posix_recvfrom (int socket, void *buffer, size_t length, int flags, sockaddr *address, socklen_t *address_len)
 
ssize_t __posix_recvmsg (int socket, msghdr *message, int flags)
 
int __posix_rename (const char *existing, const char *_new)
 
void __posix_rewinddir (DIR *dirp)
 
int __posix_rmdir (const char *path)
 
int __posix_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, timeval *timeout)
 
ssize_t __posix_send (int socket, const void *buffer, size_t length, int flags)
 
ssize_t __posix_sendmsg (int socket, const msghdr *message, int flags)
 
ssize_t __posix_sendto (int socket, const void *message, size_t length, int flags, const sockaddr *dest_addr, socklen_t dest_len)
 
int __posix_setsockopt (int socket, int level, int option_name, const void *option_value, socklen_t option_len)
 
int __posix_shutdown (int socket, int how)
 
int __posix_sockatmark (int socket)
 
int __posix_socket (int domain, int type, int protocol)
 
int __posix_socketpair (int domain, int type, int protocol, int socket_vector[2])
 
int __posix_stat (const char *path, struct stat *buf)
 
int __posix_statvfs (const char *path, struct statvfs *buf)
 
int __posix_symlink (const char *existing, const char *_new)
 
void __posix_sync (void)
 
int __posix_system (const char *command)
 
int __posix_tcdrain (int fildes)
 
int __posix_tcflush (int fildes, int queue_selector)
 
int __posix_tcgetattr (int fildes, termios *termios_p)
 
int __posix_tcsendbreak (int fildes, int duration)
 
int __posix_tcsetattr (int fildes, int optional_actions, const termios *termios_p)
 
clock_t __posix_times (tms *buf)
 
int __posix_truncate (const char *path, off_t length)
 
int __posix_unlink (const char *path)
 
int __posix_utime (const char *path, const utimbuf *times)
 
pid_t __posix_wait (int *stat_loc)
 
ssize_t __posix_write (int fildes, const void *buf, size_t nbyte)
 
ssize_t __posix_writev (int fildes, const iovec *iov, int iovcnt)
 
void initialise_monitor_handles (void)
 

Function Documentation

◆ __posix_accept()

int __posix_accept ( int  socket,
sockaddr address,
socklen_t address_len 
)

Definition at line 603 of file c-syscalls-posix.cpp.

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}
static class socket * socket(int fildes)
int socket(int domain, int type, int protocol)

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_bind()

int __posix_bind ( int  socket,
const sockaddr address,
socklen_t  address_len 
)

Definition at line 617 of file c-syscalls-posix.cpp.

619{
621 if (io == nullptr)
622 {
623 errno = EBADF;
624 return -1;
625 }
626 return io->bind (address, address_len);
627}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_chdir()

int __posix_chdir ( const char *  path)

Definition at line 867 of file c-syscalls-posix.cpp.

868{
869 errno = ENOSYS; // Not implemented
870 return -1;
871}

◆ __posix_chmod()

int __posix_chmod ( const char *  path,
mode_t  mode 
)

Definition at line 441 of file c-syscalls-posix.cpp.

442{
443 return posix::chmod (path, mode);
444}
int chmod(const char *path, mode_t mode)

References os::posix::chmod().

◆ __posix_chown()

int __posix_chown ( const char *  path,
uid_t  owner,
gid_t  group 
)

Definition at line 967 of file c-syscalls-posix.cpp.

968{
969 errno = ENOSYS; // Not implemented
970 return -1;
971}

◆ __posix_clock()

clock_t __posix_clock ( void  )

Definition at line 884 of file c-syscalls-posix.cpp.

885{
886 errno = ENOSYS; // Not implemented
887 return static_cast<clock_t> (-1);
888}

◆ __posix_close()

int __posix_close ( int  fildes)

Definition at line 103 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_closedir()

int __posix_closedir ( DIR dirp)

Definition at line 552 of file c-syscalls-posix.cpp.

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}
Directory class.
Definition directory.h:75
virtual int close(void)
Definition directory.cpp:84

References os::posix::directory::close().

◆ __posix_connect()

int __posix_connect ( int  socket,
const sockaddr address,
socklen_t  address_len 
)

Definition at line 630 of file c-syscalls-posix.cpp.

632{
634 if (io == nullptr)
635 {
636 errno = EBADF;
637 return -1;
638 }
639 return io->connect (address, address_len);
640}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_execve()

int __posix_execve ( const char *  path,
char *const  argv[],
char *const  envp[] 
)

Definition at line 891 of file c-syscalls-posix.cpp.

892{
893 errno = ENOSYS; // Not implemented
894 return -1;
895}

◆ __posix_fcntl()

int __posix_fcntl ( int  fildes,
int  cmd,
  ... 
)

Definition at line 342 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_fork()

pid_t __posix_fork ( void  )

Definition at line 898 of file c-syscalls-posix.cpp.

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}

◆ __posix_fstat()

int __posix_fstat ( int  fildes,
struct stat buf 
)

Definition at line 360 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_fstatvfs()

int __posix_fstatvfs ( int  fildes,
struct statvfs buf 
)

Definition at line 372 of file c-syscalls-posix.cpp.

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}
File class.
Definition file.h:64
unsigned int type_t
Definition io.h:125

References os::posix::file_descriptors_manager::io().

◆ __posix_fsync()

int __posix_fsync ( int  fildes)

Definition at line 416 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_ftruncate()

int __posix_ftruncate ( int  fildes,
off_t  length 
)

Definition at line 394 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_getcwd()

char * __posix_getcwd ( char *  buf,
size_t  size 
)

Definition at line 874 of file c-syscalls-posix.cpp.

875{
876 errno = ENOSYS; // Not implemented
877 return nullptr;
878}

◆ __posix_getpeername()

int __posix_getpeername ( int  socket,
sockaddr address,
socklen_t address_len 
)

Definition at line 643 of file c-syscalls-posix.cpp.

645{
647 if (io == nullptr)
648 {
649 errno = EBADF;
650 return -1;
651 }
652 return io->getpeername (address, address_len);
653}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_getpid()

pid_t __posix_getpid ( void  )

Definition at line 914 of file c-syscalls-posix.cpp.

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}

◆ __posix_getsockname()

int __posix_getsockname ( int  socket,
sockaddr address,
socklen_t address_len 
)

Definition at line 656 of file c-syscalls-posix.cpp.

658{
660 if (io == nullptr)
661 {
662 errno = EBADF;
663 return -1;
664 }
665 return io->getsockname (address, address_len);
666}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_getsockopt()

int __posix_getsockopt ( int  socket,
int  level,
int  option_name,
void *  option_value,
socklen_t option_len 
)

Definition at line 669 of file c-syscalls-posix.cpp.

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}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_gettimeofday()

int __posix_gettimeofday ( timeval *  ptimeval,
void *  ptimezone 
)

Definition at line 843 of file c-syscalls-posix.cpp.

844{
845 ptimeval->tv_sec = static_cast<time_t> (os::rtos::rtclock.now ());
846 ptimeval->tv_usec = 0;
847
848 return 0;
849}
virtual timestamp_t now(void) override
Tell the current time adjusted for epoch.
clock_rtc rtclock
The real time clock object instance.

References os::rtos::adjustable_clock::now(), and os::rtos::rtclock.

◆ __posix_ioctl()

int __posix_ioctl ( int  fildes,
int  request,
  ... 
)

Definition at line 165 of file c-syscalls-posix.cpp.

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}
Char device class.
Definition char-device.h:52

References os::posix::file_descriptors_manager::io().

◆ __posix_isatty()

int __posix_isatty ( int  fildes)

This function shall test whether fildes, an open file descriptor, is associated with a terminal device.

Definition at line 219 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_kill()

int __posix_kill ( pid_t  pid,
int  sig 
)

Definition at line 930 of file c-syscalls-posix.cpp.

931{
932 errno = ENOSYS; // Not implemented
933 return -1;
934}

◆ __posix_link()

int __posix_link ( const char *  existing,
const char *  _new 
)

Definition at line 974 of file c-syscalls-posix.cpp.

975{
976 errno = ENOSYS; // Not implemented
977 return -1;
978}

◆ __posix_listen()

int __posix_listen ( int  socket,
int  backlog 
)

Definition at line 682 of file c-syscalls-posix.cpp.

683{
685 if (io == nullptr)
686 {
687 errno = EBADF;
688 return -1;
689 }
690 return io->listen (backlog);
691}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_lseek()

off_t __posix_lseek ( int  fildes,
off_t  offset,
int  whence 
)

Definition at line 192 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_mkdir()

int __posix_mkdir ( const char *  path,
mode_t  mode 
)

Definition at line 486 of file c-syscalls-posix.cpp.

487{
488 return posix::mkdir (path, mode);
489}
int mkdir(const char *path, mode_t mode)

References os::posix::mkdir().

◆ __posix_open()

int __posix_open ( const char *  path,
int  oflag,
  ... 
)

The open() function shall establish the connection between a file and a file descriptor. It shall create an open file description that refers to a file and a file descriptor that refers to that open file description. The file descriptor is used by other I/O functions to refer to that file. The path argument points to a pathname naming the file.

Definition at line 85 of file c-syscalls-posix.cpp.

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}
io * vopen(const char *path, int oflag, std::va_list args)
Definition io.cpp:66

References os::posix::vopen().

◆ __posix_opendir()

DIR * __posix_opendir ( const char *  dirpath)

Definition at line 507 of file c-syscalls-posix.cpp.

508{
509 return reinterpret_cast<DIR*> (posix::opendir (dirpath));
510}
directory * opendir(const char *dirname)
Open directory.
Definition dirent.h:56

References os::posix::opendir().

◆ __posix_raise()

int __posix_raise ( int  sig)

Definition at line 937 of file c-syscalls-posix.cpp.

938{
939 errno = ENOSYS; // Not implemented
940 return -1;
941}

◆ __posix_read()

ssize_t __posix_read ( int  fildes,
void *  buf,
size_t  nbyte 
)

Definition at line 119 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_readdir()

dirent * __posix_readdir ( DIR dirp)

Definition at line 513 of file c-syscalls-posix.cpp.

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}
virtual dirent * read(void)
Definition directory.cpp:50

References os::posix::directory::read().

◆ __posix_readdir_r()

int __posix_readdir_r ( DIR dirp,
dirent entry,
dirent **  result 
)

Definition at line 828 of file c-syscalls-posix.cpp.

830{
831 errno = ENOSYS; // Not implemented
832 return -1;
833}

◆ __posix_readlink()

ssize_t __posix_readlink ( const char *  path,
char *  buf,
size_t  bufsize 
)

Definition at line 988 of file c-syscalls-posix.cpp.

989{
990 errno = ENOSYS; // Not implemented
991 return static_cast<ssize_t> (-1);
992}

◆ __posix_recv()

ssize_t __posix_recv ( int  socket,
void *  buffer,
size_t  length,
int  flags 
)

Definition at line 694 of file c-syscalls-posix.cpp.

695{
697 if (io == nullptr)
698 {
699 errno = EBADF;
700 return -1;
701 }
702 return io->recv (buffer, length, flags);
703}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_recvfrom()

ssize_t __posix_recvfrom ( int  socket,
void *  buffer,
size_t  length,
int  flags,
sockaddr address,
socklen_t address_len 
)

Definition at line 706 of file c-syscalls-posix.cpp.

708{
710 if (io == nullptr)
711 {
712 errno = EBADF;
713 return -1;
714 }
715 return io->recvfrom (buffer, length, flags, address, address_len);
716}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_recvmsg()

ssize_t __posix_recvmsg ( int  socket,
msghdr *  message,
int  flags 
)

Definition at line 719 of file c-syscalls-posix.cpp.

720{
722 if (io == nullptr)
723 {
724 errno = EBADF;
725 return -1;
726 }
727 return io->recvmsg (message, flags);
728}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_rename()

int __posix_rename ( const char *  existing,
const char *  _new 
)

Definition at line 459 of file c-syscalls-posix.cpp.

460{
461 return posix::rename (existing, _new);
462}
int rename(const char *existing, const char *_new)

References os::posix::rename().

◆ __posix_rewinddir()

void __posix_rewinddir ( DIR dirp)

Definition at line 537 of file c-syscalls-posix.cpp.

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}
virtual void rewind(void)
Definition directory.cpp:68

References os::posix::directory::rewind().

◆ __posix_rmdir()

int __posix_rmdir ( const char *  path)

Definition at line 492 of file c-syscalls-posix.cpp.

493{
494 return posix::rmdir (path);
495}
int rmdir(const char *path)

References os::posix::rmdir().

◆ __posix_select()

int __posix_select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  errorfds,
timeval *  timeout 
)

Definition at line 852 of file c-syscalls-posix.cpp.

854{
855 errno = ENOSYS; // Not implemented
856 return -1;
857}

◆ __posix_send()

ssize_t __posix_send ( int  socket,
const void *  buffer,
size_t  length,
int  flags 
)

Definition at line 731 of file c-syscalls-posix.cpp.

732{
734 if (io == nullptr)
735 {
736 errno = EBADF;
737 return -1;
738 }
739 return io->send (buffer, length, flags);
740}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_sendmsg()

ssize_t __posix_sendmsg ( int  socket,
const msghdr *  message,
int  flags 
)

Definition at line 743 of file c-syscalls-posix.cpp.

744{
746 if (io == nullptr)
747 {
748 errno = EBADF;
749 return -1;
750 }
751 return io->sendmsg (message, flags);
752}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_sendto()

ssize_t __posix_sendto ( int  socket,
const void *  message,
size_t  length,
int  flags,
const sockaddr dest_addr,
socklen_t  dest_len 
)

Definition at line 755 of file c-syscalls-posix.cpp.

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}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_setsockopt()

int __posix_setsockopt ( int  socket,
int  level,
int  option_name,
const void *  option_value,
socklen_t  option_len 
)

Definition at line 768 of file c-syscalls-posix.cpp.

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}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_shutdown()

int __posix_shutdown ( int  socket,
int  how 
)

Definition at line 781 of file c-syscalls-posix.cpp.

782{
784 if (io == nullptr)
785 {
786 errno = EBADF;
787 return -1;
788 }
789 return io->shutdown (how);
790}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_sockatmark()

int __posix_sockatmark ( int  socket)

Definition at line 793 of file c-syscalls-posix.cpp.

794{
796 if (io == nullptr)
797 {
798 errno = EBADF;
799 return -1;
800 }
801 return io->sockatmark ();
802}

References socket(), and os::posix::file_descriptors_manager::socket().

◆ __posix_socket()

int __posix_socket ( int  domain,
int  type,
int  protocol 
)

Definition at line 582 of file c-syscalls-posix.cpp.

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}
Network socket.

◆ __posix_socketpair()

int __posix_socketpair ( int  domain,
int  type,
int  protocol,
int  socket_vector[2] 
)

Definition at line 836 of file c-syscalls-posix.cpp.

837{
838 errno = ENOSYS; // Not implemented
839 return -1;
840}

◆ __posix_stat()

int __posix_stat ( const char *  path,
struct stat buf 
)

Definition at line 447 of file c-syscalls-posix.cpp.

448{
449 return posix::stat (path, buf);
450}
int stat(const char *path, struct stat *buf)

References os::posix::stat().

◆ __posix_statvfs()

int __posix_statvfs ( const char *  path,
struct statvfs buf 
)

Definition at line 477 of file c-syscalls-posix.cpp.

478{
479 return posix::statvfs (path, buf);
480}
int statvfs(const char *path, struct statvfs *buf)

References os::posix::statvfs().

◆ __posix_symlink()

int __posix_symlink ( const char *  existing,
const char *  _new 
)

Definition at line 981 of file c-syscalls-posix.cpp.

982{
983 errno = ENOSYS; // Not implemented
984 return -1;
985}

◆ __posix_sync()

void __posix_sync ( void  )

Definition at line 498 of file c-syscalls-posix.cpp.

499{
500 return posix::sync ();
501}
void sync(void)

References os::posix::sync().

◆ __posix_system()

int __posix_system ( const char *  command)

Definition at line 944 of file c-syscalls-posix.cpp.

945{
946 errno = ENOSYS; // Not implemented
947 return -1;
948}

◆ __posix_tcdrain()

int __posix_tcdrain ( int  fildes)

Definition at line 235 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_tcflush()

int __posix_tcflush ( int  fildes,
int  queue_selector 
)

Definition at line 300 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_tcgetattr()

int __posix_tcgetattr ( int  fildes,
termios termios_p 
)

Definition at line 256 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_tcsendbreak()

int __posix_tcsendbreak ( int  fildes,
int  duration 
)

Definition at line 321 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_tcsetattr()

int __posix_tcsetattr ( int  fildes,
int  optional_actions,
const termios termios_p 
)

Definition at line 277 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ __posix_times()

clock_t __posix_times ( tms *  buf)

Definition at line 860 of file c-syscalls-posix.cpp.

861{
862 errno = ENOSYS; // Not implemented
863 return static_cast<clock_t> (-1);
864}

◆ __posix_truncate()

int __posix_truncate ( const char *  path,
off_t  length 
)

Definition at line 453 of file c-syscalls-posix.cpp.

454{
455 return posix::truncate (path, length);
456}
int truncate(const char *path, off_t length)

References os::posix::truncate().

◆ __posix_unlink()

int __posix_unlink ( const char *  path)

Definition at line 465 of file c-syscalls-posix.cpp.

466{
467 return posix::unlink (path);
468}
int unlink(const char *path)

References os::posix::unlink().

◆ __posix_utime()

int __posix_utime ( const char *  path,
const utimbuf *  times 
)

Definition at line 471 of file c-syscalls-posix.cpp.

472{
473 return posix::utime (path, times);
474}
clock_t times(struct tms *buf)
int utime(const char *path, const utimbuf *times)

References times(), and os::posix::utime().

◆ __posix_wait()

pid_t __posix_wait ( int *  stat_loc)

Definition at line 951 of file c-syscalls-posix.cpp.

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}

◆ __posix_write()

ssize_t __posix_write ( int  fildes,
const void *  buf,
size_t  nbyte 
)

Definition at line 136 of file c-syscalls-posix.cpp.

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}
ssize_t trace_write(const void *buf, size_t nbyte)

References os::posix::file_descriptors_manager::io(), and trace_write().

◆ __posix_writev()

ssize_t __posix_writev ( int  fildes,
const iovec iov,
int  iovcnt 
)

Definition at line 153 of file c-syscalls-posix.cpp.

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}

References os::posix::file_descriptors_manager::io().

◆ initialise_monitor_handles()

void initialise_monitor_handles ( void  )

Definition at line 1000 of file c-syscalls-posix.cpp.

1001{
1002 // Default STDIN, STDOUT, STDERR not required, the __posix_write()
1003 // implementation defaults STDOUT/ERR to trace_write().
1004}