From: Philippe Gerum <rpm@xenomai.org>
To: Matthias Schneider <ma30002000@yahoo.de>,
Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>,
"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] FreeRTOS skin
Date: Mon, 05 May 2014 09:24:35 +0200 [thread overview]
Message-ID: <53673CB3.8090106@xenomai.org> (raw)
In-Reply-To: <1399238572.11209.YahooMailNeo@web171603.mail.ir2.yahoo.com>
On 05/04/2014 11:22 PM, Matthias Schneider wrote:
> ----- Original Message -----
>
>> From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
>> To: Matthias Schneider <ma30002000@yahoo.de>; "xenomai@xenomai.org" <xenomai@xenomai.org>
>> Cc:
>> Sent: Sunday, May 4, 2014 8:42 PM
>> Subject: Re: [Xenomai] FreeRTOS skin
>>
>> On 05/04/2014 06:59 PM, Matthias Schneider wrote:
>>> Hi all,
>>>
>>> please find enclosed a patch with a FreeRTOS skin for xenomai-forge I have
>>> been working on for some time. I would like to get some feedback and advice
>>> what still needs to be done to get it accepted in Xenomai. There is a set of
>>> unit tests included and the possibility to download the original FreeRTOS package
>>> in order to run most of its (platform independent) test suite. Until now I have
>>> been working under mercury only. Documentation is available in form of a README
>>> file in lib/freertos/README, which should also be a good starting point. I have
>>> not attached "configure" to the patch, so you will need to recreate the configure
>>> script first before actually running it. You can apply the patch via
>>
>>
>> Hi,
>>
>> I am not sure that checking whether a type is compatible with void *
>> will not suddenly avoid the assert check for any pointer type in:
>>
>> @@ -328,6 +328,7 @@ static inline int pshared_check(void *heap, void *addr)
>> ({
>> \
>> type handle; \
>> assert(__builtin_types_compatible_p(typeof(type), unsigned long) || \
>> + __builtin_types_compatible_p(typeof(type), void*) || \
>> __builtin_types_compatible_p(typeof(type), uintptr_t));
>> \
>> assert(ptr == NULL || __memchk(__main_heap, ptr)); \
>> handle = (type)ptr; \
>> @@ -337,6 +338,7 @@ static inline int pshared_check(void *heap, void *addr)
>> ({
>> \
>> type *ptr; \
>> assert(__builtin_types_compatible_p(typeof(handle), unsigned long) || \
>> + __builtin_types_compatible_p(typeof(handle), void*) || \
>> __builtin_types_compatible_p(typeof(handle), uintptr_t));
>> \
>> ptr = (type *)handle; \
>> ptr; \
>>
> I do agree with the argument; actually originally I had typedef'ed
> xQueueHandle, xTaskHandle and xSemaphorehandle as uintptr_t.
> However, when compiling original FreeRTOS applications like the
> "demo", I ran into many warnings (warning: comparison between
> pointer and integer) when comparing the handles to "NULL"
> like
>
> if (queueHandle != NULL) {}
>
> Now I see three possibilities:
> * stick with the void* and allow it in the check (admittedly
> greatly reducing its use)
> * change the application code
> * suppress warnings when compiling application code (not really
> my favorite)
>
> Originally the handles are tyepdef'ed to void* as well.
> Any ideas?
>
The point of this assertion is to make sure that your skin-defined object handle is wide enough to convey a native pointer directly, for the process-private configuration (with shared multi-processing enabled, this type would convey an offset instead).
There is no point in using a runtime assertion for C, we should be doing this instead:
diff --git a/include/copperplate/heapobj.h b/include/copperplate/heapobj.h
index 38deb89..6b5617c 100644
--- a/include/copperplate/heapobj.h
+++ b/include/copperplate/heapobj.h
@@ -324,21 +324,30 @@ static inline int pshared_check(void *heap, void *addr)
return 0;
}
+#ifdef __cplusplus
+#define __check_ref_width(__dst, __src) \
+ ({ \
+ assert(sizeof(__dst) >= sizeof(__src)); \
+ (typeof(__dst))__src; \
+ })
+#else
+#define __check_ref_width(__dst, __src) \
+ __builtin_choose_expr( \
+ sizeof(__dst) >= sizeof(__src), (typeof(__dst))__src, \
+ ((void)0))
+#endif
+
#define mainheap_ref(ptr, type) \
({ \
type handle; \
- assert(__builtin_types_compatible_p(typeof(type), unsigned long) || \
- __builtin_types_compatible_p(typeof(type), uintptr_t)); \
+ handle = __check_ref_width(handle, ptr); \
assert(ptr == NULL || __memchk(__main_heap, ptr)); \
- 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 = __check_ref_width(ptr, handle); \
ptr; \
})
--
Philippe.
next prev parent reply other threads:[~2014-05-05 7:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-04 16:59 [Xenomai] FreeRTOS skin Matthias Schneider
2014-05-04 18:42 ` Gilles Chanteperdrix
2014-05-04 21:22 ` Matthias Schneider
2014-05-05 7:24 ` Philippe Gerum [this message]
2014-05-17 14:40 ` Matthias Schneider
2014-05-05 10:33 ` Philippe Gerum
2014-05-05 13:37 ` Philippe Gerum
2014-05-06 7:09 ` Matthias Schneider
2014-05-06 7:46 ` Philippe Gerum
2014-05-06 7:54 ` Philippe Gerum
2014-05-06 16:50 ` Matthias Schneider
2014-05-17 14:56 ` Matthias Schneider
2014-05-05 14:03 ` Gilles Chanteperdrix
2014-05-05 14:13 ` Philippe Gerum
2014-05-06 17:19 ` Matthias Schneider
2014-05-06 17:47 ` Philippe Gerum
2014-05-06 19:46 ` Matthias Schneider
2014-05-18 18:30 ` Matthias Schneider
2014-05-19 7:46 ` Philippe Gerum
2014-05-20 7:06 ` Matthias Schneider
2014-05-20 7:53 ` Philippe Gerum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53673CB3.8090106@xenomai.org \
--to=rpm@xenomai.org \
--cc=gilles.chanteperdrix@xenomai.org \
--cc=ma30002000@yahoo.de \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.