Re: [PATCH v2] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Corinna Vinschen
On Mar 31 12:18, Peter Foley wrote:
> G++ 6.0 asserts that the "this" pointer is non-null for member functions.
> Refactor methods that check if this is non-null to be static where
> necessary, and remove the check where it is unnecessary.

No, sorry, but now.  Converting all affected functions to static
functions just because this might be null is much too intrusive for my
taste.  *If* that's really a problem going forward, I'd rather see the
pointer test moved into the caller.  But don't waste your time on a
patch yet.
 
Let's please take a step back and look at what happens.  So, here's the
question:  What error message does G++ 6 generate in case of an `if
(this)' test in a member function, and why on earth should it care and
do that?


Corinna

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


signature.asc
Description: PGP signature


Re: [PATCH] Add without-library-checks

2016-04-01 Thread Corinna Vinschen
On Mar 31 12:33, Peter Foley wrote:
> When cross-compiling a toolchan targeting cygwin, building cygwin1.dll
> requires libgcc.
> However, building libgcc requires the cygwin headers to be
> installed.
> Configuring cygwin requries the mingw-crt libraries, which require the
> cygwin headers to be installed.
> Work around this circular dependency by adding a
> --without-library-checks configure option to skip cygwin's configure checks
> for valid mingw-crt libraries.
> Since the mingw-crt libraries only require the cygwin headers to be
> installed, this allows us to successfully configure cygwin so that we
> can only install the headers without trying to build any
> libraries.

Can we please fold the --without-mingw-progs and --without-library-checks
into a single option?  Given the task is basically the same, the option
name should reflect something along the lines of "cross-build",
"bootstrap", and "stage 1", IMO.


Thanks,
Corinna

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


signature.asc
Description: PGP signature


Re: [PATCH 0/6] Protect fork() against dll- and exe-updates.

2016-04-01 Thread Corinna Vinschen
On Mar 30 11:55, Daniel Colascione wrote:
> 
> 
> On 03/30/2016 11:53 AM, Michael Haubenwallner wrote:
> > Hi,
> > 
> > this is the updated and split series of patches to use hardlinks
> > for creating the child process by fork(), in reply to
> > https://cygwin.com/ml/cygwin-developers/2016-01/msg2.html
> > https://cygwin.com/ml/cygwin-developers/2016-03/msg5.html
> > http://thread.gmane.org/gmane.os.cygwin.devel/1378
> > 
> > Thanks for review!
> > /haubi/
> > 
> > 
> 
> Creating a new process now requires a write operation on the filesystem
> hosting the binary? Seriously? I don't think that's worth it no matter
> the other benefits.

I'm with you on that, but as long as the entire functionality is
*optional* and does *not* affect environments not using it, it should
be ok.

What I'm concerned about is the size of the patches required to make
this stuff work.  I have to review this carefully but I need some time.


Corinna

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


signature.asc
Description: PGP signature


Re: [PATCH 4/6] forkables: Protect fork against dll-, exe-updates.

2016-04-01 Thread Corinna Vinschen
On Mar 30 21:12, Michael Haubenwallner wrote:
> On 03/30/2016 09:04 PM, Yaakov Selkowitz wrote:
> > On 2016-03-30 13:53, Michael Haubenwallner wrote:
> >> To support in-cygwin package managers, the fork() implementation must
> >> not rely on .exe and .dll files to stay in their original location, as
> >> the package manager's job is to replace these files.  Instead, we use
> >> the hardlinks to the original binaries in /var/run/cygfork/ to create
> >> the child process during fork, and let the main.exe.local file enable
> >> the "DotLocal Dll Redirection" feature for dlls.
> >>
> >> The (probably few) users that need an update-safe fork manually have to
> >> create the /var/run/cygfork/ directory for now, using:
> >> mkdir --mode=a=rwxt /var/run/cygfork
> > 
> > Have the security implications of this been considered?
> 
> Which security implications do you think of?
> 
> Removed but in-use binaries are available in the recycle bin anyway,
> and can manually be hardlinked to wherever one likes...

Permissions on the parent dirs and the files are always an issue...


Corinna

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


signature.asc
Description: PGP signature


Re: [PATCH 1/4] Remove leftover cruft from config.h.in

2016-04-01 Thread Corinna Vinschen
On Mar 31 14:04, Peter Foley wrote:
> HAVE_BUILTIN_MEMTEST and AC_ALLOCA were removed in 4bd8eb7d1b.
> Cleanup leftover references.

> Use the 3-arg form of AC_DEFINE.

> MALLOC_DEBUG and NEWVFORK haven't been defined since 2008
> (46162537516c5e5fbb).  Remove all references to tem.

> Don't use obsolete LIB_AC_PROG_CC.
> Run autoupdate.

All patches applied.  Given that patch 3 made MALLOC_CHECK obsolete,
I removed the definition and all calls in an extra patch.

Btw., if it's not asked too much I'd be glad if a patch series like this
comes with a cover letter (e.g. git format-patch --cover-letter).


Thanks,
Corinna

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


signature.asc
Description: PGP signature


Re: [PATCH v2] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Yaakov Selkowitz

On 2016-04-01 07:13, Corinna Vinschen wrote:

On Mar 31 12:18, Peter Foley wrote:

G++ 6.0 asserts that the "this" pointer is non-null for member functions.
Refactor methods that check if this is non-null to be static where
necessary, and remove the check where it is unnecessary.


No, sorry, but now.  Converting all affected functions to static
functions just because this might be null is much too intrusive for my
taste.  *If* that's really a problem going forward, I'd rather see the
pointer test moved into the caller.  But don't waste your time on a
patch yet.

Let's please take a step back and look at what happens.  So, here's the
question:  What error message does G++ 6 generate in case of an `if
(this)' test in a member function, and why on earth should it care and
do that?


See https://gcc.gnu.org/gcc-6/porting_to.html, section named 
"Optimizations remove null pointer checks for this".


--
Yaakov


Re: [PATCH 1/4] Remove leftover cruft from config.h.in

2016-04-01 Thread Peter Foley
On Fri, Apr 1, 2016 at 8:27 AM, Corinna Vinschen
 wrote:
> Btw., if it's not asked too much I'd be glad if a patch series like this
> comes with a cover letter (e.g. git format-patch --cover-letter).

Sure, will do in future.


Re: [PATCH] Add without-library-checks

2016-04-01 Thread Peter Foley
On Fri, Apr 1, 2016 at 8:16 AM, Corinna Vinschen
 wrote:
> Can we please fold the --without-mingw-progs and --without-library-checks
> into a single option?  Given the task is basically the same, the option
> name should reflect something along the lines of "cross-build",
> "bootstrap", and "stage 1", IMO.

Sure,
Maybe --with-cross-bootstrap?
I'll respin this when I get a chance.


Re: [PATCH v2] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Peter Foley
On Fri, Apr 1, 2016 at 9:12 AM, Yaakov Selkowitz  wrote:
> See https://gcc.gnu.org/gcc-6/porting_to.html, section named "Optimizations
> remove null pointer checks for this".

If there's an better way to do this, I'm all ears.
However, it seems to come down to either making these methods static
or passing -fno-delete-null-pointer-checks unconditionally once gcc
6.0 becomes stable.

Thanks,

Peter


Re: [PATCH v2] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Corinna Vinschen
On Apr  1 08:12, Yaakov Selkowitz wrote:
> On 2016-04-01 07:13, Corinna Vinschen wrote:
> >On Mar 31 12:18, Peter Foley wrote:
> >>G++ 6.0 asserts that the "this" pointer is non-null for member functions.
> >>Refactor methods that check if this is non-null to be static where
> >>necessary, and remove the check where it is unnecessary.
> >
> >No, sorry, but now.  Converting all affected functions to static
> >functions just because this might be null is much too intrusive for my
> >taste.  *If* that's really a problem going forward, I'd rather see the
> >pointer test moved into the caller.  But don't waste your time on a
> >patch yet.
> >
> >Let's please take a step back and look at what happens.  So, here's the
> >question:  What error message does G++ 6 generate in case of an `if
> >(this)' test in a member function, and why on earth should it care and
> >do that?
> 
> See https://gcc.gnu.org/gcc-6/porting_to.html, section named "Optimizations
> remove null pointer checks for this".

Oh well.  I kind of start to miss the K&R times...

Just kidding.  I think.


Corinna

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


signature.asc
Description: PGP signature


Re: [PATCH v2] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Corinna Vinschen
On Apr  1 09:34, Peter Foley wrote:
> On Fri, Apr 1, 2016 at 9:12 AM, Yaakov Selkowitz  
> wrote:
> > See https://gcc.gnu.org/gcc-6/porting_to.html, section named "Optimizations
> > remove null pointer checks for this".
> 
> If there's an better way to do this, I'm all ears.

As I mentioned in my first reply, I'd prefer if the callers check the
pointer explicitly.  Changing the methods to static methods seems ...
wrong.  Ugly, if you don't mind me saying so.


Thanks,
Corinna

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


signature.asc
Description: PGP signature


Re: [PATCH v2] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Peter Foley
On Fri, Apr 1, 2016 at 11:10 AM, Corinna Vinschen
 wrote:
> As I mentioned in my first reply, I'd prefer if the callers check the
> pointer explicitly.  Changing the methods to static methods seems ...
> wrong.  Ugly, if you don't mind me saying so.

Fair enough, I'll respin this at some point.


Re: [PATCH] Add without-library-checks

2016-04-01 Thread Corinna Vinschen
On Apr  1 09:31, Peter Foley wrote:
> On Fri, Apr 1, 2016 at 8:16 AM, Corinna Vinschen
>  wrote:
> > Can we please fold the --without-mingw-progs and --without-library-checks
> > into a single option?  Given the task is basically the same, the option
> > name should reflect something along the lines of "cross-build",
> > "bootstrap", and "stage 1", IMO.
> 
> Sure,
> Maybe --with-cross-bootstrap?

Sounds good.


Thanks,
Corinna

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


signature.asc
Description: PGP signature


[RFC PATCH v3] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Peter Foley
G++ 6.0 asserts that the "this" pointer is non-null for member
functions.
Refactor methods that check if this is non-null to resolve this.

Signed-off-by: Peter Foley 
---
Just wanted to make sure that this approach looked good before I fix all the 
problematic files.

 winsup/cygwin/fhandler_dsp.cc | 55 +++
 1 file changed, 40 insertions(+), 15 deletions(-)

diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc
index 9fa2c6e..55944b4 100644
--- a/winsup/cygwin/fhandler_dsp.cc
+++ b/winsup/cygwin/fhandler_dsp.cc
@@ -65,7 +65,7 @@ class fhandler_dev_dsp::Audio
   void convert_S16LE_S16BE (unsigned char *buffer, int size_bytes);
   void fillFormat (WAVEFORMATEX * format,
   int rate, int bits, int channels);
-  unsigned blockSize (int rate, int bits, int channels);
+  static unsigned blockSize (int rate, int bits, int channels);
   void (fhandler_dev_dsp::Audio::*convert_)
 (unsigned char *buffer, int size_bytes);
 
@@ -117,6 +117,7 @@ class fhandler_dev_dsp::Audio_out: public Audio
   void stop (bool immediately = false);
   int write (const char *pSampleData, int nBytes);
   void buf_info (audio_buf_info *p, int rate, int bits, int channels);
+  static void default_buf_info (audio_buf_info *p, int rate, int bits, int 
channels);
   void callback_sampledone (WAVEHDR *pHdr);
   bool parsewav (const char *&pData, int &nBytes,
 int rate, int bits, int channels);
@@ -151,6 +152,7 @@ public:
   void stop ();
   bool read (char *pSampleData, int &nBytes);
   void buf_info (audio_buf_info *p, int rate, int bits, int channels);
+  static void default_buf_info (audio_buf_info *p, int rate, int bits, int 
channels);
   void callback_blockfull (WAVEHDR *pHdr);
 
 private:
@@ -501,11 +503,11 @@ void
 fhandler_dev_dsp::Audio_out::buf_info (audio_buf_info *p,
   int rate, int bits, int channels)
 {
-  p->fragstotal = MAX_BLOCKS;
-  if (this && dev_)
+  if (dev_)
 {
   /* If the device is running we use the internal values,
 possibly set from the wave file. */
+  p->fragstotal = MAX_BLOCKS;
   p->fragsize = blockSize (freq_, bits_, channels_);
   p->fragments = Qisr2app_->query ();
   if (pHdr_ != NULL)
@@ -516,10 +518,17 @@ fhandler_dev_dsp::Audio_out::buf_info (audio_buf_info *p,
 }
   else
 {
+  default_buf_info(p, rate, bits, channels);
+}
+}
+
+void fhandler_dev_dsp::Audio_out::default_buf_info (audio_buf_info *p,
+int rate, int bits, int 
channels)
+{
+  p->fragstotal = MAX_BLOCKS;
   p->fragsize = blockSize (rate, bits, channels);
   p->fragments = MAX_BLOCKS;
   p->bytes = p->fragsize * p->fragments;
-}
 }
 
 /* This is called on an interupt so use locking.. Note Qisr2app_
@@ -953,14 +962,23 @@ fhandler_dev_dsp::Audio_in::waitfordata ()
   return true;
 }
 
+void fhandler_dev_dsp::Audio_in::default_buf_info (audio_buf_info *p,
+int rate, int bits, int 
channels)
+{
+  p->fragstotal = MAX_BLOCKS;
+  p->fragsize = blockSize (rate, bits, channels);
+  p->fragments = 0;
+  p->bytes = 0;
+}
+
 void
 fhandler_dev_dsp::Audio_in::buf_info (audio_buf_info *p,
  int rate, int bits, int channels)
 {
-  p->fragstotal = MAX_BLOCKS;
-  p->fragsize = blockSize (rate, bits, channels);
-  if (this && dev_)
+  if (dev_)
 {
+  p->fragstotal = MAX_BLOCKS;
+  p->fragsize = blockSize (rate, bits, channels);
   p->fragments = Qisr2app_->query ();
   if (pHdr_ != NULL)
p->bytes = pHdr_->dwBytesRecorded - bufferIndex_
@@ -970,8 +988,7 @@ fhandler_dev_dsp::Audio_in::buf_info (audio_buf_info *p,
 }
   else
 {
-  p->fragments = 0;
-  p->bytes = 0;
+  default_buf_info(p, rate, bits, channels);
 }
 }
 
@@ -1345,9 +1362,13 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
return -1;
  }
audio_buf_info *p = (audio_buf_info *) buf;
-   audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
-   debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
- buf, p->fragments, p->fragsize, p->bytes);
+if (audio_out_) {
+audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
+} else {
+Audio_out::default_buf_info(p, audiofreq_, audiobits_, 
audiochannels_);
+}
+debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
+  buf, p->fragments, p->fragsize, p->bytes);
return 0;
   }
 
@@ -1359,9 +1380,13 @@ fhandler_dev_dsp::_ioctl (unsigned int cmd, void *buf)
return -1;
  }
audio_buf_info *p = (audio_buf_info *) buf;
-   audio_in_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
-   debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
- buf, p->fragments

Re: [RFC PATCH v3] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Corinna Vinschen
On Apr  1 11:42, Peter Foley wrote:
> G++ 6.0 asserts that the "this" pointer is non-null for member
> functions.
> Refactor methods that check if this is non-null to resolve this.
> 
> Signed-off-by: Peter Foley 
> ---
> Just wanted to make sure that this approach looked good before I fix
> all the problematic files.

Looks good to me, except for a style issue:

> - audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
> - debug_printf ("buf=%p frags=%d fragsize=%d bytes=%d",
> -   buf, p->fragments, p->fragsize, p->bytes);
> +if (audio_out_) {
> +audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
> +} else {
> +Audio_out::default_buf_info(p, audiofreq_, audiobits_, 
> audiochannels_);
> +}

I guess this was just a result of speed-typing :) but that should be

  if (audio_out_)
{
  ...
}
  else
{
  ...
}

OTOH, single-line statements shouldn't use braces at all:

   if (audio_out_)
 audio_out_->buf_info (p, audiofreq_, audiobits_, audiochannels_);
   else
 Audio_out::default_buf_info(p, audiofreq_, audiobits_, audiochannels_);

Other than that, please go ahead.


Thanks,
Corinna

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


signature.asc
Description: PGP signature


Re: [RFC PATCH v3] Refactor to avoid nonnull checks on "this" pointer.

2016-04-01 Thread Peter Foley
On Fri, Apr 1, 2016 at 12:24 PM, Corinna Vinschen
 wrote:
> Other than that, please go ahead.

Will do.


[PATCH 0/4] Various fixes for 2.5.0

2016-04-01 Thread Yaakov Selkowitz
An assortment of unrelated patches discovered in the process of rebuilding
GCC with 2.5.0-0.10.

Yaakov Selkowitz (4):
  Feature test macros overhaul: Cygwin pthread.h
  cygwin/math: make isinf functions signed
  cygwin: update sysconf for new features
  winsup/utils: port getconf to 64-bit

 winsup/cygwin/include/pthread.h | 29 +
 winsup/cygwin/math/isinf.c  |  6 +++---
 winsup/cygwin/sysconf.cc|  6 +++---
 winsup/utils/getconf.c  | 35 +++
 4 files changed, 50 insertions(+), 26 deletions(-)

-- 
2.7.4



[PATCH 1/4] Feature test macros overhaul: Cygwin pthread.h

2016-04-01 Thread Yaakov Selkowitz
As a Cygwin-specific header, there is no need to guard functions based on
capability macros.  Instead, guard several blocks based on additions or
removals in later versions of POSIX.1, along with a few which are only
XSI or GNU extensions.

Signed-off-by: Yaakov Selkowitz 
---
 winsup/cygwin/include/pthread.h | 29 +
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/winsup/cygwin/include/pthread.h b/winsup/cygwin/include/pthread.h
index 84e0a14..83631dd 100644
--- a/winsup/cygwin/include/pthread.h
+++ b/winsup/cygwin/include/pthread.h
@@ -75,9 +75,6 @@ int pthread_attr_getinheritsched (const pthread_attr_t *, int 
*);
 int pthread_attr_getschedparam (const pthread_attr_t *, struct sched_param *);
 int pthread_attr_getschedpolicy (const pthread_attr_t *, int *);
 int pthread_attr_getscope (const pthread_attr_t *, int *);
-int pthread_attr_getstack (const pthread_attr_t *, void **, size_t *);
-int pthread_attr_getstackaddr (const pthread_attr_t *, void **)
-__attribute__ ((__deprecated__));
 int pthread_attr_init (pthread_attr_t *);
 int pthread_attr_setdetachstate (pthread_attr_t *, int);
 int pthread_attr_setguardsize (pthread_attr_t *, size_t);
@@ -86,16 +83,18 @@ int pthread_attr_setschedparam (pthread_attr_t *, const 
struct sched_param *);
 int pthread_attr_setschedpolicy (pthread_attr_t *, int);
 int pthread_attr_setscope (pthread_attr_t *, int);
 
-#ifdef _POSIX_THREAD_ATTR_STACKADDR
+#if __POSIX_VISIBLE >= 200112
+int pthread_attr_getstack (const pthread_attr_t *, void **, size_t *);
 int pthread_attr_setstack (pthread_attr_t *, void *, size_t);
+#endif
+#if __POSIX_VISIBLE < 200809
+int pthread_attr_getstackaddr (const pthread_attr_t *, void **)
+__attribute__ ((__deprecated__));
 int pthread_attr_setstackaddr (pthread_attr_t *, void *)
 __attribute__ ((__deprecated__));
 #endif
-
-#ifdef _POSIX_THREAD_ATTR_STACKSIZE
 int pthread_attr_getstacksize (const pthread_attr_t *, size_t *);
 int pthread_attr_setstacksize (pthread_attr_t *, size_t);
-#endif
 
 int pthread_cancel (pthread_t);
 /* Macros for cleanup_push and pop;
@@ -135,6 +134,7 @@ int pthread_condattr_setclock (pthread_condattr_t *, 
clockid_t);
 int pthread_condattr_setpshared (pthread_condattr_t *, int);
 
 /* Barriers */
+#if __POSIX_VISIBLE >= 200112
 int pthread_barrierattr_init (pthread_barrierattr_t *);
 int pthread_barrierattr_setpshared (pthread_barrierattr_t *, int);
 int pthread_barrierattr_getpshared (const pthread_barrierattr_t *, int *);
@@ -143,6 +143,7 @@ int pthread_barrier_init (pthread_barrier_t *,
   const pthread_barrierattr_t *, unsigned);
 int pthread_barrier_destroy (pthread_barrier_t *);
 int pthread_barrier_wait (pthread_barrier_t *);
+#endif
 
 /* Threads */
 int pthread_create (pthread_t *, const pthread_attr_t *,
@@ -150,7 +151,9 @@ int pthread_create (pthread_t *, const pthread_attr_t *,
 int pthread_detach (pthread_t);
 int pthread_equal (pthread_t, pthread_t);
 void pthread_exit (void *) __attribute__ ((__noreturn__));
+#if __POSIX_VISIBLE >= 200112
 int pthread_getcpuclockid (pthread_t, clockid_t *);
+#endif
 int pthread_getschedparam (pthread_t, int *, struct sched_param *);
 void *pthread_getspecific (pthread_key_t);
 int pthread_join (pthread_t, void **);
@@ -177,13 +180,16 @@ int pthread_mutexattr_setpshared (pthread_mutexattr_t *, 
int);
 int pthread_mutexattr_settype (pthread_mutexattr_t *, int);
 
 /* Spinlocks */
+#if __POSIX_VISIBLE >= 200112
 int pthread_spin_destroy (pthread_spinlock_t *);
 int pthread_spin_init (pthread_spinlock_t *, int);
 int pthread_spin_lock (pthread_spinlock_t *);
 int pthread_spin_trylock (pthread_spinlock_t *);
 int pthread_spin_unlock (pthread_spinlock_t *);
+#endif
 
 /* RW Locks */
+#if __XSI_VISIBLE >= 500 || __POSIX_VISIBLE >= 200112
 int pthread_rwlock_destroy (pthread_rwlock_t *rwlock);
 int pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t 
*attr);
 int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock);
@@ -196,12 +202,15 @@ int pthread_rwlockattr_getpshared (const 
pthread_rwlockattr_t *attr,
   int *pshared);
 int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *attr, int pshared);
 int pthread_rwlockattr_destroy (pthread_rwlockattr_t *rwlockattr);
+#endif
 
 int pthread_once (pthread_once_t *, void (*)(void));
 
+#if __XSI_VISIBLE >= 500
 /* Concurrency levels - X/Open interface */
 int pthread_getconcurrency (void);
 int pthread_setconcurrency (int);
+#endif
 
 
 pthread_t pthread_self (void);
@@ -214,11 +223,15 @@ void pthread_testcancel (void);
 
 /* Non posix calls */
 
+#if __GNU_VISIBLE
 int pthread_getattr_np (pthread_t, pthread_attr_t *);
 int pthread_sigqueue (pthread_t *, int, const union sigval);
+int pthread_yield (void);
+#endif
+#if __MISC_VISIBLE /* HP-UX, others? */
 int pthread_suspend (pthread_t);
 int pthread_continue (pthread_t);
-int pthread_yield (void);
+#endif
 
 #ifdef __cplusplus
 }
-- 
2.7.4



[PATCH 2/4] cygwin/math: make isinf functions signed

2016-04-01 Thread Yaakov Selkowitz
glibc returns -1 for negative infinity:

http://man7.org/linux/man-pages/man3/isinfl.3.html
https://sourceware.org/bugzilla/show_bug.cgi?id=15367

Signed-off-by: Yaakov Selkowitz 
---
 winsup/cygwin/math/isinf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/math/isinf.c b/winsup/cygwin/math/isinf.c
index e7d3e26..fd9e299 100644
--- a/winsup/cygwin/math/isinf.c
+++ b/winsup/cygwin/math/isinf.c
@@ -1,18 +1,18 @@
 int
 isinf (double x)
 {
-  return __builtin_isinf (x);
+  return __builtin_isinf_sign (x);
 }
 
 int
 isinff (float x)
 {
-  return __builtin_isinf (x);
+  return __builtin_isinf_sign (x);
 }
 
 int
 isinfl (long double x)
 {
-  return __builtin_isinf (x);
+  return __builtin_isinf_sign (x);
 }
 
-- 
2.7.4



[PATCH 4/4] winsup/utils: port getconf to 64-bit

2016-04-01 Thread Yaakov Selkowitz
The available specifications obviously differ on 32-bit and 64-bit, as
already handled in .

Signed-off-by: Yaakov Selkowitz 
---
 winsup/utils/getconf.c | 35 +++
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/winsup/utils/getconf.c b/winsup/utils/getconf.c
index 8732be1..993aa29 100644
--- a/winsup/utils/getconf.c
+++ b/winsup/utils/getconf.c
@@ -385,22 +385,33 @@ struct spec_variable {
   int valid;
 };
 
+#if __LP64__
+#define ILP32 0
+#define LP64 1
+#else
+#define ILP32 1
+#define LP64 0
+#endif
+
 static const struct spec_variable spec_table[] = {
-  { "POSIX_V7_ILP32_OFF32",0 },
-  { "POSIX_V7_ILP32_OFFBIG",   1 },
-  { "POSIX_V7_LP64_OFF64", 0 },
-  { "POSIX_V7_LPBIG_OFFBIG",   0 },
-  { "POSIX_V6_ILP32_OFF32",0 },
-  { "POSIX_V6_ILP32_OFFBIG",   1 },
-  { "POSIX_V6_LP64_OFF64", 0 },
-  { "POSIX_V6_LPBIG_OFFBIG",   0 },
-  { "XBS5_ILP32_OFF32",0 },
-  { "XBS5_ILP32_OFFBIG",   1 },
-  { "XBS5_LP64_OFF64", 0 },
-  { "XBS5_LPBIG_OFFBIG",   0 },
+  { "POSIX_V7_ILP32_OFF32",0   },
+  { "POSIX_V7_ILP32_OFFBIG",   ILP32   },
+  { "POSIX_V7_LP64_OFF64", LP64},
+  { "POSIX_V7_LPBIG_OFFBIG",   LP64},
+  { "POSIX_V6_ILP32_OFF32",0   },
+  { "POSIX_V6_ILP32_OFFBIG",   ILP32   },
+  { "POSIX_V6_LP64_OFF64", LP64},
+  { "POSIX_V6_LPBIG_OFFBIG",   LP64},
+  { "XBS5_ILP32_OFF32",0   },
+  { "XBS5_ILP32_OFFBIG",   ILP32   },
+  { "XBS5_LP64_OFF64", LP64},
+  { "XBS5_LPBIG_OFFBIG",   LP64},
   { NULL, 0 },
 };
 
+#undef ILP32
+#undef LP64
+
 static int a_flag = 0; /* list all variables */
 static int v_flag = 0; /* follow given specification */
 
-- 
2.7.4



[PATCH 3/4] cygwin: update sysconf for new features

2016-04-01 Thread Yaakov Selkowitz
POSIX spawn and thread barriers have since been added.  Also fix a typo in
_POSIX2_C_DEV (result is the same).

Signed-off-by: Yaakov Selkowitz 
---
 winsup/cygwin/sysconf.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/sysconf.cc b/winsup/cygwin/sysconf.cc
index ae35c6e..0d33bcb 100644
--- a/winsup/cygwin/sysconf.cc
+++ b/winsup/cygwin/sysconf.cc
@@ -565,7 +565,7 @@ static struct
   {cons, {c:PTHREAD_DESTRUCTOR_ITERATIONS}},   /*  53, 
_SC_THREAD_DESTRUCTOR_ITERATIONS */
   {cons, {c:_POSIX_ADVISORY_INFO}},/*  54, _SC_ADVISORY_INFO */
   {cons, {c:ATEXIT_MAX}},  /*  55, _SC_ATEXIT_MAX */
-  {cons, {c:-1L}}, /*  56, _SC_BARRIERS */
+  {cons, {c:_POSIX_BARRIERS}}, /*  56, _SC_BARRIERS */
   {cons, {c:BC_BASE_MAX}}, /*  57, _SC_BC_BASE_MAX */
   {cons, {c:BC_DIM_MAX}},  /*  58, _SC_BC_DIM_MAX */
   {cons, {c:BC_SCALE_MAX}},/*  59, _SC_BC_SCALE_MAX */
@@ -584,7 +584,7 @@ static struct
   {cons, {c:_POSIX_REGEXP}},   /*  72, _SC_REGEXP */
   {cons, {c:RE_DUP_MAX}},  /*  73, _SC_RE_DUP_MAX */
   {cons, {c:_POSIX_SHELL}},/*  74, _SC_SHELL */
-  {cons, {c:-1L}}, /*  75, _SC_SPAWN */
+  {cons, {c:_POSIX_SPAWN}},/*  75, _SC_SPAWN */
   {cons, {c:_POSIX_SPIN_LOCKS}},   /*  76, _SC_SPIN_LOCKS */
   {cons, {c:-1L}}, /*  77, _SC_SPORADIC_SERVER */
   {nsup, {c:0}},   /*  78, _SC_SS_REPL_MAX */
@@ -618,7 +618,7 @@ static struct
   {cons, {c:_XOPEN_VERSION}},  /* 106, _SC_XOPEN_VERSION */
   {cons, {c:_POSIX2_CHAR_TERM}},   /* 107, _SC_2_CHAR_TERM */
   {cons, {c:_POSIX2_C_BIND}},  /* 108, _SC_2_C_BIND */
-  {cons, {c:_POSIX2_C_BIND}},  /* 109, _SC_2_C_DEV */
+  {cons, {c:_POSIX2_C_DEV}},   /* 109, _SC_2_C_DEV */
   {cons, {c:-1L}}, /* 110, _SC_2_FORT_DEV */
   {cons, {c:-1L}}, /* 111, _SC_2_FORT_RUN */
   {cons, {c:-1L}}, /* 112, _SC_2_LOCALEDEF */
-- 
2.7.4