Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes and stubs to the posix option for systemd #1201

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions options/posix/generic/mqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
10 changes: 10 additions & 0 deletions options/posix/generic/nl_types.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <nl_types.h>

#include <bits/ensure.h>
#include <mlibc/debug.hpp>

char *catgets(nl_catd, int, int, const char *) {
__ensure(!"Not implemented");
__builtin_unreachable();
}

6 changes: 6 additions & 0 deletions options/posix/generic/posix_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#endif

#include <bits/ensure.h>
#include <bits/posix/posix_string.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions options/posix/generic/sys-uio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
4 changes: 4 additions & 0 deletions options/posix/generic/termios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions options/posix/include/bits/posix/posix_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
14 changes: 14 additions & 0 deletions options/posix/include/dlfcn.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define _DLFCN_H

#include <mlibc-config.h>
#include <bits/size_t.h>

#define RTLD_LOCAL 0
#define RTLD_LAZY 1
Expand All @@ -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" {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions options/posix/include/mqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
14 changes: 14 additions & 0 deletions options/posix/include/nl_types.h
Original file line number Diff line number Diff line change
@@ -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 */
4 changes: 2 additions & 2 deletions options/posix/include/sys/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand Down
11 changes: 11 additions & 0 deletions options/posix/include/sys/msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions options/posix/include/sys/sem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions options/posix/include/sys/uio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _SYS_UIO_H
#define _SYS_UIO_H

#include <abi-bits/pid_t.h>
#include <bits/posix/iovec.h>
#include <bits/ssize_t.h>
#include <bits/off_t.h>
Expand All @@ -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
Expand Down
52 changes: 52 additions & 0 deletions options/posix/include/syslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions options/posix/include/termios.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
1 change: 1 addition & 0 deletions options/posix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading