mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-16 17:51:42 +00:00
feat(userspace/libc): implement functions for porting apps
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
41
Userspace/libc/include/sys/select.h
Normal file
41
Userspace/libc/include/sys/select.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_SELECT_H
|
||||
#define _SYS_SELECT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define FD_SETSIZE 1024
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long fds_bits[(FD_SETSIZE + (8 * sizeof(unsigned long) - 1)) / (8 * sizeof(unsigned long))];
|
||||
} fd_set;
|
||||
|
||||
#define FD_CLR(fd, fdset) ((fdset)->fds_bits[(fd) / (8 * sizeof(unsigned long))] &= ~(1UL << ((fd) % (8 * sizeof(unsigned long)))))
|
||||
#define FD_ISSET(fd, fdset) (((fdset)->fds_bits[(fd) / (8 * sizeof(unsigned long))] & (1UL << ((fd) % (8 * sizeof(unsigned long))))) != 0)
|
||||
#define FD_SET(fd, fdset) ((fdset)->fds_bits[(fd) / (8 * sizeof(unsigned long))] |= (1UL << ((fd) % (8 * sizeof(unsigned long)))))
|
||||
#define FD_ZERO(fdset) (memset((fdset), 0, sizeof(fd_set)))
|
||||
|
||||
int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds, struct timeval *restrict timeout);
|
||||
int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds, const struct timespec *restrict timeout, const sigset_t *restrict sigmask);
|
||||
|
||||
#endif // _SYS_SELECT_H
|
51
Userspace/libc/include/sys/time.h
Normal file
51
Userspace/libc/include/sys/time.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TIME_H
|
||||
#define _SYS_TIME_H
|
||||
|
||||
#include <bits/libc.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
|
||||
typedef long time_t;
|
||||
typedef long suseconds_t;
|
||||
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec; /* Seconds */
|
||||
suseconds_t tv_usec; /* Microseconds */
|
||||
};
|
||||
|
||||
struct itimerval
|
||||
{
|
||||
struct timeval it_interval; /* Timer interval */
|
||||
struct timeval it_value; /* Current value */
|
||||
};
|
||||
|
||||
/* Values for the which argument of getitimer() and setitimer() */
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
int getitimer(int which, struct itimerval *value);
|
||||
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
|
||||
// int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds, struct timeval *restrict timeout);
|
||||
int setitimer(int which, const struct itimerval *restrict new_value, struct itimerval *restrict old_value);
|
||||
int utimes(const char *filename, const struct timeval times[2]);
|
||||
|
||||
#endif // _SYS_TIME_H
|
31
Userspace/libc/include/sys/un.h
Normal file
31
Userspace/libc/include/sys/un.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
This file is part of Fennix C Library.
|
||||
|
||||
Fennix C Library is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_UN_H
|
||||
#define _SYS_UN_H
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define SUN_PATH_SIZE 108
|
||||
|
||||
struct sockaddr_un
|
||||
{
|
||||
sa_family_t sun_family; /* Address family */
|
||||
char sun_path[SUN_PATH_SIZE]; /* Socket pathname storage */
|
||||
};
|
||||
|
||||
#endif // _SYS_UN_H
|
Reference in New Issue
Block a user