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-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,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 DD0BA1F4B5 for ; Sat, 16 Nov 2019 12:15:43 +0000 (UTC) Received: from localhost ([::1]:47544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVwzO-0003uc-DC for normalperson@yhbt.net; Sat, 16 Nov 2019 07:15:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34437) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVwzJ-0003uE-7m for bug-gnulib@gnu.org; Sat, 16 Nov 2019 07:15:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVwzH-00046f-QD for bug-gnulib@gnu.org; Sat, 16 Nov 2019 07:15:37 -0500 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::9]:28336) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVwzH-00043B-44 for bug-gnulib@gnu.org; Sat, 16 Nov 2019 07:15:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1573906531; 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=3JYmLduOSX077IK1e+/USVi30nkXRr0Ff4O4bzb2L6Y=; b=chVvXrRd7VW1TCBFF3TNG07rSxM2IXvEdrl+ByrpddY/F9nj6ajdFMJYNqlCP/k6ff hr0Ql57R2UN3MnBINrJiFxpKHJDuWeeOANfUJUygbEbiGWf44tj//9xLVYVhQMSdhurD 9wH6Er+H12xEErIwM8uJgBfm+doYE6Ef7ozH8kfTRZitR6NTTnhAXHPHNSFmqTpvzsm8 0jN/SKxsYKepLtU/iVOU8kHcMhhdDGDGXg/+UoDAFPZJb+Z4awAiV6NGRd7FFN3JGVyb ktxS1a8cSmtjnvLk2qRMpPOSX9ktJP1kCoXzt8NkMPB9lycDhsAFMmgnZv4zNaL6Srk/ XGZA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOH6fzxfs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 44.29.0 DYNA|AUTH) with ESMTPSA id g09d55vAGCFUpT5 (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Sat, 16 Nov 2019 13:15:30 +0100 (CET) From: Bruno Haible To: Christian Biesinger Subject: Re: time_r module does not work on MingW Date: Sat, 16 Nov 2019 13:15:30 +0100 Message-ID: <2192288.myS54ITcZ4@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <1576792.iqhKLmYyPN@omega> References: <1576792.iqhKLmYyPN@omega> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a01:238:20a:202:5300::9 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: bug-gnulib@gnu.org, Christian Biesinger Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This patch fixes the issue. The cause was that the contents of in mingw depends on whether or was included before. 2019-11-16 Bruno Haible time_r: Fix for mingw. Reported by Christian Biesinger in . * lib/time.in.h: On mingw, include . * m4/time_r.m4 (gl_TIME_R): On mingw, include before . Test for localtime_r in a way that works when it is defined as an inline function. diff --git a/lib/time.in.h b/lib/time.in.h index 94e1da3..dc00503 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -37,6 +37,12 @@ # define _@GUARD_PREFIX@_TIME_H +/* mingw's provides the functions asctime_r, ctime_r, gmtime_r, + localtime_r only if or has been included before. */ +# if defined __MINGW32__ +# include +# endif + # @INCLUDE_NEXT@ @NEXT_TIME_H@ /* NetBSD 5.0 mis-defines NULL. */ diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 5caeca7..72cc975 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -17,19 +17,54 @@ AC_DEFUN([gl_TIME_R], dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is dnl not defined. - AC_CHECK_DECLS([localtime_r], [], [], [[#include ]]) + AC_CHECK_DECLS([localtime_r], [], [], + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]]) if test $ac_cv_have_decl_localtime_r = no; then HAVE_DECL_LOCALTIME_R=0 fi - AC_CHECK_FUNCS_ONCE([localtime_r]) - if test $ac_cv_func_localtime_r = yes; then + dnl We can't use AC_CHECK_FUNC here, because localtime_r() is defined as an + dnl inline function on mingw. + AC_CACHE_CHECK([for localtime_r], [gl_cv_func_localtime_r], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]], + [[time_t a; + struct tm r; + localtime_r (&a, &r); + ]]) + ], + [gl_cv_func_localtime_r=yes], + [gl_cv_func_localtime_r=no]) + ]) + if test $gl_cv_func_localtime_r = yes; then HAVE_LOCALTIME_R=1 AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], [gl_cv_time_r_posix], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( - [[#include ]], + [[/* mingw's provides the functions asctime_r, ctime_r, + gmtime_r, localtime_r only if or has + been included before. */ + #if defined __MINGW32__ + # include + #endif + #include + ]], [[/* We don't need to append 'restrict's to the argument types, even though the POSIX signature has the 'restrict's, since C99 says they can't affect type compatibility. */