OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [mq_setattr.c] - Blame information for rev 207

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* Copyright 2002, Red Hat Inc. */
2
 
3
#include <mqueue.h>
4
#include <errno.h>
5
#include <sys/sem.h>
6
#include <string.h>
7
#define _LIBC 1
8
#include <sys/lock.h>
9
#undef _LIBC
10
 
11
#include "mqlocal.h"
12
 
13
int
14
mq_setattr (mqd_t msgid, const struct mq_attr *mqstat, struct mq_attr *omqstat)
15
{
16
  struct libc_mq *info;
17
  struct sembuf sb0 = {0, -1, 0};
18
  int num_msgs;
19
  int rc = 0;
20
 
21
  info = __find_mq (msgid);
22
 
23
  if (info == NULL)
24
    {
25
      errno = EBADF;
26
      return -1;
27
    }
28
 
29
  /* temporarily lock message queue */
30
  semop (info->semid, &sb0, 1);
31
 
32
  /* make copy of old structure */
33
  if (omqstat != NULL)
34
    {
35
      num_msgs = semctl (info->semid, 3, GETVAL);
36
      if (num_msgs >= 0)
37
        {
38
          memcpy (omqstat, info->attr, sizeof(struct mq_attr));
39
          omqstat->mq_curmsgs = num_msgs;
40
        }
41
      else
42
        rc = -1;
43
    }
44
 
45
  /* only the mq_flags field can be changed */
46
  info->attr->mq_flags = mqstat->mq_flags;
47
 
48
  /* release message queue */
49
  sb0.sem_op = 1;
50
  semop (info->semid, &sb0, 1);
51
 
52
  return rc;
53
}
54
 
55
 
56
 
57
 
58
 
59
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.