diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-02-22 16:46:26 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-02-22 16:46:26 -0800 |
commit | 3a8a20d685dbfb500187099d76e56e848ad347ed (patch) | |
tree | e70d7bca1b7b60f8dfb731971fb92d65d09af42c /ext/posix_mq | |
parent | c4c4554c3ceef9208fe7f8473b970e9f522ab9b9 (diff) | |
download | ruby_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')
-rw-r--r-- | ext/posix_mq/extconf.rb | 3 | ||||
-rw-r--r-- | ext/posix_mq/posix_mq.c | 31 |
2 files changed, 34 insertions, 0 deletions
diff --git a/ext/posix_mq/extconf.rb b/ext/posix_mq/extconf.rb index ed119a3..310de3d 100644 --- a/ext/posix_mq/extconf.rb +++ b/ext/posix_mq/extconf.rb @@ -10,4 +10,7 @@ have_func('rb_thread_blocking_region') have_library("m") have_library("rt") have_library("pthread") + +have_func("mq_timedsend") +have_func("mq_timedreceive") create_makefile("posix_mq_ext") 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) { |