1 /* Deep copy of a pthread_attr_t object.
2 Copyright (C) 2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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 <https://www.gnu.org/licenses/>. */
24 __pthread_attr_copy (pthread_attr_t
*target
, const pthread_attr_t
*source
)
26 /* Avoid overwriting *TARGET until all allocations have
28 union pthread_attr_transparent temp
;
29 temp
.external
= *source
;
31 /* Force new allocation. This function has full ownership of temp. */
32 temp
.internal
.cpuset
= NULL
;
33 temp
.internal
.cpusetsize
= 0;
37 struct pthread_attr
*isource
= (struct pthread_attr
*) source
;
39 /* Propagate affinity mask information. */
40 if (isource
->cpusetsize
> 0)
41 ret
= __pthread_attr_setaffinity_np (&temp
.external
,
47 /* Deallocate because we have ownership. */
48 __pthread_attr_destroy (&temp
.external
);
52 /* Transfer ownership. *target is not assumed to have been
54 *target
= temp
.external
;
57 libc_hidden_def (__pthread_attr_copy
)