This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch RFC: Use internal qsort function in libbacktrace
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 5 Mar 2014 10:25:27 +0100
- Subject: Re: Patch RFC: Use internal qsort function in libbacktrace
- Authentication-results: sourceware.org; auth=none
- References: <mcrppm1mi78 dot fsf at iant-glaptop dot roam dot corp dot google dot com>
On Wed, Mar 5, 2014 at 4:34 AM, Ian Lance Taylor <iant@google.com> wrote:
> The GNU glibc qsort function will call malloc in some cases. That makes
> it unsuitable for libbacktrace, which is intended to work when called
> from a signal handler. This patch changes libbacktrace to use an
> internal qsort function.
>
> I'm posting this for comments in case anybody sees anything wrong with
> the implementation. I'll commit it in a day or two if I don't hear
> anything.
>
> Bootstrapped and ran libbacktrace and Go tests on
> x86_64-unknown-linux-gnu.
Doesn't it make sense to put this into libiberty and call it
sigsafe_qsort or qsort_sigsafe? (not sure if there is a standard
suffix/prefix for signal-safe variants of functions like _r is
for thread-safe variants)
Thanks,
Richard.
> Ian
>
>
> 2014-03-04 Ian Lance Taylor <iant@google.com>
>
> * sort.c: New file.
> * stest.c: New file.
> * internal.h (backtrace_qsort): Declare.
> * dwarf.c (read_abbrevs): Call backtrace_qsort instead of qsort.
> (read_line_info, read_function_entry): Likewise.
> (read_function_info, build_dwarf_data): Likewise.
> * elf.c (elf_initialize_syminfo): Likewise.
> * Makefile.am (libbacktrace_la_SOURCES): Add sort.c.
> (stest_SOURCES, stest_LDADD): Define.
> (check_PROGRAMS): Add stest.
>
>