Keith Marshall
keith****@users*****
Sun Aug 26 23:21:49 JST 2018
On 30/07/18 16:13, Eli Zaretskii wrote: >> From: Keith Marshall <keith at ...> >> Date: Mon, 30 Jul 2018 03:11:42 +0100 >> >>> https://lists.gnu.org/archive/html/bug-gnulib/2018-07/msg00116.html >> >> In which Paul Eggert (erroneously) states: >>> Yes, the POSIX spec for <time.h> requires CLOCK_REALTIME to be a >>> symbolic constant, and it says that a symbolic constant must be a >>> macro that expands to a compile-time constant expression with an >>> integer type (it need not be usable in #if). >> >> With all respect due to Eggert, for the most part, POSIX says no >> such thing. Let's break it down: >> >>> Yes, the POSIX spec for <time.h> requires CLOCK_REALTIME to be a >>> symbolic constant, ... >> >> Indeed, to this extent, (and not much further), Eggert is correct. >> >>> ... and it says that a symbolic constant must be a macro ... >> >> No, it doesn't; other forms of symbolic constant are permitted. >> What POSIX actually says, is that *individually* symbolic constants >> *may* be required to be defined as macros; the <time.h> >> specification stipulates no such requirement for either >> CLOCK_REALTIME, or CLOCK_MONOTONIC. > > Well, at least this page: > > http://pubs.opengroup.org/onlinepubs/9699919799/ > > says (under "Symbolic Constant"): > > 3.380 Symbolic Constant > > An object-like macro defined with a constant value. > > Unless stated otherwise, the following shall apply to every > symbolic constant: > > . It expands to a compile-time constant expression with an > integer type. > > . It may be defined as another type of constant-e.g., an > enumeration constant-as well as being a macro. > > . It need not be usable in #if preprocessing directives. > > [...snip...] > > I think you are reading different versions of Posix. We're reading the same version, but Paul Eggert is selectively ignoring parts of it: in this case, "unless stated otherwise" comes into effect, since the type is explicitly required to be "clockid_t", which in our present implementation is a pointer type. (It's constant at run-time, but kind of difficult to make it so at compile-time; in such cases, the appendix[*] to the same version of POSIX grants licence for symbolic constants, such that "macros are not required to be usable in #if, or even to expand to constant expressions, unless explicitly stated"). > Anyway, I'm not an expert on this, I just want this to work ;-) > >> I suspect that the solution for clock_gettime() is trivial. >> Although POSIX.1-2008 may not strictly require them, it does allow, >> and it would certainly be prudent to add, self-referencing macro >> aliases for the two symbolic constants. >> >> Does the attached replacement for $MINGW_ROOT/include/time.h >> provide a satisfactory work-around? > > It will most definitely solve the problem, because all that is > needed is for CLOCK_REALTIME to be a macro which can be tested by > "#if defined". Unfortunately, it exposes a defect in GCC's Ada implementation: if CLOCK_REALTIME, and CLOCK_MONOTONIC, are declared as macros, it then uses them in in-line assembly language contexts which require them to represent compile-time integer constants, and when they aren't, then the Ada libraries cannot be compiled. Ada is a totally alien language, to me, so I wouldn't have a hope of understanding what its in-line assembly is intended to achieve, and I wouldn't have a clue how it might be fixed, much less offer a patch. However, at the expense of a small additional run-time overhead in our POSIX clock implementation, I can adapt it to use compile-time constant pseudo-pointer definitions for the standard clockid_t entities; (the additional overhead would arise from translation of the pseudo-pointer to a real pointer, on every clock API call, rather than have the real pointer assigned once, at process image load-time). Since I would prefer not to drop Ada, as a supported language, it may be prudent to explore such an alternative implementation for the POSIX clock API. [*]: http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap03.html -- Regards, Keith. Public key available from keys.gnupg.net Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature Url : https://lists.osdn.me/mailman/archives/mingw-users/attachments/20180826/8ca018b9/attachment.pgp