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.6 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,URIBL_BLOCKED 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 8C5781F5AE for ; Tue, 30 Jun 2020 01:08:01 +0000 (UTC) Received: from localhost ([::1]:39374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jq4ki-00048t-BD for normalperson@yhbt.net; Mon, 29 Jun 2020 21:08:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jq4ke-00048j-VK for bug-gnulib@gnu.org; Mon, 29 Jun 2020 21:07:57 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.218]:30775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jq4kc-0004VP-4Q; Mon, 29 Jun 2020 21:07:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1593479270; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=NLUCP3dTe/tU6/oSqRYmwRMIW0EY6WGqE0eXDR6YdmQ=; b=cF4bAqxL5J6KulfLkt8HlKzUBEmssmBSp5movejf45Cq6aVBWLL1FrQnwDy7lw56Wm ao90rISEbyht6hY4qroeAmRBL3KokzkdVbn4m0so/uynH9U1AbFkKgktHv7Uf/6Bu8E/ tlYInmPglJSECiZsB0+stGpyjwdVghx5uiQhJu0vfPIXmHFIvvsttDuMcx7H5w5T+EHc Cjb7F+IhazGUfTwqr01Fn8IKR9VlifYyht8Y+/rpWZnd6VIC32R1bKF+Cfxf0VrZukHe jc3vWCnkjsHYhammm/yQCM/d6hX8nSAVTqHDaiOxLu1X4BqFjmUfc4cU2t4AAe4wLCJ7 aOJw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 46.10.5 DYNA|AUTH) with ESMTPSA id R03d1aw5U17eWKC (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); Tue, 30 Jun 2020 03:07:40 +0200 (CEST) From: Bruno Haible To: bug-gnulib@gnu.org Subject: Re: socklen_t data type Date: Tue, 30 Jun 2020 03:07:39 +0200 Message-ID: <2247884.BChNpACfHN@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-179-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <83eepx23cd.fsf@gnu.org> References: <83eepx23cd.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.218; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/29 21:07:50 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN 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: , Cc: Rahul Das , Keith Marshall , Eli Zaretskii Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" [Ccing Keith Marshall as the reporter of ] Hi Eli, > Gnulib's sys/socket.h has this: > > # if @HAVE_WINSOCK2_H@ > /* Include headers needed by the emulation code. */ > # include > # include > > # if !GNULIB_defined_socklen_t > typedef int socklen_t; > # define GNULIB_defined_socklen_t 1 > # endif > > # endif > > This unconditionally defines socklen_t on MS-Windows systems as a > signed int data type. Why is this unconditional? Earlier, it was unconditionally needed. > This page: > > https://pubs.opengroup.org/onlinepubs/007908799/xns/syssocket.h.html > > says: > > makes available a type, socklen_t, which is an > unsigned opaque integral type of length of at least 32 bits. The page you cite is part of SUSv2. It has been superseded by POSIX, first by the 2004 edition: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html and then by the current edition: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html Please update your bookmarks. > So socklen_t could be an unsigned data type, which would then conflict > with the above. > > And in fact mingw.org's MinGW recently changed the socklen_t data type > to be unsigned int, which breaks compilation of Gnulib's > sys_socket.c. Is MinGW in error here? Looking at the prototypes of the function inet_ntop [1] it should be 'unsigned int' or 'size_t'. Looking at the prototypes of the functions connect [2], accept [3], bind [4], getpeername [5], getsockname [6], getsockopt [7], recvfrom [8], sendto [9], setsockopt [10] it should be 'int'. But regardless how mingw defines 'socklen_t' (as 'int' or as 'unsigned int'), none of these prototypes is POSIX compliant anyway, since all these prototypes have the WSAAPI attribute. So, gnulib should define socklen_t if and only if the system's header don't. The code which does this is in m4/socklen.m4. I'm therefore applying the patch below. [1] https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop [2] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-connect [3] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept [4] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-bind [5] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getpeername [6] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockname [7] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-getsockopt [8] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-recvfrom [9] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-sendto [10] https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-setsockopt 2020-06-29 Bruno Haible sys_socket: Don't define socklen_t if it is already defined on mingw. Reported by Keith Marshall in , by Rahul Das in , and by Eli Zaretskii in . * lib/sys_socket.in.h (socklen_t): Remove definition. diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h index 948d689..577947d 100644 --- a/lib/sys_socket.in.h +++ b/lib/sys_socket.in.h @@ -195,12 +195,7 @@ struct sockaddr_storage /* Include headers needed by the emulation code. */ # include # include - -# if !GNULIB_defined_socklen_t -typedef int socklen_t; -# define GNULIB_defined_socklen_t 1 -# endif - +/* If these headers don't define socklen_t, does. */ # endif /* Rudimentary 'struct msghdr'; this works as long as you don't try to