This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fix PR sanitizer/55617 via qsort - dtors part


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]