Title: [232599] trunk/Source/bmalloc
Revision
232599
Author
[email protected]
Date
2018-06-07 14:05:29 -0700 (Thu, 07 Jun 2018)

Log Message

bmalloc: Fix 'noreturn' warnings when compiling with -std=gnu++17
<https://webkit.org/b/186400>

Reviewed by Saam Barati.

Fixes the following warnings when compiling with gnu++17:

    Source/bmalloc/bmalloc/Scavenger.cpp:363:1: error: function 'threadRunLoop' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
    {
    ^
    Source/bmalloc/bmalloc/Scavenger.cpp:358:1: error: function 'threadEntryPoint' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
    {
    ^

* bmalloc/BCompiler.h:
(BCOMPILER): Add support for the BCOMPILER() macro, then add
BCOMPILER(GCC_OR_CLANG).  Taken from Source/WTF/wtf/Compiler.h.
(BNO_RETURN): Implement 'norerturn' support using the new
BCOMPILER() macros.  Taken from Source/WTF/wtf/Compiler.h.
* bmalloc/Scavenger.cpp:
(bmalloc::Scavenger::threadRunLoop): Remove the workaround that
tricked older compilers into thinking the while() loop wasn't
infinite.
* bmalloc/Scavenger.h:
(bmalloc::Scavenger::threadEntryPoint): Add BNO_RETURN attribute.
(bmalloc::Scavenger::threadRunLoop): Ditto.

Modified Paths

Diff

Modified: trunk/Source/bmalloc/ChangeLog (232598 => 232599)


--- trunk/Source/bmalloc/ChangeLog	2018-06-07 21:01:19 UTC (rev 232598)
+++ trunk/Source/bmalloc/ChangeLog	2018-06-07 21:05:29 UTC (rev 232599)
@@ -1,3 +1,32 @@
+2018-06-07  David Kilzer  <[email protected]>
+
+        bmalloc: Fix 'noreturn' warnings when compiling with -std=gnu++17
+        <https://webkit.org/b/186400>
+
+        Reviewed by Saam Barati.
+
+        Fixes the following warnings when compiling with gnu++17:
+
+            Source/bmalloc/bmalloc/Scavenger.cpp:363:1: error: function 'threadRunLoop' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
+            {
+            ^
+            Source/bmalloc/bmalloc/Scavenger.cpp:358:1: error: function 'threadEntryPoint' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
+            {
+            ^
+
+        * bmalloc/BCompiler.h:
+        (BCOMPILER): Add support for the BCOMPILER() macro, then add
+        BCOMPILER(GCC_OR_CLANG).  Taken from Source/WTF/wtf/Compiler.h.
+        (BNO_RETURN): Implement 'norerturn' support using the new
+        BCOMPILER() macros.  Taken from Source/WTF/wtf/Compiler.h.
+        * bmalloc/Scavenger.cpp:
+        (bmalloc::Scavenger::threadRunLoop): Remove the workaround that
+        tricked older compilers into thinking the while() loop wasn't
+        infinite.
+        * bmalloc/Scavenger.h:
+        (bmalloc::Scavenger::threadEntryPoint): Add BNO_RETURN attribute.
+        (bmalloc::Scavenger::threadRunLoop): Ditto.
+
 2018-05-29  Saam Barati  <[email protected]>
 
         JSC should put bmalloc's scavenger into mini mode

Modified: trunk/Source/bmalloc/bmalloc/BCompiler.h (232598 => 232599)


--- trunk/Source/bmalloc/bmalloc/BCompiler.h	2018-06-07 21:01:19 UTC (rev 232598)
+++ trunk/Source/bmalloc/bmalloc/BCompiler.h	2018-06-07 21:05:29 UTC (rev 232599)
@@ -25,6 +25,9 @@
 
 #pragma once
 
+/* BCOMPILER() - the compiler being used to build the project */
+#define BCOMPILER(BFEATURE) (defined BCOMPILER_##BFEATURE && BCOMPILER_##BFEATURE)
+
 /* BCOMPILER_HAS_CLANG_FEATURE() - whether the compiler supports a particular language or library feature. */
 /* http://clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension */
 #ifdef __has_feature
@@ -35,3 +38,19 @@
 
 #define BASAN_ENABLED BCOMPILER_HAS_CLANG_FEATURE(address_sanitizer)
 
+/* BCOMPILER(GCC_OR_CLANG) - GNU Compiler Collection or Clang */
+
+#if defined(__GNUC__)
+#define BCOMPILER_GCC_OR_CLANG 1
+#endif
+
+/* BNO_RETURN */
+
+#if !defined(BNO_RETURN) && BCOMPILER(GCC_OR_CLANG)
+#define BNO_RETURN __attribute((__noreturn__))
+#endif
+
+#if !defined(BNO_RETURN)
+#define BNO_RETURN
+#endif
+

Modified: trunk/Source/bmalloc/bmalloc/Scavenger.cpp (232598 => 232599)


--- trunk/Source/bmalloc/bmalloc/Scavenger.cpp	2018-06-07 21:01:19 UTC (rev 232598)
+++ trunk/Source/bmalloc/bmalloc/Scavenger.cpp	2018-06-07 21:05:29 UTC (rev 232599)
@@ -374,9 +374,7 @@
     // We require any state change while we are sleeping to signal to our
     // condition variable and wake us up.
     
-    auto truth = [] { return true; };
-    
-    while (truth()) {
+    while (true) {
         if (m_state == State::Sleep) {
             std::unique_lock<Mutex> lock(m_mutex);
             m_condition.wait(lock, [&]() { return m_state != State::Sleep; });

Modified: trunk/Source/bmalloc/bmalloc/Scavenger.h (232598 => 232599)


--- trunk/Source/bmalloc/bmalloc/Scavenger.h	2018-06-07 21:01:19 UTC (rev 232598)
+++ trunk/Source/bmalloc/bmalloc/Scavenger.h	2018-06-07 21:05:29 UTC (rev 232599)
@@ -82,8 +82,8 @@
 
     void scheduleIfUnderMemoryPressureHoldingLock(size_t bytes);
 
-    static void threadEntryPoint(Scavenger*);
-    void threadRunLoop();
+    BNO_RETURN static void threadEntryPoint(Scavenger*);
+    BNO_RETURN void threadRunLoop();
     
     void setSelfQOSClass();
     void setThreadName(const char*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to