1 /* Test for the long double redirections in error* functions
2 when they are returned as function pointer BZ #29033.
3 Copyright (C) 2023 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
27 #include <sys/cdefs.h>
29 #include <support/capture_subprocess.h>
30 #include <support/check.h>
31 #include <support/xdlfcn.h>
33 #if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
34 # define LDBL_NAME(alias) "__" #alias "ieee128"
35 #elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
36 # define LDBL_NAME(alias) "__nldbl_" #alias
38 # define LDBL_NAME(alias) #alias
41 typedef void (*error_func_t
) (int, int, const char*, ...);
42 typedef void (*error_at_line_func_t
) (int, int, const char*,
43 unsigned int, const char*, ...);
46 __attribute__ ((noinline
))
47 get_error_func (void) {
52 __attribute__ ((noinline
))
53 get_error_at_line_func (void) {
54 return &error_at_line
;
60 /* Prepare the symbol names as per long double standards */
61 char *error_sym
= NULL
;
62 char *error_sym_at_line
= NULL
;
63 error_sym
= (char *) LDBL_NAME(error
);
64 error_sym_at_line
= (char *) LDBL_NAME(error_at_line
);
65 TEST_VERIFY (error_sym
!= NULL
&& error_sym_at_line
!= NULL
);
66 /* Map the function pointers to appropriate redirected error symbols */
68 fp
= get_error_func ();
69 if (fp
!= xdlsym (RTLD_DEFAULT
, error_sym
))
71 printf ("FAIL: fp=%p error_sym=%p\n", fp
, error_sym
);
75 error_at_line_func_t fpat
;
76 fpat
= get_error_at_line_func ();
77 if (fpat
!= xdlsym (RTLD_DEFAULT
, error_sym_at_line
))
79 printf ("FAIL: fpat=%p error_sym_at_line=%p\n",
80 fpat
, error_sym_at_line
);
87 #include <support/test-driver.c>