* sysdeps/m68k/fpu/bits/mathinline.h: Don't define log2 as inline.
[glibc.git] / elf / dl-dst.h
blob5d19922e4c0f01e587d9db86dd9834b2147efe5b
1 /* Handling of dynamic sring tokens.
2 Copyright (C) 1999, 2001 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 /* Determine the number of DST elements in the name. Only if IS_PATH is
21 nonzero paths are recognized (i.e., multiple, ':' separated filenames). */
22 #define DL_DST_COUNT(name, is_path) \
23 ({ \
24 size_t __cnt = 0; \
25 const char *__sf = strchr (name, '$'); \
27 if (__builtin_expect (__sf != NULL, 0)) \
28 __cnt = _dl_dst_count (__sf, is_path); \
30 __cnt; })
32 /* Prototype for used function. */
33 extern size_t _dl_dst_count (const char *name, int is_path);
36 /* Guess from the number of DSTs the length of the result string. */
37 #define DL_DST_REQUIRED(l, name, len, cnt) \
38 ({ \
39 size_t origin_len; \
40 size_t __len = (len); \
42 /* Now we make a guess how many extra characters on top of the length \
43 of S we need to represent the result. We know that we have CNT \
44 replacements. Each at most can use \
45 MAX (strlen (ORIGIN), strlen (_dl_platform)) \
46 minus 7 (which is the length of "$ORIGIN"). \
48 First get the origin string if it is not available yet. This can \
49 only happen for the map of the executable. */ \
50 if ((l)->l_origin == NULL) \
51 { \
52 assert ((l)->l_name[0] == '\0'); \
53 (l)->l_origin = _dl_get_origin (); \
54 origin_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \
55 ? strlen ((l)->l_origin) : 0); \
56 } \
57 else \
58 origin_len = (l)->l_origin == (char *) -1 ? 0 : strlen ((l)->l_origin); \
60 __len + cnt * (MAX (origin_len, _dl_platformlen) - 7); })
62 /* Find origin of the executable. */
63 extern const char *_dl_get_origin (void);
66 /* Perform the DST substitution. */
67 #define DL_DST_SUBSTITUTE(l, name, res, is_path) \
68 _dl_dst_substitute (l, name, res, is_path)
70 /* Prototype for used function. */
71 extern char *_dl_dst_substitute (struct link_map *l, const char *name,
72 char *result, int is_path);