Page 1 of 1

NetBSD/alpha build fault

Posted: 25 Sep 2004 20:28
by Guest
I can't compile VLC on NetBSD/alpha. If you want to have a full build log and all, please contact me at weel at caltech dot edu (I don't read this forum) and I'll try the build again and get you a log file, but basically this is why it doesn't build:

in include/vlc_threads_funcs.h , the assumption is being made repeatedly that you can cast a pointer to a pthread to an int. Pointers to threads are stored in various variables and return values of type int, which just doesn't fly on an alpha, which is a 64 bit processor. On the alpha, int is 32 bits and a pointer is 64 bits. This is why pointers should be stored in variables that have a pointer type. If it is not clear what the pointer type should be, or you don't want to have to export that type definition to lots of other files, you can just use void*, but not int. ANSI C does not prescribe that your way needs to work, and your approach may or may not break on other 64 bit machines (some of them have 64 bit ints by default; on the alpha, long is defined to be 64 bits.)

Posted: 25 Sep 2004 22:44
by The DJ
Yes this is a known problem. This was one of the few points where we were truly lazy in my point of view in the design of the vlc sourcecode and it definetly should be fixed.

I'll add this to the todo list.

Posted: 25 Sep 2004 22:47
by Gibalou
It looks like the only pthread casting done in include/vlc_threads_funcs.h are the pthread_self() ones which are only used to display debug messages. Are these the one creating build problems ? They could easily be solved although I don't really understand why the compiler doesn't abide the explicit cast.

Even C won't cast to to a type of a different size

Posted: 26 Sep 2004 03:56
by Guest
Gibalou: well, on alpha, int is 32 bits, and void* is 64. Even though C has a pretty permissive type system, you really can't cast a 64 bit value to a 32 bit one.

Derk-Jan: bedankt! NetBSD/alpha is misschien niet zo'n gebruikelijk platform, maar juist daarom is het altijd een goede testbench voor dit soort stomme pointerfoutjes die op een x86 "toevallig" goed gaan.

Posted: 26 Sep 2004 10:04
by Sigmund
You can easily cast a 64 bit integer to a 32 or even a 8 bit integer in C. I don't see way the same shouldn't be true for a pointer.