aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--NEWS11
-rw-r--r--chopstx.c22
-rw-r--r--chopstx.h7
-rw-r--r--contrib/adc-mkl27z.c7
-rw-r--r--contrib/adc-stm32f103.c3
-rw-r--r--eventflag.c3
7 files changed, 42 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 851df3d..c3f7f08 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2016-06-28 NIIBE Yutaka <gniibe@fsij.org>
+
+ * chopstx.h (struct chx_poll_head): Declare here.
+
+ * chopstx.c (chopstx_poll): Don't use varargs, but use
+ an array of pointer.
+ (chopstx_intr_wait): Follow the change of chopstx_poll.
+ * eventflag.c (eventflag_wait_timeout): Likewise.
+ * contrib/adc-stm32f103.c (adc_wait_completion): Likewise.
+ * contrib/adc-mkl27z.c (adc_wait_completion): Likewise.
+
2016-06-16 Niibe Yutaka <gniibe@fsij.org>
* VERSION: 1.0.
diff --git a/NEWS b/NEWS
index 16fe07a..a1ac1c5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,17 @@
NEWS - Noteworthy changes
+* Major changes in Chopstx 1.1
+
+ Released 2016-07-XX
+
+** API change: chopstx_poll
+In version 1.0, chopstx_poll has variable arguments. It found
+that it's challenging for ffi or lower level C implementation.
+An example is that a program touches FPU registers for varargs.
+So, we decided to avoid use of varargs in Chopstx.
+
+
* Major changes in Chopstx 1.0
Released 2016-06-16
diff --git a/chopstx.c b/chopstx.c
index d27acb0..b6bf1e7 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -335,11 +335,6 @@ struct chx_thread { /* inherits PQ */
struct chx_cleanup *clp;
};
-struct chx_poll_head {
- uint16_t type;
- uint16_t ready;
-};
-
static void
chx_cpu_sched_lock (void)
@@ -1464,7 +1459,7 @@ chx_intr_hook (struct chx_px *px, struct chx_poll_head *pd)
void
chopstx_intr_wait (chopstx_intr_t *intr)
{
- chopstx_poll (NULL, 1, intr);
+ chopstx_poll (NULL, 1, (struct chx_poll_head **)&intr);
}
@@ -1749,17 +1744,17 @@ chx_proxy_init (struct chx_px *px, uint32_t *cp)
* chopstx_poll - wait for condition variable, thread's exit, or IRQ
* @usec_p: Pointer to usec for timeout. Forever if NULL.
* @n: Number of poll descriptors
- * @VARARGS: Pointers to an object which should be one of:
+ * @pd_array: Pointer to an array of poll descriptor pointer which
+ * should be one of:
* chopstx_poll_cond_t, chopstx_poll_join_t, or chopstx_intr_t.
*
* Returns number of active descriptors.
*/
int
-chopstx_poll (uint32_t *usec_p, int n, ...)
+chopstx_poll (uint32_t *usec_p, int n, struct chx_poll_head *pd_array[])
{
uint32_t counter = 0;
int i;
- va_list ap;
struct chx_px px[n];
struct chx_poll_head *pd;
int r = 0;
@@ -1769,10 +1764,9 @@ chopstx_poll (uint32_t *usec_p, int n, ...)
for (i = 0; i < n; i++)
chx_proxy_init (&px[i], &counter);
- va_start (ap, n);
for (i = 0; i < n; i++)
{
- pd = va_arg (ap, struct chx_poll_head *);
+ pd = pd_array[i];
pd->ready = 0;
px[i].ready_p = &pd->ready;
if (pd->type == CHOPSTX_POLL_COND)
@@ -1782,7 +1776,6 @@ chopstx_poll (uint32_t *usec_p, int n, ...)
else
chx_join_hook (&px[i], pd);
}
- va_end (ap);
chx_cpu_sched_lock ();
chx_spin_lock (&px->lock);
@@ -1818,11 +1811,9 @@ chopstx_poll (uint32_t *usec_p, int n, ...)
while (r == 0);
}
- va_start (ap, n);
for (i = 0; i < n; i++)
{
- pd = va_arg (ap, struct chx_poll_head *);
-
+ pd = pd_array[i];
chx_cpu_sched_lock ();
chx_spin_lock (&px[i].lock);
if (pd->type == CHOPSTX_POLL_COND)
@@ -1864,7 +1855,6 @@ chopstx_poll (uint32_t *usec_p, int n, ...)
chx_spin_unlock (&px[i].lock);
chx_cpu_sched_unlock ();
}
- va_end (ap);
if (r < 0)
chopstx_exit (CHOPSTX_CANCELED);
diff --git a/chopstx.h b/chopstx.h
index e1a8cd8..b8daa0e 100644
--- a/chopstx.h
+++ b/chopstx.h
@@ -121,6 +121,11 @@ enum {
CHOPSTX_POLL_JOIN,
};
+struct chx_poll_head {
+ uint16_t type;
+ uint16_t ready;
+};
+
struct chx_poll_cond {
uint16_t type;
uint16_t ready;
@@ -153,6 +158,6 @@ void chopstx_claim_irq (chopstx_intr_t *intr, uint8_t irq_num);
void chopstx_intr_wait (chopstx_intr_t *intr); /* DEPRECATED */
-int chopstx_poll (uint32_t *usec_p, int n, ...);
+int chopstx_poll (uint32_t *usec_p, int n, struct chx_poll_head *pd_array[]);
#define CHOPSTX_THREAD_SIZE 64
diff --git a/contrib/adc-mkl27z.c b/contrib/adc-mkl27z.c
index 19f9f5b..d5b679e 100644
--- a/contrib/adc-mkl27z.c
+++ b/contrib/adc-mkl27z.c
@@ -295,12 +295,13 @@ adc_stop (void)
int
adc_wait_completion (void)
{
+ struct chx_poll_head *pd_array[1] = { (struct chx_poll_head *)&adc_intr };
+ int i;
+
while (1)
{
- int i;
-
/* Wait DMA completion */
- chopstx_poll (NULL, 1, &adc_intr);
+ chopstx_poll (NULL, 1, pd_array);
DMA0->DSR_BCR = (1 << 24);
DMA1->DSR_BCR = (1 << 24);
diff --git a/contrib/adc-stm32f103.c b/contrib/adc-stm32f103.c
index 6a8076e..a44942f 100644
--- a/contrib/adc-stm32f103.c
+++ b/contrib/adc-stm32f103.c
@@ -298,10 +298,11 @@ int
adc_wait_completion (void)
{
uint32_t flags;
+ struct chx_poll_head *pd_array[1] = { (struct chx_poll_head *)&adc_intr };
while (1)
{
- chopstx_poll (NULL, 1, &adc_intr);
+ chopstx_poll (NULL, 1, pd_array);
flags = DMA1->ISR & STM32_DMA_ISR_MASK; /* Channel 1 interrupt cause. */
/*
* Clear interrupt cause of channel 1.
diff --git a/eventflag.c b/eventflag.c
index 6271dbc..c6a871e 100644
--- a/eventflag.c
+++ b/eventflag.c
@@ -111,9 +111,10 @@ eventmask_t
eventflag_wait_timeout (struct eventflag *ev, uint32_t usec)
{
chopstx_poll_cond_t poll_desc;
+ struct chx_poll_head *pd_array[1] = { (struct chx_poll_head *)&poll_desc };
eventflag_prepare_poll (ev, &poll_desc);
- chopstx_poll (&usec, 1, &poll_desc);
+ chopstx_poll (&usec, 1, pd_array);
return eventflag_get (ev);
}