delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/02/15/14:54:34

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DABAC3857C7A
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=fexl.com
Authentication-Results: sourceware.org; spf=none smtp.mailfrom=pc AT fexl DOT com
X_CMAE_Category: , ,
X-CNFS-Analysis: v=2.4 cv=S+wcfKgP c=1 sm=1 tr=0 ts=602ad173 cx=a_idp_x
a=PDGaJ8dF8zRAWf39Bu4Cgw==:117 a=PDGaJ8dF8zRAWf39Bu4Cgw==:17
a=KGjhK52YXX0A:10 a=IkcTkHD0fZMA:10 a=qa6Q16uM49sA:10 a=Ehmfxr484HgA:10
a=BteEbYCXQihtarNRQQcA:9 a=QEXdDO2ut3YA:10
X-CM-Score: 0
X-Scanned-by: Cloudmark Authority Engine
X-Authed-Username: Y2hrb3JlZmZAd2luZHN0cmVhbS5uZXQ=
Authentication-Results: smtp02.aqua.bos.sync.lan
smtp.user=chkoreff AT windstream DOT net; auth=pass (LOGIN)
Subject: Re: setrlimit always fails
To: 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>
From: Patrick Chkoreff <pc AT fexl DOT com>
Autocrypt: addr=pc AT fexl DOT com; keydata=
mQINBFVTu9wBEAD3HrqNmAU5TPesso2t7QG+bq/Y9Brz0X/9JIqPHT4eSiRCQmm228QFJfm8
eRo4yw0gG/Jb535P8MrFfkRconzW6ttsftlQkzzjskpvyUCcJ6ReRNFBzPKRSSEIm9keqG0v
JQ28ffa0dvH7DIWZpdVveaHtwH/Jy5wrmErpcXjA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QkPCeOLAAoJEI/YYoGmqVZtABsP/25z6bTxB5szwFOqdkSTpGlVeCqHxInsH60BeliBzr1p
qAX6urpdMwNzCpRa9DroU7wwtOJ2z7FtCCdoDtnCaWRLqw2lqsZp7KeGOrCCHbSbpr/KXj2s
wrN5AH69tSUN6yQlL3NdaD4go3VbjVNY2fFZkzi+ohlrVqaBZGPv/YaZhVnW29Z+bss2Emsp
3+x49RmOSXvSRHE4CsBbayIRIPwt4WvtbEzwquHn8Z3e7/4yBO43phaVkgP3YBR9Pv5dEYgr
teBB0XtJ6DO08vmtMjvziXS6lcdj0cS+znoyyN8DLT8Na4LcEWeQaM6kZG3QoO4ZA17KPq1V
hE2QPKNmfGcsTSZnz+I/RLyel0A75JzbcTXRKAnKGppZL5Mapgmk9MWyHdV+/LFDpvoNUkN4
mBpJ7CSeR59pJ8u7v8bHPnBR1w0TYySONrpN/46JdZj4IuKP9h+6K3j0dKFycKobhCT0Mdel
9Xj7W/jmScEA9+Vbg7quRy5ay5nRWh18STdLp1AHwyZZ+5XscdCHgtqu/jYecPxjB37ILfl7
mcDR+8yj4yHZEyFW+n8ai3+Lijea+KdjE0/7nWwYIJNs9TWwL2cOPURznPHdFWTg5qFUIils
L55yRVFSzndW7wiYONMHRIWTF5kGLDeMTP357EDVsKRxAg0G2w2fQVKC5HD9L8N3
Message-ID: <b55c516e-4b20-2dbb-3785-a7006dd049eb@fexl.com>
Date: Mon, 15 Feb 2021 14:54:26 -0500
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
MIME-Version: 1.0
In-Reply-To: <20210215091419.GJ4251@calimero.vinschen.de>
X-Vade-Verditct: clean
X-Vade-Analysis: gggruggvucftvghtrhhoucdtuddrgeduledrieekgdduvdeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuufgjpfetvefqtfdphgfkpfffuffvtffgtefopdfqfgfvnecuuegrihhlohhuthemuceftddunecunecujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheprfgrthhrihgtkhcuvehhkhhorhgvfhhfuceophgtsehfvgiglhdrtghomheqnecuggftrfgrthhtvghrnhepgffhvdelgeekueffgeevgefgkeehgfeguedvveffgfehgfdvteejgefhkedtiefgnecukfhppeegtddrudefkedrudejfedrkeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedtrddufeekrddujeefrdekgeenpdhmrghilhhfrhhomhepphgtsehfvgiglhdrtghomhenpdhrtghpthhtoheptgihghifihhnsegthihgfihinhdrtghomhen
X-Vade-Client: WINDSTREAM
X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,
SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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>
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 11FJsX0n022523

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.

I have stripped down my requirements as far as possible.  I created a
file "test_stuff.c" as follows, with the most minimal preambles that
actually work on each platform (Cygwin or Linux):

~~
#ifdef __CYGWIN__

#define _XOPEN_SOURCE
#include <stdint.h>
#include <sys/time.h>
#include <time.h>

#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;
    }

~~


That compiles successfully on both Cygwin and Linux, using the simple
command "gcc -c test_stuff.c".

Note that in the case of Linux, the define __USE_XOPEN is absolutely
essential, and define _XOPEN_SOURCE makes no difference.  This is an
experimental fact on the two Linux machines I tested.

Note also that on Cygwin, I must define _XOPEN_SOURCE before including
stdint.h.  There are all kinds of weird interactions and different
ordering requirements between the Linux and Cygwin code.  So let's look
at some options, and show how they work on both Linux and Cygwin.

OPTION 1:

#define _XOPEN_SOURCE
#include <stdint.h>
#include <sys/time.h>
#include <time.h>

Result on Cygwin: SUCCESS

Result on Linux:
error: ‘timegm’ undeclared
error: ‘timelocal’ undeclared


OPTION 2:

#include <stdint.h>
#include <sys/time.h>
#define _XOPEN_SOURCE
#include <time.h>

Result on Cygwin:
error: 'strptime' undeclared

Result on Linux:
error: 'strptime' undeclared


OPTION 3:

#include <stdint.h>
#include <sys/time.h>
#define __USE_XOPEN
#define _XOPEN_SOURCE
#include <time.h>

Result on Cygwin:
error: 'strptime' undeclared

Result on Linux:  SUCCESS


Consequently I see nothing simpler than the test_stuff.c code at the top
of this email.  By all means correct me if I am wrong.  Propose a
preamble on this list, and I'll jam it into my test code and see if it
compiles on both Cygwin and Linux.  I can literally compile the exact
same code file on both Cygwin and Linux, due to how I've got sharing set up.


-- Patrick
--
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