mirror of
https://git.musl-libc.org/git/musl
synced 2025-02-08 22:34:20 +03:00
mq: add x32-specific implementations to work around mismatched kernel ABI
the kernel mq_attr structure has 8 64-bit longs instead of 8 32-bit longs. it's not clear that this is the nicest way to implement the fix, but the concept (translation) is right, and the details can be changed later if desired.
This commit is contained in:
parent
561cd07dff
commit
d36e5bf83b
22
src/mq/x32/mq_open.c
Normal file
22
src/mq/x32/mq_open.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <mqueue.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include "syscall.h"
|
||||
|
||||
mqd_t mq_open(const char *name, int flags, ...)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
struct mq_attr *attr = 0;
|
||||
long long attrbuf[8];
|
||||
if (*name == '/') name++;
|
||||
if (flags & O_CREAT) {
|
||||
va_list ap;
|
||||
va_start(ap, flags);
|
||||
mode = va_arg(ap, mode_t);
|
||||
attr = va_arg(ap, struct mq_attr *);
|
||||
if (attr) for (int i=0; i<8; i++)
|
||||
attrbuf[i] = *(long *)((char *)attr + i*sizeof(long));
|
||||
va_end(ap);
|
||||
}
|
||||
return syscall(SYS_mq_open, name, flags, mode, attr?attrbuf:0);
|
||||
}
|
14
src/mq/x32/mq_setattr.c
Normal file
14
src/mq/x32/mq_setattr.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include <mqueue.h>
|
||||
#include "syscall.h"
|
||||
|
||||
int mq_setattr(mqd_t mqd, const struct mq_attr *restrict new, struct mq_attr *restrict old)
|
||||
{
|
||||
long long attr[8];
|
||||
if (new) for (int i=0; i<8; i++)
|
||||
attr[i] = *(long *)((char *)new + i*sizeof(long));
|
||||
int ret = __syscall(SYS_mq_getsetattr, mqd, new?attr:0, old?attr:0);
|
||||
if (ret < 0) return __syscall_ret(ret);
|
||||
if (old) for (int i=0; i<8; i++)
|
||||
*(long *)((char *)old + i*sizeof(long)) = attr[i];
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user