[Xenomai-git] Philippe Gerum : alchemy/task: fix for pshared mode

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: a8c43ada4288857a3d593b60d1d45cc11fa5432d
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=a8c43ada4288857a3d593b60d1d45cc11fa5432d

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:33:56 2015 +0200

alchemy/task: fix for pshared mode

---

 include/alchemy/task.h |5 -
 lib/alchemy/task.c |   54 +---
 2 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/include/alchemy/task.h b/include/alchemy/task.h
index cc3e3c0..685d478 100644
--- a/include/alchemy/task.h
+++ b/include/alchemy/task.h
@@ -52,7 +52,10 @@ typedef struct RT_TASK RT_TASK;
 struct RT_TASK_MCB {
int flowid;
int opcode;
-   void *data;
+   union {
+   dref_type(void *) __dref;
+   void *data;
+   };
ssize_t size;
 };
 
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 327e916..857496b 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1698,6 +1698,7 @@ ssize_t rt_task_send_timed(RT_TASK *task,
   RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r,
   const struct timespec *abs_timeout)
 {
+   void *rbufin = NULL, *rbufout = NULL;
struct alchemy_task_wait *wait;
struct threadobj *current;
struct alchemy_task *tcb;
@@ -1741,10 +1742,31 @@ ssize_t rt_task_send_timed(RT_TASK *task,
tcb-flowgen = 1;
 
wait-request = *mcb_s;
+   /*
+* Payloads exchanged with remote tasks have to go through the
+* main heap.
+*/
+   if (mcb_s-size  0  !threadobj_local_p(tcb-thobj)) {
+   rbufin = xnmalloc(mcb_s-size);
+   if (rbufin == NULL) {
+   ret = -ENOMEM;
+   goto cleanup;
+   }
+   memcpy(rbufin, mcb_s-data, mcb_s-size);
+   wait-request.__dref = __moff(rbufin);
+   }
wait-request.flowid = tcb-flowgen;
if (mcb_r) {
-   wait-reply.data = mcb_r-data;
wait-reply.size = mcb_r-size;
+   wait-reply.data = mcb_r-data;
+   if (mcb_r-size  0  !threadobj_local_p(tcb-thobj)) {
+   rbufout = xnmalloc(mcb_r-size);
+   if (rbufout == NULL) {
+   ret = -ENOMEM;
+   goto cleanup;
+   }
+   wait-reply.__dref = __moff(rbufout);
+   }
} else {
wait-reply.data = NULL;
wait-reply.size = 0;
@@ -1760,12 +1782,20 @@ ssize_t rt_task_send_timed(RT_TASK *task,
goto out;
goto done;
}
-   ret = wait-reply.size;
 
+   ret = wait-reply.size;
+   if (!threadobj_local_p(tcb-thobj)  ret  0  mcb_r)
+   memcpy(mcb_r-data, rbufout, ret);
+cleanup:
threadobj_finish_wait();
 done:
syncobj_unlock(tcb-sobj_msg, syns);
 out:
+   if (rbufin)
+   xnfree(rbufin);
+   if (rbufout)
+   xnfree(rbufout);
+   
CANCEL_RESTORE(svc);
 
return ret;
@@ -1903,8 +1933,12 @@ int rt_task_receive_timed(RT_TASK_MCB *mcb_r,
goto fixup;
}
 
-   if (mcb_s-size  0)
-   memcpy(mcb_r-data, mcb_s-data, mcb_s-size);
+   if (mcb_s-size  0) {
+   if (!threadobj_local_p(thobj))
+   memcpy(mcb_r-data, __mptr(mcb_s-__dref), mcb_s-size);
+   else
+   memcpy(mcb_r-data, mcb_s-data, mcb_s-size);
+   }
 
/* The flow identifier is always strictly positive. */
ret = mcb_s-flowid;
@@ -2020,8 +2054,8 @@ int rt_task_reply(int flowid, RT_TASK_MCB *mcb_s)
/*
 * NOTE: sending back a NULL or zero-length reply is perfectly
 * valid; it just means to unblock the client without passing
-* it back any reply data. What is invalid is sending a
-* response larger than what the client expects.
+* it back any reply data. Sending a response larger than what
+* the client expects is invalid.
 */
if (mcb_r-size  size) {
ret = -ENOBUFS; /* Client will get this too. */
@@ -2029,8 +2063,12 @@ int rt_task_reply(int flowid, RT_TASK_MCB *mcb_s)
} else {
ret = 0;
mcb_r-size = size;
-   if (size  0)
-   memcpy(mcb_r-data, mcb_s-data, size);
+   if (size  0) {
+   if (!threadobj_local_p(thobj))
+   memcpy(__mptr(mcb_r-__dref), mcb_s-data, 
size);
+   else
+   memcpy(mcb_r-data, mcb_s-data, size);
+   }
}
 
mcb_r-flowid = flowid;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org

[Xenomai-git] Philippe Gerum : copperplate/traceobj: add helpers for checking a status

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d2f00c25e3edd721fb71c016af46e370a5485958
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d2f00c25e3edd721fb71c016af46e370a5485958

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Jun  2 09:55:36 2015 +0200

copperplate/traceobj: add helpers for checking a status

---

 include/copperplate/traceobj.h |   22 ++
 lib/boilerplate/ancillaries.c  |1 +
 lib/copperplate/traceobj.c |   30 +++---
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/include/copperplate/traceobj.h b/include/copperplate/traceobj.h
index 613b043..be660aa 100644
--- a/include/copperplate/traceobj.h
+++ b/include/copperplate/traceobj.h
@@ -40,6 +40,20 @@ do { 
\
__traceobj_assert_failed(trobj, __FILE__, __LINE__, 
__STRING(cond)); \
 } while(0)
 
+#define traceobj_check(__trobj, __status, __expected)  \
+do {   \
+   if (__status != __expected) \
+   __traceobj_check_abort(__trobj, __FILE__, __LINE__, \
+  __status, __expected);   \
+} while(0)
+
+#define traceobj_check_warn(__trobj, __status, __expected) \
+do {   \
+   if (__status != __expected) \
+   __traceobj_check_warn(__trobj, __FILE__, __LINE__,  \
+ __status, __expected);\
+} while(0)
+
 #define traceobj_mark(trobj, mark) \
__traceobj_mark(trobj, __FILE__, __LINE__, mark)
 
@@ -65,6 +79,14 @@ void traceobj_join(struct traceobj *trobj);
 void __traceobj_assert_failed(struct traceobj *trobj,
  const char *file, int line, const char *cond);
 
+void __traceobj_check_abort(struct traceobj *trobj,
+   const char *file, int line,
+   int received, int expected);
+
+void __traceobj_check_warn(struct traceobj *trobj,
+  const char *file, int line,
+  int received, int expected);
+   
 void __traceobj_mark(struct traceobj *trobj,
 const char *file, int line, int mark);
 
diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
index 244e6f6..21aa667 100644
--- a/lib/boilerplate/ancillaries.c
+++ b/lib/boilerplate/ancillaries.c
@@ -152,6 +152,7 @@ static const char *__esym_map[] = {
__esym_def(ENOSYS),
__esym_def(ETIMEDOUT),
__esym_def(ENOMSG),
+   __esym_def(EIDRM),
__esym_def(EADDRINUSE),
 };
 
diff --git a/lib/copperplate/traceobj.c b/lib/copperplate/traceobj.c
index a06cfd9..8d4ee9b 100644
--- a/lib/copperplate/traceobj.c
+++ b/lib/copperplate/traceobj.c
@@ -194,8 +194,7 @@ static void dump_marks(struct traceobj *trobj) /* lock held 
*/
fflush(stderr);
 }
 
-void __traceobj_assert_failed(struct traceobj *trobj,
- const char *file, int line, const char *cond)
+static void dump_marks_on_error(struct traceobj *trobj)
 {
struct service svc;
 
@@ -208,8 +207,33 @@ void __traceobj_assert_failed(struct traceobj *trobj,
pop_cleanup_lock(trobj-lock);
 
CANCEL_RESTORE(svc);
+}
+
+void __traceobj_assert_failed(struct traceobj *trobj,
+ const char *file, int line, const char *cond)
+{
+   dump_marks_on_error(trobj);
+   panic(trace assertion failed:\n  %s:%d = \%s\, file, 
line, cond);
+}
+
+void __traceobj_check_abort(struct traceobj *trobj,
+   const char *file, int line,
+   int received, int expected)
+{
+   dump_marks_on_error(trobj);
+   panic(wrong return status:\n  %s:%d = %s (want %s), 
file, line,
+ symerror(received  0 ? -received : received),
+ symerror(expected  0 ? -expected : expected));
+}
 
-   panic(trace assertion failed:\n%s:%d = \%s\, file, line, cond);
+void __traceobj_check_warn(struct traceobj *trobj,
+  const char *file, int line,
+  int received, int expected)
+{
+   dump_marks_on_error(trobj);
+   warning(wrong return status:\n  %s:%d = %s (want %s), 
file, line,
+   symerror(received  0 ? -received : received),
+   symerror(expected  0 ? -expected : expected));
 }
 
 void __traceobj_mark(struct traceobj *trobj,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/heap: fix for remote requests (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 380f6de994327058309e4e5a146e1a58e15ae98c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=380f6de994327058309e4e5a146e1a58e15ae98c

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:23:50 2015 +0200

alchemy/heap: fix for remote requests (pshared)

---

 lib/alchemy/heap.c |   15 +--
 lib/alchemy/heap.h |4 ++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/alchemy/heap.c b/lib/alchemy/heap.c
index 38ffc26..10b7f83 100644
--- a/lib/alchemy/heap.c
+++ b/lib/alchemy/heap.c
@@ -245,7 +245,7 @@ int rt_heap_create(RT_HEAP *heap,
generate_name(hcb-name, name, heap_namegen);
hcb-mode = mode;
hcb-size = heapsz;
-   hcb-sba = NULL;
+   hcb-sba = __moff(NULL);
 
if (mode  H_PRIO)
sobj_flags = SYNCOBJ_PRIO;
@@ -432,7 +432,7 @@ int rt_heap_alloc_timed(RT_HEAP *heap,
goto out;
 
if (hcb-mode  H_SINGLE) {
-   p = hcb-sba;
+   p = __mptr(hcb-sba);
if (p)
goto done;
if (size  0  size != hcb-size) {
@@ -444,7 +444,7 @@ int rt_heap_alloc_timed(RT_HEAP *heap,
ret = -ENOMEM;
goto done;
}
-   hcb-sba = p;
+   hcb-sba = __moff(p);
goto done;
}
 
@@ -467,7 +467,7 @@ int rt_heap_alloc_timed(RT_HEAP *heap,
goto out;
}
} else
-   p = wait-ptr;
+   p = __mptr(wait-ptr);
 
threadobj_finish_wait();
 done:
@@ -509,6 +509,7 @@ int rt_heap_free(RT_HEAP *heap, void *block)
struct syncstate syns;
struct service svc;
int ret = 0;
+   void *ptr;
 
CANCEL_DEFER(svc);
 
@@ -534,9 +535,11 @@ int rt_heap_free(RT_HEAP *heap, void *block)
 */
syncobj_for_each_grant_waiter_safe(hcb-sobj, thobj, tmp) {
wait = threadobj_get_wait(thobj);
-   wait-ptr = heapobj_alloc(hcb-hobj, wait-size);
-   if (wait-ptr)
+   ptr = heapobj_alloc(hcb-hobj, wait-size);
+   if (ptr) {
+   wait-ptr = __moff(ptr);
syncobj_grant_to(hcb-sobj, thobj);
+   }
}
 done:
put_alchemy_heap(hcb, syns);
diff --git a/lib/alchemy/heap.h b/lib/alchemy/heap.h
index 909454d..e76e36f 100644
--- a/lib/alchemy/heap.h
+++ b/lib/alchemy/heap.h
@@ -33,13 +33,13 @@ struct alchemy_heap {
struct clusterobj cobj;
int mode;
size_t size;
-   void *sba;
+   dref_type(void *) sba;
struct fsobj fsobj;
 };
 
 struct alchemy_heap_wait {
size_t size;
-   void *ptr;
+   dref_type (void *) ptr;
 };
 
 #define heap_magic 0x8a8aebeb


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/buffer: fix for remote requests (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: e3cdd08341ce9dba7e0b4ee65b14f68e5008281b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=e3cdd08341ce9dba7e0b4ee65b14f68e5008281b

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:15:18 2015 +0200

alchemy/buffer: fix for remote requests (pshared)

---

 lib/alchemy/buffer.c |   14 --
 lib/alchemy/buffer.h |2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lib/alchemy/buffer.c b/lib/alchemy/buffer.c
index ca4817e..d9d7c98 100644
--- a/lib/alchemy/buffer.c
+++ b/lib/alchemy/buffer.c
@@ -153,7 +153,7 @@ static void buffer_finalize(struct syncobj *sobj)
 
bcb = container_of(sobj, struct alchemy_buffer, sobj);
registry_destroy_file(bcb-fsobj);
-   xnfree(bcb-buf);
+   xnfree(__mptr(bcb-buf));
xnfree(bcb);
 }
 fnref_register(libalchemy, buffer_finalize);
@@ -216,6 +216,7 @@ int rt_buffer_create(RT_BUFFER *bf, const char *name,
struct alchemy_buffer *bcb;
struct service svc;
int sobj_flags = 0;
+   void *buf;
int ret;
 
if (threadobj_irq_p())
@@ -232,12 +233,13 @@ int rt_buffer_create(RT_BUFFER *bf, const char *name,
goto fail;
}
 
-   bcb-buf = xnmalloc(bufsz);
-   if (bcb == NULL) {
+   buf = xnmalloc(bufsz);
+   if (buf == NULL) {
ret = __bt(-ENOMEM);
goto fail_bufalloc;
}
 
+   bcb-buf = __moff(buf);
generate_name(bcb-name, name, buffer_namegen);
bcb-mode = mode;
bcb-bufsz = bufsz;
@@ -276,7 +278,7 @@ fail_register:
registry_destroy_file(bcb-fsobj);
syncobj_uninit(bcb-sobj);
 fail_syncinit:
-   xnfree(bcb-buf);
+   xnfree(buf);
 fail_bufalloc:
xnfree(bcb);
 fail:
@@ -500,7 +502,7 @@ redo:
n = bcb-bufsz - rdoff;
else
n = rbytes;
-   memcpy(p, bcb-buf + rdoff, n);
+   memcpy(p, __mptr(bcb-buf) + rdoff, n);
p += n;
rdoff = (rdoff + n) % bcb-bufsz;
rbytes -= n;
@@ -716,7 +718,7 @@ ssize_t rt_buffer_write_timed(RT_BUFFER *bf,
else
n = rbytes;
 
-   memcpy(bcb-buf + wroff, p, n);
+   memcpy(__mptr(bcb-buf) + wroff, p, n);
p += n;
wroff = (wroff + n) % bcb-bufsz;
rbytes -= n;
diff --git a/lib/alchemy/buffer.h b/lib/alchemy/buffer.h
index beb1f5b..3c99d0c 100644
--- a/lib/alchemy/buffer.h
+++ b/lib/alchemy/buffer.h
@@ -31,7 +31,7 @@ struct alchemy_buffer {
struct clusterobj cobj;
size_t bufsz;
int mode;
-   void *buf;
+   dref_type(void *) buf;
size_t rdoff;
size_t wroff;
size_t fillsz;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : boilerplate, copperplate: fix syncluster with remote sync (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: fa8b8c534166276f9a9f9df7ba83b04acddd37e4
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=fa8b8c534166276f9a9f9df7ba83b04acddd37e4

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 16:52:34 2015 +0200

boilerplate, copperplate: fix syncluster with remote sync (pshared)

---

 include/boilerplate/scope.h   |   26 
 include/copperplate/cluster.h |9 -
 include/copperplate/threadobj.h   |6 +--
 lib/boilerplate/hash.c|4 --
 lib/copperplate/cluster.c |   19 -
 lib/copperplate/heapobj-pshared.c |   79 +++--
 lib/copperplate/threadobj.c   |2 +-
 7 files changed, 80 insertions(+), 65 deletions(-)

diff --git a/include/boilerplate/scope.h b/include/boilerplate/scope.h
index 9e551ae..ae71063 100644
--- a/include/boilerplate/scope.h
+++ b/include/boilerplate/scope.h
@@ -31,10 +31,15 @@ extern void *__main_heap;
 
 int pshared_check(void *heap, void *addr);
 
-#define dref_type(t)   memoff_t
-#define __memoff(base, addr)   ((caddr_t)(addr) - (caddr_t)(base))
-#define __memptr(base, off)((caddr_t)(base) + (off))
-#define __memchk(base, addr)   pshared_check(base, addr)
+#define dref_type(t)   memoff_t
+
+#define __memoff(__base, __addr)   ((caddr_t)(__addr) - (caddr_t)(__base))
+#define __memptr(__base, __off)((caddr_t)(__base) + (__off))
+#define __memchk(__base, __addr)   pshared_check(__base, __addr)
+
+#define __moff(__p)__memoff(__main_heap, __p)
+#define __mptr(__off)  __memptr(__main_heap, __off)
+#define __mchk(__p)__memchk(__main_heap, __p)
 
 #define mutex_scope_attribute  PTHREAD_PROCESS_SHARED
 #define sem_scope_attribute1
@@ -47,10 +52,15 @@ int pshared_check(void *heap, void *addr);
 
 #define __main_heapNULL
 
-#define dref_type(t)   __typeof__(t)
-#define __memoff(base, addr)   (addr)
-#define __memptr(base, off)(off)
-#define __memchk(base, addr)   1
+#define dref_type(t)   __typeof__(t)
+
+#define __memoff(__base, __addr)   (__addr)
+#define __memptr(__base, __off)(__off)
+#define __memchk(__base, __addr)   1
+
+#define __moff(__p)(__p)
+#define __mptr(__off)  (__off)
+#define __mchk(__p)1
 
 #define mutex_scope_attribute  PTHREAD_PROCESS_PRIVATE
 #define sem_scope_attribute0
diff --git a/include/copperplate/cluster.h b/include/copperplate/cluster.h
index af7dfee..c29d6f2 100644
--- a/include/copperplate/cluster.h
+++ b/include/copperplate/cluster.h
@@ -155,7 +155,14 @@ pid_t pvclusterobj_cnode(const struct pvclusterobj *cobj)
 #endif /* !CONFIG_XENO_PSHARED */
 
 struct syncluster_wait_struct {
-   const char *name;
+   union {
+   struct {
+   dref_type(char *) name;
+   } shared;
+   struct {
+   const char *name;
+   } private;
+   };
 };
 
 #ifdef __cplusplus
diff --git a/include/copperplate/threadobj.h b/include/copperplate/threadobj.h
index edc4d6c..4562dcb 100644
--- a/include/copperplate/threadobj.h
+++ b/include/copperplate/threadobj.h
@@ -179,7 +179,7 @@ struct threadobj {
struct holder wait_link;
int wait_status;
int wait_prio;
-   void *wait_union;
+   dref_type(void *) wait_union;
size_t wait_size;
timer_t periodic_timer;
 
@@ -496,14 +496,14 @@ static inline int threadobj_get_errno(struct threadobj 
*thobj)
struct threadobj *__thobj = threadobj_current();\
assert(__thobj != NULL);\
assert(sizeof(typeof(T)) = __thobj-wait_size);\
-   __thobj-wait_union;\
+   (void *)__mptr(__thobj-wait_union);\
})
 
 #define threadobj_finish_wait()do { } while (0)
 
 static inline void *threadobj_get_wait(struct threadobj *thobj)
 {
-   return thobj-wait_union;
+   return __mptr(thobj-wait_union);
 }
 
 static inline const char *threadobj_get_name(struct threadobj *thobj)
diff --git a/lib/boilerplate/hash.c b/lib/boilerplate/hash.c
index 35fcf73..aa35fa4 100644
--- a/lib/boilerplate/hash.c
+++ b/lib/boilerplate/hash.c
@@ -44,10 +44,6 @@
c -= a; c -= b; c ^= (b15);   \
 }
 
-#define __moff(__p)__memoff(__main_heap, __p)
-#define __mptr(__p)__memptr(__main_heap, __p)
-#define __mchk(__p)__memchk(__main_heap, __p)
-
 static inline int store_key(struct hashobj *obj,
const void *key, size_t len,
const struct hash_operations *hops);
diff --git a/lib/copperplate/cluster.c b/lib/copperplate/cluster.c
index 7353aa8..9355d94 100644
--- a/lib/copperplate/cluster.c
+++ b/lib/copperplate/cluster.c
@@ -255,9 +255,8 @@ redo:
hobj = hash_search(main_catalog, name, strlen(name),
   hash_operations);

[Xenomai-git] Philippe Gerum : psos/queue: fix for remote requests (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: ec34dc22f3099d19fd48896ac4e2a1fd2a9161df
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=ec34dc22f3099d19fd48896ac4e2a1fd2a9161df

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:29:52 2015 +0200

psos/queue: fix for remote requests (pshared)

---

 lib/psos/queue.c |4 ++--
 lib/psos/queue.h |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/psos/queue.c b/lib/psos/queue.c
index c3a27ae..42d0130 100644
--- a/lib/psos/queue.c
+++ b/lib/psos/queue.c
@@ -258,7 +258,7 @@ static u_long __q_send_inner(struct psos_queue *q, unsigned 
long flags,
if (bytes  maxbytes)
bytes = maxbytes;
if (bytes  0)
-   memcpy(wait-ptr, buffer, bytes);
+   memcpy(__mptr(wait-ptr), buffer, bytes);
wait-size = bytes;
goto done;
}
@@ -462,7 +462,7 @@ retry:
timespec = NULL;
 
wait = threadobj_prepare_wait(struct psos_queue_wait);
-   wait-ptr = buffer;
+   wait-ptr = __moff(buffer);
wait-size = msglen;
 
ret = syncobj_wait_grant(q-sobj, timespec, syns);
diff --git a/lib/psos/queue.h b/lib/psos/queue.h
index 0493a8a..4ca4389 100644
--- a/lib/psos/queue.h
+++ b/lib/psos/queue.h
@@ -43,7 +43,7 @@ struct psos_queue {
 
 struct psos_queue_wait {
size_t size;
-   void *ptr;
+   dref_type(void *) ptr;
 };
 
 extern struct cluster psos_queue_table;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/queue: fix for remote requests (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: d4d6d55da739284eaffdeafaa99a2c5b725e4204
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d4d6d55da739284eaffdeafaa99a2c5b725e4204

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:25:37 2015 +0200

alchemy/queue: fix for remote requests (pshared)

---

 lib/alchemy/queue.c |4 ++--
 lib/alchemy/queue.h |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/alchemy/queue.c b/lib/alchemy/queue.c
index f53bc7a..42f82c7 100644
--- a/lib/alchemy/queue.c
+++ b/lib/alchemy/queue.c
@@ -654,7 +654,7 @@ int rt_queue_write(RT_QUEUE *queue,
if (size  usersz)
size = usersz;
if (size  0)
-   memcpy(wait-userbuf, buf, size);
+   memcpy(__mptr(wait-userbuf), buf, size);
wait-usersz = size;
syncobj_grant_to(qcb-sobj, waiter);
ret = 1;
@@ -981,7 +981,7 @@ wait:
}
 
wait = threadobj_prepare_wait(struct alchemy_queue_wait);
-   wait-userbuf = buf;
+   wait-userbuf = __moff(buf);
wait-usersz = size;
wait-msg = NULL;
 
diff --git a/lib/alchemy/queue.h b/lib/alchemy/queue.h
index 04c3c15..8aa3327 100644
--- a/lib/alchemy/queue.h
+++ b/lib/alchemy/queue.h
@@ -50,7 +50,7 @@ struct alchemy_queue_msg {
 
 struct alchemy_queue_wait {
struct alchemy_queue_msg *msg;
-   void *userbuf;
+   dref_type(void *) userbuf;
size_t usersz;
 };
 


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : copperplate/traceobj: add helpers for checking a status

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 2a7dcee23f32c01bd20dd9ecf1a2553f18abe78c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=2a7dcee23f32c01bd20dd9ecf1a2553f18abe78c

Author: Philippe Gerum r...@xenomai.org
Date:   Tue Jun  2 09:55:36 2015 +0200

copperplate/traceobj: add helpers for checking a status

---

 include/copperplate/traceobj.h |   22 ++
 lib/boilerplate/ancillaries.c  |1 +
 lib/copperplate/traceobj.c |   30 +++---
 3 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/include/copperplate/traceobj.h b/include/copperplate/traceobj.h
index 613b043..be660aa 100644
--- a/include/copperplate/traceobj.h
+++ b/include/copperplate/traceobj.h
@@ -40,6 +40,20 @@ do { 
\
__traceobj_assert_failed(trobj, __FILE__, __LINE__, 
__STRING(cond)); \
 } while(0)
 
+#define traceobj_check(__trobj, __status, __expected)  \
+do {   \
+   if (__status != __expected) \
+   __traceobj_check_abort(__trobj, __FILE__, __LINE__, \
+  __status, __expected);   \
+} while(0)
+
+#define traceobj_check_warn(__trobj, __status, __expected) \
+do {   \
+   if (__status != __expected) \
+   __traceobj_check_warn(__trobj, __FILE__, __LINE__,  \
+ __status, __expected);\
+} while(0)
+
 #define traceobj_mark(trobj, mark) \
__traceobj_mark(trobj, __FILE__, __LINE__, mark)
 
@@ -65,6 +79,14 @@ void traceobj_join(struct traceobj *trobj);
 void __traceobj_assert_failed(struct traceobj *trobj,
  const char *file, int line, const char *cond);
 
+void __traceobj_check_abort(struct traceobj *trobj,
+   const char *file, int line,
+   int received, int expected);
+
+void __traceobj_check_warn(struct traceobj *trobj,
+  const char *file, int line,
+  int received, int expected);
+   
 void __traceobj_mark(struct traceobj *trobj,
 const char *file, int line, int mark);
 
diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
index 244e6f6..21aa667 100644
--- a/lib/boilerplate/ancillaries.c
+++ b/lib/boilerplate/ancillaries.c
@@ -152,6 +152,7 @@ static const char *__esym_map[] = {
__esym_def(ENOSYS),
__esym_def(ETIMEDOUT),
__esym_def(ENOMSG),
+   __esym_def(EIDRM),
__esym_def(EADDRINUSE),
 };
 
diff --git a/lib/copperplate/traceobj.c b/lib/copperplate/traceobj.c
index a06cfd9..8d4ee9b 100644
--- a/lib/copperplate/traceobj.c
+++ b/lib/copperplate/traceobj.c
@@ -194,8 +194,7 @@ static void dump_marks(struct traceobj *trobj) /* lock held 
*/
fflush(stderr);
 }
 
-void __traceobj_assert_failed(struct traceobj *trobj,
- const char *file, int line, const char *cond)
+static void dump_marks_on_error(struct traceobj *trobj)
 {
struct service svc;
 
@@ -208,8 +207,33 @@ void __traceobj_assert_failed(struct traceobj *trobj,
pop_cleanup_lock(trobj-lock);
 
CANCEL_RESTORE(svc);
+}
+
+void __traceobj_assert_failed(struct traceobj *trobj,
+ const char *file, int line, const char *cond)
+{
+   dump_marks_on_error(trobj);
+   panic(trace assertion failed:\n  %s:%d = \%s\, file, 
line, cond);
+}
+
+void __traceobj_check_abort(struct traceobj *trobj,
+   const char *file, int line,
+   int received, int expected)
+{
+   dump_marks_on_error(trobj);
+   panic(wrong return status:\n  %s:%d = %s (want %s), 
file, line,
+ symerror(received  0 ? -received : received),
+ symerror(expected  0 ? -expected : expected));
+}
 
-   panic(trace assertion failed:\n%s:%d = \%s\, file, line, cond);
+void __traceobj_check_warn(struct traceobj *trobj,
+  const char *file, int line,
+  int received, int expected)
+{
+   dump_marks_on_error(trobj);
+   warning(wrong return status:\n  %s:%d = %s (want %s), 
file, line,
+   symerror(received  0 ? -received : received),
+   symerror(expected  0 ? -expected : expected));
 }
 
 void __traceobj_mark(struct traceobj *trobj,


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : vxworks/queue: fix for remote requests (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 7f4f2c8f97752756ae6e72dfb44884b1e1c02b81
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=7f4f2c8f97752756ae6e72dfb44884b1e1c02b81

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:31:28 2015 +0200

vxworks/queue: fix for remote requests (pshared)

---

 lib/vxworks/msgQLib.c |4 ++--
 lib/vxworks/msgQLib.h |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/vxworks/msgQLib.c b/lib/vxworks/msgQLib.c
index 087dbf6..aa0b71c 100644
--- a/lib/vxworks/msgQLib.c
+++ b/lib/vxworks/msgQLib.c
@@ -219,7 +219,7 @@ retry:
timespec = NULL;
 
wait = threadobj_prepare_wait(struct wind_queue_wait);
-   wait-ptr = buffer;
+   wait-ptr = __moff(buffer);
wait-size = maxNBytes;
 
ret = syncobj_wait_grant(mq-sobj, timespec, syns);
@@ -285,7 +285,7 @@ STATUS msgQSend(MSG_Q_ID msgQId, const char *buffer, UINT 
bytes,
if (bytes  maxbytes)
bytes = maxbytes;
if (bytes  0)
-   memcpy(wait-ptr, buffer, bytes);
+   memcpy(__mptr(wait-ptr), buffer, bytes);
wait-size = bytes;
goto done;
}
diff --git a/lib/vxworks/msgQLib.h b/lib/vxworks/msgQLib.h
index 2c31268..f6a1749 100644
--- a/lib/vxworks/msgQLib.h
+++ b/lib/vxworks/msgQLib.h
@@ -39,7 +39,7 @@ struct wind_mq {
 
 struct wind_queue_wait {
size_t size;
-   void *ptr;
+   dref_type(void *) ptr;
 };
 
 #endif /* _VXWORKS_MSGQLIB_H */


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git


[Xenomai-git] Philippe Gerum : alchemy/task: fix for remote messages (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 139d2e4c0dc78e3868f9fb0509ace488dc4f902c
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=139d2e4c0dc78e3868f9fb0509ace488dc4f902c

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:33:56 2015 +0200

alchemy/task: fix for remote messages (pshared)

---

 include/alchemy/task.h |5 -
 lib/alchemy/task.c |   54 +---
 2 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/include/alchemy/task.h b/include/alchemy/task.h
index cc3e3c0..685d478 100644
--- a/include/alchemy/task.h
+++ b/include/alchemy/task.h
@@ -52,7 +52,10 @@ typedef struct RT_TASK RT_TASK;
 struct RT_TASK_MCB {
int flowid;
int opcode;
-   void *data;
+   union {
+   dref_type(void *) __dref;
+   void *data;
+   };
ssize_t size;
 };
 
diff --git a/lib/alchemy/task.c b/lib/alchemy/task.c
index 327e916..857496b 100644
--- a/lib/alchemy/task.c
+++ b/lib/alchemy/task.c
@@ -1698,6 +1698,7 @@ ssize_t rt_task_send_timed(RT_TASK *task,
   RT_TASK_MCB *mcb_s, RT_TASK_MCB *mcb_r,
   const struct timespec *abs_timeout)
 {
+   void *rbufin = NULL, *rbufout = NULL;
struct alchemy_task_wait *wait;
struct threadobj *current;
struct alchemy_task *tcb;
@@ -1741,10 +1742,31 @@ ssize_t rt_task_send_timed(RT_TASK *task,
tcb-flowgen = 1;
 
wait-request = *mcb_s;
+   /*
+* Payloads exchanged with remote tasks have to go through the
+* main heap.
+*/
+   if (mcb_s-size  0  !threadobj_local_p(tcb-thobj)) {
+   rbufin = xnmalloc(mcb_s-size);
+   if (rbufin == NULL) {
+   ret = -ENOMEM;
+   goto cleanup;
+   }
+   memcpy(rbufin, mcb_s-data, mcb_s-size);
+   wait-request.__dref = __moff(rbufin);
+   }
wait-request.flowid = tcb-flowgen;
if (mcb_r) {
-   wait-reply.data = mcb_r-data;
wait-reply.size = mcb_r-size;
+   wait-reply.data = mcb_r-data;
+   if (mcb_r-size  0  !threadobj_local_p(tcb-thobj)) {
+   rbufout = xnmalloc(mcb_r-size);
+   if (rbufout == NULL) {
+   ret = -ENOMEM;
+   goto cleanup;
+   }
+   wait-reply.__dref = __moff(rbufout);
+   }
} else {
wait-reply.data = NULL;
wait-reply.size = 0;
@@ -1760,12 +1782,20 @@ ssize_t rt_task_send_timed(RT_TASK *task,
goto out;
goto done;
}
-   ret = wait-reply.size;
 
+   ret = wait-reply.size;
+   if (!threadobj_local_p(tcb-thobj)  ret  0  mcb_r)
+   memcpy(mcb_r-data, rbufout, ret);
+cleanup:
threadobj_finish_wait();
 done:
syncobj_unlock(tcb-sobj_msg, syns);
 out:
+   if (rbufin)
+   xnfree(rbufin);
+   if (rbufout)
+   xnfree(rbufout);
+   
CANCEL_RESTORE(svc);
 
return ret;
@@ -1903,8 +1933,12 @@ int rt_task_receive_timed(RT_TASK_MCB *mcb_r,
goto fixup;
}
 
-   if (mcb_s-size  0)
-   memcpy(mcb_r-data, mcb_s-data, mcb_s-size);
+   if (mcb_s-size  0) {
+   if (!threadobj_local_p(thobj))
+   memcpy(mcb_r-data, __mptr(mcb_s-__dref), mcb_s-size);
+   else
+   memcpy(mcb_r-data, mcb_s-data, mcb_s-size);
+   }
 
/* The flow identifier is always strictly positive. */
ret = mcb_s-flowid;
@@ -2020,8 +2054,8 @@ int rt_task_reply(int flowid, RT_TASK_MCB *mcb_s)
/*
 * NOTE: sending back a NULL or zero-length reply is perfectly
 * valid; it just means to unblock the client without passing
-* it back any reply data. What is invalid is sending a
-* response larger than what the client expects.
+* it back any reply data. Sending a response larger than what
+* the client expects is invalid.
 */
if (mcb_r-size  size) {
ret = -ENOBUFS; /* Client will get this too. */
@@ -2029,8 +2063,12 @@ int rt_task_reply(int flowid, RT_TASK_MCB *mcb_s)
} else {
ret = 0;
mcb_r-size = size;
-   if (size  0)
-   memcpy(mcb_r-data, mcb_s-data, size);
+   if (size  0) {
+   if (!threadobj_local_p(thobj))
+   memcpy(__mptr(mcb_r-__dref), mcb_s-data, 
size);
+   else
+   memcpy(mcb_r-data, mcb_s-data, size);
+   }
}
 
mcb_r-flowid = flowid;


___
Xenomai-git mailing list

[Xenomai-git] Philippe Gerum : psos/rn: fix for remote requests (pshared)

2015-06-02 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 4a2b080ed3514b8f5760727ce6769b6971c2dd7b
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4a2b080ed3514b8f5760727ce6769b6971c2dd7b

Author: Philippe Gerum r...@xenomai.org
Date:   Mon Jun  1 17:29:59 2015 +0200

psos/rn: fix for remote requests (pshared)

---

 lib/psos/rn.c |6 +++---
 lib/psos/rn.h |2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/psos/rn.c b/lib/psos/rn.c
index e665b33..f87e19e 100644
--- a/lib/psos/rn.c
+++ b/lib/psos/rn.c
@@ -264,7 +264,7 @@ starve:
timespec = NULL;
 
wait = threadobj_prepare_wait(struct psos_rn_wait);
-   wait-ptr = NULL;
+   wait-ptr = __moff(NULL);
wait-size = size;
 
ret = syncobj_wait_grant(rn-sobj, timespec, syns);
@@ -279,7 +279,7 @@ starve:
goto out;
}
 
-   *segaddr = wait-ptr;
+   *segaddr = __mptr(wait-ptr);
 done:
syncobj_unlock(rn-sobj, syns);
 out:
@@ -329,7 +329,7 @@ u_long rn_retseg(u_long rnid, void *segaddr)
if (seg) {
rn-busynr++;
rn-usedmem += heapobj_validate(rn-hobj, seg);
-   wait-ptr = seg;
+   wait-ptr = __moff(seg);
syncobj_grant_to(rn-sobj, thobj);
}
}
diff --git a/lib/psos/rn.h b/lib/psos/rn.h
index 43dd7a1..1a026a0 100644
--- a/lib/psos/rn.h
+++ b/lib/psos/rn.h
@@ -41,7 +41,7 @@ struct psos_rn {
 
 struct psos_rn_wait {
size_t size;
-   void *ptr;
+   dref_type(void *) ptr;
 };
 
 extern struct pvcluster psos_rn_table;


___
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git