+/* FIXME Remove the "0 &&" below to make the test pass.
+ * This should not be a Lightning issue. It is crashing
+ * like this at exit:
+ * Thread 2 "catomic" received signal SIGSEGV, Segmentation fault.
+ * [Switching to Thread 0xf6acc480 (LWP 2561)]
+ * _IO_acquire_lock_fct (p=<synthetic pointer>) at libioP.h:797
+ * 797 libioP.h: No such file or directory.
+ * (gdb) bt
+ * #0 _IO_acquire_lock_fct (p=<synthetic pointer>) at libioP.h:797
+ * #1 _IO_puts (str=0x1 <error: Cannot access memory at address 0x1>)
+ * at ioputs.c:36
+ * #2 0xf8eca180 in ?? ()
+ * unless using these hacks, to not use stdio.
+ * Note that the problem will still happen on purpose, to not risk hiding
+ * a problem.
+ */
+#if 0 && defined(__hppa__)
+# if DEBUG
+# define DEBUG 0
+# define PRINT_OK() \
+ do { \
+ jit_prepare(); \
+ jit_pushargi(STDOUT_FILENO); \
+ jit_pushargi((jit_word_t)"ok\n"); \
+ jit_pushargri(3); \
+ jit_finishi(write); \
+ } while (0)
+# endif
+#else
+# define PRINT_OK() \
+ do { \
+ jit_prepare(); \
+ jit_pushargi((jit_word_t)"ok"); \
+ jit_finishi(puts); \
+ } while (0)
+#endif
+
+#if DEBUG
+volatile
+#endif
+jit_word_t lock;
+pthread_t tids[4];
+
+#if DEBUG
+int debug_offset(void)
+{
+ int i;
+ pthread_t self = pthread_self();
+ for (i = 0; i < 4; ++i)
+ if (tids[i] == self)
+ return i;
+ return -1;
+}
+
+void debug_spin(void)
+{
+ printf(" spin %d : %ld\n", debug_offset(), lock);
+}
+
+void debug_lock(void)
+{
+ printf(" lock %d : %ld\n", debug_offset(), lock);
+}
+
+void debug_unlock(void)
+{
+ printf("unlock %d : %ld\n", debug_offset(), lock);
+}
+#define DEBUG_SPIN() jit_calli(debug_spin)
+#define DEBUG_LOCK() jit_calli(debug_lock)
+#define DEBUG_UNLOCK() jit_calli(debug_unlock)
+#else
+#define DEBUG_SPIN() /**/
+#define DEBUG_LOCK() /**/
+#define DEBUG_UNLOCK() /**/
+#endif
+