Module: xenomai-3
Branch: next
Commit: da225271ab8ec9a9f3a7e12f22010c040f243049
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=da225271ab8ec9a9f3a7e12f22010c040f243049

Author: Philippe Gerum <r...@xenomai.org>
Date:   Mon Jan 18 11:12:51 2016 +0100

boilerplate/scope: add helpers for nullable reference

This pair of additional helpers allows for conveying NULL into
offset-based references.

---

 include/boilerplate/scope.h |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/include/boilerplate/scope.h b/include/boilerplate/scope.h
index 98e1fe8..ded6a2c 100644
--- a/include/boilerplate/scope.h
+++ b/include/boilerplate/scope.h
@@ -37,9 +37,11 @@ int pshared_check(void *heap, void *addr);
 #define __memptr(__base, __off)                ((void *)((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 __moff(__p)            __memoff(__main_heap, __p)
+#define __moff_nullable(__p)   (__p ? __memoff(__main_heap, __p) : 0)
+#define __mptr(__off)          __memptr(__main_heap, __off)
+#define __mptr_nullable(__off) (__off ? __memptr(__main_heap, __off) : NULL)
+#define __mchk(__p)            __memchk(__main_heap, __p)
 
 #define mutex_scope_attribute  PTHREAD_PROCESS_SHARED
 #define sem_scope_attribute    1
@@ -58,9 +60,11 @@ int pshared_check(void *heap, void *addr);
 #define __memptr(__base, __off)                (__off)
 #define __memchk(__base, __addr)       1
 
-#define __moff(__p)    (__p)
-#define __mptr(__off)  (__off)
-#define __mchk(__p)    1
+#define __moff(__p)            (__p)
+#define __moff_nullable(__p)   (__p)
+#define __mptr(__off)          (__off)
+#define __mptr_nullable(__off) (__off)
+#define __mchk(__p)            1
 
 #define mutex_scope_attribute  PTHREAD_PROCESS_PRIVATE
 #define sem_scope_attribute    0


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

Reply via email to