GNU C Library master sources branch release/2.28/master updated. glibc-2.28-61-g1a8db07

fw@sourceware.org fw@sourceware.org
Sat Dec 15 18:09:00 GMT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.28/master has been updated
       via  1a8db070fa42276f290e20c294a51b4fc9c51f83 (commit)
      from  4d7af7815af5217db6e8fde6032ddf4f6b2a4420 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1a8db070fa42276f290e20c294a51b4fc9c51f83

commit 1a8db070fa42276f290e20c294a51b4fc9c51f83
Author: Florian Weimer <fweimer@redhat.com>
Date:   Sat Dec 15 18:58:09 2018 +0100

    support: Do not require overflow builtin in support/blob_repeat.c
    
    It is only available in GCC 5 and later.
    
    Tested-by: Romain Naour <romain.naour@gmail.com>
    (cherry picked from commit 0c1719e65b2a5a80331d4f635612799f853b0479)

diff --git a/ChangeLog b/ChangeLog
index c12b599..d845949 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-12-15  Florian Weimer  <fweimer@redhat.com>
+
+	* support/blob_repeat.c (check_mul_overflow_size_t): New function.
+	(minimum_stride_size): Use it.
+	(support_blob_repeat_allocate): Likewise.
+
 2018-12-13  Andreas Schwab  <schwab@suse.de>
 
 	[BZ #23861]
diff --git a/support/blob_repeat.c b/support/blob_repeat.c
index 16c1e44..718846d 100644
--- a/support/blob_repeat.c
+++ b/support/blob_repeat.c
@@ -34,6 +34,26 @@
    optimization because mappings carry a lot of overhead.  */
 static const size_t maximum_small_size = 4 * 1024 * 1024;
 
+/* Set *RESULT to LEFT * RIGHT.  Return true if the multiplication
+   overflowed.  See <malloc/malloc-internal.h>.  */
+static inline bool
+check_mul_overflow_size_t (size_t left, size_t right, size_t *result)
+{
+#if __GNUC__ >= 5
+  return __builtin_mul_overflow (left, right, result);
+#else
+  /* size_t is unsigned so the behavior on overflow is defined.  */
+  *result = left * right;
+  size_t half_size_t = ((size_t) 1) << (8 * sizeof (size_t) / 2);
+  if (__glibc_unlikely ((left | right) >= half_size_t))
+    {
+      if (__glibc_unlikely (right != 0 && *result / right != left))
+        return true;
+    }
+  return false;
+#endif
+}
+
 /* Internal helper for fill.  */
 static void
 fill0 (char *target, const char *element, size_t element_size,
@@ -118,8 +138,8 @@ minimum_stride_size (size_t page_size, size_t element_size)
      common multiple, it appears only once.  Therefore, shift one
      factor.  */
   size_t multiple;
-  if (__builtin_mul_overflow (page_size >> common_zeros, element_size,
-                              &multiple))
+  if (check_mul_overflow_size_t (page_size >> common_zeros, element_size,
+                                 &multiple))
     return 0;
   return multiple;
 }
@@ -255,7 +275,7 @@ support_blob_repeat_allocate (const void *element, size_t element_size,
                               size_t count)
 {
   size_t total_size;
-  if (__builtin_mul_overflow (element_size, count, &total_size))
+  if (check_mul_overflow_size_t (element_size, count, &total_size))
     {
       errno = EOVERFLOW;
       return (struct support_blob_repeat) { 0 };

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             |    6 ++++++
 support/blob_repeat.c |   26 +++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources



More information about the Glibc-cvs mailing list