Yaakov (Cygwin/X | 2 May 2011 17:33
Picon
Gravatar

[PATCH] pthread_attr_getstack{,addr}, pthread_getattr_np

This implements pthread_attr_getstack(), pthread_attr_getstackaddr, and
pthread_getattr_np(), which I need for webkitgtk.

In essence, I added a stackaddr member to pthread_attr, which is
accessed (slightly differently) by pthread_attr_getstack{,attr},
behaving just as on Linux.  The bulk of the work is to support
pthread_getattr_np, which provides the real attributes of the given
thread, including the real stack address and size.

The pthread_attr_setstack{,addr} setters are not implemented, as I have
yet to find a way to set the thread stack address on Windows.  For that
reason I'm not defining _POSIX_THREAD_ATTR_STACKADDR, as the feature is
not yet (fully) implemented.

Patches for winsup/cygwin and winsup/doc, as well as a sample program
for Cygwin and Linux, attached.

Yaakov

Attachment (pthread-attr-test.c): text/x-csrc, 1046 bytes
Yaakov (Cygwin/X | 2 May 2011 18:07
Picon
Gravatar

[PATCH] define _SC_SPIN_LOCKS

Corresponding patch to newlib just committed; this is the patch for
winsup/cygwin/sysconf.cc.

Yaakov

Corinna Vinschen | 2 May 2011 18:08
Favicon

Re: [PATCH] define _SC_SPIN_LOCKS

On May  2 11:07, Yaakov (Cygwin/X) wrote:
> Corresponding patch to newlib just committed; this is the patch for
> winsup/cygwin/sysconf.cc.
> 
> 
> Yaakov
> 

> 2011-05-02  Yaakov Selkowitz  <yselkowitz <at> ...>
> 
> 	* sysconf.cc (sca): Set _SC_SPIN_LOCKS to _POSIX_SPIN_LOCKS.

Thanks.  Go ahead.

Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Christopher Faylor | 2 May 2011 22:11
Favicon

Re: [PATCH] pthread_attr_getstack{,addr}, pthread_getattr_np

On Mon, May 02, 2011 at 10:33:09AM -0500, Yaakov (Cygwin/X) wrote:
>This implements pthread_attr_getstack(), pthread_attr_getstackaddr, and
>pthread_getattr_np(), which I need for webkitgtk.
>
>In essence, I added a stackaddr member to pthread_attr, which is
>accessed (slightly differently) by pthread_attr_getstack{,attr},
>behaving just as on Linux.  The bulk of the work is to support
>pthread_getattr_np, which provides the real attributes of the given
>thread, including the real stack address and size.
>
>The pthread_attr_setstack{,addr} setters are not implemented, as I have
>yet to find a way to set the thread stack address on Windows.  For that
>reason I'm not defining _POSIX_THREAD_ATTR_STACKADDR, as the feature is
>not yet (fully) implemented.

Cygwin already plays with the stack address.  It has to for situations
when you call fork() from a thread.

>Patches for winsup/cygwin and winsup/doc, as well as a sample program
>for Cygwin and Linux, attached.

The patch looks good.  Please check in.

Thanks.

cgf

Corinna Vinschen | 3 May 2011 09:56
Favicon

Re: [PATCH] pthread_attr_getstack{,addr}, pthread_getattr_np

On May  2 16:11, Christopher Faylor wrote:
> On Mon, May 02, 2011 at 10:33:09AM -0500, Yaakov (Cygwin/X) wrote:
> >This implements pthread_attr_getstack(), pthread_attr_getstackaddr, and
> >pthread_getattr_np(), which I need for webkitgtk.
> >
> >In essence, I added a stackaddr member to pthread_attr, which is
> >accessed (slightly differently) by pthread_attr_getstack{,attr},
> >behaving just as on Linux.  The bulk of the work is to support
> >pthread_getattr_np, which provides the real attributes of the given
> >thread, including the real stack address and size.
> >
> >The pthread_attr_setstack{,addr} setters are not implemented, as I have
> >yet to find a way to set the thread stack address on Windows.  For that
> >reason I'm not defining _POSIX_THREAD_ATTR_STACKADDR, as the feature is
> >not yet (fully) implemented.
> 
> Cygwin already plays with the stack address.  It has to for situations
> when you call fork() from a thread.

Isn't that what GetThreadContext/SetThreadContext is for?

Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Christopher Faylor | 3 May 2011 23:01
Favicon

Re: [PATCH] pthread_attr_getstack{,addr}, pthread_getattr_np

On Tue, May 03, 2011 at 09:56:35AM +0200, Corinna Vinschen wrote:
>On May  2 16:11, Christopher Faylor wrote:
>> On Mon, May 02, 2011 at 10:33:09AM -0500, Yaakov (Cygwin/X) wrote:
>> >This implements pthread_attr_getstack(), pthread_attr_getstackaddr, and
>> >pthread_getattr_np(), which I need for webkitgtk.
>> >
>> >In essence, I added a stackaddr member to pthread_attr, which is
>> >accessed (slightly differently) by pthread_attr_getstack{,attr},
>> >behaving just as on Linux.  The bulk of the work is to support
>> >pthread_getattr_np, which provides the real attributes of the given
>> >thread, including the real stack address and size.
>> >
>> >The pthread_attr_setstack{,addr} setters are not implemented, as I have
>> >yet to find a way to set the thread stack address on Windows.  For that
>> >reason I'm not defining _POSIX_THREAD_ATTR_STACKADDR, as the feature is
>> >not yet (fully) implemented.
>> 
>> Cygwin already plays with the stack address.  It has to for situations
>> when you call fork() from a thread.
>
>Isn't that what GetThreadContext/SetThreadContext is for?

If you're just setting ebp/esp yes but you also have to mess around with
the locations where Windows stores stack frame information.

cgf

Chiheng Xu | 4 May 2011 05:09
Picon

initialize local variable wait_return

--

-- 
Chiheng Xu
Attachment (1.patch): application/octet-stream, 596 bytes
Chiheng Xu | 4 May 2011 05:11
Picon

Re: initialize local variable wait_return

2011-05-04  Chiheng Xu  <chiheng.xu <at> gmail.com>

       * fhandler.cc (fhandler_base_overlapped::wait_overlapped): initialize
local variable wait_return , otherwise, gcc-4.3.4 will not compile it.

--

-- 
Chiheng Xu

Christopher Faylor | 4 May 2011 08:03
Favicon

Re: initialize local variable wait_return

On Wed, May 04, 2011 at 11:11:52AM +0800, Chiheng Xu wrote:
>2011-05-04  Chiheng Xu  <chiheng.xu <at> gmail.com>
>
>       * fhandler.cc (fhandler_base_overlapped::wait_overlapped): initialize
>local variable wait_return , otherwise, gcc-4.3.4 will not compile it.

Sorry but this is the wrong solution to this problem.  I rewrote the
code recently to carefully set error conditions at each decision point.
Globally setting it at the beginning is a step backwards and it actually
masks the real problem.

cgf

Andy Koppe | 4 May 2011 08:04
Picon

locale initialization issue

Hi,

I stumbled across an issues with locale initialization when the "C"
locale is specified in the environment.

$ cat test.c
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>

int main(void) {
  char cs[8];
  puts(nl_langinfo(CODESET));
  printf("%i\n", wctomb(cs, 0x80));
  return 0;
}

The program doesn't call setlocale, so it should be using the "C"
locale with its ASCII charset, which means the wctomb() call with a
codepoint outside the ASCII range should fail. And that's exactly what
happens as long as the locale set in the environment is something
other than "C", e.g.:

$ LC_ALL=C.UTF-8 ./test
ANSI_X3.4-1968
-1

$ LC_ALL=en_GB.ISO-8859-15 ./test
ANSI_X3.4-1968
(Continue reading)


Gmane