This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fix PR sanitizer/55617 via qsort - dtors part
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jack Howarth <howarth at bromo dot med dot uc dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, glider at google dot com, dodji at redhat dot com, kcc at google dot com, dvyukov at google dot com, mikestump at comcast dot net, iain at codesourcery dot com
- Date: Mon, 4 Feb 2013 23:41:42 +0100
- Subject: Re: [PATCH] fix PR sanitizer/55617 via qsort - dtors part
- References: <20130204215802.GA25355@bromo.med.uc.edu>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Feb 04, 2013 at 04:58:02PM -0500, Jack Howarth wrote:
> --- gcc/config/darwin.c (revision 195735)
> +++ gcc/config/darwin.c (working copy)
> @@ -89,7 +89,14 @@ typedef struct GTY(()) ctor_record {
> int position; /* original position */
> } ctor_record;
>
> +typedef struct GTY(()) dtor_record {
> + rtx symbol;
> + int priority; /* destructor priority */
> + int position; /* original position */
> +} dtor_record;
The type is the same, so I'd just rename ctor_record to cdtor_record
or similar.
> @@ -1740,6 +1758,22 @@ sort_ctor_records (const void * a, const
> return 0;
> }
>
> +static int
> +sort_dtor_records (const void * a, const void * b)
> +{
> + const dtor_record *da = (const dtor_record *)a;
> + const dtor_record *db = (const dtor_record *)b;
> + if (da->priority > db->priority)
> + return 1;
> + if (da->priority < db->priority)
> + return -1;
> + if (da->position > db->position)
> + return 1;
> + if (da->position < db->position)
> + return -1;
> + return 0;
> +}
And with that you don't need a new comparison function.
> static void
> finalize_ctors()
Please fix up formatting, missing space before (.
> {
> @@ -1760,18 +1794,24 @@ finalize_ctors()
> }
> }
>
> -void
> -machopic_asm_out_destructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
> +static void
> +finalize_dtors()
And here too.
Jakub