Module: xenomai-forge
Branch: master
Commit: 60552c25d0455fab97209046e3da78ba147f7664
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=60552c25d0455fab97209046e3da78ba147f7664

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Nov 27 17:21:22 2011 +0100

copperplate/heapobj: do not set shared bit on private heap memory

---

 include/copperplate/heapobj.h |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h
index be718e4..cf05d9e 100644
--- a/include/copperplate/heapobj.h
+++ b/include/copperplate/heapobj.h
@@ -88,6 +88,23 @@ static inline memoff_t mainheap_off(void *addr)
        return addr ? (memoff_t)__memoff(__pshared_heap, addr) : 0;
 }
 
+#ifdef CONFIG_XENO_PSHARED
+/*
+ * ptr shall point to a block of memory allocated within the main heap
+ * if non-null; such address is always 8-byte aligned. Handles of
+ * shared heap pointers are returned with bit #0 set, which serves as
+ * a special tag detected in mainhead_deref(). A null pointer is
+ * always translated as a null handle.
+ */
+#define mainheap_ref(ptr, type)                                                
\
+       ({                                                              \
+               type handle;                                            \
+               assert(__builtin_types_compatible_p(typeof(type), unsigned 
long) || \
+                      __builtin_types_compatible_p(typeof(type), uintptr_t)); \
+               assert(ptr == NULL || __memchk(__pshared_heap, ptr));   \
+               handle = (type)mainheap_off(ptr);                       \
+               handle|1;                                               \
+       })
 /*
  * Handles of shared heap-based pointers have bit #0 set. Other values
  * are not translated, and the return value is the original handle
@@ -101,23 +118,25 @@ static inline memoff_t mainheap_off(void *addr)
                ptr = (handle & 1) ? (type *)mainheap_ptr(handle & ~1UL) : 
(type *)handle; \
                ptr;                                                    \
        })
-
-/*
- * ptr shall point to a block of memory allocated within the main heap
- * if non-null; such address is always 8-byte aligned. Handles of
- * shared heap pointers are returned with bit #0 set, which serves as
- * a special tag detected in mainhead_deref(). A null pointer is
- * always translated as a null handle.
- */
+#else
 #define mainheap_ref(ptr, type)                                                
\
        ({                                                              \
                type handle;                                            \
                assert(__builtin_types_compatible_p(typeof(type), unsigned 
long) || \
                       __builtin_types_compatible_p(typeof(type), uintptr_t)); \
                assert(ptr == NULL || __memchk(__pshared_heap, ptr));   \
-               handle = (type)mainheap_off(ptr);                       \
-               handle|1;                                               \
+               handle = (type)ptr;                                     \
+               handle;                                                 \
        })
+#define mainheap_deref(handle, type)                                   \
+       ({                                                              \
+               type *ptr;                                              \
+               assert(__builtin_types_compatible_p(typeof(handle), unsigned 
long) || \
+                      __builtin_types_compatible_p(typeof(handle), 
uintptr_t)); \
+               ptr = (type *)handle;                                   \
+               ptr;                                                    \
+       })
+#endif
 
 static inline size_t heapobj_size(struct heapobj *hobj)
 {


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to