crypt: Remove manul entry for --enable-crypt
[glibc.git] / nptl / pthread_attr_setaffinity.c
blob96a060c03943ab6b4aa54c9f50f725bd38c25062
1 /* Copyright (C) 2003-2023 Free Software Foundation, Inc.
2 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.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <errno.h>
19 #include <limits.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <pthreadP.h>
23 #include <shlib-compat.h>
26 int
27 __pthread_attr_setaffinity_np (pthread_attr_t *attr, size_t cpusetsize,
28 const cpu_set_t *cpuset)
30 struct pthread_attr *iattr;
32 iattr = (struct pthread_attr *) attr;
34 if (cpuset == NULL || cpusetsize == 0)
36 if (iattr->extension != NULL)
38 free (iattr->extension->cpuset);
39 iattr->extension->cpuset = NULL;
40 iattr->extension->cpusetsize = 0;
43 else
45 int ret = __pthread_attr_extension (iattr);
46 if (ret != 0)
47 return ret;
49 if (iattr->extension->cpusetsize != cpusetsize)
51 void *newp = realloc (iattr->extension->cpuset, cpusetsize);
52 if (newp == NULL)
53 return ENOMEM;
55 iattr->extension->cpuset = newp;
56 iattr->extension->cpusetsize = cpusetsize;
59 memcpy (iattr->extension->cpuset, cpuset, cpusetsize);
62 return 0;
64 libc_hidden_def (__pthread_attr_setaffinity_np)
65 versioned_symbol (libc, __pthread_attr_setaffinity_np,
66 pthread_attr_setaffinity_np, GLIBC_2_32);
69 #if SHLIB_COMPAT (libc, GLIBC_2_3_4, GLIBC_2_32)
70 /* Compat symbol with the old libc version. */
71 strong_alias (__pthread_attr_setaffinity_np, __pthread_attr_setaffinity_alias)
72 compat_symbol (libc, __pthread_attr_setaffinity_alias,
73 pthread_attr_setaffinity_np, GLIBC_2_3_4);
74 #endif
76 #if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
77 int
78 __pthread_attr_setaffinity_old (pthread_attr_t *attr, cpu_set_t *cpuset)
80 /* The old interface by default assumed a 1024 processor bitmap. */
81 return __pthread_attr_setaffinity_np (attr, 128, cpuset);
83 compat_symbol (libc, __pthread_attr_setaffinity_old,
84 pthread_attr_setaffinity_np, GLIBC_2_3_3);
85 #endif