public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* __errno_location() like functionality in Cygwin
@ 2001-05-03  3:37 Dmitry Timoshkov
  2001-05-03 23:18 ` Dmitry Timoshkov
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Timoshkov @ 2001-05-03  3:37 UTC (permalink / raw)
  To: cygwin

Hello.

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:

static int myerrno = 0;
static char buf[256];

int *__errno_location(void)
{
    return &myerrno;
}

int *__errno(void)
{
    return &myerrno;
}

int main(void)
{
    int ret;

    /* provoke an error */
    ret = read(-1, buf, 255);
    printf("ret = %d, myerrno = %d\n", ret, myerrno);

    return 0;
}

Any suggestions?

Thanks in advance.
--
Dmitry.



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: __errno_location() like functionality in Cygwin
  2001-05-03  3:37 __errno_location() like functionality in Cygwin Dmitry Timoshkov
@ 2001-05-03 23:18 ` Dmitry Timoshkov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Timoshkov @ 2001-05-03 23:18 UTC (permalink / raw)
  To: 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.

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?

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.
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?

Thanks in advance for any pointers and suggestions.
--
Dmitry.



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-05-03 23:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-03  3:37 __errno_location() like functionality in Cygwin Dmitry Timoshkov
2001-05-03 23:18 ` Dmitry Timoshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).