Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/sys/linux/mq_close.c')
-rw-r--r--newlib/libc/sys/linux/mq_close.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/newlib/libc/sys/linux/mq_close.c b/newlib/libc/sys/linux/mq_close.c
new file mode 100644
index 000000000..f80744327
--- /dev/null
+++ b/newlib/libc/sys/linux/mq_close.c
@@ -0,0 +1,48 @@
+/* Copyright 2002, Red Hat Inc. */
+
+#include <mqueue.h>
+#include <errno.h>
+#include <sys/sem.h>
+#define _LIBC
+#include <sys/lock.h>
+#undef _LIBC
+
+#include "mqlocal.h"
+
+int
+mq_close (mqd_t msgid)
+{
+ struct libc_mq *info;
+ struct sembuf sb0 = {0, -1, 0};
+ int rc;
+ int semid;
+
+ info = __find_mq (msgid);
+
+ if (info == NULL)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ /* lock message queue */
+ semid = info->semid;
+ rc = semop (semid, &sb0, 1);
+
+ if (rc == 0)
+ {
+ __cleanup_mq (msgid);
+
+ /* unlock message queue */
+ sb0.sem_op = 1;
+ semop (semid, &sb0, 1);
+ }
+
+ return rc;
+}
+
+
+
+
+
+