dl-librecon.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Optional code to distinguish library flavours.
  2. Copyright (C) 2001-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
  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. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef _DL_LIBRECON_H
  17. #define _DL_LIBRECON_H 1
  18. static inline void __attribute__ ((unused, always_inline))
  19. _dl_osversion_init (char *assume_kernel)
  20. {
  21. unsigned long int i, j, osversion = 0;
  22. char *p = assume_kernel, *q;
  23. for (i = 0; i < 3; i++, p = q + 1)
  24. {
  25. j = _dl_strtoul (p, &q);
  26. if (j >= 255 || p == q || (i < 2 && *q && *q != '.'))
  27. {
  28. osversion = 0;
  29. break;
  30. }
  31. osversion |= j << (16 - 8 * i);
  32. if (!*q)
  33. break;
  34. }
  35. if (osversion)
  36. GLRO(dl_osversion) = osversion;
  37. }
  38. /* Recognizing extra environment variables. */
  39. #define EXTRA_LD_ENVVARS_13 \
  40. if (memcmp (envline, "ASSUME_KERNEL", 13) == 0) \
  41. { \
  42. _dl_osversion_init (&envline[14]); \
  43. break; \
  44. }
  45. #define DL_OSVERSION_INIT \
  46. do { \
  47. char *assume_kernel = getenv ("LD_ASSUME_KERNEL"); \
  48. if (assume_kernel) \
  49. _dl_osversion_init (assume_kernel); \
  50. } while (0)
  51. #endif /* dl-librecon.h */