summaryrefslogtreecommitdiff
path: root/print_mq_attr.c
blob: 6a0da15f72dd6f422581f56399c2356d3202aad5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright (c) 2004 Ulrich Drepper <drepper@redhat.com>
 * Copyright (c) 2005-2015 Dmitry V. Levin <ldv@strace.io>
 * Copyright (c) 2015-2018 The strace developers.
 * All rights reserved.
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "defs.h"

#include DEF_MPERS_TYPE(mq_attr_t)

#ifdef HAVE_MQUEUE_H
# include <mqueue.h>
typedef struct mq_attr mq_attr_t;
#elif defined HAVE_LINUX_MQUEUE_H
# include <linux/types.h>
# include <linux/mqueue.h>
typedef struct mq_attr mq_attr_t;
#endif

#include MPERS_DEFS

#include "xlat/mq_attr_flags.h"

MPERS_PRINTER_DECL(void, printmqattr, struct tcb *const tcp,
		   const kernel_ulong_t addr, const bool decode_flags)
{
#if defined HAVE_MQUEUE_H || defined HAVE_LINUX_MQUEUE_H
	mq_attr_t attr;
	if (umove_or_printaddr(tcp, addr, &attr))
		return;
	if (decode_flags) {
		tprint_struct_begin();
		PRINT_FIELD_FLAGS(attr, mq_flags, mq_attr_flags, "O_???");
	} else {
		tprint_struct_begin();
		PRINT_FIELD_X(attr, mq_flags);
	}
	tprint_struct_next();
	PRINT_FIELD_D(attr, mq_maxmsg);
	tprint_struct_next();
	PRINT_FIELD_D(attr, mq_msgsize);
	tprint_struct_next();
	PRINT_FIELD_D(attr, mq_curmsgs);
	tprint_struct_end();
#else
	printaddr(addr);
#endif
}