x86: Consolidate NPTL/non versions of vfork
[glibc.git] / nptl / pt-vfork.c
blob81d1b7195bfb6f64fe05487dfbd0ec97b48dede2
1 /* vfork ABI-compatibility entry points for libpthread.
2 Copyright (C) 2014 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 <http://www.gnu.org/licenses/>. */
19 #include <unistd.h>
20 #include <shlib-compat.h>
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. */
31 #if (SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20) \
32 || SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20))
34 extern __typeof (vfork) __libc_vfork; /* Defined in libc. */
36 # ifdef HAVE_IFUNC
38 attribute_hidden __attribute__ ((used))
39 __typeof (vfork) *
40 vfork_ifunc (void)
42 return &__libc_vfork;
45 # ifdef HAVE_ASM_SET_DIRECTIVE
46 # define DEFINE_VFORK(name) \
47 asm (".set " #name ", vfork_ifunc\n" \
48 ".globl " #name "\n" \
49 ".type " #name ", %gnu_indirect_function");
50 # else
51 # define DEFINE_VFORK(name) \
52 asm (#name " = vfork_ifunc\n" \
53 ".globl " #name "\n" \
54 ".type " #name ", %gnu_indirect_function");
55 # endif
57 # else
59 attribute_hidden
60 pid_t
61 vfork_compat (void)
63 return __libc_vfork ();
66 # define DEFINE_VFORK(name) weak_alias (vfork_compat, name)
68 # endif
69 #endif
71 #if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20)
72 DEFINE_VFORK (vfork)
73 #endif
75 #if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20)
76 DEFINE_VFORK (__vfork)
77 #endif