delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/05/05/04:03:30

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
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" <dmitry AT sloboda DOT ru>
To: "Robinow, David" <drobinow AT dayton DOT adroit DOT com>
Cc: <cygwin AT cygwin DOT com>
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
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" <drobinow AT dayton DOT adroit DOT com> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019