diff --git a/options/posix/generic/mqueue.cpp b/options/posix/generic/mqueue.cpp index d63541978a..3719028cd5 100644 --- a/options/posix/generic/mqueue.cpp +++ b/options/posix/generic/mqueue.cpp @@ -20,3 +20,8 @@ mqd_t mq_open(const char *, int, ...) { __ensure(!"Not implemented"); __builtin_unreachable(); } + +int mq_close(mqd_t) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} diff --git a/options/posix/generic/nl_types.cpp b/options/posix/generic/nl_types.cpp new file mode 100644 index 0000000000..e8d28b941e --- /dev/null +++ b/options/posix/generic/nl_types.cpp @@ -0,0 +1,10 @@ +#include + +#include +#include + +char *catgets(nl_catd, int, int, const char *) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} + diff --git a/options/posix/generic/posix_string.cpp b/options/posix/generic/posix_string.cpp index 838b85b012..29b16ce1a1 100644 --- a/options/posix/generic/posix_string.cpp +++ b/options/posix/generic/posix_string.cpp @@ -3,6 +3,7 @@ #endif #include +#include #include #include #include @@ -152,6 +153,11 @@ void *memrchr(const void *m, int c, size_t n) { return 0; } +void explicit_bzero(void *s, size_t n) { + s = memset(s, 0, n); + asm volatile("" : : "r"(s) : "memory"); +} + char *strerror_l(int errnum, locale_t) { mlibc::infoLogger() << "mlibc: strerror_l locale is ignored!" << frg::endlog; return strerror(errnum); diff --git a/options/posix/generic/sys-uio.cpp b/options/posix/generic/sys-uio.cpp index 0f14bc03ec..607b224878 100644 --- a/options/posix/generic/sys-uio.cpp +++ b/options/posix/generic/sys-uio.cpp @@ -65,3 +65,13 @@ ssize_t pwritev(int, const struct iovec *, int, off_t) { __ensure(!"Not implemented"); __builtin_unreachable(); } + +ssize_t process_vm_readv(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} + +ssize_t process_vm_writev(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} diff --git a/options/posix/generic/termios.cpp b/options/posix/generic/termios.cpp index 631456aa53..09c26b9744 100644 --- a/options/posix/generic/termios.cpp +++ b/options/posix/generic/termios.cpp @@ -101,3 +101,7 @@ int tcsetattr(int fd, int opts, const struct termios *attr) { return 0; } +int cfsetspeed(struct termios *, speed_t) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} diff --git a/options/posix/include/bits/posix/posix_string.h b/options/posix/include/bits/posix/posix_string.h index 1e2096ae10..1e76ab138d 100644 --- a/options/posix/include/bits/posix/posix_string.h +++ b/options/posix/include/bits/posix/posix_string.h @@ -43,6 +43,7 @@ char *strcasestr(const char *__s1, const char *__s2); (char *) memcpy(__buf, __str, __len - 1); \ }) void *memrchr(const void *__m, int __c, size_t __n); +void explicit_bzero(void *__s, size_t __n); #endif /* defined(_GNU_SOURCE) */ /* BSD extensions */ diff --git a/options/posix/include/dlfcn.h b/options/posix/include/dlfcn.h index 4e63279935..b45625115c 100644 --- a/options/posix/include/dlfcn.h +++ b/options/posix/include/dlfcn.h @@ -3,6 +3,7 @@ #define _DLFCN_H #include +#include #define RTLD_LOCAL 0 #define RTLD_LAZY 1 @@ -19,6 +20,8 @@ #define RTLD_DL_LINKMAP 2 #define RTLD_DI_LINKMAP 2 +#define RTLD_DI_SERINFO 4 +#define RTLD_DI_SERINFOSIZE 5 #ifdef __cplusplus extern "C" { @@ -58,6 +61,17 @@ typedef struct { #define DLFO_EH_SEGMENT_TYPE PT_GNU_EH_FRAME #endif +typedef struct { + char *dls_name; + unsigned int dls_flags; +} Dl_serpath; + +typedef struct { + size_t dls_size; + unsigned int dls_cnt; + Dl_serpath dls_serpath[1]; +} Dl_serinfo; + struct dl_find_object { unsigned long long dlfo_flags; void *dlfo_map_start; diff --git a/options/posix/include/mqueue.h b/options/posix/include/mqueue.h index cbee138e5c..485607f3ea 100644 --- a/options/posix/include/mqueue.h +++ b/options/posix/include/mqueue.h @@ -15,6 +15,7 @@ int mq_getattr(mqd_t __mqdes, struct mq_attr *__attr); int mq_setattr(mqd_t __mqdes, const struct mq_attr *__restrict__ __newattr, struct mq_attr *__restrict__ __oldattr); int mq_unlink(const char *__name); mqd_t mq_open(const char *__name, int __flags, ...); +int mq_close(mqd_t __mqdes); #endif /* !__MLIBC_ABI_ONLY */ diff --git a/options/posix/include/nl_types.h b/options/posix/include/nl_types.h index 8878629551..754f262933 100644 --- a/options/posix/include/nl_types.h +++ b/options/posix/include/nl_types.h @@ -1,6 +1,20 @@ #ifndef NL_TYPES_H #define NL_TYPES_H +#ifdef __cplusplus +extern "C" { +#endif +typedef void *nl_catd; + +#ifndef __MLIBC_ABI_ONLY + +char *catgets(nl_catd __catalog, int __set, int __number, const char *__string); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif #endif /* NL_TYPES_H */ diff --git a/options/posix/include/sys/ipc.h b/options/posix/include/sys/ipc.h index e8c1714e1a..091bef3295 100644 --- a/options/posix/include/sys/ipc.h +++ b/options/posix/include/sys/ipc.h @@ -31,13 +31,13 @@ extern "C" { typedef int key_t; struct ipc64_perm { - key_t __ipc_perm_key; + key_t __key; uid_t uid; gid_t gid; uid_t cuid; gid_t cgid; mode_t mode; - short __ipc_perm_seq; + short __seq; short __pad; unsigned long __unused[2]; }; diff --git a/options/posix/include/sys/msg.h b/options/posix/include/sys/msg.h index f62220ac66..be4afe20ec 100644 --- a/options/posix/include/sys/msg.h +++ b/options/posix/include/sys/msg.h @@ -9,6 +9,17 @@ extern "C" { #endif +struct msginfo { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + unsigned short int msgseg; +}; + #ifndef __MLIBC_ABI_ONLY int msgget(key_t __key, int __msgflg); diff --git a/options/posix/include/sys/sem.h b/options/posix/include/sys/sem.h index d98f91f3f8..9ebc9f3928 100644 --- a/options/posix/include/sys/sem.h +++ b/options/posix/include/sys/sem.h @@ -12,11 +12,17 @@ extern "C" { #define GETPID 11 #define GETVAL 12 #define GETALL 13 +#define GETNCNT 14 +#define GETZCNT 15 #define SETVAL 16 #define SETALL 17 #define SEM_UNDO 0x1000 +#define SEM_STAT 18 +#define SEM_INFO 19 +#define SEM_STAT_ANY 20 + struct sembuf { unsigned short int sem_num; short int sem_op; @@ -31,6 +37,19 @@ struct semid_ds { unsigned long sem_nsems; }; +struct seminfo { + int semmap; + int semmni; + int semmns; + int semmnu; + int semmsl; + int semopm; + int semume; + int semusz; + int semvmx; + int semaem; +}; + #ifndef __MLIBC_ABI_ONLY int semget(key_t __key, int __nsems, int __semflg); diff --git a/options/posix/include/sys/uio.h b/options/posix/include/sys/uio.h index 1547036d83..7e3c7aa731 100644 --- a/options/posix/include/sys/uio.h +++ b/options/posix/include/sys/uio.h @@ -1,6 +1,7 @@ #ifndef _SYS_UIO_H #define _SYS_UIO_H +#include #include #include #include @@ -22,6 +23,12 @@ ssize_t writev(int __fd, const struct iovec *__iov, int __iovcnt); ssize_t preadv(int __fd, const struct iovec *__iov, int __iovcnt, off_t __offset); ssize_t pwritev(int __fd, const struct iovec *__iov, int __iovcnt, off_t __offset); +// Linux extensions +ssize_t process_vm_readv(pid_t __pid, const struct iovec *__local_iov, unsigned long __liovcnt, const struct iovec *__remote_iov, + unsigned long __riovcnt, unsigned long __flags); +ssize_t process_vm_writev(pid_t __pid, const struct iovec *__local_iov, unsigned long __liovcnt, const struct iovec *__remote_iov, + unsigned long __riovcnt, unsigned long __flags); + #endif /* !__MLIBC_ABI_ONLY */ #ifdef __cplusplus diff --git a/options/posix/include/syslog.h b/options/posix/include/syslog.h index c984be1696..93412b1afe 100644 --- a/options/posix/include/syslog.h +++ b/options/posix/include/syslog.h @@ -55,6 +55,58 @@ extern "C" { #define LOG_INFO 6 #define LOG_DEBUG 7 +#if defined SYSLOG_NAMES && defined __USE_MISC +typedef struct _code { + char *c_name; + int c_val; +} CODE; + +#define INTERNAL_NOPRI 0x10 +#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES << 3, 0) + +CODE prioritynames[] = { + { "alert", LOG_ALERT }, + { "crit", LOG_CRIT }, + { "debug", LOG_DEBUG }, + { "emerg", LOG_EMERG }, + { "err", LOG_ERR }, + { "error", LOG_ERR }, /* DEPRECATED */ + { "info", LOG_INFO }, + { "none", INTERNAL_NOPRI }, /* INTERNAL */ + { "notice", LOG_NOTICE }, + { "panic", LOG_EMERG }, /* DEPRECATED */ + { "warn", LOG_WARNING }, /* DEPRECATED */ + { "warning", LOG_WARNING }, + { NULL, -1 } +}; + +CODE facilitynames[] = { + { "auth", LOG_AUTH }, + { "authpriv", LOG_AUTHPRIV }, + { "cron", LOG_CRON }, + { "daemon", LOG_DAEMON }, + { "ftp", LOG_FTP }, + { "kern", LOG_KERN }, + { "lpr", LOG_LPR }, + { "mail", LOG_MAIL }, + { "mark", INTERNAL_MARK }, /* INTERNAL */ + { "news", LOG_NEWS }, + { "security", LOG_AUTH }, /* DEPRECATED */ + { "syslog", LOG_SYSLOG }, + { "user", LOG_USER }, + { "uucp", LOG_UUCP }, + { "local0", LOG_LOCAL0 }, + { "local1", LOG_LOCAL1 }, + { "local2", LOG_LOCAL2 }, + { "local3", LOG_LOCAL3 }, + { "local4", LOG_LOCAL4 }, + { "local5", LOG_LOCAL5 }, + { "local6", LOG_LOCAL6 }, + { "local7", LOG_LOCAL7 }, + { NULL, -1 } +}; +#endif + #ifndef __MLIBC_ABI_ONLY void closelog(void); diff --git a/options/posix/include/termios.h b/options/posix/include/termios.h index 7f62142e4e..33f3776997 100644 --- a/options/posix/include/termios.h +++ b/options/posix/include/termios.h @@ -81,6 +81,7 @@ int tcgetattr(int fd, struct termios *__attr); pid_t tcgetsid(int __fd); int tcsendbreak(int __fd, int __duration); int tcsetattr(int __fd, int __optional_actions, const struct termios *__attr); +int cfsetspeed(struct termios *__tios, speed_t __speed); #endif /* !__MLIBC_ABI_ONLY */ diff --git a/options/posix/meson.build b/options/posix/meson.build index 531188b2f6..6c67dfefef 100644 --- a/options/posix/meson.build +++ b/options/posix/meson.build @@ -14,6 +14,7 @@ libc_sources += files( 'generic/lookup.cpp', 'generic/netdb.cpp', 'generic/net-if.cpp', + 'generic/nl_types.cpp', 'generic/poll.cpp', 'generic/posix_ctype.cpp', 'generic/posix-file-io.cpp',