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

Reply via email to