mqueue2.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Checking macros for mq functions.
  2. Copyright (C) 2007 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #ifndef _FCNTL_H
  17. # error "Never include <bits/mqueue2.h> directly; use <mqueue.h> instead."
  18. #endif
  19. /* Check that calls to mq_open with O_CREAT set have an appropriate third and fourth
  20. parameter. */
  21. extern mqd_t mq_open (__const char *__name, int __oflag, ...)
  22. __THROW __nonnull ((1));
  23. extern mqd_t __mq_open_2 (__const char *__name, int __oflag) __nonnull ((1));
  24. extern mqd_t __REDIRECT (__mq_open_alias, (__const char *__name, int __oflag, ...),
  25. mq_open) __nonnull ((1));
  26. __errordecl (__mq_open_wrong_number_of_args,
  27. "mq_open can be called either with 2 or 4 arguments");
  28. __errordecl (__mq_open_missing_mode_and_attr,
  29. "mq_open with O_CREAT in second argument needs 4 arguments");
  30. __extern_always_inline mqd_t
  31. mq_open (__const char *__name, int __oflag, ...)
  32. {
  33. if (__va_arg_pack_len () != 0 && __va_arg_pack_len () != 2)
  34. __mq_open_wrong_number_of_args ();
  35. if (__builtin_constant_p (__oflag))
  36. {
  37. if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () == 0)
  38. {
  39. __mq_open_missing_mode_and_attr ();
  40. return __mq_open_2 (__name, __oflag);
  41. }
  42. return __mq_open_alias (__name, __oflag, __va_arg_pack ());
  43. }
  44. if (__va_arg_pack_len () == 0)
  45. return __mq_open_2 (__name, __oflag);
  46. return __mq_open_alias (__name, __oflag, __va_arg_pack ());
  47. }