> Hi,
>
> Thanks for the fun question :)
Well I figured this was way way to trivial a test to go wrong here and be
damned if I could see what my problem was. I just, you know, had to post this
thing and hope no one came back and said "found the problem, you're an idiot!"
:-)
> The problem is that _POSIX_SOURCE 1 means that memalign() doesn't get
> defined. You're using -erroff=%all which suppressed the warning message.
arggghh .. lovely
I was using -Xa in the CFLAGS and really should have been -Xc to enforce the
usage of the _POSIX_SOURCE define. At least, I think so. I need that in a much
larger project in order to enforce portability over to Red Hat and quite
frankly I told the project managers, hey, we are running Niagara/Fujitsu
servers, can we just stay there ? Pretty please? :-\
> Here's a short example:
>
> #define _POSIX_SOURCE 1
> #include <stdlib.h>
> #include <stdio.h>
>
> int main()
> {
> char * buffer;
> printf("%i\n",sizeof(size_t));
> buffer=(char*)memalign(64,8);
> buffer[0]='\0';
> }
>
>
> cc -m64 -g -xs m.c
> "m.c", line 9: warning: implicit function declaration: memalign
>
> ./a.out
> 8
> Segmentation Fault (core dumped)
>
> Because memalign is not defined in the header files it gets implicitly
>
> declared returning an int rather than a void*, so the top half of the
>
> pointer gets thrown away.
>
> if you add the prototype
>
> long long memalign(long long, long long);
>
> the program works. But I wonder whether you need the _POSIX_SOURCE
> definition.
I don't think I need it at all, however it is a spec being tossed at me by
people that read a book once. So thank you and Garrett for getting back to me
so quickly. I am mostly happy to see the same names and a chunk of email from a
maillist I once knew and loved. Oh .. the nostalgia ..
Dennis
ps: I have all your books. Yes .. all of them. :-)
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code