From a756987d2ae2a029bfe5c8cf00a9853379fbcb91 Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Wed, 1 Jun 2016 07:47:58 +0900
Subject: Fix chx_fatal

---
 AUTHORS   | 15 ++++++++++-----
 ChangeLog |  5 +++++
 chopstx.c |  8 +++++---
 chopstx.h |  2 +-
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 7fcdd8f..f0fa39c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -23,16 +23,21 @@ Mateusz Zalega:
 
 NIIBE Yutaka:
     Write the library:
-	chopstx.c, eventflag.c, entry.c,
-	clk_gpio_init-kl.c, clk_gpio_init-stm32.c
+	chopstx.c, entry.c, eventflag.c,
         chopstx.h, eventflag.h
+    Write the drivers mcu/*:
+    	clk_gpio_init-mkl27z.c, clk_gpio_init-stm32.c,
+	sys-stm32f103.c, sys-stm32f030.c, sys-mkl27z.c,
+	adc-stm32f103.c, adc-mkl27z.c
     Draw the logo:
 	chopstx.svg, chopstx.png
     Write examples:
-        example-led, example-cdc, example-fsm-55
-    Write board:
+        example-led, example-cdc, example-fsm-55, example-fs-bb48
+    Write board/*:
         board-fst-01.h, board-fst-01-00.h,
 	board-olimex-stm32-h103.h, board-stm8s-discovery.h
 	board-cq-starm.h, board-stbee-mini.h, board-stbee.h,
 
-	board-stm32f0-discovery.h, board-fsm-55.h
+	board-stm32f0-discovery.h, board-fsm-55.h,
+
+	board-fs-bb48.h
diff --git a/ChangeLog b/ChangeLog
index 8a16449..caa6385 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-01  NIIBE Yutaka  <gniibe@fsij.org>
+
+	* chopstx.h (chx_fatal): Remove weak attribute from declaration.
+	* chopstx.c (chx_fatal): Add weak attribute to implementation.
+
 2016-05-31  NIIBE Yutaka  <gniibe@fsij.org>
 
 	* VERSION: 0.12.
diff --git a/chopstx.c b/chopstx.c
index 5d90a1f..5c9aed0 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -208,6 +208,8 @@ chx_prio_init (void)
 	    | (CPU_EXCEPTION_PRIORITY_PENDSV << 16));
 }
 
+void __attribute__((weak)) chx_fatal (uint32_t err_code);
+
 /**
  * chx_fatal - Fatal error point.
  * @err_code: Error code
@@ -444,8 +446,8 @@ enum  {
   THREAD_WAIT_MTX,
   THREAD_WAIT_CND,
   THREAD_WAIT_TIME,
+  THREAD_WAIT_EXIT,
   THREAD_WAIT_POLL,
-  THREAD_JOIN,
   /**/
   THREAD_EXITED=0x0E,
   THREAD_FINISHED=0x0F
@@ -1191,7 +1193,7 @@ requeue (struct chx_thread *tp)
       chx_spin_unlock (&cond->lock);
       /* We don't know who can wake up this thread.  */
     }
-  else if (tp->state == THREAD_JOIN)
+  else if (tp->state == THREAD_WAIT_EXIT)
     /* Requeue is not needed as waiting for the thread is only by one.  */
     return (struct chx_thread *)tp->v;
 
@@ -1572,7 +1574,7 @@ chopstx_join (chopstx_t thd, void **ret)
       chx_spin_lock (&q_join.lock);
       ll_prio_enqueue ((struct chx_pq *)running, &q_join.q);
       running->v = (uint32_t)tp;
-      running->state = THREAD_JOIN;
+      running->state = THREAD_WAIT_EXIT;
       tp->flag_join_req = 1;
 
       /* Priority inheritance.  */
diff --git a/chopstx.h b/chopstx.h
index 94eb5b0..e1a8cd8 100644
--- a/chopstx.h
+++ b/chopstx.h
@@ -83,7 +83,7 @@ void chopstx_cond_broadcast (chopstx_cond_t *cond);
  * Library provides default implementation as weak reference.
  * User can replace it.
   */
-void chx_fatal (uint32_t err_code) __attribute__((__weak__, __noreturn__));
+void chx_fatal (uint32_t err_code) __attribute__((__noreturn__));
 
 int chopstx_join (chopstx_t, void **);
 void chopstx_exit (void *retval) __attribute__((__noreturn__));
-- 
cgit v1.2.3