On 10/30/12 13:03, Udo Grabowski (IMK) wrote: > I see sometimes people linking with -lpthread (do NOT use -pthread), > without setting -mt for the Sun Studio compilers, see, e.g., > the Parrot (OI 151a7) config: > > /usr/lib/parrot/3.6.0/tools/lib/Parrot/Config/Generated.pm > > This is wrong and should be corrected for all OI specs for > multithreaded programs where this switch is missing, for > the compile and the link steps.
Both -lpthread and -lthread are unnecessary to create multithreaded applications on modern Solaris (i.e., Solaris 10, OpenSolaris, OpenIndiana and newer) because all of the interfaces have been folded into libc. All applications are multithreaded; the distinction was removed during S10 development. The days when there was a dummy error-returning pthread_create() in libc, and you could tell whether you were in a single-threaded environment by checking for that error are gone. Any place you were using those things, you may as well stop now. There is a nit regarding fork1() versus forkall() semantics, but if you need to know about that then you should definitely read the libpthread man page. And you should certainly use fork1() or forkall() in preference to just plain fork() in a modern application. The other thing "-mt" does is turn on _REENTRANT, which generally causes the header files to give you prototypes for the slightly unusual "_r" variants of the library functions with static data. (They're not always needed because most library functions defined with static data internally use thread-local variables and are mt-safe anyway.) But if you're already compiling successfully without _REENTRANT, then you probably don't need it. A lot of blood was spilled over the multi-threaded versus single-threaded distinction in the past, and it's a good thing that most of the distinction is now moot. Turn on "-mt" if you like, but I think you may be waving a dead chicken. -- James Carlson 42.703N 71.076W <[email protected]> _______________________________________________ OpenIndiana-discuss mailing list [email protected] http://openindiana.org/mailman/listinfo/openindiana-discuss
