delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/02/15/15:48:15

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E657386180C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1613422092;
bh=nCpEE7FcTJvko1A2ei29rleqQC6mhYYU+AXtTf8r3oU=;
h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=BrNjQNp/Po0g+VFcktl/mwf+ybqJTgw4ADB3LkR8+cQ3YNYXtsL0n+Hk8wKD0/nFC
NIiaZ30CY8YzZ1teRrcUgiR/lYKfMnkng5g/u7cPPjI7n4z0j3H2gm+3aukp1BwcJs
ONaQh/TL0FzdGHSRgiffzvYSgYd35+oG8pbSz69Y=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A2BC73857C7B
Date: Mon, 15 Feb 2021 21:48:04 +0100
To: Patrick Chkoreff <pc AT fexl DOT com>
Subject: Re: setrlimit always fails
Message-ID: <YCreBGKMpVwfWrvR@calimero.vinschen.de>
Mail-Followup-To: Patrick Chkoreff <pc AT fexl DOT com>, cygwin AT cygwin DOT com
References: <b0924bcb-56d0-a026-84b5-71750537facb AT fexl DOT com>
<1c233bc7-401b-568f-36d5-48c4f1d4dcea AT cornell DOT edu>
<efc6c8da-7c22-4c8a-a334-c9803efb0e10 AT fexl DOT com>
<20210215091419 DOT GJ4251 AT calimero DOT vinschen DOT de>
<b55c516e-4b20-2dbb-3785-a7006dd049eb AT fexl DOT com>
MIME-Version: 1.0
In-Reply-To: <b55c516e-4b20-2dbb-3785-a7006dd049eb@fexl.com>
X-Provags-ID: V03:K1:DQ7NShXEoF/DQSkFNTfzqNg46PAmR9JR4bq9MrCHaCdk5AxmLop
h7FWz0IJ5EZ+Tpo0on2W9/AIlgnqb28HTC4RBwqbcAKo2lm60X1TW9LKKS9CbfuG1CaCe9R
ghZEYxOfykWNPIpmcuzPf67c3PLLevsjro9R4fV7k5mFhL25NitooRUzULMlUHSl9Py0mFV
VZ/NV8WgtNbBGFTu4pIMg==
X-UI-Out-Filterresults: notjunk:1;V03:K0:c6rX0X4Qk+Y=:eIUZhiEZsSggZuX6DNO55p
GIb/XlhsBUSC4XkDpZNDTc8XnBtj+YLD6vSztvGHdRms3YJlv3hehFBLoXmvGZbF7gjmgZrlf
AFfwVFa4OJmxu4hfIOKFCAwloogJnnkAsrjMuNvP2wGT7UhMtIVzZLmtNTcsCo50YqTrr7y5l
7g/x95tWe00goG/ztw7lX+ScAG+6PYscXpZuU5qscD4H52oxSAookmU5rXrqw+9uh7StrLB7W
cY8b1chM/4Ra0C63fw+zQ2WGfL94XD/I6FIjN0l9Zma1AtZeU+xvBNbDIpDskkqh7jrt+WEfB
o05ofrFgw4HVA12DIu7+HNctj9U40R3Pl2hmEn5BmChfrw1Oq1+T1MQD8VCsizwiv8QkxU+Z9
rb6jjsF2mT8dxdmhoJrAOq6ROG+vnxfayvEnlgg5cfux2AR3T9i1a5I8U1DM48KLy2b0w0z+o
W2jeI6qNag==
X-Spam-Status: No, score=-101.4 required=5.0 tests=BAYES_00,
GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE,
RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NEUTRAL,
TXREP autolearn=ham autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>, cygwin AT cygwin DOT com
Errors-To: cygwin-bounces AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 11FKmFUC029337

On Feb 15 14:54, Patrick Chkoreff wrote:
> Corinna Vinschen wrote on 2/15/21 4:14 AM:
> 
> > That looks wrong.  The __USE_<standard> flags are internal flags from
> > GLibc and not supposed to be used by application code.  Check the Linux
> > man page for strptime, the usage of _XOPEN_SOURCE or another flag
> > including _XOPEN_SOURCE (e. g. _GNU_SOURCE) is required.  So this:
> > 
> >   #define _XOPEN_SOURCE
> >   #include <time.h>
> 
> One would think so, but I tried it on two different Linux machines and
> it failed with:
> 
> error: ‘strptime’ undeclared
> 
> To fix that, I must define _USE_XOPEN

You really, really must not use this macro.

> #else
> 
> #include <stdint.h>
> #include <sys/time.h>
> #define __USE_XOPEN
> #include <time.h>
> 
> #endif
> 
> void stuff(void)
>     {
>     uint64_t n;
>     time_t t;
>     struct timeval tv;
>     (void)n;
>     (void)t;
>     (void)tv;
>     (void)time;
>     (void)gettimeofday;
>     (void)timegm;
>     (void)timelocal;
>     (void)gmtime;
>     (void)localtime;
>     (void)strftime;
>     (void)strptime;
>     }

The problem here is that you mix functions only defined under
_XOPEN_SOURCE with stuff only defined with _DEFAULT_SOURCE from the same
header.  Either define both feature test macros, or define _GNU_SOURCE.

This works:

#define _XOPEN_SOURCE
#define _DEFAULT_SOURCE
#include <stdint.h>
#include <sys/time.h>
#include <time.h>
void stuff(void)
[...]

This works, too:

#define _GNU_SOURCE
#include <stdint.h>
#include <sys/time.h>
#include <time.h>
void stuff(void)
[...]


Corinna
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019