mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-01 18:39:16 +00:00
feat(userspace/libc): implement functions for porting apps
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
@ -70,5 +70,10 @@ int sysdep(ChangeDirectory)(const char *Pathname);
|
||||
char *sysdep(GetWorkingDirectory)(char *Buffer, size_t Size);
|
||||
int sysdep(Brk)(void *Address);
|
||||
int sysdep(FileControl)(int Descriptor, int Command, void *Arg);
|
||||
int sysdep(ClockGetTime)(clockid_t ClockID, struct timespec *TP);
|
||||
time_t sysdep(Time)(void);
|
||||
clock_t sysdep(Clock)(void);
|
||||
int sysdep(RemoveDirectory)(const char *Pathname);
|
||||
int sysdep(Unlink)(const char *Pathname);
|
||||
|
||||
#endif // FENNIX_BITS_LIBC_H
|
||||
|
29
Userspace/libc/include/iconv.h
Normal file
29
Userspace/libc/include/iconv.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
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 _ICONV_H
|
||||
#define _ICONV_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef void *iconv_t;
|
||||
|
||||
iconv_t iconv_open(const char *tocode, const char *fromcode);
|
||||
size_t iconv(iconv_t cd, char **restrict inbuf, size_t *restrict inbytesleft, char **restrict outbuf, size_t *restrict outbytesleft);
|
||||
int iconv_close(iconv_t cd);
|
||||
|
||||
#endif // _ICONV_H
|
@ -27,6 +27,8 @@ extern "C"
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long long __a;
|
||||
|
@ -106,7 +106,7 @@ extern "C"
|
||||
int fputs(const char *restrict s, FILE *restrict stream);
|
||||
size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
|
||||
FILE *freopen(const char *restrict, const char *restrict, FILE *restrict);
|
||||
int fscanf(FILE *restrict, const char *restrict, ...);
|
||||
int fscanf(FILE *restrict stream, const char *restrict format, ...);
|
||||
int fseek(FILE *stream, long offset, int whence);
|
||||
int fseeko(FILE *, off_t, int);
|
||||
int fsetpos(FILE *, const fpos_t *);
|
||||
@ -131,16 +131,16 @@ extern "C"
|
||||
int putc_unlocked(int c, FILE *stream);
|
||||
int putchar_unlocked(int c);
|
||||
int puts(const char *s);
|
||||
int remove(const char *);
|
||||
int remove(const char *path);
|
||||
int rename(const char *, const char *);
|
||||
int renameat(int, const char *, int, const char *);
|
||||
void rewind(FILE *);
|
||||
int scanf(const char *restrict, ...);
|
||||
int scanf(const char *restrict format, ...);
|
||||
void setbuf(FILE *restrict, char *restrict);
|
||||
int setvbuf(FILE *restrict, char *restrict, int, size_t);
|
||||
int snprintf(char *restrict s, size_t n, const char *restrict format, ...);
|
||||
int sprintf(char *restrict s, const char *restrict format, ...);
|
||||
int sscanf(const char *restrict, const char *restrict, ...);
|
||||
int sscanf(const char *restrict s, const char *restrict format, ...);
|
||||
FILE *tmpfile(void);
|
||||
char *tmpnam(char *);
|
||||
int ungetc(int, FILE *);
|
||||
@ -149,7 +149,7 @@ extern "C"
|
||||
int vfscanf(FILE *restrict, const char *restrict, va_list);
|
||||
int vprintf(const char *restrict, va_list);
|
||||
int vscanf(const char *restrict, va_list);
|
||||
int vsnprintf(char *restrict, size_t, const char *restrict, va_list);
|
||||
int vsnprintf(char *restrict s, size_t n, const char *restrict format, va_list ap);
|
||||
int vsprintf(char *restrict, const char *restrict, va_list);
|
||||
int vsscanf(const char *restrict, const char *restrict, va_list);
|
||||
|
||||
|
@ -102,7 +102,8 @@ extern "C"
|
||||
double strtod(const char *, char **);
|
||||
long strtol(const char *restrict nptr, char **restrict endptr, int base);
|
||||
long long strtoll(const char *restrict nptr, char **restrict endptr, int base);
|
||||
unsigned long int strtoul(const char *, char **, int);
|
||||
unsigned long int strtoul(const char *restrict str, char **restrict endptr, int base);
|
||||
unsigned long long strtoull(const char *restrict str, char **restrict endptr, int base);
|
||||
int system(const char *command);
|
||||
int ttyslot(void);
|
||||
int unlockpt(int);
|
||||
|
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
|
@ -49,7 +49,7 @@ extern "C"
|
||||
struct timespec it_value; /* Timer expiration. */
|
||||
} itimerspec;
|
||||
|
||||
#define CLOCKS_PER_SEC
|
||||
#define CLOCKS_PER_SEC 1000000
|
||||
#define TIME_UTC
|
||||
#define CLOCK_MONOTONIC __SYS_CLOCK_MONOTONIC
|
||||
#define CLOCK_PROCESS_CPUTIME_ID __SYS_CLOCK_PROCESS_CPUTIME_ID
|
||||
@ -64,10 +64,10 @@ extern "C"
|
||||
char *asctime(const struct tm *);
|
||||
clock_t clock(void);
|
||||
int clock_getcpuclockid(pid_t, clockid_t *);
|
||||
int clock_getres(clockid_t, struct timespec *);
|
||||
int clock_gettime(clockid_t, struct timespec *);
|
||||
int clock_getres(clockid_t clock_id, struct timespec *res);
|
||||
int clock_gettime(clockid_t clock_id, struct timespec *tp);
|
||||
int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
|
||||
int clock_settime(clockid_t, const struct timespec *);
|
||||
int clock_settime(clockid_t clock_id, const struct timespec *tp);
|
||||
char *ctime(const time_t *);
|
||||
double difftime(time_t, time_t);
|
||||
struct tm *getdate(const char *);
|
||||
@ -81,7 +81,7 @@ extern "C"
|
||||
size_t strftime(char *restrict, size_t, const char *restrict, const struct tm *restrict);
|
||||
size_t strftime_l(char *restrict, size_t, const char *restrict, const struct tm *restrict, locale_t);
|
||||
char *strptime(const char *restrict, const char *restrict, struct tm *restrict);
|
||||
time_t time(time_t *);
|
||||
time_t time(time_t *tloc);
|
||||
int timer_create(clockid_t, struct sigevent *restrict, timer_t *restrict);
|
||||
int timer_delete(timer_t);
|
||||
int timer_getoverrun(timer_t);
|
||||
|
@ -121,7 +121,7 @@ extern "C"
|
||||
ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
|
||||
ssize_t read(int fildes, void *buf, size_t nbyte);
|
||||
int readlink(const char *, char *, size_t);
|
||||
int rmdir(const char *);
|
||||
int rmdir(const char *path);
|
||||
void *sbrk(intptr_t incr);
|
||||
int setgid(gid_t);
|
||||
int setpgid(pid_t, pid_t);
|
||||
@ -141,7 +141,7 @@ extern "C"
|
||||
char *ttyname(int);
|
||||
int ttyname_r(int, char *, size_t);
|
||||
useconds_t ualarm(useconds_t, useconds_t);
|
||||
int unlink(const char *);
|
||||
int unlink(const char *path);
|
||||
int usleep(useconds_t);
|
||||
pid_t vfork(void);
|
||||
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
||||
|
Reference in New Issue
Block a user