Peter Foley | 30 Mar 15:15 2016

[PATCH] fix typo in netinit/ip.h

The type for the ip_tos member was typoed, fix it.

include/netinet/ip.h: fix type of ip_tos

Signed-off-by: Peter Foley <pefoley2 <at>>
 winsup/cygwin/include/netinet/ip.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/include/netinet/ip.h b/winsup/cygwin/include/netinet/ip.h
index b952d53..1f6ebbe 100644
--- a/winsup/cygwin/include/netinet/ip.h
+++ b/winsup/cygwin/include/netinet/ip.h
 <at>  <at>  -63,7 +63,7  <at>  <at>  struct ip {
 		     ip_hl:4;		/* header length */
 #endif /* not _IP_VHL */
-	u_int_8   ip_tos;		/* type of service */
+	u_int8_t   ip_tos;		/* type of service */
 	u_int16_t ip_len;		/* total length */
 	u_int16_t ip_id;		/* identification */
 	u_int16_t ip_off;		/* fragment offset field */


Yaakov Selkowitz | 28 Mar 19:48 2016

[PATCH] cygwin: export __getpagesize

The inclusion of <sys/cygwin.h> by <sys/shm.h>, besides causing namespace
pollution, also makes it very difficult to get the WINVER-dependent parts
of the former.  This affects code (such as x11vnc -unixpw_nis) which use
both SysV shared memory (e.g. the X11 MIT-SHM extension) and user password

getpagesize is the simplest function to retreive this information, but it
is a legacy function and would also pollute the global namespace. The LSB
lists another form which is in the implementation-reserved namespace:

Signed-off-by: Yaakov Selkowitz <yselkowi <at>>
 winsup/cygwin/common.din               | 1 +
 winsup/cygwin/include/cygwin/shm.h     | 5 +++--
 winsup/cygwin/include/cygwin/version.h | 3 ++-
 winsup/cygwin/                   | 4 ++++
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din
index fe714d8..7e72abe 100644
--- a/winsup/cygwin/common.din
+++ b/winsup/cygwin/common.din
 <at>  <at>  -60,6 +60,7  <at>  <at>  __freading NOSIGFE
 __fsetlocking SIGFE
 __fwritable NOSIGFE
 __fwriting NOSIGFE
+__getpagesize = getpagesize SIGFE
 __getreent NOSIGFE
(Continue reading)

Peter Foley | 21 Mar 17:43 2016

Update toplevel files from gcc

When building a cross compiler targeting cygwin, the target objcopy
binary wasn't properly picked up.
It appears that a fix for this has been commited to the gcc tree;a=commit;h=fc740d700395d97b6719e8a0e64f75d01ab0d8fd

A patch to copy the updated Makefile.def, Makefile.tpl and from gcc and regenerate and configure is
1.4M, so too large to send to the mailing list.

Would it be possible for someone to sync the latest toplevel files from gcc?


Peter Foley

Peter Foley | 19 Mar 18:45 2016

[PATCH 01/11] Remove unused and unsafe call to __builtin_frame_address

initial_sp has been unused since commit fbf23e3 back in 2000.
Keep the value, so as to avoid changing the offset of magic_biscuit.

error: calling 'void* __builtin_frame_address(unsigned int)' with a
nonzero argument is unsafe [-Werror=frame-address]
   u->initial_sp = (char *) __builtin_frame_address (1);

lib/ (_cygwin_crt0_common): Initialize initial_sp
with nullptr.

Signed-off-by: Peter Foley <pefoley2 <at>>
 winsup/cygwin/lib/ | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/lib/ b/winsup/cygwin/lib/
index 718ce94..96ebeee 100644
--- a/winsup/cygwin/lib/
+++ b/winsup/cygwin/lib/
 <at>  <at>  -135,9 +135,8  <at>  <at>  _cygwin_crt0_common (MainFunc f, per_process *u)
   u->premain[3] = cygwin_premain3;
   u->fmode_ptr = &_fmode;

-  /* This is used to record what the initial sp was.  The value is needed
-     when copying the parent's stack to the child during a fork.  */
-  u->initial_sp = (char *) __builtin_frame_address (1);
+  /* Unused */
+  u->initial_sp = nullptr;
(Continue reading)

Jon Turney | 15 Mar 14:12 2016

[PATCH] Attempt to fix Coverity issues in ssp

	* ssp.c (lookup_thread_id): Consistently check if tix is a null
	(run_program): Annotate that STATUS_BREAKPOINT falls-through to
	(main): Guard against high_pc-low_pc overflow and malloc failure.

Signed-off-by: Jon Turney <jon.turney <at>>
 winsup/utils/ssp.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/winsup/utils/ssp.c b/winsup/utils/ssp.c
index c9165f3..0bca544 100644
--- a/winsup/utils/ssp.c
+++ b/winsup/utils/ssp.c
 <at>  <at>  -182,7 +182,10  <at>  <at>  static HANDLE
 lookup_thread_id (DWORD threadId, int *tix)
   int i;
-  *tix = 0;
+  if (tix)
+    *tix = 0;
   for (i=0; i<num_active_threads; i++)
     if (active_thread_ids[i] == threadId)
 <at>  <at>  -463,6 +466,7  <at>  <at>  run_program (char *cmdline)
 		      thread_return_address[tix] = rv;
(Continue reading)

Yaakov Selkowitz | 15 Mar 04:13 2016

[PATCH] Cygwin: define byteswap.h inlines as macros

The bswap_* "functions" are macros in glibc, so they may be tested for
by the preprocessor (e.g. #ifdef bswap_16).

Signed-off-by: Yaakov Selkowitz <yselkowi <at>>
 winsup/cygwin/include/byteswap.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/include/byteswap.h b/winsup/cygwin/include/byteswap.h
index cd5a726..9f73c5a 100644
--- a/winsup/cygwin/include/byteswap.h
+++ b/winsup/cygwin/include/byteswap.h
 <at>  <at>  -16,23 +16,27  <at>  <at>  extern "C" {

 static __inline unsigned short
-bswap_16 (unsigned short __x)
+__bswap_16 (unsigned short __x)
   return (__x >> 8) | (__x << 8);

 static __inline unsigned int
-bswap_32 (unsigned int __x)
+__bswap_32 (unsigned int __x)
-  return (bswap_16 (__x & 0xffff) << 16) | (bswap_16 (__x >> 16));
+  return (__bswap_16 (__x & 0xffff) << 16) | (__bswap_16 (__x >> 16));

(Continue reading)

Peter Foley | 14 Mar 23:03 2016

Re: [PATCH] Regenerate newlib/configure

On Mon, Mar 14, 2016 at 12:23 PM, Peter Foley <pefoley2 <at>> wrote:
> Fix undefined libtool macros _LT_DECL_SED and _LT_PROG_ECHO_BACKSLASH
> newlib/ChangeLog
> * configure: Regenerate.
> ---
>  newlib/configure | 9339 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 9306 insertions(+), 33 deletions(-)


Just realized that this should have been sent to the newlib list.
I'll re-submit this there.


Peter Foley

Václav Haisman | 11 Mar 11:28 2016

Fwd: [PATCH] spinlock spin with pause instruction


I have noticed that Cygwin's spinlock goes into heavy sleeping code
for each spin. It seems it would be a good idea to actually try to
spin a bit first. There is this 'pause' instruction which let's the
CPU make such busy loops be less busy. Here is a patch to do this.

diff --git a/winsup/cygwin/ b/winsup/cygwin/
index 01cfd5b..56e66f1 100644
--- a/winsup/cygwin/
+++ b/winsup/cygwin/
 <at>  <at>  -1917,6 +1917,19  <at>  <at>  pthread_spinlock::lock ()
   pthread_t self = ::pthread_self ();
   int result = -1;
+  unsigned spins = 0;
+  /*
+    We want to spin using 'pause' instruction on multi-core system but we
+    want to avoid this on single-core systems.
+    The limit of 1000 spins is semi-arbitrary. Microsoft suggests (in their
+    InitializeCriticalSectionAndSpinCount documentation on MSDN) they are
+    using spin count limit 4000 for their heap manager critical
+    sections. Other source suggest spin count as small as 200 for fast path
+    of mutex locking.
(Continue reading)

Mark Geisert | 11 Mar 09:07 2016

[PATCH] Documentation covering profiling Cygwin programs.

This patch set updates the Cygwin User's Guide to say something about profiling.

Existing winsup/doc files programming.xml and setup-env.xml are updated.
A new winsup/doc file gprof.xml is added.

I'd appreciate any comments y'all may have on formatting and/or content.
Thanks much,

From adc25dc19ade01fe42d4a4446a24b45ddd01f106 Mon Sep 17 00:00:00 2001
From: Mark Geisert <mark <at>>
Date: Thu, 10 Mar 2016 23:56:56 -0800
Subject: [PATCH] Documentation covering profiling Cygwin programs.

 winsup/doc/gprof.xml       | 250 +++++++++++++++++++++++++++++++++++++++++++++
 winsup/doc/programming.xml |   1 +
 winsup/doc/setup-env.xml   |   9 +-
 3 files changed, 259 insertions(+), 1 deletion(-)
 create mode 100644 winsup/doc/gprof.xml

diff --git a/winsup/doc/gprof.xml b/winsup/doc/gprof.xml
new file mode 100644
index 0000000..b2043cb
--- /dev/null
+++ b/winsup/doc/gprof.xml
 <at>  <at>  -0,0 +1,250  <at>  <at> 
+<?xml version="1.0" encoding='UTF-8'?>
(Continue reading)

Mark Geisert | 9 Mar 09:39 2016

[PATCH] Support profiling of multi-threaded apps.

This is Version 3 incorporating review comments of Version 2.  This is just the 
code patch; a separate doc patch is forthcoming.

Change log relative to winsup/cygwin:

         * include/sys/cygwin.h: Add CW_CYGHEAP_PROFTHR_ALL.
         * (cygheap_profthr_all): New C-callable function that
         runs cygheap's threadlist handing each pthread's thread handle in
         turn to profthr_byhandle().
         * (cygwin_internal): Add case CW_CYGHEAP_PROFTHR_ALL.
         * gmon.c (_mcleanup): Add support for multiple simultaneous
         gmon.out* files named via environment variable GMON_OUT_PREFIX.
         * gmon.h (struct gmonparam): Make state decl volatile.
         * mcount.c (_MCOUNT_DECL): Change stores into gmonparam.state to use
         Interlocked operations. Add #include "winsup.h", update commentary.
         * profil.c (profthr_byhandle): New function abstracting out the
         updating of profile counters based on a thread handle.
         (profthr_func): Update to call profthr_byhandle() to sample the main
         thread then call cygheap_profthr_all() indirectly through
         cygwin_internal(CW_CYGHEAP_PROFTHR_ALL) to sample all other threads.
         (profile_off): Zero targthr to indicate profiling was turned off.
         (profile_on): Fix handle leak on failure path.
         (profile_child): New callback func to restart profiling in child
         process after a fork if the parent was being profiled.
         (profile_ctl): Call pthread_atfork() to set profile_child callback.


(Continue reading)

Jon Turney | 8 Mar 12:14 2016

[PATCH] faq: Sort BLODA list and update advice on fixing fork failures

	* faq-using.xml(bloda): Alphabetically sort BLODA list for ease of
	finding things in it.  (fixing-fork-failures) Update to suggest
	rebase-trigger rather than running rebaseall via dash yourself.
	Mention detect_bloda CYGWIN token.

Signed-off-by: Jon Turney <jon.turney <at>>
 winsup/doc/faq-using.xml | 88 ++++++++++++++++++++++++++++++------------------
 1 file changed, 56 insertions(+), 32 deletions(-)

diff --git a/winsup/doc/faq-using.xml b/winsup/doc/faq-using.xml
index ae72145..9194677 100644
--- a/winsup/doc/faq-using.xml
+++ b/winsup/doc/faq-using.xml
 <at>  <at>  -1286,39 +1286,39  <at>  <at>  behaviour which affect the operation of other programs, such as Cygwin.
 <para>Among the software that has been found to cause difficulties are:</para>
-<listitem><para>Sonic Solutions burning software containing DLA component (when DLA disabled)</para></listitem>
-<listitem><para>Norton/McAfee/Symantec antivirus or antispyware</para></listitem>
-<listitem><para>Logitech webcam software with "Logitech process monitor" service</para></listitem>
-<listitem><para>Kerio, Agnitum or ZoneAlarm Personal Firewall</para></listitem>
-<listitem><para>Iolo System Mechanic/AntiVirus/Firewall</para></listitem>
-<listitem><para>Windows Defender </para></listitem>
-<listitem><para>Various programs by Wave Systems Corp using wxvault.dll, including Embassy Trust
Suite and Embassy Security Center</para></listitem>
-<listitem><para>NOD32 Antivirus</para></listitem>
-<listitem><para>ByteMobile laptop optimization client</para></listitem>
-<listitem><para>Earthlink Total-Access</para></listitem>
(Continue reading)