1 /* Copyright (C) 2006-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2006.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
32 size_t ps
= sysconf (_SC_PAGESIZE
);
37 half
= (half
>> 1) & ~(uintptr_t) (ps
- 1);
38 buf
= mmap ((void *) half
, 2 * ps
, PROT_READ
| PROT_WRITE
,
39 MAP_PRIVATE
| MAP_ANON
, -1, 0);
40 if (buf
== MAP_FAILED
|| buf
!= (void *) half
)
42 puts ("Couldn't mmap 2 pages in the middle of address space");
46 xdrmem_create (&xdrs
, (char *) buf
, 2 * ps
, XDR_ENCODE
);
48 #define T(type, val) \
50 if (! xdr_##type (&xdrs, &v_##type)) \
52 puts ("encoding of " #type \
53 " " #val " failed"); \
59 u_int pos
= xdr_getpos (&xdrs
);
63 if (! xdr_setpos (&xdrs
, pos
))
65 puts ("xdr_setpos during encoding failed");
75 xdrmem_create (&xdrs
, (char *) buf
, 2 * ps
, XDR_DECODE
);
77 #define T(type, val) \
79 if (! xdr_##type (&xdrs, &v_##type)) \
81 puts ("decoding of " #type \
82 " " #val " failed"); \
85 if (v_##type != val) \
87 puts ("decoded value differs, " \
88 "type " #type " " #val); \
94 pos
= xdr_getpos (&xdrs
);
98 if (! xdr_setpos (&xdrs
, pos
))
100 puts ("xdr_setpos during encoding failed");
113 #define TEST_FUNCTION do_test ()
114 #include "../test-skeleton.c"