~nabijaczleweli/wg14

b6a1d98d3ed19145969201feef58d0cd5132bdd3 — наб 2 years ago
Initial commit :/

https://twitter.com/__phantomderp/status/1468040630932750343
4 files changed, 250 insertions(+), 0 deletions(-)

A .build.yml
A LICENCE
A Makefile
A N????.mom
A  => .build.yml +66 -0
@@ 1,66 @@
image: debian/sid
secrets:
  - a6de06d3-a327-40e9-824d-e4a7e577eaf6  # wg14 SSH key
packages:
  - groff
  - ghostscript
  - gsfonts
tasks:
  # https://nabijaczleweli.xyz/content/blogn_t/007-groff-Tps-cyrillic-et-al.html
  - prepare-fonts: |
      mkdir devps; cd devps
      for f in {C,T}{R,B,I,BI}; do
        in="$(awk '$1 == "internalname" {print $2; exit}' "/usr/share/groff/current/font/devps/$f")";
        echo $f: $in;
        src="$(awk -v cur="/$in" '
          $1 ~ /^\// && $2 ~ /^[\/\(]/ {
            if($2 ~ /^\//)
              aliases[$1] = $2;
            else
              paths[$1] = $2;
          }
          END {
            while(cur in aliases)
              cur = aliases[cur];
            if(cur in paths) {
              sub(/^\(/, "", paths[cur]);
              sub(/(pfb)?\)$/, "", paths[cur]);
              print paths[cur]
            } else {
              print "last: " cur > "/dev/stderr";
              exit 1
            }
          }' /var/lib/ghostscript/fonts/Fontmap)";
        echo ${src}afm;
        afmtodit $(expr "$f" : C > /dev/null && printf -- -n) -cmi0 \
          -d /usr/share/groff/current/font/devps/DESC \
          -e /usr/share/groff/current/font/devps/text.enc \
          "${src}afm" /usr/share/groff/current/font/devps/generate/textmap "$f";
      done
      sudo ln -s /usr/local/share/groff/site-font /usr/share/groff
      sudo mkdir -p /usr/local/share/groff/site-font
      sudo mv ../devps /usr/local/share/groff/site-font
  - build: |
      git -C wg14/ worktree add ../wg14-output output
      rm -rf wg14-output/*
      DESTDIR=../wg14-output/ make -C wg14
  - push: |
      cd wg14-output/
      for f in *.pdf; do echo "# [${f%.pdf}](//srhtcdn.githack.com/~nabijaczleweli/wg14/blob/output/$f)"; done > README.md
      git add .
      git config user.email "nabijaczleweli/autouploader@nabijaczleweli.xyz"
      git config user.name "наб autouploader"
      git remote set-url origin 'git@git.sr.ht:~nabijaczleweli/wg14'
      ssh-keyscan git.sr.ht > ~/.ssh/known_hosts
      git commit -m "Output update by job $JOB_ID" || exit 0
      while true; do
        git push && break
        for _ in $(seq 0 10); do
          sleep 3
          git fetch
          git rebase
          git push && break 2
        done
        echo "Couldn't push manpages!"
        exit 1
      done

A  => LICENCE +10 -0
@@ 1,10 @@
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

A  => Makefile +8 -0
@@ 1,8 @@
# SPDX-License-Identifier: 0BSD

PAGES = $(wildcard *.mom)

pages : $(patsubst %.mom,$(DESTDIR)%.pdf,$(PAGES))

$(DESTDIR)%.pdf : %.mom
	pdfmom -Tps -K utf-8 -t $^ | ps2pdf - $@

A  => N????.mom +166 -0
@@ 1,166 @@
.\" SPDX-License-Identifier: 0BSD
.\"
.TITLE     "\fIN????\fP: \f(CBnsec_t \fP\f(CR&&\f(CR\fP\f(CB timespec::tv_nsec\fP"
.PDF_TITLE "\*[$TITLE]
.AUTHOR    "\v'-.5v'\*[UP 8p]наб"
.ATTRIBUTE_STRING ""  \" Don't print 'by'
.HEADER_LEFT "наб"
.\" Page, style, formatting
.PRINTSTYLE TYPESET
.PAPER	    A4
.L_MARGIN   2.5c
.R_MARGIN   2.5c
.B_MARGIN   2.5c
.\"
.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
.NEWCOLOUR dark-grey RGB #343434
.XCOLOR    darkgreen green
.XCOLOR        red   red
.NEWCOLOUR darkwhite RGB #A0A0A0
.\" Make QUOTE look like CODE
.QUOTE_FAMILY C
.QUOTE_FONT   B
.QUOTE_SIZE   +1.5
.QUOTE_COLOR  dark-grey
.QUOTE_INDENT 9p
.\"
.CODE_FONT  B
.CODE_SIZE  115
.CODE_COLOR dark-grey
.CONDENSE   87
.\"
.HEADING_STYLE 1 NUMBER FONT B SIZE +1 BASELINE_ADJUST \n[.v]/5
.HEADING_STYLE 2 NUMBER FONT I SIZE +.25 BASELINE_ADJUST \n[.v]/5
.\" Wrapper around QUOTE
.de COD
. QUOTE
. nop \*[COND]\\$*\*[CONDX]
. 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
..
.\"
.DOCHEADER_ADVANCE 4.5c \" Begin this distance down from top of page
.\"
.START
.
\v'-5i'
.TS
ll.
Document #:	????
Date:	2021-12-06
Project:	Programming Language C
.PDF_WWW_LINK mailto:nabijaczleweli@nabijaczleweli.xyz PREFIX "Reply-to:	      наб <" SUFFIX > nabijaczleweli@nabijaczleweli.xyz
.TE
.
.\"
.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/n2573.pdf N2573
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
\*[COND]
time_t tv_sec;  // whole seconds -- ≥ 0
long   tv_nsec; // nanoseconds -- [0, 999999999]
\*[CONDX]
.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
\*[COND]
struct timespec {
  time_t tv_sec;
  long   tv_nsec;
};
\*[CONDX]
.QUOTE OFF
under the \fIkernel ABI\fP: the LP64 AMD64.
This means that from the ILP32 userspace, it looks like this:
.QUOTE
\*[COND]
struct timespec {
  time_t  tv_sec;
  int64_t tv_nsec;
};
\*[CONDX]
.QUOTE OFF
The shortest available \f(CBint64_t\fP is \f(CBlong long\fP \(em a pickle indeed!
.
.HEADING 1 NAMED wording "Proposed wording"
.HEADING 2 NAMED "7.27.1.3" "7.27.1.3"
.in +1cm
The types declared are \f(CBsize_t\fP (described in 7.19);
.COD clock_t
and
.COD clock_t
which are real types capable of representing times;
.COD \*[green]nsec_t
\*[green]which is an integer type capable of representing the range [0, 999999999];\*[dark-grey]
.COD struct timespec
which holds and interval specified in seconds and nanoseconds (which may represent a calendar time based on a particular epoch); and
.COD struct tm
which holds the components of a calendar time, called the \fIbroken-down time\fP.
.in
.
.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
\*[COND]
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]nsec_t tv_nsec; // nanoseconds -- [0, 999999999]
\*[CONDX]
.QUOTE OFF
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(CBnsec_t\fP can simply continue to be \f(CBlong\fP.
.PP
However, this enforces the need to cast \f(CBtv_nsec\fP to a concrete type for formatting,
or other processing, and allows user code to actually store it in its original form.
.
.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
.
.PP
.br
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.