pt-vfork.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* vfork ABI-compatibility entry points for libpthread.
  2. Copyright (C) 2014-2019 Free Software Foundation, Inc.
  3. 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.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <unistd.h>
  16. #include <shlib-compat.h>
  17. /* libpthread used to have its own vfork implementation that differed
  18. from libc's only in having a pointless micro-optimization. There
  19. is no longer any use to having a separate copy in libpthread, but
  20. the historical ABI requires it. For static linking, there is no
  21. need to provide anything here--the libc version will be linked in.
  22. For shared library ABI compatibility, there must be __vfork and
  23. vfork symbols in libpthread.so; so we define them using IFUNC to
  24. redirect to the libc function. */
  25. /* Note! If the architecture doesn't support IFUNC, then we need an
  26. alternate target-specific mechanism to implement this. So we just
  27. assume IFUNC here and require that the target override this file
  28. if necessary.
  29. If the architecture can assume all supported versions of gcc will
  30. produce a tail-call to __libc_vfork, consider including the version
  31. in sysdeps/unix/sysv/linux/aarch64/pt-vfork.c. */
  32. #if !HAVE_IFUNC
  33. # error "must write pt-vfork for this machine or get IFUNC support"
  34. #endif
  35. #if (SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20) \
  36. || SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20))
  37. extern __typeof (vfork) __libc_vfork; /* Defined in libc. */
  38. # undef INIT_ARCH
  39. # define INIT_ARCH()
  40. # define DEFINE_VFORK(name) libc_ifunc (name, &__libc_vfork)
  41. #endif
  42. #if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20)
  43. extern __typeof(vfork) vfork_ifunc;
  44. DEFINE_VFORK (vfork_ifunc)
  45. compat_symbol (libpthread, vfork_ifunc, vfork, GLIBC_2_0);
  46. #endif
  47. #if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20)
  48. extern __typeof(vfork) __vfork_ifunc;
  49. DEFINE_VFORK (__vfork_ifunc)
  50. compat_symbol (libpthread, __vfork_ifunc, __vfork, GLIBC_2_1_2);
  51. #endif