diff options
author | Danny Holman <dholman@gymli.org> | 2024-06-05 13:47:01 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-06-05 13:47:01 -0500 |
commit | 5db066eb5184cc45e7634838b5b0b8c67cb2ae25 (patch) | |
tree | 9201570bb47cf57cd41f7efc8bf764b3ec70b802 /include | |
parent | e5aff92e72a0d0e1c18ddaab80b2efe370f04588 (diff) |
Create build targets for a skeleton libc that only includes enough
functionality to get a cross compiler running.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/stdint.h | 32 | ||||
-rw-r--r-- | include/unistd.h | 143 |
2 files changed, 175 insertions, 0 deletions
diff --git a/include/stdint.h b/include/stdint.h new file mode 100644 index 0000000..4f6e71d --- /dev/null +++ b/include/stdint.h @@ -0,0 +1,32 @@ +#ifndef STDINT_H +#define STDINT_H + +#include <bits/types.h> + +#define INT8_MIN (-1-0x7F) +#define INT16_MIN (-1-0x7FFF) +#define INT32_MIN (-1-0x7FFFFFFF) +#define INT64_MIN (-1-0x7FFFFFFFFFFFFFFF) + +#define INT8_MAX (0x7F) +#define INT16_MAX (0x7FFF) +#define INT32_MAX (0x7FFFFFFF) +#define INT64_MAX (0x7FFFFFFFFFFFFFFF) + +#define UINT8_MAX (0xFF) +#define UINT16_MAX (0xFFFF) +#define UINT32_MAX (0xFFFFFFFF) +#define UINT64_MAX (0xFFFFFFFFFFFFFFFF) + +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST64_MAX INT64_MAX + +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#endif diff --git a/include/unistd.h b/include/unistd.h new file mode 100644 index 0000000..8c7eae4 --- /dev/null +++ b/include/unistd.h @@ -0,0 +1,143 @@ +#ifndef UNISTD_H +#define UNISTD_H + +#include <sys/types.h> +#include <stdint.h> +#include <stddef.h> + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#define SEEK_DATA 3 +#define SEEK_HOLE 4 + +#define NULL ((void*)0) + +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 + +int pipe(); +int pipe2(); +int close(int fildes); +int dup(int fildes); +int dup2(); +int dup3(); +off_t lseek(); +int fsync(); +int fdatasync(); + +ssize_t read(int fildes, void *buf, size_t nbyte); +ssize_t write(int fildes, const void *buf, size_t nbyte); +ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset); +ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset); + +int chown(const char *path, uid_t owner, gid_t group); +int fchown(int fildes, uid_t owner, gid_t group); +int lchown(const char *path, uid_t owner, gid_t group); +int fchownat(int fildes, const char *path, uid_t owner, gid_t group); + +int link(const char *target, const char *lpath); +int linkat(int target_fd, const char *tpath, int link_fd, const char *lpath); +int symlink(const char *target, const char *lpath); +int symlinkat(const char *target, int fildes, const char *lpath); +ssize_t readlink(const char* __restrict path, char* __restrict buf, size_t bufsz); +ssize_t readlinkat(int fildes, const char* __restrict path, char* __restrict buf, size_t bufsz); +int unlink(const char *lpath); +int unlinkat(int fildes, const char *lpath, int flag); +int rmdir(const char *path); +int truncate(const char *path, off_t length); +int ftruncate(int fildes, off_t length); + +int access(const char *path, int amode); +int faccessat(int fildes, const char *path, int amode, int flag); + +int chdir(const char *path); +int fchdir(int fildes); +char* getcwd(char *buf, size_t bufsz); + +unsigned int alarm(unsigned int seconds); +unsigned int sleep(unsigned int seconds); +unsigned int ualarm(useconds_t usec); +unsigned int usleep(useconds_t usec); +int pause(void); + +pid_t fork(void); +pid_t vfork(void); +void _exit(int status); +int execve(const char *pathname, char* const argv[], char* const envp[]); +int execv(const char *pathname, char* const argv[]); +int execle(const char *pathname, const char *argv, ...); +int execl(const char *pathname, const char *argv, ...); +int execvp(const char *pathname, char* const argv[]); +int execvpe(const char *pathname, char* const argv[], char* const envp[]); +int execlp(const char *pathname, char* const argv[], ...); +int fexecve(int fildes, char* const argv[], char* const envp[]); + +pid_t getpid(void); +pid_t getppid(void); +pid_t getpgrp(void); +pid_t getpgid(pid_t); +int setpgid(pid_t pid, pid_t pgid); +pid_t setsid(void); +pid_t getsid(pid_t pid); +char* ttyname(int fildes); +int ttyname_r(int fildes, char *buf, size_t bufsz); +int isatty(int fildes); +pid_t tcgetpgrp(int fildes); + +uid_t getuid(void); +uid_t geteuid(void); +gid_t getgid(void); +gid_t getegid(void); +int getgroups(int gidsetsize, gid_t grouplist[]); +int setuid(uid_t uid); +int seteuid(uid_t euid); +int setgid(gid_t gid); +int setegid(gid_t egid); + +char* getlogin(void); +int getlogin_r(char *buf, size_t bufsz); +char* ctermid(char *buf); + +long int pathconf(const char *path, int name); +long int fpathconf(int fildes, int name); +long int sysconf(int name); +size_t confstr(int name, char *buf, size_t bufsz); + +int setreuid(uid_t ruid, uid_t euid); +int setregid(gid_t rgid, gid_t egid); +int lockf(int fildes, int op, off_t length); + +int nice(int incr); +void sync(void); +pid_t setpgrp(void); +void swab(const void* __restrict from, void* __restrict to, ssize_t n); + +int brk(void *addr); +void* sbrk(intptr_t incr); + +int vhangup(void); +int chroot(const char *path); +int getpagesize(void); +int getdtablesize(void); + +int gethostname(char *buf, size_t bufsz); +int sethostname(const char *name, size_t len); +int getdomainname(char *buf, size_t bufsz); +int setdomainname(const char *name, size_t len); +int daemon(int nochdir, int noclose); + +char* getusershell(void); +void setusershell(void); +void endusershell(void); + +int acct(const char *path); +int getentropy(void *buffer, size_t bufsz); + +#endif |