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 Message-ID: <001301c0d541$88636620$15782ec3@dima> From: "Dmitry Timoshkov" To: "Robinow, David" Cc: References: <80575AFA5F0DD31197CE00805F650D7602CF04 AT wilber DOT adroit DOT com> Subject: Re: oldhand cygwinner needed: RE: __errno_location() like functionality in Cygwin Date: Sat, 5 May 2001 16:56:52 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-MDRcpt-To: cygwin AT cygwin DOT com X-MDRemoteIP: 195.46.120.21 X-Return-Path: dmitry AT sloboda DOT ru X-MDaemon-Deliver-To: cygwin AT cygwin DOT com "Robinow, David" wrote: > > As I already mentioned, that approach works fine in Linux. As > > far as I know, > > similar mechanisms are provided by FreeBSD (__error()), > > Solaris (___errno()), > > UnixWare (__thr_errno()). > > > > Is it true that Cygwin has no analogous functionality? > I have not actually used threads under Cygwin so I may > be completely wrong here, but here's what I think. > > /usr/include/sys/errno.h defines errno as a macro (int * __errno) > __errno is provided by the operating system. You do not have > to create this yourself. __errno is provided not by the OS, but by the Cygwin1.dll - Cygwin's libc run-time. As far as I know from the sources, Cygwin doesn't allocate new errno instance for each new created thread. It uses _impure_ptr defined as _REENT everywhere in the code. > You do not want to define errno yourself. > Delete any declarations of errno in your program. > You can use errno in your program and it will be thread safe. > It just works. I'm afraid it doesn't. > Somebody please tell me if I'm wrong. Okay, seems it's time to discuss what should be done to achieve needed functionality. I propose introduce new Cygwin function set_errno_location_handler((int* (*__errno_location)(void))) which will set Cygwin internal __errno() pointer to the new one. Something like this: static int *CYGWIN__errno(void) { return &_REENT->_errno; } int* (*__errno)(void) = CYGWIN__errno; void set_errno_location_handler(int* (*new__errno)(void)) { __errno = new__errno; } Any comments? -- Dmitry. -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple