This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
From: Ulrich Drepper <drepper@redhat.com> Date: 29 Aug 2001 19:21:14 -0700 Mark Kettenis <kettenis@wins.uva.nl> writes: > Attached you'll find a little test program that does some basic > testing of __frame_state_for. Looks good. We just need some configure magic to disable the test. I think it should be placed in the csu subdir. Here's an attempt at the configure magic. I've "tested" this in my Linux-to-Hurd cross compilation environment, which means that "make check" doesn't actually run the test. It builds fine though, and the test runs OK as a standalone program. Index: ChangeLog from Mark Kettenis <kettenis@gnu.org> * configure.in: Add test for __frame_state_for. * config.make.in (have-frame-state-for): New variable. * csu/Makefile [have-frame-state-for=yes] (tests): Add test-eh. * csu/test-eh.c: New file. Index: config.make.in =================================================================== RCS file: /cvs/glibc/libc/config.make.in,v retrieving revision 1.79 diff -u -p -r1.79 config.make.in --- config.make.in 2001/08/29 18:05:39 1.79 +++ config.make.in 2001/08/31 09:06:32 @@ -46,6 +46,7 @@ have-Bgroup = @libc_cv_Bgroup@ need-nopic-initfini = @nopic_initfini@ with-cvs = @with_cvs@ old-glibc-headers = @old_glibc_headers@ +have-frame-state-for = @libc_cv_gcc_frame_state_for@ versioning = @VERSIONING@ oldest-abi = @oldest_abi@ Index: configure.in =================================================================== RCS file: /cvs/glibc/libc/configure.in,v retrieving revision 1.326 diff -u -p -r1.326 configure.in --- configure.in 2001/08/29 18:05:56 1.326 +++ configure.in 2001/08/31 09:06:33 @@ -1373,6 +1373,12 @@ static) ;; esac +AC_CACHE_CHECK(for __frame_state_for, libc_cv_gcc_frame_state_for, + [AC_TRY_LINK(, [__frame_state_for();], + libc_cv_gcc_frame_state_for=yes, + libc_cv_gcc_frame_state_for=no)]) +AC_SUBST(libc_cv_gcc_frame_state_for) + dnl Check whether compiler understands __builtin_expect. AC_CACHE_CHECK(for __builtin_expect, libc_cv_gcc_builtin_expect, [cat > conftest.c <<EOF Index: csu/Makefile =================================================================== RCS file: /cvs/glibc/libc/csu/Makefile,v retrieving revision 1.50 diff -u -p -r1.50 Makefile --- csu/Makefile 2001/07/06 04:54:45 1.50 +++ csu/Makefile 2001/08/31 09:06:33 @@ -123,6 +123,10 @@ extra-objs += abi-note.o init.o asm-CPPFLAGS += -I$(objpfx). endif +ifeq (yes,$(have-frame-state-for)) +tests += test-eh +endif + include ../Rules # Make these in the lib pass so they're available in time to link things with. --- /dev/null Thu Feb 19 16:30:24 1998 +++ csu/test-eh.c Fri Aug 31 10:44:01 2001 @@ -0,0 +1,106 @@ +/* Tests for __frame_state_for. + Copyright (C) 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Mark Kettenis <kettenis@gnu.org>, 2001. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <search.h> +#include <stdio.h> +#include <stdlib.h> + +/* Prototype for our test function. */ +extern int do_test (int argc, char *argv[]); + +/* This defines the `main' function and some more. */ +#include <test-skeleton.c> + +struct frame_state; + +/* Not declared in any header. */ +extern struct frame_state *__frame_state_for (void *, struct frame_state *); + +/* Exit status. */ +int result = EXIT_SUCCESS; + +int +compare (const void *a, const void *b) +{ + /* 1K should be enough for all currently supported platforms. */ + struct frame_state *udata = alloca (1024); + + /* The tests below are arranged such that this function is always + called such that A or B always contains a pointer to the name of + the function being tested. */ + const char *func = *(char **) a ?: *(char **)b; + void *pc; + + puts (func); + + pc = __builtin_extract_return_addr (__builtin_return_address (0)) - 1; + if (__frame_state_for (pc, udata) == NULL) + { + fprintf (stderr, "Cannot find frame info for %s\n", func); + result = EXIT_FAILURE; + } + + return 0; +} + +int +do_test (int argc, char *argv[]) +{ + { + void *root = NULL; + char *key1 = NULL; + const char *key2 = "tsearch"; + + tsearch (&key1, &root, compare); + tsearch (&key2, &root, compare); + } + + { + const char *key = "lfind"; + const char *array[] = { key, NULL }; + int nmemb = 2; + + lfind (&key, array, &nmemb, sizeof (char), compare); + } + + { + const char *key = "lsearch"; + const char *array[] = { key, NULL }; + int nmemb = 2; + + lsearch (&key, array, &nmemb, sizeof (char), compare); + } + + { + const char *key = "bsearch"; + const char *array[] = { key, NULL }; + + bsearch (&key, array, 2, sizeof (char *), compare); + } + + { + const char *func = "qsort"; + const char *array[] = { func, NULL }; + + qsort (array, 2, sizeof (char *), compare); + } + + return result; +}
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |