[cfe-dev] Memory allocation in a named address space
Juan Carlos Martinez Santos
juanc.martinez.santos at gmail.com
Sat Oct 17 09:13:18 PDT 2009
Hello,
How I can allocate a chunk of memory in a named address space different than
#0 (or intrinsic)?
I tried...
#define HEAP_2 __attribute__((address_space(2)))
#include <stdlib.h>
int main() {
int HEAP_2 *ptr = malloc(10 * sizeof (int));
if (ptr == NULL) {
}
else {
free(ptr);
ptr = NULL;
}
return (1);
}
However, I got...
++++++++++++++++++++++++++++++++++++++++++++++
~/test$ <8 at emperor:~/test$> clang malloc_pift.c
malloc_pift.c:7:20: error: illegal implicit cast between two pointers with
different address spaces
int HEAP_2 *ptr = malloc(10 * sizeof (int));
^~~~~~~~~~~~~~~~~~~~~~~~~
malloc_pift.c:7:20: warning: initializing 'void *' discards qualifiers,
expected 'int __attribute__((address_space(2))) *'
int HEAP_2 *ptr = malloc(10 * sizeof (int));
^~~~~~~~~~~~~~~~~~~~~~~~~
malloc_pift.c:8:13: error: illegal implicit cast between two pointers with
different address spaces
if (ptr == NULL) {
^~~~
/home/jcmartin78/llvm/Debug/lib/clang/1.1/include/stddef.h:38:14: note:
instantiated from:
#define NULL ((void*)0)
^~~~~~~~~~
malloc_pift.c:11:12: error: illegal implicit cast between two pointers with
different address spaces
free(ptr);
^~~
malloc_pift.c:11:12: warning: passing 'int __attribute__((address_space(2)))
*' discards qualifiers, expected 'void *'
free(ptr);
^~~
malloc_pift.c:12:13: error: illegal implicit cast between two pointers with
different address spaces
ptr = NULL;
^~~~
/home/jcmartin78/llvm/Debug/lib/clang/1.1/include/stddef.h:38:14: note:
instantiated from:
#define NULL ((void*)0)
^~~~~~~~~~
6 diagnostics generated.
++++++++++++++++++++++++++++++++++++++++++++++=
Thanks in advance,
--
Juan Carlos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091017/b0409db1/attachment.html>
More information about the cfe-dev
mailing list