From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 14DA51F66E for ; Sun, 23 Aug 2020 23:30:22 +0000 (UTC) Received: from localhost ([::1]:45682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k9zRM-00086R-Vy for normalperson@yhbt.net; Sun, 23 Aug 2020 19:30:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9zRK-00086J-2D for bug-gnulib@gnu.org; Sun, 23 Aug 2020 19:30:18 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([85.215.255.23]:21213) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k9zRG-0003Jq-BN for bug-gnulib@gnu.org; Sun, 23 Aug 2020 19:30:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1598225411; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=3tqWXC9tqTIuQQ2epWjiCd4qImQcqUmqJtybvSjaCa8=; b=JBPX/+GWNkrz4OPs+Js+xqT3TNq2GjBxKCIRtroS5vgvbwaAtwSwRViycfSdJI918A r6wyPufvISXAs+Enhaq5xNok2y2bqaarGkTWYx8gqW43k/OQH9AAk0tt07E6Z2U5eunK EAhdJGqPvF+1Hw32XfREwpUAzfMR55OFPjEKUKOt5aNZB1TRsfoYZl8Qqgd+/MPIxkWy 9BCsTSfrwp6wykWEnoy9ZL3FW2Jm6FCZQcqPe7xYrCu+GqoNcxr2fGB4N87t8F5foJmF IDr3nmRo0LxBsLDMcZ7BnOuiXwYDYLqXus8Wc+IgR7A/qoTFtsr44es7yEqrCKZl3zvZ G3EA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqfyyPs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.10.7 DYNA|AUTH) with ESMTPSA id z05f0fw7NNUBFoS (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Mon, 24 Aug 2020 01:30:11 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: pid_t on 64-bit Windows Date: Mon, 24 Aug 2020 01:30:10 +0200 Message-ID: <5981491.j28A7ECyTM@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1637239.bd6KyFXra9" Content-Transfer-Encoding: 7Bit Received-SPF: none client-ip=85.215.255.23; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/23 19:30:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This is a multi-part message in MIME format. --nextPart1637239.bd6KyFXra9 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On 64-bit Windows, pid_t needs to be 64-bit large, i.e. intptr_t or 'long long' or '__int64'. This is because the return type of _spawnv* (when invoked with _P_NOWAIT) and the argument of the _cwait function are 'intptr_t' (see [1][2]: "The return value from an asynchronous _spawnvp or _wspawnvp (_P_NOWAIT or _P_NOWAITO specified for mode) is the process handle." On mingw, this is already the case. But on MSVC (and MSVC/clang), the 'pid_t' type is nowhere defined. In this case, gnulib defines it through config.h. [1] https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnvp-wspawnvp [2] https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/cwait 2020-08-23 Bruno Haible tests: Don't assume that pid_t fits in an 'int'. * tests/test-nonblocking-pipe-main.c (main): Use type 'pid_t' instead of 'int'. * tests/test-nonblocking-socket-main.c (main): Likewise. sys_types: Fix definition of pid_t on 64-bit MSVC. * m4/pid_t.m4: New file. * modules/sys_types (Files): Add it. * modules/dirent (Files): Likewise. * modules/fcntl-h (Files): Likewise. * modules/sched (Files): Likewise. * modules/signal-h (Files): Likewise. * modules/spawn (Files): Likewise. * modules/sys_stat (Files): Likewise. * modules/sys_wait (Files): Likewise. * modules/termios (Files): Likewise. * modules/unistd (Files): Likewise. --nextPart1637239.bd6KyFXra9 Content-Disposition: attachment; filename="0001-sys_types-Fix-definition-of-pid_t-on-64-bit-MSVC.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-sys_types-Fix-definition-of-pid_t-on-64-bit-MSVC.patch" >From efe32f6a916b6addcfe60d2283cef4cebc6177ff Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 24 Aug 2020 01:19:18 +0200 Subject: [PATCH 1/2] sys_types: Fix definition of pid_t on 64-bit MSVC. * m4/pid_t.m4: New file. * modules/sys_types (Files): Add it. * modules/dirent (Files): Likewise. * modules/fcntl-h (Files): Likewise. * modules/sched (Files): Likewise. * modules/signal-h (Files): Likewise. * modules/spawn (Files): Likewise. * modules/sys_stat (Files): Likewise. * modules/sys_wait (Files): Likewise. * modules/termios (Files): Likewise. * modules/unistd (Files): Likewise. --- ChangeLog | 15 +++++++++++++++ m4/pid_t.m4 | 33 +++++++++++++++++++++++++++++++++ modules/dirent | 1 + modules/fcntl-h | 1 + modules/sched | 1 + modules/signal-h | 1 + modules/spawn | 1 + modules/sys_stat | 1 + modules/sys_types | 1 + modules/sys_wait | 1 + modules/termios | 1 + modules/unistd | 1 + 12 files changed, 58 insertions(+) create mode 100644 m4/pid_t.m4 diff --git a/ChangeLog b/ChangeLog index e54c89f..9c2dcdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2020-08-23 Bruno Haible + sys_types: Fix definition of pid_t on 64-bit MSVC. + * m4/pid_t.m4: New file. + * modules/sys_types (Files): Add it. + * modules/dirent (Files): Likewise. + * modules/fcntl-h (Files): Likewise. + * modules/sched (Files): Likewise. + * modules/signal-h (Files): Likewise. + * modules/spawn (Files): Likewise. + * modules/sys_stat (Files): Likewise. + * modules/sys_wait (Files): Likewise. + * modules/termios (Files): Likewise. + * modules/unistd (Files): Likewise. + +2020-08-23 Bruno Haible + inttypes: Fix {PRI,SCN}*PTR on 32-bit native Windows (regr. 2020-07-21). * m4/inttypes.m4 (gl_INTTYPES_PRI_SCN): Fix syntax error in test program. diff --git a/m4/pid_t.m4 b/m4/pid_t.m4 new file mode 100644 index 0000000..321082d --- /dev/null +++ b/m4/pid_t.m4 @@ -0,0 +1,33 @@ +# pid_t.m4 serial 1 +dnl Copyright (C) 2020 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Define pid_t if the headers don't define it. +AC_DEFUN([AC_TYPE_PID_T], +[ + AC_CHECK_TYPE([pid_t], + [], + [dnl On 64-bit native Windows, define it to the equivalent of 'intptr_t' + dnl (= 'long long' = '__int64'), because that is the return type + dnl of the _spawnv* functions + dnl + dnl and the argument type of the _cwait function + dnl . + dnl Otherwise (on 32-bit Windows and on old Unix platforms), define it + dnl to 'int'. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #if defined _WIN64 && !defined __CYGWIN__ + LLP64 + #endif + ]]) + ], + [gl_pid_type='int'], + [gl_pid_type='__int64']) + AC_DEFINE_UNQUOTED([pid_t], [$gl_pid_type], + [Define as a signed integer type capable of holding a process identifier.]) + ], + [AC_INCLUDES_DEFAULT]) +]) diff --git a/modules/dirent b/modules/dirent index 6f615b4..08a6326 100644 --- a/modules/dirent +++ b/modules/dirent @@ -5,6 +5,7 @@ Files: lib/dirent.in.h m4/dirent_h.m4 m4/unistd_h.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/fcntl-h b/modules/fcntl-h index ff74dec..2ef0106 100644 --- a/modules/fcntl-h +++ b/modules/fcntl-h @@ -5,6 +5,7 @@ Files: lib/fcntl.in.h m4/fcntl_h.m4 m4/fcntl-o.m4 +m4/pid_t.m4 Depends-on: extensions diff --git a/modules/sched b/modules/sched index 0b6bcae..572c57b 100644 --- a/modules/sched +++ b/modules/sched @@ -4,6 +4,7 @@ A include file. Files: lib/sched.in.h m4/sched_h.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/signal-h b/modules/signal-h index 810e2bf..2f38e9b 100644 --- a/modules/signal-h +++ b/modules/signal-h @@ -4,6 +4,7 @@ A GNU-like . Files: lib/signal.in.h m4/signal_h.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/spawn b/modules/spawn index 6e03294..f1b99ca 100644 --- a/modules/spawn +++ b/modules/spawn @@ -4,6 +4,7 @@ A POSIX compliant . Files: lib/spawn.in.h m4/spawn_h.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/sys_stat b/modules/sys_stat index af276ab..42ae932 100644 --- a/modules/sys_stat +++ b/modules/sys_stat @@ -5,6 +5,7 @@ Files: lib/sys_stat.in.h m4/sys_stat_h.m4 m4/unistd_h.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/sys_types b/modules/sys_types index 81a11aa..c00862c 100644 --- a/modules/sys_types +++ b/modules/sys_types @@ -5,6 +5,7 @@ Files: lib/sys_types.in.h m4/sys_types_h.m4 m4/off_t.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/sys_wait b/modules/sys_wait index bedd7e1..73ce50b 100644 --- a/modules/sys_wait +++ b/modules/sys_wait @@ -4,6 +4,7 @@ A for systems with missing declarations. Files: lib/sys_wait.in.h m4/sys_wait_h.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/termios b/modules/termios index 88056cc..8cb73e4 100644 --- a/modules/termios +++ b/modules/termios @@ -4,6 +4,7 @@ A that works around platform issues. Files: lib/termios.in.h m4/termios_h.m4 +m4/pid_t.m4 Depends-on: include_next diff --git a/modules/unistd b/modules/unistd index b14faaa..18b91c4 100644 --- a/modules/unistd +++ b/modules/unistd @@ -6,6 +6,7 @@ m4/unistd_h.m4 lib/unistd.c lib/unistd.in.h m4/off_t.m4 +m4/pid_t.m4 Depends-on: extern-inline -- 2.7.4 --nextPart1637239.bd6KyFXra9 Content-Disposition: attachment; filename="0002-tests-Don-t-assume-that-pid_t-fits-in-an-int.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0002-tests-Don-t-assume-that-pid_t-fits-in-an-int.patch" >From 83f2c832a760bd7e5d32e2d2ab8298f697cf3f70 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 24 Aug 2020 01:22:49 +0200 Subject: [PATCH 2/2] tests: Don't assume that pid_t fits in an 'int'. * tests/test-nonblocking-pipe-main.c (main): Use type 'pid_t' instead of 'int'. * tests/test-nonblocking-socket-main.c (main): Likewise. --- ChangeLog | 5 +++++ tests/test-nonblocking-pipe-main.c | 2 +- tests/test-nonblocking-socket-main.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c2dcdc..073f968 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2020-08-23 Bruno Haible + tests: Don't assume that pid_t fits in an 'int'. + * tests/test-nonblocking-pipe-main.c (main): Use type 'pid_t' instead + of 'int'. + * tests/test-nonblocking-socket-main.c (main): Likewise. + sys_types: Fix definition of pid_t on 64-bit MSVC. * m4/pid_t.m4: New file. * modules/sys_types (Files): Add it. diff --git a/tests/test-nonblocking-pipe-main.c b/tests/test-nonblocking-pipe-main.c index 0e132f0..ec19be5 100644 --- a/tests/test-nonblocking-pipe-main.c +++ b/tests/test-nonblocking-pipe-main.c @@ -44,7 +44,7 @@ main (int argc, char *argv[]) const char *child_path; int test; int fd[2]; - int child; + pid_t child; int exitcode; child_path = argv[1]; diff --git a/tests/test-nonblocking-socket-main.c b/tests/test-nonblocking-socket-main.c index 500479d..d2cf50e 100644 --- a/tests/test-nonblocking-socket-main.c +++ b/tests/test-nonblocking-socket-main.c @@ -47,7 +47,7 @@ main (int argc, char *argv[]) int test; int server; int port; - int child; + pid_t child; int server_socket; int exitcode; -- 2.7.4 --nextPart1637239.bd6KyFXra9--