~nabijaczleweli/wg14

863419bc7c1bda289255652e6172cc0c9e1edcca — наб 2 years ago be764ec
helps when you actually add the document
2 files changed, 159 insertions(+), 1 deletions(-)

M .build.yml
A N2878P1.mom
M .build.yml => .build.yml +1 -1
@@ 46,7 46,7 @@ tasks:
      DESTDIR=../wg14-output/ make -C wg14
  - push: |
      cd wg14-output/
      for f in n*.pdf N*.pdf; do echo "# [$(sed '/^\.TITLE/!d;s/^\.TITLE[^"]*"//;s/"$//;s/\\f(..//g;s/\\f.//g' ../wg14/${f%.pdf}.mom)](//srhtcdn.githack.com/~nabijaczleweli/wg14/blob/output/${f//\?/%3F})"; done > README.md
      for f in n*.pdf N*.pdf; do [ -e "$f" ] || continue; echo "# [$(sed '/^\.TITLE/!d;s/^\.TITLE[^"]*"//;s/"$//;s/\\f(..//g;s/\\f.//g' ../wg14/${f%.pdf}.mom)](//srhtcdn.githack.com/~nabijaczleweli/wg14/blob/output/${f//\?/%3F})"; done > README.md
      git add .
      git config user.email "nabijaczleweli/autouploader@nabijaczleweli.xyz"
      git config user.name "наб autouploader"

A N2878P1.mom => N2878P1.mom +158 -0
@@ 0,0 1,158 @@
.\" SPDX-License-Identifier: 0BSD
.\"
.TITLE     "\fIN???? (p1)\fP\f(CR: \fP\f(CBnsec_t \fP\f(CR&&\f(CR\fP\f(CB timespec::tv_nsec\fP"
.PDF_TITLE "\*[$TITLE]
.AUTHOR    "\v'-.5v'\*[UP 8p]наб"
.\" http://www.open-std.org/jtc1/sc22/wg14/www/contributing says we need a cover page
.SUBTITLE      "\s9\f(CBtimespec::tv_nsec\fR is too wide and unsatisfiable by some architectures." \
               "\v'-.3v'Relaxing the type by introducing \f(CBnsec_t\fP can alleviate this."
.ATTRIBUTE_STRING ""  \" Drop 'by'
.HEADER_LEFT "наб"
.COVER       TITLE SUBTITLE AUTHOR
.PDF_BOOKMARKS_OPEN
.\" Page, style, formatting
.PRINTSTYLE TYPESET
.PAPER	    A4
.L_MARGIN   2c
.R_MARGIN   2c
.\"
.FAM      T
.FT       R
.PT_SIZE  10.5
.AUTOLEAD 3
.\"
.PARA_INDENT 6p
.\"
.COVER_LEAD     +3.5
.DOCHEADER_LEAD +3.5
.\" Color for code snippets
.XCOLOR    darkgreen green
.XCOLOR        red   red
.NEWCOLOUR darkwhite RGB #909090
.\"
.QUOTE_FAMILY C
.QUOTE_FONT   B
.QUOTE_INDENT 9p
.\"
.HEADING_STYLE 1 NUMBER FONT B SIZE +1  BASELINE_ADJUST \n[.v]/5
.HEADING_STYLE 2 NUMBER FONT I SIZE +.5 BASELINE_ADJUST \n[.v]/5
.\" Wrapper around QUOTE
.de COD
. QUOTE
. nop \\$*
. QUOTE OFF
..
.\" Note box
.de BOX-NOTE
. ie \\n[#NUM_ARGS]=1 .DBX .5 0 \\n[.l]u \\$1
. el .DBX .5 0 \\$1 \\$2
. ALD 15p
. IB 6p
..
.\" Table of contents
.SPACE_TOC_ITEMS
.AUTO_RELOCATE_TOC
.TOC_ENTRY_STYLE 2 FONT I
.\"
.DOCHEADER_ADVANCE 4.5c \" Begin this distance down from top of page
.\"
.START
.
.RLD 0.75cm
Document #:\h'|1i'????
.br
Date:\h'|1i'????-??-??
.br
Revisions:\h'|1i'\c
.PDF_WWW_LINK http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2878.pdf N2878
.br
Project:\h'|1i'Programming Language C
.br
Reply-to:\h'|1i'наб
.PDF_WWW_LINK mailto:nabijaczleweli@nabijaczleweli.xyz PREFIX < SUFFIX > nabijaczleweli@nabijaczleweli.xyz
.IBQ
.
.\"
.HEADING 1 NAMED intro "The issue"
.PP
The current wording in the current draft C2X standard
.PDF_WWW_LINK http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2731.pdf N2731
from 7.27.1.4 is:
.in +1cm
The range and precision of times representable in \f(CBclock_t\fP and \f(CBtime_t\fP are implementation-defined.
The \f(CBtimespec\fP structure shall contain at least the following members, in any order.
The semantics of the members and their normal ranges are expressed in the comments.\*[SUP]342)\*[SUPX]
.QUOTE
time_t tv_sec;  // whole seconds -- ≥ 0
long   tv_nsec; // nanoseconds -- [0, 999999999]
.QUOTE OFF
.in
However, this presents a small set of problems:
.LIST alpha
.SHIFT_LIST 9p
.ITEM
the minor: this is a hold-over from I16L32 architectures, and on LP64 architectures \f(CBlong\fPs are way too big, and
.ITEM
the major: there are existing implementations which \fIcannot\fP conform to this, due to ABI requirements.
.LIST END
.
.HEADING 1 NAMED examples "Examples"
.PP
Under Linux®, on the
.PDF_WWW_LINK https://raw.githubusercontent.com/wiki/hjl-tools/x86-psABI/x86-64-psABI-1.0.pdf X32
ABI, the kernel's \f(CBstruct timespec\fP is invariably
.QUOTE
struct timespec {
  time_t tv_sec;
  long   tv_nsec;
};
.QUOTE OFF
under the \fIkernel ABI\fP: the LP64 AMD64.
This means that from the ILP32 userspace, it looks like this:
.QUOTE
struct timespec {
  time_t  tv_sec;
  int64_t tv_nsec;
};
.QUOTE OFF
The shortest available \f(CBint64_t\fP is \f(CBlong long\fP,
and the libc \fImust\fP expose a kernel-ABI-compatible \f(CBtimespec\fR
\(em a pickle indeed!
.
.HEADING 1 NAMED wording "Proposed wording"
.HEADING 2 NAMED "7.27.1.4" "7.27.1.4"
.in +1cm
The range and precision of times representable in \f(CBclock_t\fP and \f(CBtime_t\fP are implementation-defined.
The \f(CBtimespec\fP structure shall contain at least the following members, in any order.
The semantics of the members and their normal ranges are expressed in the comments.\*[SUP]342)\*[SUPX]
.QUOTE
time_t tv_sec;  // whole seconds -- ≥ 0
\*[red]\o'l\(em'\o'o\(em'\o'n\(em'\o'g\(em'\o'\ \(em'\o'\ \(em'\o'\ \(em'\o't\(em'\o'v\(em'\o'_\(em'\o'n\(em'\o's\(em'\o'e\(em'\o'c\(em'\o';\(em'\o'\ \(em'\o'/\(em'\o'/\(em'\o'\ \(em'\o'n\(em'\o'a\(em'\o'n\(em'\o'o\(em'\o's\(em'\o'e\(em'\o'c\(em'\o'o\(em'\o'n\(em'\o'd\(em'\o's\(em'\o'\ \(em'\o'-\(em'\o'-\(em'\o'\ \(em'\o'[\(em'\o'0\(em'\o',\(em'\o'\ \(em'\o'9\(em'\o'9\(em'\o'9\(em'\o'9\(em'\o'9\(em'\o'9\(em'\o'9\(em'\o'9\(em'\o'9\(em'\o']\(em'
\*[green]/* see below */ tv_nsec; // nanoseconds -- [0, 999999999]
.QUOTE OFF
\*[green]The \f(CBtv_nsec\fP member shall be of an implementation-defined signed integer type capable of representing the range [0, 999999999].\*[\*[default]]
.in
.PP
.in +1cm
The \f(CBtm\fP structure shall\*[darkwhite]… [rest of section unchanged]\*[\*[default]]
.in
.
.HEADING 1 NAMED rationale "Rationale"
.PP
Being strictly additive, this changes nothing on already-conforming implementations:
\f(CBtv_nsec\fP can simply continue to be a \f(CBlong\fP.
.PP
However, this enforces the need to cast \f(CBtv_nsec\fP to a concrete type for formatting
and other processing.
.
.HEADING 1 NAMED references "References"
The current Linux ABI \f(CBtimespec\fR situation:
.PDF_WWW_LINK https://sourceware.org/pipermail/libc-alpha/2021-December/133702.html
\(em this is part of a larger thread born out of an attempt to accurately describe \f(CBtimespec::tv_nsec\fP as part of Linux man-pages' \fBsystem_data_types\fP(7):
.PDF_WWW_LINK https://lore.kernel.org/linux-man/ec1dcc655184f6cdaae40ff8b7970b750434e4ef.1638123425.git.nabijaczleweli@nabijaczleweli.xyz/T/
.
.PP
.br
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
.
.TOC