Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Subject: oldhand cygwinner needed: RE: __errno_location() like functionality in Cygwin Date: Fri, 4 May 2001 16:38:41 +1000 MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Message-ID: X-MS-Has-Attach: content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.4417.0 X-MS-TNEF-Correlator: Thread-Topic: __errno_location() like functionality in Cygwin Thread-Index: AcDUYO7wrqvNmxs4SyqALMBJo8iSNQAABsPA From: "Robert Collins" To: "Dmitry Timoshkov" , Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id CAA19253 > -----Original Message----- > From: Dmitry Timoshkov [mailto:dmitry AT sloboda DOT ru] > Sent: Friday, May 04, 2001 5:18 PM > To: cygwin AT cygwin DOT com > Subject: Re: __errno_location() like functionality in Cygwin > > > Hello again. > > I wrote: > > > I'm new to this list. I'd like to know, is it possible to define > > my own __errno() function, which will provide functionality like > > __errno_location() in linux? > > > > This simple program works in linux, but doesn't under Cygwin: > [sample skipped] > > I'm sorry, perhaps I sent too little information to make > things to be more clear. Probably. I would have commented if I'd realised you were having trouble with threads. > I have installed Cygwin 1.1.8 on win2000 and want to port > multithreaded application > that currently works under Linux. > > That application allocates for each created thread Thread > Local Storage and saves in it > its own errno variable. Application defines its own function > __errno_location in which > it returns address of that thread local errno variable. Can > anybody shed some light > whether it possible or not to do the same trick under Cygwin? > Or just say that it is > impossible? Do you mean TLS or pthread_key's ? Using native windows threads calls will break libc to some degree or another. > I searched archives of this mailing list and have read FAQ > and documentation about > two possible ways to achieve reentrancy using reent struct. > The first method requires > to replace all standard library calls by their _*_r > equivalents. That's not an option. Why not? If you are writing threaded applications, you must either a) use thread safe library functions or b) syncronise your code. If you have taken option b) then you are already thread safe. If you have not taken option b) then you are using functions that are not guaranteed thread safe (_r functions usually are, but a lot of non _r functions are also guaranteed thread safe. The point is that option a) involves checking). > The second method requires to assign _impure_ptr to the > pointer of thread local reent > structrure before EVERY libc call. Am I understand it correctly? Uhmm, I have no idea what you mean here. You should have _no_ static variables that are unguarded (ie don't use mutexs) and all global structs should have their access guarded. As for errno in cygwin I'm not sure off the top of my head as to it's thread safeness... comments anyone? Rob > Thanks in advance for any pointers and suggestions. > -- > Dmitry. > > > > -- > Want to unsubscribe from this list? > Check out: http://cygwin.com/ml/#unsubscribe-simple > > -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple