1 /* Make sure that pthread_attr_getaffinity_np does not crash when the input
2 cpuset size is smaller than that in the attribute structure.
4 Copyright (C) 2013-2015 Free Software Foundation, Inc.
5 This file is part of the GNU C Library.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
25 #include <sys/param.h>
28 #define RETURN_IF_FAIL(f, ...) \
30 int ret = f (__VA_ARGS__); \
33 printf ("%s:%d: %s returned %d (errno = %d)\n", __FILE__, __LINE__, \
42 for (int i = 0; i < 10; i++)
45 cpu_set_t *cpuset = CPU_ALLOC (512);
46 size_t cpusetsize = CPU_ALLOC_SIZE (512);
47 CPU_ZERO_S (cpusetsize, cpuset);
49 RETURN_IF_FAIL (pthread_attr_init, &attr);
50 RETURN_IF_FAIL (pthread_attr_setaffinity_np, &attr, cpusetsize, cpuset);
53 cpuset = CPU_ALLOC (1);
54 cpusetsize = CPU_ALLOC_SIZE (1);
55 RETURN_IF_FAIL (pthread_attr_getaffinity_np, &attr, cpusetsize, cpuset);
62 #define TEST_FUNCTION do_test ()
63 #include "../test-skeleton.c"