cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

unistd.h (1133B)


      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
     16static __attribute__((unused))
     17int msleep(unsigned int msecs)
     18{
     19	struct timeval my_timeval = { msecs / 1000, (msecs % 1000) * 1000 };
     20
     21	if (sys_select(0, 0, 0, 0, &my_timeval) < 0)
     22		return (my_timeval.tv_sec * 1000) +
     23			(my_timeval.tv_usec / 1000) +
     24			!!(my_timeval.tv_usec % 1000);
     25	else
     26		return 0;
     27}
     28
     29static __attribute__((unused))
     30unsigned int sleep(unsigned int seconds)
     31{
     32	struct timeval my_timeval = { seconds, 0 };
     33
     34	if (sys_select(0, 0, 0, 0, &my_timeval) < 0)
     35		return my_timeval.tv_sec + !!my_timeval.tv_usec;
     36	else
     37		return 0;
     38}
     39
     40static __attribute__((unused))
     41int usleep(unsigned int usecs)
     42{
     43	struct timeval my_timeval = { usecs / 1000000, usecs % 1000000 };
     44
     45	return sys_select(0, 0, 0, 0, &my_timeval);
     46}
     47
     48static __attribute__((unused))
     49int tcsetpgrp(int fd, pid_t pid)
     50{
     51	return ioctl(fd, TIOCSPGRP, &pid);
     52}
     53
     54#endif /* _NOLIBC_UNISTD_H */