about summary refs log tree commit homepage
path: root/ext/posix_mq/posix_mq.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-02-22 16:46:26 -0800
committerEric Wong <normalperson@yhbt.net>2011-02-22 16:46:26 -0800
commit3a8a20d685dbfb500187099d76e56e848ad347ed (patch)
treee70d7bca1b7b60f8dfb731971fb92d65d09af42c /ext/posix_mq/posix_mq.c
parentc4c4554c3ceef9208fe7f8473b970e9f522ab9b9 (diff)
downloadruby_posix_mq-3a8a20d685dbfb500187099d76e56e848ad347ed.tar.gz
Some ancient systems don't support mq_timedsend and
mq_timedreceive but somehow manage to support other POSIX
mq_* functions.
Diffstat (limited to 'ext/posix_mq/posix_mq.c')
-rw-r--r--ext/posix_mq/posix_mq.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/ext/posix_mq/posix_mq.c b/ext/posix_mq/posix_mq.c
index 01b5dbd..d59cd30 100644
--- a/ext/posix_mq/posix_mq.c
+++ b/ext/posix_mq/posix_mq.c
@@ -133,6 +133,30 @@ struct rw_args {
         struct timespec *timeout;
 };
 
+#ifndef HAVE_MQ_TIMEDSEND
+static mqd_t
+not_timedsend(mqd_t mqdes, const char *msg_ptr,
+              size_t msg_len, unsigned msg_prio,
+              const struct timespec *abs_timeout)
+{
+        rb_bug("mq_timedsend workaround failed");
+        return (mqd_t)-1;
+}
+#  define mq_timedsend not_timedsend
+#endif
+#ifndef HAVE_MQ_TIMEDRECEIVE
+static ssize_t
+not_timedreceive(mqd_t mqdes, char *msg_ptr,
+                 size_t msg_len, unsigned *msg_prio,
+                 const struct timespec *abs_timeout)
+{
+        rb_bug("mq_timedreceive workaround failed");
+        return (mqd_t)-1;
+}
+#  define mq_timedreceive not_timedreceive
+#endif
+
+#if defined(HAVE_MQ_TIMEDRECEIVE) && defined(HAVE_MQ_TIMEDSEND)
 static void num2timespec(struct timespec *ts, VALUE t)
 {
         switch (TYPE(t)) {
@@ -174,6 +198,13 @@ static void num2timespec(struct timespec *ts, VALUE t)
                 }
         }
 }
+#else
+static void num2timespec(struct timespec *ts, VALUE t)
+{
+        rb_raise(rb_eNotImpError,
+                 "mq_timedsend and/or mq_timedreceive missing");
+}
+#endif
 
 static struct timespec *convert_timeout(struct timespec *dest, VALUE t)
 {