Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jeff Law <jeffrey.law@oss.qualcomm.com>
To: Jan Dubiec <jdx@o2.pl>, gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH v2] H8/300: sim: Fix simulator hang caused by qsort on Windows/MinGW
Date: Tue, 1 Sep 2026 21:47:26 -0600	[thread overview]
Message-ID: <fa3ce41f-5333-43ff-8c2e-82c07e283b73@oss.qualcomm.com> (raw)
In-Reply-To: <20260901071022.1682657-1-jdx@o2.pl>



On 9/1/26 1:05 AM, Jan Dubiec wrote:
> On Windows, qsort() uses an unstable sorting algorithm, which results
> in a "shuffled" opcode table rather than a properly sorted one, causing
> the entire simulator to hang.
>
> The simulator happens to work on Linux, but this behavior is not
> guaranteed, because the glibc documentation clearly states that "If
> two elements compare equal, their order after sorting is unpredictable."
>
> This patch introduces two additional sort keys to the instruction
> comparator function, making the resulting opcode table as close as
> possible to the one that would be produced by a stable sorting algorithm.
Looks sensible to me (I believe the code in question is mine).  I'm not 
sure what privs I've got for the H8 in the sim repo these days. So wait 
for other feedback rather than pushing immediately.

One class of pure formatting nit you should probably fix:


> +
> +  /* The 3rd sort key  */
> +  cmp = strcmp(p1->name, p2->name);
GNU style guidelines require a space between the function name and the 
open paren for the argument list.  The same nit appears several times in 
this patch (strlen, strchr, strncmp calls)

Jeff

  reply	other threads:[~2026-09-02  3:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  7:05 Jan Dubiec
2026-09-02  3:47 ` Jeff Law [this message]
2026-09-02  8:30   ` Jan Dubiec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa3ce41f-5333-43ff-8c2e-82c07e283b73@oss.qualcomm.com \
    --to=jeffrey.law@oss.qualcomm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jdx@o2.pl \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox