Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prevent inlining for empty placeholders of sthread_enable/disable.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 7 Feb 2023 19:40:27 +0000 (20:40 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 7 Feb 2023 19:52:21 +0000 (20:52 +0100)
See the gcc documentation about function attribute noinline for details.

Hope to fix hangs seen with optimized builds on recent Alpine/Linux.

Let's see also if it works as is with all supported compilers.

docs/source/Doxyfile
include/xbt/base.h
src/xbt/xbt_main.cpp

index db9ec7e..1595fcb 100644 (file)
@@ -59,10 +59,9 @@ PREDEFINED             += \
     SIMGRID_REGISTER_PLUGIN(id,desc,init)= \
     XBT_PUBLIC= \
     XBT_PUBLIC_DATA=extern \
-    XBT_PUBLIC= \
-    XBT_INLINE= \
-    XBT_ALWAYS_INLINE= \
     XBT_PRIVATE= \
+    XBT_ALWAYS_INLINE= \
+    XBT_ATTRIB_NOINLINE= \
     XBT_ATTRIB_NORETURN= \
     XBT_ATTRIB_UNUSED= \
     XBT_LOG_NEW_DEFAULT_SUBCATEGORY(cname,parent,desc)= \
index 5b55cb7..4a18d1a 100644 (file)
@@ -64,6 +64,8 @@
 #  define XBT_ATTRIB_DESTRUCTOR(prio) __attribute__((__destructor__))
 #endif
 
+#define XBT_ATTRIB_NOINLINE __attribute__((noinline))
+
 #if defined(__GNUC__)
 #define XBT_ALWAYS_INLINE inline __attribute__((always_inline))
 #else
index 7574526..4d41e07 100644 (file)
@@ -53,11 +53,13 @@ const int xbt_pagebits = static_cast<int>(log2(xbt_pagesize));
  */
 static void xbt_preinit() XBT_ATTRIB_CONSTRUCTOR(200);
 static void xbt_postexit();
-void sthread_enable()
+XBT_ATTRIB_NOINLINE void sthread_enable()
 { // These symbols are used from ContextSwapped in any case, but they are only useful
+  asm("");
 }
-void sthread_disable()
+XBT_ATTRIB_NOINLINE void sthread_disable()
 { //  when libsthread is LD_PRELOADED. In this case, sthread's implem gets used instead.
+  asm("");
 }
 
 static void xbt_preinit()