]> git.ipfire.org Git - thirdparty/glibc.git/blame - nptl/pt-vfork.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nptl / pt-vfork.c
CommitLineData
5675da1e 1/* vfork ABI-compatibility entry points for libpthread.
b168057a 2 Copyright (C) 2014-2015 Free Software Foundation, Inc.
5675da1e
RM
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19#include <unistd.h>
20#include <shlib-compat.h>
21
22/* libpthread used to have its own vfork implementation that differed
23 from libc's only in having a pointless micro-optimization. There
24 is no longer any use to having a separate copy in libpthread, but
25 the historical ABI requires it. For static linking, there is no
26 need to provide anything here--the libc version will be linked in.
27 For shared library ABI compatibility, there must be __vfork and
28 vfork symbols in libpthread.so; so we define them using IFUNC to
29 redirect to the libc function. */
30
8820e3ac
RH
31/* Note! If the architecture doesn't support IFUNC, then we need an
32 alternate target-specific mechanism to implement this. So we just
33 assume IFUNC here and require that the target override this file
34 if necessary.
35
36 If the architecture can assume all supported versions of gcc will
37 produce a tail-call to __libc_vfork, consider including the version
38 in sysdeps/unix/sysv/linux/aarch64/pt-vfork.c. */
39
40#if !HAVE_IFUNC
41# error "must write pt-vfork for this machine or get IFUNC support"
42#endif
43
5675da1e
RM
44#if (SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20) \
45 || SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20))
46
47extern __typeof (vfork) __libc_vfork; /* Defined in libc. */
48
900e445f
RH
49static __typeof (vfork) *
50__attribute__ ((used))
51vfork_resolve (void)
5675da1e
RM
52{
53 return &__libc_vfork;
54}
55
8820e3ac
RH
56# ifdef HAVE_ASM_SET_DIRECTIVE
57# define DEFINE_VFORK(name) \
900e445f 58 asm (".set " #name ", vfork_resolve\n" \
5675da1e
RM
59 ".globl " #name "\n" \
60 ".type " #name ", %gnu_indirect_function");
8820e3ac
RH
61# else
62# define DEFINE_VFORK(name) \
900e445f 63 asm (#name " = vfork_resolve\n" \
5675da1e
RM
64 ".globl " #name "\n" \
65 ".type " #name ", %gnu_indirect_function");
5675da1e
RM
66# endif
67#endif
68
69#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20)
900e445f
RH
70DEFINE_VFORK (vfork_ifunc)
71compat_symbol (libpthread, vfork_ifunc, vfork, GLIBC_2_0);
5675da1e
RM
72#endif
73
74#if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20)
900e445f
RH
75DEFINE_VFORK (__vfork_ifunc)
76compat_symbol (libpthread, __vfork_ifunc, __vfork, GLIBC_2_1_2);
5675da1e 77#endif