Skip to content

Commit

Permalink
(#1108) Add POSIX message queue scope wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbiesek committed Nov 28, 2022
1 parent 0aab4bf commit ad514f3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/scopestdlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ extern int scopelibc_setns(int, int);
extern int scopelibc_chown(const char *, uid_t, gid_t);
extern int scopelibc_fchown(int, uid_t, gid_t);
extern int scopelibc_symlink(const char *, const char *);
extern int scopelibc_mq_close(mqd_t);
extern int scopelibc_mq_send(mqd_t, const char *, size_t, unsigned int);
extern ssize_t scopelibc_mq_receive(mqd_t, char *, size_t, unsigned int *);
extern int scopelibc_mq_unlink(const char *);
extern int scopelibc_mq_getattr(mqd_t, struct mq_attr *);

static int g_go_static;

Expand Down Expand Up @@ -1234,3 +1239,28 @@ int
scope_symlink(const char *target, const char *linkpath) {
return scopelibc_symlink(target, linkpath);
}

int
scope_mq_close(mqd_t mqdes) {
return scopelibc_mq_close(mqdes);
}

int
scope_mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio) {
return scopelibc_mq_send(mqdes, msg_ptr, msg_len, msg_prio);
}

ssize_t
scope_mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio) {
return scopelibc_mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
}

int
scope_mq_unlink(const char *name) {
return scopelibc_mq_unlink(name);
}

int
scope_mq_getattr(mqd_t mqd, struct mq_attr *attr) {
return scopelibc_mq_getattr(mqd, attr);
}
8 changes: 8 additions & 0 deletions src/scopestdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <mqueue.h>
#include <netdb.h>
#include <poll.h>
#include <pthread.h>
Expand All @@ -38,6 +39,7 @@ extern int scopelibc_sscanf(const char *, const char *, ...);
extern int scopelibc_fscanf(FILE *, const char *, ...);
extern int scopelibc_sprintf(char *, const char *, ...);
extern int scopelibc_asprintf(char **, const char *, ...);
extern int scopelibc_mq_open(const char *, int, ...);
extern int scopelibc_errno_val;
extern FILE scopelibc___stdin_FILE;
extern FILE scopelibc___stdout_FILE;
Expand All @@ -56,6 +58,7 @@ extern int32_t ** scopelibc___ctype_tolower_loc(void);
#define scope_fscanf scopelibc_fscanf
#define scope_sprintf scopelibc_sprintf
#define scope_asprintf scopelibc_asprintf
#define scope_mq_open scopelibc_mq_open
#define scope_errno scopelibc_errno_val
#define scope_stdin (&scopelibc___stdin_FILE)
#define scope_stdout (&scopelibc___stdout_FILE)
Expand Down Expand Up @@ -285,6 +288,11 @@ int scope_setns(int, int);
int scope_chown(const char *, uid_t, gid_t);
int scope_fchown(int, uid_t, gid_t);
int scope_symlink(const char *, const char *);
int scope_mq_close(mqd_t);
int scope_mq_send(mqd_t, const char *, size_t, unsigned int);
ssize_t scope_mq_receive(mqd_t, char *, size_t, unsigned int *);
int scope_mq_unlink(const char *);
int scope_mq_getattr(mqd_t, struct mq_attr *);


#endif // __SCOPE_STDLIB_H__

0 comments on commit ad514f3

Please sign in to comment.