~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/include/nolibc/unistd.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
  2 /*
  3  * unistd function definitions for NOLIBC
  4  * Copyright (C) 2017-2022 Willy Tarreau <w@1wt.eu>
  5  */
  6 
  7 #ifndef _NOLIBC_UNISTD_H
  8 #define _NOLIBC_UNISTD_H
  9 
 10 #include "std.h"
 11 #include "arch.h"
 12 #include "types.h"
 13 #include "sys.h"
 14 
 15 
 16 #define STDIN_FILENO  0
 17 #define STDOUT_FILENO 1
 18 #define STDERR_FILENO 2
 19 
 20 
 21 static __attribute__((unused))
 22 int msleep(unsigned int msecs)
 23 {
 24         struct timeval my_timeval = { msecs / 1000, (msecs % 1000) * 1000 };
 25 
 26         if (sys_select(0, 0, 0, 0, &my_timeval) < 0)
 27                 return (my_timeval.tv_sec * 1000) +
 28                         (my_timeval.tv_usec / 1000) +
 29                         !!(my_timeval.tv_usec % 1000);
 30         else
 31                 return 0;
 32 }
 33 
 34 static __attribute__((unused))
 35 unsigned int sleep(unsigned int seconds)
 36 {
 37         struct timeval my_timeval = { seconds, 0 };
 38 
 39         if (sys_select(0, 0, 0, 0, &my_timeval) < 0)
 40                 return my_timeval.tv_sec + !!my_timeval.tv_usec;
 41         else
 42                 return 0;
 43 }
 44 
 45 static __attribute__((unused))
 46 int usleep(unsigned int usecs)
 47 {
 48         struct timeval my_timeval = { usecs / 1000000, usecs % 1000000 };
 49 
 50         return sys_select(0, 0, 0, 0, &my_timeval);
 51 }
 52 
 53 static __attribute__((unused))
 54 int tcsetpgrp(int fd, pid_t pid)
 55 {
 56         return ioctl(fd, TIOCSPGRP, &pid);
 57 }
 58 
 59 #define __syscall_narg(_0, _1, _2, _3, _4, _5, _6, N, ...) N
 60 #define _syscall_narg(...) __syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0)
 61 #define _syscall(N, ...) __sysret(my_syscall##N(__VA_ARGS__))
 62 #define _syscall_n(N, ...) _syscall(N, __VA_ARGS__)
 63 #define syscall(...) _syscall_n(_syscall_narg(__VA_ARGS__), ##__VA_ARGS__)
 64 
 65 /* make sure to include all global symbols */
 66 #include "nolibc.h"
 67 
 68 #endif /* _NOLIBC_UNISTD_H */
 69 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php