~ubuntu-branches/ubuntu/breezy/uclibc/breezy

« back to all changes in this revision

Viewing changes to librt/mq_open.c

  • Committer: Bazaar Package Importer
  • Author(s): David Schleef
  • Date: 2005-04-18 13:29:53 UTC
  • mfrom: (1.1.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050418132953-hzuzafmpkxuj0gvj
Tags: 0.9.27-1
* New upstream release.
* Acknowledge NMU (Closes: #268989) and fix the bug it caused
  (Closes: #284326)
* Add gross versioned dependency for gcc-3.3, and make sure we use
  gcc-3.3 in the gcc wrapper. (Closes: #304806)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * mq_open.c - open a message queue.
 
3
 */
 
4
 
 
5
#include <errno.h>
 
6
#include <stdarg.h>
 
7
#include <stddef.h>
 
8
#include <sys/syscall.h>
 
9
 
 
10
#include <mqueue.h>
 
11
 
 
12
#ifdef __NR_mq_open
 
13
 
 
14
#define __NR___syscall_mq_open __NR_mq_open
 
15
static inline _syscall4(int, __syscall_mq_open, const char *, name,
 
16
        int, oflag, __kernel_mode_t, mode, void *, attr);
 
17
/*
 
18
 * Establish connection between a process and a message queue and
 
19
 * return message queue descriptor or (mqd_t) -1 on error.
 
20
 * oflag determines the type of access used. If O_CREAT is on oflag, the
 
21
 * third argument is taken as a `mode_t', the mode of the created
 
22
 * message queue, and the fourth argument is taken as `struct mq_attr *',
 
23
 * pointer to message queue attributes.
 
24
 * If the fourth argument is NULL, default attributes are used.
 
25
 */
 
26
mqd_t mq_open(const char *name, int oflag, ...)
 
27
{
 
28
    mode_t mode;
 
29
    struct mq_attr *attr;
 
30
 
 
31
    if (name[0] != '/') {
 
32
        __set_errno(EINVAL);
 
33
        return -1;
 
34
    }
 
35
 
 
36
    mode = 0;
 
37
    attr = NULL;
 
38
 
 
39
    if (oflag & O_CREAT) {
 
40
        va_list ap;
 
41
 
 
42
        va_start(ap, oflag);
 
43
        mode = va_arg(ap, mode_t);
 
44
        attr = va_arg(ap, struct mq_attr *);
 
45
 
 
46
        va_end(ap);
 
47
    }
 
48
 
 
49
    return __syscall_mq_open(name + 1, oflag, mode, attr);
 
50
}
 
51
 
 
52
#endif