New test to expose erroneous negative sign on logb(1) (bug 887).
[glibc.git] / elf / dl-dst.h
blob3663f59ef9d85e28ddcc20676ee117c8693213bf
1 /* Handling of dynamic sring tokens.
2 Copyright (C) 1999,2001-2004,2006,2007,2011 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 <http://www.gnu.org/licenses/>. */
19 #include "trusted-dirs.h"
21 /* Determine the number of DST elements in the name. Only if IS_PATH is
22 nonzero paths are recognized (i.e., multiple, ':' separated filenames). */
23 #define DL_DST_COUNT(name, is_path) \
24 ({ \
25 size_t __cnt = 0; \
26 const char *__sf = strchr (name, '$'); \
28 if (__builtin_expect (__sf != NULL, 0)) \
29 __cnt = _dl_dst_count (__sf, is_path); \
31 __cnt; })
34 #ifdef SHARED
35 # define IS_RTLD(l) (l) == &GL(dl_rtld_map)
36 #else
37 # define IS_RTLD(l) 0
38 #endif
39 /* Guess from the number of DSTs the length of the result string. */
40 #define DL_DST_REQUIRED(l, name, len, cnt) \
41 ({ \
42 size_t __len = (len); \
43 size_t __cnt = (cnt); \
45 if (__cnt > 0) \
46 { \
47 size_t dst_len; \
48 /* Now we make a guess how many extra characters on top of the \
49 length of S we need to represent the result. We know that \
50 we have CNT replacements. Each at most can use \
51 MAX (MAX (strlen (ORIGIN), strlen (_dl_platform)), \
52 strlen (DL_DST_LIB)) \
53 minus 4 (which is the length of "$LIB"). \
55 First get the origin string if it is not available yet. \
56 This can only happen for the map of the executable or, when \
57 auditing, in ld.so. */ \
58 DL_DST_REQ_STATIC (l) \
59 if ((l)->l_origin == NULL) \
60 { \
61 assert ((l)->l_name[0] == '\0' || IS_RTLD (l)); \
62 (l)->l_origin = _dl_get_origin (); \
63 dst_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \
64 ? strlen ((l)->l_origin) : 0); \
65 } \
66 else \
67 dst_len = (l)->l_origin == (char *) -1 \
68 ? 0 : strlen ((l)->l_origin); \
69 dst_len = MAX (MAX (dst_len, GLRO(dl_platformlen)), \
70 strlen (DL_DST_LIB)); \
71 if (dst_len > 4) \
72 __len += __cnt * (dst_len - 4); \
73 } \
75 __len; })
77 #ifdef SHARED
78 # define DL_DST_REQ_STATIC(l) /* nothing */
79 #else
80 # define DL_DST_REQ_STATIC(l) \
81 if ((l) == NULL) \
82 { \
83 const char *origin = _dl_get_origin (); \
84 dst_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \
85 } \
86 else
87 #endif