2 * Copyright (c) 2003-2007 Ulrich Drepper <drepper@redhat.com>
3 * Copyright (c) 2005-2016 Dmitry V. Levin <ldv@altlinux.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 print_node(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
34 if (elem_size < sizeof(long)) {
35 tprintf("%#0*x", (int) elem_size * 2 + 2,
36 * (unsigned int *) elem_buf);
38 tprintf("%#0*lx", (int) elem_size * 2 + 2,
39 * (unsigned long *) elem_buf);
46 print_nodemask(struct tcb *tcp, unsigned long addr, unsigned long maxnodes)
48 const unsigned long nmemb =
49 (maxnodes + 8 * current_wordsize - 2) / (8 * current_wordsize);
51 if (nmemb < maxnodes / (8 * current_wordsize) ||
52 (maxnodes && !nmemb)) {
58 print_array(tcp, addr, nmemb, &buf, current_wordsize,
59 umoven_or_printaddr, print_node, 0);
62 SYS_FUNC(migrate_pages)
64 tprintf("%d, %lu, ", (int) tcp->u_arg[0], tcp->u_arg[1]);
65 print_nodemask(tcp, tcp->u_arg[2], tcp->u_arg[1]);
67 print_nodemask(tcp, tcp->u_arg[3], tcp->u_arg[1]);
72 #include "xlat/policies.h"
73 #include "xlat/mbindflags.h"
77 printaddr(tcp->u_arg[0]);
78 tprintf(", %lu, ", tcp->u_arg[1]);
79 printxval_long(policies, tcp->u_arg[2], "MPOL_???");
81 print_nodemask(tcp, tcp->u_arg[3], tcp->u_arg[4]);
82 tprintf(", %lu, ", tcp->u_arg[4]);
83 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
88 SYS_FUNC(set_mempolicy)
90 printxval(policies, tcp->u_arg[0], "MPOL_???");
92 print_nodemask(tcp, tcp->u_arg[1], tcp->u_arg[2]);
93 tprintf(", %lu", tcp->u_arg[2]);
98 #include "xlat/mempolicyflags.h"
100 SYS_FUNC(get_mempolicy)
104 if (!umove_or_printaddr(tcp, tcp->u_arg[0], &pol)) {
106 printxval(policies, pol, "MPOL_???");
110 print_nodemask(tcp, tcp->u_arg[1], tcp->u_arg[2]);
111 tprintf(", %lu, ", tcp->u_arg[2]);
112 printaddr(tcp->u_arg[3]);
114 printflags_long(mempolicyflags, tcp->u_arg[4], "MPOL_???");
119 #include "xlat/move_pages_flags.h"
122 print_addr(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
126 if (elem_size < sizeof(long)) {
127 addr = * (unsigned int *) elem_buf;
129 addr = * (unsigned long *) elem_buf;
138 print_status(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
140 const int status = * (int *) elem_buf;
142 if (status < 0 && (unsigned) -status < nerrnos)
143 tprintf("%s", errnoent[-status]);
145 tprintf("%d", status);
151 print_int(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
153 tprintf("%d", * (int *) elem_buf);
160 const unsigned long npages = tcp->u_arg[1];
164 tprintf("%d, %lu, ", (int) tcp->u_arg[0], npages);
165 print_array(tcp, tcp->u_arg[2], npages, &buf, current_wordsize,
166 umoven_or_printaddr, print_addr, 0);
168 print_array(tcp, tcp->u_arg[3], npages, &buf, sizeof(int),
169 umoven_or_printaddr, print_int, 0);
172 print_array(tcp, tcp->u_arg[4], npages, &buf, sizeof(int),
173 umoven_or_printaddr, print_status, 0);
175 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");