[PATCH 7/8] Remove empty MT_SAFE and MT_SAFE_OBJECTS

2020-10-12 Thread Jon Turney
---
 winsup/cygwin/Makefile.in | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 7f19a57fd..6d205f7a7 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -71,7 +71,6 @@ CRT0:=$(cygwin_build)/crt0.o
 #
 # --enable options from configure
 #
-MT_SAFE:=@MT_SAFE@
 CCEXTRA=
 COMMON_CFLAGS=-MMD ${$(*F)_CFLAGS} -Wimplicit-fallthrough=5 -Werror 
-fmerge-constants -ftracer $(CCEXTRA)
 ifeq ($(target_cpu),x86_64)
@@ -147,7 +146,6 @@ MALLOC_OFILES:=malloc.o
 
 DLL_IMPORTS:=${shell $(CC) -print-file-name=w32api/libkernel32.a} ${shell 
$(CC) -print-file-name=w32api/libntdll.a}
 
-MT_SAFE_OBJECTS:=
 #
 LIBC_OFILES:= \
arc4random_stir.o \
@@ -420,7 +418,6 @@ DLL_OFILES:= \
$(LIBC_OFILES) \
$(MATH_OFILES) \
$(TZCODE_OFILES) \
-   $(MT_SAFE_OBJECTS)
 
 EXCLUDE_STATIC_OFILES:=$(addprefix --exclude=,\
cygtls.o \
-- 
2.28.0



[PATCH 4/8] Remove AC_ARG_PROGRAM/program_transform_name

2020-10-12 Thread Jon Turney
Not done consistently, and probably never used.
---
 winsup/cygwin/configure.ac  | 15 ---
 winsup/lsaauth/configure.ac |  2 --
 winsup/utils/Makefile.in|  4 +---
 winsup/utils/configure.ac   |  2 --
 4 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/winsup/cygwin/configure.ac b/winsup/cygwin/configure.ac
index ac019c94e..757ebcfb0 100644
--- a/winsup/cygwin/configure.ac
+++ b/winsup/cygwin/configure.ac
@@ -67,21 +67,6 @@ no)   ;;
 esac
 ])
 
-dnl The only time we might want to transform the install names
-dnl is for unix x cygwin.  Otherwise we don't.  For now we don't
-dnl transform names.
-
-dnl if test "x$cross_compiling" = "xno" -a ; then
-dnl   if test "x$program_transform_name" = "xs,x,x,"; then
-dnl program_transform_name=""
-dnl   fi
-dnl   if test "x$program_transform_name" = "x"; then
-dnl program_transform_name="s,^,$target_alias-,"
-dnl   else
-dnl program_transform_name="$program_transform_name -e s,^,$target_alias-,"
-dnl   fi
-dnl fi
-
 case "$target_cpu" in
i?86)
DLL_NAME="cygwin1.dll"
diff --git a/winsup/lsaauth/configure.ac b/winsup/lsaauth/configure.ac
index 995a0991d..f2b2c6329 100644
--- a/winsup/lsaauth/configure.ac
+++ b/winsup/lsaauth/configure.ac
@@ -32,8 +32,6 @@ esac
 AC_CHECK_PROGS(MINGW64_CC, x86_64-w64-mingw32-gcc)
 test -z "$MINGW64_CC" && AC_MSG_ERROR([no acceptable mingw64 cc found in 
\$PATH])
 
-AC_ARG_PROGRAM
-
 AC_PROG_INSTALL
 
 AC_CONFIG_FILES([Makefile cyglsa.def:cyglsa.din])
diff --git a/winsup/utils/Makefile.in b/winsup/utils/Makefile.in
index 248939645..c3297c6c1 100644
--- a/winsup/utils/Makefile.in
+++ b/winsup/utils/Makefile.in
@@ -37,7 +37,6 @@ prefix:=@prefix@
 exec_prefix:=@exec_prefix@
 
 bindir:=@bindir@
-program_transform_name:=@program_transform_name@
 
 override INSTALL:=@INSTALL@
 override INSTALL_PROGRAM:=@INSTALL_PROGRAM@
@@ -176,8 +175,7 @@ realclean: clean
 install: all
/bin/mkdir -p ${DESTDIR}${bindir}
for i in $(CYGWIN_BINS) ${filter-out testsuite.exe,$(MINGW_BINS)} ; do \
- n=`echo $$i | sed '$(program_transform_name)'`; \
- $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$n; \
+ $(INSTALL_PROGRAM) $$i $(DESTDIR)$(bindir)/$$i; \
done
 
 $(cygwin_build)/libcygwin.a: $(cygwin_build)/Makefile
diff --git a/winsup/utils/configure.ac b/winsup/utils/configure.ac
index 63fc55e56..ce35f9c7b 100644
--- a/winsup/utils/configure.ac
+++ b/winsup/utils/configure.ac
@@ -28,8 +28,6 @@ AC_PROG_CXX
 
 AC_CYGWIN_INCLUDES
 
-AC_ARG_PROGRAM
-
 AC_PROG_INSTALL
 
 AC_CHECK_PROGS(MINGW_CXX, ${target_cpu}-w64-mingw32-g++)
-- 
2.28.0



[PATCH 1/8] Drop looking for w32api in winsup/w32api

2020-10-12 Thread Jon Turney
Stop looking for w32api headers in the (no longer existent)
winsup/w32api directory (removed in commit 61746d6a).
---
 winsup/acinclude.m4 | 2 --
 1 file changed, 2 deletions(-)

diff --git a/winsup/acinclude.m4 b/winsup/acinclude.m4
index 80c920e8c..865ef8b5d 100644
--- a/winsup/acinclude.m4
+++ b/winsup/acinclude.m4
@@ -50,8 +50,6 @@ if test -n "$with_windows_headers"; then
 else
AC_MSG_ERROR([cannot find windef.h in specified --with-windows-headers 
path: $saw_windows_headers]);
 fi
-elif test -d "$winsup_srcdir/w32api/include/windef.h"; then
-windows_headers="$winsup_srcdir/w32api/include"
 else
 windows_headers=$(cd $($ac_cv_prog_CC -xc /dev/null -E -include windef.h 
2>/dev/null | sed -n 's%^# 1 "\([^"]*\)/windef\.h".*$%\1%p' | head -n1) 
2>/dev/null && pwd)
 if test -z "$windows_headers" -o ! -d "$windows_headers"; then
-- 
2.28.0



[PATCH 8/8] Remove unused doc/ug-info.xml

2020-10-12 Thread Jon Turney
Remove doc/ug-info.xml, not used in any document.
---
 winsup/doc/ug-info.xml | 36 
 1 file changed, 36 deletions(-)
 delete mode 100644 winsup/doc/ug-info.xml

diff --git a/winsup/doc/ug-info.xml b/winsup/doc/ug-info.xml
deleted file mode 100644
index c5b4a67c8..0
--- a/winsup/doc/ug-info.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd";>
-
-http://www.w3.org/2001/XInclude";>
-   2001-22-03
-   Cygwin User's Guide
-   
-   
-   Joshua Daniel
-   Franklin
-   
-   
-   Corinna
-   Vinschen
-   
-   
-   Christopher
-   Faylor
-   
-   
-   DJ
-   Delorie
-   
-   
-   Pierre
-   Humblet
-   
-   
-   Geoffrey
-   Noer
-   
-   
-
-   
-
-- 
2.28.0



[PATCH 5/8] Drop AC_SUBST(LIBSERVER)

2020-10-12 Thread Jon Turney
The autoconf variable LIBSERVER isn't defined, and it's value isn't
used. (The Makefile.in contains a literal value for the name of this
library instead).
---
 winsup/cygwin/configure.ac | 1 -
 1 file changed, 1 deletion(-)

diff --git a/winsup/cygwin/configure.ac b/winsup/cygwin/configure.ac
index 757ebcfb0..32862d7e5 100644
--- a/winsup/cygwin/configure.ac
+++ b/winsup/cygwin/configure.ac
@@ -86,7 +86,6 @@ case "$target_cpu" in
 esac
 
 AC_CONFIGURE_ARGS
-AC_SUBST(LIBSERVER)
 AC_SUBST(DLL_NAME)
 AC_SUBST(DLL_ENTRY)
 AC_SUBST(DEF_DLL_ENTRY)
-- 
2.28.0



[PATCH 0/8] Makefile/configure cleanups

2020-10-12 Thread Jon Turney
Some Makefile.in and configure.ac cleanups and de-cruftification.  This is
preparatory to an Automakeification series still being worked on.

For ease of reviewing, this patch doesn't contain changes to generated files
which would be made by a autoreconf.

Jon Turney (8):
  Drop looking for w32api in winsup/w32api
  Drop STDINCFLAGS overrides
  Remove AC_PROG_MAKE_SET
  Remove AC_ARG_PROGRAM/program_transform_name
  Drop AC_SUBST(LIBSERVER)
  Remove autoconf variable INSTALL_LICENSE
  Remove empty MT_SAFE and MT_SAFE_OBJECTS
  Remove unused doc/ug-info.xml

 winsup/Makefile.in|  4 +---
 winsup/acinclude.m4   |  2 --
 winsup/configure.ac   |  6 --
 winsup/cygserver/configure.ac |  2 --
 winsup/cygwin/Makefile.in |  9 -
 winsup/cygwin/configure.ac| 18 --
 winsup/doc/ug-info.xml| 36 ---
 winsup/lsaauth/configure.ac   |  2 --
 winsup/utils/Makefile.in  |  4 +---
 winsup/utils/configure.ac |  2 --
 10 files changed, 2 insertions(+), 83 deletions(-)
 delete mode 100644 winsup/doc/ug-info.xml

-- 
2.28.0



[PATCH 3/8] Remove AC_PROG_MAKE_SET

2020-10-12 Thread Jon Turney
This is only needed if we are using an ancient make which doesn't set
${MAKE}, but we say "This makefile requires GNU make." everywhere.

It only has an effect if @SET_MAKE@ is used, which we aren't doing
consistently.
---
 winsup/configure.ac   | 2 --
 winsup/cygserver/configure.ac | 2 --
 winsup/cygwin/Makefile.in | 2 --
 winsup/cygwin/configure.ac| 2 --
 4 files changed, 8 deletions(-)

diff --git a/winsup/configure.ac b/winsup/configure.ac
index 131dc79ee..e917ee1c5 100644
--- a/winsup/configure.ac
+++ b/winsup/configure.ac
@@ -43,7 +43,5 @@ INSTALL_LICENSE="install-license"
 
 AC_SUBST(INSTALL_LICENSE)
 
-AC_PROG_MAKE_SET
-
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
diff --git a/winsup/cygserver/configure.ac b/winsup/cygserver/configure.ac
index 560de0c05..d8b2a61fa 100644
--- a/winsup/cygserver/configure.ac
+++ b/winsup/cygserver/configure.ac
@@ -55,8 +55,6 @@ AC_CHECK_TOOL(NM, nm, nm)
 AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool)
 AC_CHECK_TOOL(WINDRES, windres, windres)
 
-AC_PROG_MAKE_SET
-
 AC_ARG_ENABLE(debugging,
 [ --enable-debugging   Build a cygwin DLL which has more consistency 
checking for debugging],
 [case "${enableval}" in
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 3a7a73adb..7f19a57fd 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -94,8 +94,6 @@ STRIP:=@STRIP@
 LDSCRIPT:=cygwin.sc
 MKDIRP:=$(INSTALL) -m 755 -d
 
-@SET_MAKE@
-
 # Setup the testing framework, if you have one
 EXPECT = `if [ -f $${rootme}/../../expect/expect$(EXEEXT) ] ; then \
echo $${rootme}/../../expect/expect$(EXEEXT) ; \
diff --git a/winsup/cygwin/configure.ac b/winsup/cygwin/configure.ac
index ff12dc259..ac019c94e 100644
--- a/winsup/cygwin/configure.ac
+++ b/winsup/cygwin/configure.ac
@@ -59,8 +59,6 @@ AC_CHECK_TOOL(RANLIB, ranlib, ranlib)
 AC_CHECK_TOOL(STRIP, strip, strip)
 AC_CHECK_TOOL(WINDRES, windres, windres)
 
-AC_PROG_MAKE_SET
-
 AC_ARG_ENABLE(debugging,
 [ --enable-debugging   Build a cygwin DLL which has more consistency 
checking for debugging],
 [case "${enableval}" in
-- 
2.28.0



[PATCH 6/8] Remove autoconf variable INSTALL_LICENSE

2020-10-12 Thread Jon Turney
Remove autoconf variable INSTALL_LICENSE, which has a constant value
which is only used once.
---
 winsup/Makefile.in  | 4 +---
 winsup/configure.ac | 4 
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/winsup/Makefile.in b/winsup/Makefile.in
index 148d98531..dc1c0 100644
--- a/winsup/Makefile.in
+++ b/winsup/Makefile.in
@@ -44,8 +44,6 @@ SUBDIRS=@subdirs@
 INSTALL_SUBDIRS=${patsubst %,install_%,$(SUBDIRS)}
 CLEAN_SUBDIRS=${patsubst %,clean_%,$(SUBDIRS)}
 
-INSTALL_LICENSE:=@INSTALL_LICENSE@
-
 .PHONY: all install clean distclean all-info info install-info install-license 
check \
$(SUBDIRS) $(INSTALL_SUBDIRS) $(CLEAN_SUBDIRS)
 
@@ -67,7 +65,7 @@ install-license: CYGWIN_LICENSE COPYING
  ${INSTALL} $$i $(DESTDIR)$(prefix)/share/doc/Cygwin ; \
done
 
-install: Makefile $(INSTALL_LICENSE) $(INSTALL_SUBDIRS)
+install: Makefile install-license $(INSTALL_SUBDIRS)
 
 clean distclean: $(CLEAN_SUBDIRS)
 
diff --git a/winsup/configure.ac b/winsup/configure.ac
index e917ee1c5..13f8883eb 100644
--- a/winsup/configure.ac
+++ b/winsup/configure.ac
@@ -39,9 +39,5 @@ if test "x$with_cross_bootstrap" != "xyes"; then
 AC_CONFIG_SUBDIRS([utils])
 fi
 
-INSTALL_LICENSE="install-license"
-
-AC_SUBST(INSTALL_LICENSE)
-
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
-- 
2.28.0



[PATCH 2/8] Drop STDINCFLAGS overrides

2020-10-12 Thread Jon Turney
This used to turn off -nostdinc on a per-file basis, but has no effect
since 4c36016b.
---
 winsup/cygwin/Makefile.in | 4 
 1 file changed, 4 deletions(-)

diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index f775f0691..3a7a73adb 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -583,10 +583,6 @@ exec_CFLAGS:=-fno-builtin-execve
 fhandler_proc_CFLAGS+=-DUSERNAME="\"$(USER)\"" -DHOSTNAME="\"$(HOSTNAME)\""
 fhandler_proc_CFLAGS+=-DGCC_VERSION="\"`$(CC) -v 2>&1 | tail -n 1`\""
 
-_cygwin_crt0_common_STDINCFLAGS:=yes
-libstdcxx_wrapper_STDINCFLAGS:=yes
-cxx_STDINCFLAGS:=yes
-
 .PHONY: all force dll_ofiles install all_target install_target all_host \
install_host install install-libs install-headers \
clean distclean realclean maintainer-clean
-- 
2.28.0



Re: [PATCH 0/1] Fix MSG_WAITALL support

2020-10-12 Thread Ken Brown via Cygwin-patches

On 10/12/2020 2:02 PM, Ken Brown via Cygwin-patches wrote:

It looks to me like there's been a bug in the MSG_WAITALL support for
AF_INET and AF_LOCAL sockets ever since that support was first
introduced 13 years ago in commit 023a2fa7.  If I'm right, MSG_WAITALL
has never worked.

This patch fixes it.  I'll push it in a few days if no one sees
anything wrong with it.

In a followup email I'll show how I tested it.


Attached are slight variants of the server/client programs from Section 57.2 of 
Kerrisk's book, "The Linux Programming Interface".  The only essential 
difference is that I've changed the server program to (a) use a small buffer 
(size 10 instead of 100) and (b) use 'recv' with the MSG_WAITALL flag instead of 
'read'.  The 'recv' call shouldn't return until it reads 10 bytes.


To test, run waitall_sv in one terminal and waitall_cl in a second.  Type 
something in the second terminal (followed by RET), and it should be echoed in 
the first.  But because of the MSG_WAITALL flag, the echoing shouldn't occur 
until 10 bytes have been written.  For example, if I type "abcd" in the 
second terminal and then do it again, I should see the following:


# Terminal 2:
$ ./waitall_cl
abcd
abcd

# Terminal 1:
$ ./waitall_sv
abcd
abcd

Here the echoing in Terminal 1 shouldn't occur until I've typed both "abcd" 
lines in Terminal 2.


[Note that there is a newline character after each "abcd", so "abcd" is 5 
bytes long, and the two lines together are 10 bytes long.]


Before I apply my patch, each line typed in Terminal 2 is immediately echoed in 
Terminal 1.  After I apply the patch, the echoing doesn't occur until I've typed 
both lines.


Ken
#include 
#include 
#include 
#include 
#include 
#include 

#define SV_SOCK_PATH "/tmp/waitall"

#define BUF_SIZE 10

#define BACKLOG 5

int
main ()
{
struct sockaddr_un addr;
int sfd, cfd;
ssize_t nread;
char buf[BUF_SIZE];

if ((sfd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
  {
perror ("socket");
exit (1);
  }
if (remove (SV_SOCK_PATH) < 0 && errno != ENOENT)
  {
perror ("remove");
exit (1);
  }

memset (&addr, 0, sizeof (struct sockaddr_un));
addr.sun_family = AF_UNIX;
strncpy (addr.sun_path, SV_SOCK_PATH, sizeof (addr.sun_path) - 1);

if (bind (sfd, (struct sockaddr *) &addr, sizeof (struct sockaddr_un)) < 0)
  {
perror ("bind");
exit (1);
  }

if (listen (sfd, BACKLOG) < 0)
  {
perror ("listen");
exit (1);
  }

while (1)
  {
cfd = accept (sfd, NULL, NULL);
if (cfd < 0)
  {
perror ("accept");
exit (1);
  }

/* Transfer data from connected socket to stdout until EOF. */
while ((nread = recv (cfd, buf, BUF_SIZE, MSG_WAITALL)) > 0)
  if (write (STDOUT_FILENO, buf, nread) != nread)
{
  perror ("partial/failed write");
  exit (1);
}

if (nread < 0)
  {
perror ("read");
exit (1);
  }

if (close (cfd) < 0)
  {
perror ("close");
exit (1);
  }
  }
}
#include 
#include 
#include 
#include 
#include 
#include 

#define SV_SOCK_PATH "/tmp/waitall"

#define BUF_SIZE 100

int
main ()
{
struct sockaddr_un addr;
int sfd;
ssize_t nread;
char buf[BUF_SIZE];

if ((sfd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
  {
perror ("socket");
exit (1);
  }

memset (&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
strncpy (addr.sun_path, SV_SOCK_PATH, sizeof(addr.sun_path) - 1);

if (connect (sfd, (struct sockaddr *) &addr,
sizeof (struct sockaddr_un)) < 0)
  {
perror ("connect");
exit (1);
  }

/* Copy stdin to socket. */
while ((nread = read (STDIN_FILENO, buf, BUF_SIZE)) > 0)
  if (write (sfd, buf, nread) != nread)
{
  perror ("partial/failed write");
  exit (1);
}

if (nread < 0)
  {
perror ("read");
exit (1);
  }
}


[PATCH 0/1] Fix MSG_WAITALL support

2020-10-12 Thread Ken Brown via Cygwin-patches
It looks to me like there's been a bug in the MSG_WAITALL support for
AF_INET and AF_LOCAL sockets ever since that support was first
introduced 13 years ago in commit 023a2fa7.  If I'm right, MSG_WAITALL
has never worked.

This patch fixes it.  I'll push it in a few days if no one sees
anything wrong with it.

In a followup email I'll show how I tested it.

Ken Brown (1):
  Cygwin: AF_INET and AF_LOCAL: recv_internal: fix MSG_WAITALL support

 winsup/cygwin/fhandler_socket_inet.cc  | 2 +-
 winsup/cygwin/fhandler_socket_local.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.28.0



[PATCH 1/1] Cygwin: AF_INET and AF_LOCAL: recv_internal: fix MSG_WAITALL support

2020-10-12 Thread Ken Brown via Cygwin-patches
If MSG_WAITALL is set, recv_internal calls WSARecv or WSARecvFrom in a
loop, in an effort to fill all the scatter-gather buffers.  The test
for whether all the buffers are full was previously incorrect.
---
 winsup/cygwin/fhandler_socket_inet.cc  | 2 +-
 winsup/cygwin/fhandler_socket_local.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_socket_inet.cc 
b/winsup/cygwin/fhandler_socket_inet.cc
index 71e92e341..bc08d3cf1 100644
--- a/winsup/cygwin/fhandler_socket_inet.cc
+++ b/winsup/cygwin/fhandler_socket_inet.cc
@@ -1208,7 +1208,7 @@ fhandler_socket_inet::recv_internal (LPWSAMSG wsamsg, 
bool use_recvmsg)
  --wsacnt;
}
}
- if (!wret)
+ if (!wsacnt)
break;
}
   else if (WSAGetLastError () != WSAEWOULDBLOCK)
diff --git a/winsup/cygwin/fhandler_socket_local.cc 
b/winsup/cygwin/fhandler_socket_local.cc
index 8bfba225a..c94bf828f 100644
--- a/winsup/cygwin/fhandler_socket_local.cc
+++ b/winsup/cygwin/fhandler_socket_local.cc
@@ -1212,7 +1212,7 @@ fhandler_socket_local::recv_internal (LPWSAMSG wsamsg, 
bool use_recvmsg)
  --wsacnt;
}
}
- if (!wret)
+ if (!wsacnt)
break;
}
   else if (WSAGetLastError () != WSAEWOULDBLOCK)
-- 
2.28.0