Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sam James <sam@gentoo.org>
To: binutils@sourceware.org, gdb-patches@sourceware.org
Cc: Sam James <sam@gentoo.org>
Subject: [PATCH] libiberty: sync with gcc
Date: Sat, 29 Jun 2024 18:17:11 +0100	[thread overview]
Message-ID: <20240629171711.2305705-1-sam@gentoo.org> (raw)

This imports the following commits from GCC as of r15-1722-g7682d115402743:
	ca2f7c84927f libiberty: Invoke D demangler when --format=auto
	94792057ad4a Fix up duplicated words mostly in comments, part 1
	20e57660e64e libiberty: Fix error return value in pex_unix_exec_child [PR113957].
	52ac4c6be866 [libiberty] remove TBAA violation in iterative_hash, improve code-gen
	53bb7145135c libiberty: Fix up libiberty_vprintf_buffer_size
	65388b28656d c++, demangle: Implement https://github.com/itanium-cxx-abi/cxx-abi/issues/148 non-proposal
---
 libiberty/ChangeLog                     | 45 +++++++++++++++++
 libiberty/cplus-dem.c                   |  2 +-
 libiberty/dyn-string.c                  |  2 +-
 libiberty/functions.texi                | 14 +++---
 libiberty/hashtab.c                     | 23 ++++-----
 libiberty/pex-unix.c                    |  2 +
 libiberty/regex.c                       |  2 +-
 libiberty/testsuite/d-demangle-expected |  5 ++
 libiberty/vprintf-support.c             | 65 ++++++++++++++++++++++---
 9 files changed, 131 insertions(+), 29 deletions(-)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 884c8b70f87..cdcd4b3ced8 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,48 @@
+2024-04-02  Tom Tromey  <tom@tromey.com>
+
+	* cplus-dem.c (cplus_demangle): Try the D demangler with
+	"auto" format.
+	* testsuite/d-demangle-expected: Add --format=auto test.
+
+2024-04-02  Jakub Jelinek  <jakub@redhat.com>
+
+	* regex.c (byte_re_match_2_internal): Fix duplicated words in comment;
+	next next -> next.
+	* dyn-string.c (dyn_string_init): Fix duplicated words in comment;
+	of of -> of.
+
+2024-02-19  Iain Sandoe  <iain@sandoe.co.uk>
+
+	PR other/113957
+	* pex-unix.c (pex_unix_exec_child): Set pid = -1 in the error
+	paths, since that is used to signal an erroneous outcome for
+	the routine.
+
+2024-02-15  Richard Biener  <rguenther@suse.de>
+
+	* hashtab.c (iterative_hash): Remove TBAA violating handling
+	of aligned little-endian case in favor of just keeping the
+	aligned case special-cased.  Use | for composing a larger word.
+
+2024-02-12  Jakub Jelinek  <jakub@redhat.com>
+
+	* vprintf-support.c (libiberty_vprintf_buffer_size): Handle
+	properly l, ll, z, t or on _WIN32 I64 modifiers for diouxX
+	and L modifier for fFgGeE.
+
+2024-01-13  Jakub Jelinek  <jakub@redhat.com>
+
+	* cp-demangle.c (FNQUAL_COMPONENT_CASE): Add case for
+	DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION.
+	(d_dump): Handle DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION.
+	(d_nested_name): Parse H after N in nested name.
+	(d_count_templates_scopes): Handle
+	DEMANGLE_COMPONENT_XOBJ_MEMBER_FUNCTION.
+	(d_print_mod): Likewise.
+	(d_print_function_type): Likewise.
+	* testsuite/demangle-expected: Add tests for explicit object
+	member functions.
+
 2023-12-05  Jakub Jelinek  <jakub@redhat.com>
 
 	* configure.ac (HAVE_X86_SHA1_HW_SUPPORT): Verify __get_cpuid and
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index 8b92946981f..ee9e84f5d6b 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -186,7 +186,7 @@ cplus_demangle (const char *mangled, int options)
   if (GNAT_DEMANGLING)
     return ada_demangle (mangled, options);
 
-  if (DLANG_DEMANGLING)
+  if (DLANG_DEMANGLING || AUTO_DEMANGLING)
     {
       ret = dlang_demangle (mangled, options);
       if (ret)
diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c
index ecd8c069984..5805c0b4ff8 100644
--- a/libiberty/dyn-string.c
+++ b/libiberty/dyn-string.c
@@ -47,7 +47,7 @@ Boston, MA 02110-1301, USA.  */
 
 /* Performs in-place initialization of a dyn_string struct.  This
    function can be used with a dyn_string struct on the stack or
-   embedded in another object.  The contents of of the string itself
+   embedded in another object.  The contents of the string itself
    are still dynamically allocated.  The string initially is capable
    of holding at least SPACE characeters, including the terminating
    NUL.  If SPACE is 0, it will silently be increated to 1.  
diff --git a/libiberty/functions.texi b/libiberty/functions.texi
index 651b169b040..b56b02e0686 100644
--- a/libiberty/functions.texi
+++ b/libiberty/functions.texi
@@ -165,7 +165,7 @@ not recommended.
 
 @end deftypefn
 
-@c make-temp-file.c:108
+@c make-temp-file.c:95
 @deftypefn Replacement const char* choose_tmpdir ()
 
 Returns a pointer to a directory path suitable for creating temporary
@@ -192,7 +192,7 @@ Concatenate zero or more of strings and return the result in freshly
 
 @end deftypefn
 
-@c argv.c:485
+@c argv.c:495
 @deftypefn Extension int countargv (char * const *@var{argv})
 
 Return the number of elements in @var{argv}.
@@ -257,7 +257,7 @@ symbolic name or message.
 
 @end deftypefn
 
-@c argv.c:339
+@c argv.c:352
 @deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp})
 
 The @var{argcp} and @code{argvp} arguments are pointers to the usual
@@ -726,7 +726,7 @@ relative prefix can be found, return @code{NULL}.
 
 @end deftypefn
 
-@c make-temp-file.c:185
+@c make-temp-file.c:173
 @deftypefn Replacement char* make_temp_file (const char *@var{suffix})
 
 Return a temporary file name (as a string) or @code{NULL} if unable to
@@ -1747,7 +1747,7 @@ that the converted value is unsigned.
 @c strtoll.c:33
 @deftypefn Supplemental {long long int} strtoll (const char *@var{string}, @
   char **@var{endptr}, int @var{base})
-@deftypefnx Supplemental {unsigned long long int} strtoul (@
+@deftypefnx Supplemental {unsigned long long int} strtoull (@
   const char *@var{string}, char **@var{endptr}, int @var{base})
 
 The @code{strtoll} function converts the string in @var{string} to a
@@ -1938,8 +1938,8 @@ does the return value.  The third argument is unused in @libib{}.
 @deftypefn Extension int writeargv (char * const *@var{argv}, FILE *@var{file})
 
 Write each member of ARGV, handling all necessary quoting, to the file
-associated with FILE, separated by whitespace.  Return 0 on success,
-non-zero if an error occurred while writing to FILE.
+named by FILE, separated by whitespace.  Return 0 on success, non-zero
+if an error occurred while writing to FILE.
 
 @end deftypefn
 
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index 48f28078114..e3a07256a30 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -940,26 +940,23 @@ iterative_hash (const void *k_in /* the key */,
   c = initval;           /* the previous hash value */
 
   /*---------------------------------------- handle most of the key */
-#ifndef WORDS_BIGENDIAN
-  /* On a little-endian machine, if the data is 4-byte aligned we can hash
-     by word for better speed.  This gives nondeterministic results on
-     big-endian machines.  */
-  if (sizeof (hashval_t) == 4 && (((size_t)k)&3) == 0)
-    while (len >= 12)    /* aligned */
+  /* Provide specialization for the aligned case for targets that cannot
+     efficiently perform misaligned loads of a merged access.  */
+  if ((((size_t)k)&3) == 0)
+    while (len >= 12)
       {
-	a += *(hashval_t *)(k+0);
-	b += *(hashval_t *)(k+4);
-	c += *(hashval_t *)(k+8);
+	a += (k[0] | ((hashval_t)k[1]<<8) | ((hashval_t)k[2]<<16) | ((hashval_t)k[3]<<24));
+	b += (k[4] | ((hashval_t)k[5]<<8) | ((hashval_t)k[6]<<16) | ((hashval_t)k[7]<<24));
+	c += (k[8] | ((hashval_t)k[9]<<8) | ((hashval_t)k[10]<<16)| ((hashval_t)k[11]<<24));
 	mix(a,b,c);
 	k += 12; len -= 12;
       }
   else /* unaligned */
-#endif
     while (len >= 12)
       {
-	a += (k[0] +((hashval_t)k[1]<<8) +((hashval_t)k[2]<<16) +((hashval_t)k[3]<<24));
-	b += (k[4] +((hashval_t)k[5]<<8) +((hashval_t)k[6]<<16) +((hashval_t)k[7]<<24));
-	c += (k[8] +((hashval_t)k[9]<<8) +((hashval_t)k[10]<<16)+((hashval_t)k[11]<<24));
+	a += (k[0] | ((hashval_t)k[1]<<8) | ((hashval_t)k[2]<<16) | ((hashval_t)k[3]<<24));
+	b += (k[4] | ((hashval_t)k[5]<<8) | ((hashval_t)k[6]<<16) | ((hashval_t)k[7]<<24));
+	c += (k[8] | ((hashval_t)k[9]<<8) | ((hashval_t)k[10]<<16)| ((hashval_t)k[11]<<24));
 	mix(a,b,c);
 	k += 12; len -= 12;
       }
diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c
index af98062a94c..f3a1cc95ada 100644
--- a/libiberty/pex-unix.c
+++ b/libiberty/pex-unix.c
@@ -695,6 +695,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED,
 	{
 	  *err = ret;
 	  *errmsg = "posix_spawnp";
+	  pid = -1; /* The value of pid is unspecified on failure.  */
 	  goto exit;
 	}
     }
@@ -705,6 +706,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED,
 	{
 	  *err = ret;
 	  *errmsg = "posix_spawn";
+	  pid = -1;
 	  goto exit;
 	}
     }
diff --git a/libiberty/regex.c b/libiberty/regex.c
index 4841c5a08f9..67747e6ce5a 100644
--- a/libiberty/regex.c
+++ b/libiberty/regex.c
@@ -5597,7 +5597,7 @@ byte_re_match_2_internal (struct re_pattern_buffer *bufp,
      to resume scanning the pattern; the second one is where to resume
      scanning the strings.  If the latter is zero, the failure point is
      a ``dummy''; if a failure happens and the failure point is a dummy,
-     it gets discarded and the next next one is tried.  */
+     it gets discarded and the next one is tried.  */
 #ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global.  */
   PREFIX(fail_stack_type) fail_stack;
 #endif
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 47b059c4298..cfbdf2a52cb 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -1470,3 +1470,8 @@ demangle.anonymous
 --format=dlang
 _D8demangle9anonymous03fooZ
 demangle.anonymous.foo
+#
+# Test that 'auto' works.
+--format=auto
+_D8demangle9anonymous03fooZ
+demangle.anonymous.foo
diff --git a/libiberty/vprintf-support.c b/libiberty/vprintf-support.c
index b590e5ab034..0543ec0554e 100644
--- a/libiberty/vprintf-support.c
+++ b/libiberty/vprintf-support.c
@@ -56,6 +56,7 @@ libiberty_vprintf_buffer_size (const char *format, va_list args)
     {
       if (*p++ == '%')
 	{
+	  int prec = 0;
 	  while (strchr ("-+ #0", *p))
 	    ++p;
 	  if (*p == '*')
@@ -76,8 +77,43 @@ libiberty_vprintf_buffer_size (const char *format, va_list args)
 	      else
 	      total_width += strtoul (p, (char **) &p, 10);
 	    }
-	  while (strchr ("hlL", *p))
-	    ++p;
+	  do
+	    {
+	      switch (*p)
+		{
+		case 'h':
+		  ++p;
+		  continue;
+		case 'l':
+		case 'L':
+		  ++prec;
+		  ++p;
+		  continue;
+		case 'z':
+		  prec = 3;
+		  ++p;
+		  continue;
+		case 't':
+		  prec = 4;
+		  ++p;
+		  continue;
+#ifdef _WIN32
+		case 'I':
+		  if (p[1] == '6' && p[2] == '4')
+		    {
+		      prec = 2;
+		      p += 3;
+		      continue;
+		    }
+		  break;
+#endif
+		default:
+		  break;
+		}
+	      break;
+	    }
+	  while (1);
+
 	  /* Should be big enough for any format specifier except %s and floats.  */
 	  total_width += 30;
 	  switch (*p)
@@ -88,6 +124,15 @@ libiberty_vprintf_buffer_size (const char *format, va_list args)
 	    case 'u':
 	    case 'x':
 	    case 'X':
+	      switch (prec)
+		{
+		case 0: (void) va_arg (ap, int); break;
+		case 1: (void) va_arg (ap, long int); break;
+		case 2: (void) va_arg (ap, long long int); break;
+		case 3: (void) va_arg (ap, size_t); break;
+		case 4: (void) va_arg (ap, ptrdiff_t); break;
+		}
+	      break;
 	    case 'c':
 	      (void) va_arg (ap, int);
 	      break;
@@ -96,10 +141,18 @@ libiberty_vprintf_buffer_size (const char *format, va_list args)
 	    case 'E':
 	    case 'g':
 	    case 'G':
-	      (void) va_arg (ap, double);
-	      /* Since an ieee double can have an exponent of 307, we'll
-		 make the buffer wide enough to cover the gross case. */
-	      total_width += 307;
+	      if (!prec)
+		{
+		  (void) va_arg (ap, double);
+		  /* Since an ieee double can have an exponent of 308, we'll
+		     make the buffer wide enough to cover the gross case. */
+		  total_width += 308;
+		}
+	      else
+		{
+		  (void) va_arg (ap, long double);
+		  total_width += 4932;
+		}
 	      break;
 	    case 's':
 	      total_width += strlen (va_arg (ap, char *));
-- 
2.45.2


             reply	other threads:[~2024-06-29 17:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-29 17:17 Sam James [this message]
2024-07-12  7:55 ` Sam James
2024-07-12  8:06   ` Nick Clifton
2024-07-12 21:49     ` Sam James
2024-08-20 17:01 Andrew Burgess
2024-09-04 16:07 ` Andrew Burgess
2024-11-18  6:02 Sam James
2024-11-22 15:30 ` Tom Tromey
2024-11-22 15:46   ` Sam James
2024-11-22 23:43     ` Tom Tromey
2025-05-14 11:49 Andreas Schwab
2025-07-10 13:30 Matthieu Longo
2025-07-23 17:36 ` Tom Tromey
2025-07-25  9:17   ` Matthieu Longo

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=20240629171711.2305705-1-sam@gentoo.org \
    --to=sam@gentoo.org \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    /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