1 /* Support for reading /etc/ld.so.cache files written by Linux ldconfig.
2 Copyright (C) 2022-2023 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 <https://www.gnu.org/licenses/>. */
22 #if defined __loongarch_double_float
23 # define _DL_CACHE_DEFAULT_ID (FLAG_LARCH_FLOAT_ABI_DOUBLE | FLAG_ELF_LIBC6)
25 # define _DL_CACHE_DEFAULT_ID (FLAG_LARCH_FLOAT_ABI_SOFT | FLAG_ELF_LIBC6)
28 #define _dl_cache_check_flags(flags) \
29 ((flags) == _DL_CACHE_DEFAULT_ID)
31 /* If given a path to one of our library directories, adds every library
32 directory via add_dir (), otherwise just adds the giver directory. On
33 LoongArch, libraries can be found in paths ending in:
36 so this will add all of those paths. */
38 #define add_system_dir(dir) \
41 static const char* lib_dirs[] = { \
46 const size_t lib_len = sizeof ("/lib") - 1; \
47 size_t len = strlen (dir); \
51 memcpy (path, dir, len + 1); \
53 for (ptr = lib_dirs; *ptr != NULL; ptr++) \
55 const char *lib_dir = *ptr; \
56 size_t dir_len = strlen (lib_dir); \
59 && !memcmp (path + len - dir_len, lib_dir, dir_len)) \
61 len -= dir_len - lib_len; \
68 && !memcmp (path + len - lib_len, "/lib", lib_len)) \
69 for (ptr = lib_dirs; *ptr != NULL; ptr++) \
71 const char *lib_dir = *ptr; \
72 size_t dir_len = strlen (lib_dir); \
74 assert (dir_len >= lib_len); \
75 memcpy (path + len, lib_dir + lib_len, \
76 dir_len - lib_len + 1); \
82 #include_next <dl-cache.h>