From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,3ea3751944fb5801 X-Google-Attributes: gidfee84,public From: ali@asterix.hi.Com (Shaheen Ali) Subject: Re: Threads Date: 1995/04/19 Message-ID: #1/1 X-Deja-AN: 101270980 references: <3lpjq8$r07@bcarh8ab.bnr.ca> <1995Apr11.170345.14566@decvax.dec.com> organization: Hitachi Computer Products (America), Inc. newsgroups: comp.unix.osf.osf1 "Jeffrey" == Jeffrey M Denham writes: In article <1995Apr11.170345.14566@decvax.dec.com> denham@denham.zk3.dec.com (Jeffrey M. Denham) writes: [...Alot of stuff I deleted. Basically, Dan Reynolds wants to know what to do about two different errno's in a library or a binary...] Jeffrey> Here's a reply from a DECthreads developer who hasn't had Jeffrey> time to monitor the newsgroup lately: Jeffrey> That's simply untrue! DECthreads and libc_r do write the Jeffrey> global "int errno" when they report an error, but that's Jeffrey> strictly secondary and only for compatibility with code Jeffrey> that's not built using _REENTRANT. They ALSO set a per-thread Jeffrey> errno, and that's what all code should be reading when using Jeffrey> thread-safe libraries. While everything that this engineer writes is true there is an underlying assumption that ALL libraries linked against a thread consuming application are thread safe. Notice, that MT programs should not link against libc.a, but rather against libc_r.a. This is absolutely necessary. All libraries, .o's, shared libraries and all binaries (crt0.o and mcrt0.o) should be libsafe if the program is multithreaded. Not following this guideline puts the program at risk of fetching the wrong errno. In the simple case of linking foo.c to the proper thread library should be handled by the compiler. Sometimes, the compiler cannot do this. In this case, the user should guard his makefiles against including non-threadsafe, non-reentrant libraries. If you link a multithreaded program against libX or libXt, I am pretty sure that these will pass errno in the thread-deadly global variable. The results are sure to be crazy. DEC may be kind enough to provide thread-safe versions of these libraries. In that case, be sure that your multithreaded program is using them. Shaheen -- -- "They're gone, buddy. But, look at the bright side: They're GONE, buddy!" -- The Cat, _Red Dwarf_ Shaheen H. Ali, Hitachi Computer Products, Waltham, MA ali@hi.com, [ space left blank due to unsolicited advice ] work phone: (617) 890 0444, fax: (617) 890 4998 PGP fingerprint = 9C B1 FB F2 A5 62 64 C1 CB 6A E6 3A 86 B0 A4 B7