version.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Copyright (C) 1992-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #include "version.h"
  15. #include <tls.h>
  16. #include <libc-abis.h>
  17. #include <gnu/libc-version.h>
  18. static const char __libc_release[] = RELEASE;
  19. static const char __libc_version[] = VERSION;
  20. static const char banner[] =
  21. "GNU C Library "PKGVERSION RELEASE" release version "VERSION".\n\
  22. Copyright (C) 2026 Free Software Foundation, Inc.\n\
  23. This is free software; see the source for copying conditions.\n\
  24. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
  25. PARTICULAR PURPOSE.\n\
  26. Compiled by GNU CC version "__VERSION__".\n"
  27. #ifdef LIBC_ABIS_STRING
  28. LIBC_ABIS_STRING
  29. #endif
  30. #ifdef __LINUX_KERNEL_VERSION_STR
  31. "Minimum supported kernel: " __LINUX_KERNEL_VERSION_STR "\n"
  32. #endif
  33. "For bug reporting instructions, please see:\n\
  34. "REPORT_BUGS_TO".\n";
  35. #include <unistd.h>
  36. extern void __libc_print_version (void) attribute_hidden;
  37. void
  38. __libc_print_version (void)
  39. {
  40. __write (STDOUT_FILENO, banner, sizeof banner - 1);
  41. }
  42. extern const char *__gnu_get_libc_release (void);
  43. const char *
  44. __gnu_get_libc_release (void)
  45. {
  46. return __libc_release;
  47. }
  48. weak_alias (__gnu_get_libc_release, gnu_get_libc_release)
  49. extern const char *__gnu_get_libc_version (void);
  50. const char *
  51. __gnu_get_libc_version (void)
  52. {
  53. return __libc_version;
  54. }
  55. weak_alias (__gnu_get_libc_version, gnu_get_libc_version)
  56. /* This function is the entry point for the shared object.
  57. Running the library as a program will get here. */
  58. extern void __libc_main (void) __attribute__ ((noreturn));
  59. void
  60. __libc_main (void)
  61. {
  62. __libc_print_version ();
  63. _exit (0);
  64. }