Re: transpiling to low level C

Liste des GroupesRevenir à cl c  
Sujet : Re: transpiling to low level C
De : cr88192 (at) *nospam* gmail.com (BGB)
Groupes : comp.lang.c
Date : 28. Dec 2024, 20:59:24
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vkplb6$g94b$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Mozilla Thunderbird
On 12/28/2024 11:24 AM, Tim Rentsch wrote:
BGB <cr88192@gmail.com> writes:
 
On 12/23/2024 3:18 PM, Tim Rentsch wrote:
>
Michael S <already5chosen@yahoo.com> writes:
>
On Mon, 23 Dec 2024 09:46:46 +0100
David Brown <david.brown@hesbynett.no> wrote:
>
And Tim did not rule out using the standard library,
>
Are you sure?
>
I explicitly called out setjmp and longjmp as being excluded.
Based on that, it's reasonable to infer the rest of the
standard library is allowed.
>
Furthermore I don't think it matters.  Except for a very small
set of functions -- eg, fopen, fgetc, fputc, malloc, free --
everything else in the standard library either isn't important
for Turing Completeness or can be synthesized from the base
set.  The functionality of fprintf(), for example, can be
implemented on top of fputc and non-library language features.
>
If I were to choose a set of primitive functions, probably:
   malloc/free and/or realloc
     could define, say:
       malloc(sz) => realloc(NULL, sz)
       free(ptr) => realloc(ptr, 0)
     Maybe _msize and _mtag/..., but this is non-standard.
       With _msize, can implement realloc on top of malloc/free.
>
For basic IO:
   fopen, fclose, fseek, fread, fwrite
>
printf could be implemented on top of vsnprintf and fputs
   fputs can be implemented on top of fwrite (via strlen).
   With a temporary buffer buffer being used for the printed string.
 Most of these aren't needed.  I think everything can be
done using only fopen, fclose, fgetc, fputc, and feof.
If you only have fgetc and fputc, IO speeds are going to be unacceptably slow for non-trivial file sizes.
If you try to fake fseek by closing, re-opening, and an fgetc loop, well, also going to be very slow.
Then again, fgetc/fputc as the primary operations could make sense for text files if the implementation is doing some form of format conversion (such as converting between LF only and CR+LF), though admittedly IMO one is better off treating text files as equivalent to binary files (and letting the application deal with any conversions here).
OTOH:
   fgetc and fputc can be implemented via fread and fwrite;
   feof (for normal files) can be implemented via fseek (*1);
     Similar, ftell could be treated as a special case of fseek.
*1: Say, if the internal fseek call were made to return the current file position (similar to lseek).
...
Well, in another also recently left facing off with the wonk of UTF-8 normalization for the VFS layer in my project (for paths/filenames). Options:
   Do Nothing, assume valid UTF-8 and that it is sensibly normalized;
     May risk malformed encodings at deeper levels of the VFS though.
   Encoding only normalization:
     Normalize to an M-UTF-8 variant and call it done.
   Do a subset of normalizing combining characters.
     The full set of Unicode rules would likely be too bulky;
     Filesystem should have no concept of locale;
     The rules should be ideally be "semi frozen" once defined.
At present, this is applied at the level of VFS syscalls (like "open()" or "opendir()").
Current thinking is that it will normalize to a variant of M-UTF-8 NFC (characters are stored in composed forms), but:
Will only apply the rules covering the Latin-1 and Latin Extended A spaces, and a subset of Latin Extended B.
Though, a case could be made for limiting the scope solely to the Latin-1/1252 range (and passing everything beyond this along as-is).
Less sure, had also added cases for the Roman numeral characters, mostly for decomposing them into ASCII; various ligatures would also be decomposed to ASCII (excluding those which appear as their own glyph, so AE and OE are left as-is, but IJ/DZ/... would be decomposed). A case could also be made for leaving these alone (passing them along unmodified). Depends mostly on the open question of whether or not these convey relevant semantic information (or are merely historical/aesthetic).
At present, the rules are stored as a table, with roughly 8 bytes needed per combiner rule (increases to 12 once initialized, mostly because it allocates a pair of 16-bit hash chains).
   Namely: SrcCodepoint1, SrcCodepoint2, DstCodepoint, Flags
     Flags specify when and how the rule is applied.
     SrcCodepoint2 is currently 0x0000 for simple conversion rules.
     DstCodepoint is used for lookup for decompose.
     ...
Limiting the scope also makes things likely more repeatable (where inconsistent normalization could result in file lookup issues in cases where rules differ, if stepping on the offending code-points). Goal is mostly to find an acceptable set of rules that can be "mostly frozen". Though, in most cases this is likely N/A as the majority of filenames tend to be plain ASCII.
The responsibility for any more advanced normalization (or locale-dependent stuff) would be left up at the application level.
Can't seem to find much information about "best practices" in these areas.
It is not certain normalizing for combining characters is actually a good idea, vs only normalizing for codepoint encoding. Mostly to deal with cases where malformed data is submitted to the VFS, or possibly 1252 (if the VFS calls and similar are given something that is invalid UTF-8, then it may be assumed to be 1252). Theoretically, the locale code in the C library is expected to normalize for 1252 vs UTF-8 though (but, ideally, the integrity of the VFS should be kept protected from this sort of thing).
This also applies to console printing, which is also expected to be handed UTF-8, but may also normalize the strings. Though, there is some wonk with the console here in my case.
Seemingly (from what I can gather):
   Linux:
     It is per FS driver;
     Some are "do nothing", others normalize.
   MacOS:
     Also depends on filesystem:
       HFS/HFS+, normalizing (as NFD for some reason);
       APFS, does nothing (apparently leads to a lot of hassles).
   Windows:
     FAT32: Depends solely on OS locale;
     NTFS: Locale rules are baked-in when the drive is formatted.
       The relevant tables are held in filesystem metadata.
...

Date Sujet#  Auteur
15 Dec 24 * transpiling to low level C130Thiago Adams
15 Dec 24 +* Re: transpiling to low level C10Lawrence D'Oliveiro
15 Dec 24 i`* Re: transpiling to low level C9Thiago Adams
15 Dec 24 i `* Re: transpiling to low level C8Lawrence D'Oliveiro
16 Dec 24 i  `* Re: transpiling to low level C7Thiago Adams
16 Dec 24 i   `* Re: transpiling to low level C6BGB
16 Dec 24 i    +- Re: transpiling to low level C1Thiago Adams
16 Dec 24 i    +- Re: transpiling to low level C1bart
16 Dec 24 i    +- Re: transpiling to low level C1Lawrence D'Oliveiro
16 Dec 24 i    `* Re: transpiling to low level C2Keith Thompson
17 Dec 24 i     `- Re: transpiling to low level C1bart
15 Dec 24 +* Re: transpiling to low level C3Chris M. Thomasson
15 Dec 24 i`* Re: transpiling to low level C2Thiago Adams
15 Dec 24 i `- Re: transpiling to low level C1Chris M. Thomasson
15 Dec 24 +* Re: transpiling to low level C3bart
15 Dec 24 i`* Re: transpiling to low level C2Thiago Adams
15 Dec 24 i `- Re: transpiling to low level C1Thiago Adams
15 Dec 24 `* Re: transpiling to low level C113Bonita Montero
15 Dec 24  +* Re: transpiling to low level C110bart
16 Dec 24  i`* Re: transpiling to low level C109BGB
16 Dec 24  i +- Re: transpiling to low level C1David Brown
16 Dec 24  i +* Re: transpiling to low level C22Thiago Adams
17 Dec 24  i i`* Re: transpiling to low level C21BGB
17 Dec 24  i i `* Re: transpiling to low level C20Thiago Adams
17 Dec 24  i i  +* Re: transpiling to low level C15Thiago Adams
17 Dec 24  i i  i`* Re: transpiling to low level C14Thiago Adams
17 Dec 24  i i  i `* Re: transpiling to low level C13bart
17 Dec 24  i i  i  `* Re: transpiling to low level C12Thiago Adams
17 Dec 24  i i  i   `* Re: transpiling to low level C11bart
18 Dec 24  i i  i    `* Re: transpiling to low level C10BGB
18 Dec 24  i i  i     `* Re: transpiling to low level C9Thiago Adams
19 Dec 24  i i  i      `* Re: transpiling to low level C8BGB
19 Dec 24  i i  i       `* Re: transpiling to low level C7bart
19 Dec 24  i i  i        `* Re: transpiling to low level C6BGB
19 Dec 24  i i  i         +* Re: transpiling to low level C3bart
19 Dec 24  i i  i         i`* Re: transpiling to low level C2BGB
20 Dec 24  i i  i         i `- Re: transpiling to low level C1BGB
23 Dec 24  i i  i         `* Re: transpiling to low level C2Lawrence D'Oliveiro
23 Dec 24  i i  i          `- Re: transpiling to low level C1BGB
17 Dec 24  i i  `* Re: transpiling to low level C4BGB
17 Dec 24  i i   +* Re: transpiling to low level C2Thiago Adams
18 Dec 24  i i   i`- Re: transpiling to low level C1BGB
21 Dec 24  i i   `- Re: transpiling to low level C1Lawrence D'Oliveiro
16 Dec 24  i +* Re: transpiling to low level C72Janis Papanagnou
16 Dec 24  i i+* Re: transpiling to low level C16bart
16 Dec 24  i ii`* Re: transpiling to low level C15Janis Papanagnou
17 Dec 24  i ii `* Re: transpiling to low level C14bart
17 Dec 24  i ii  +* Re: transpiling to low level C12Keith Thompson
17 Dec 24  i ii  i+- Re: transpiling to low level C1BGB
17 Dec 24  i ii  i`* Re: transpiling to low level C10bart
17 Dec 24  i ii  i +- Re: transpiling to low level C1Janis Papanagnou
17 Dec 24  i ii  i +* Re: transpiling to low level C6Waldek Hebisch
17 Dec 24  i ii  i i+* Re: transpiling to low level C4bart
18 Dec 24  i ii  i ii`* Re: transpiling to low level C3Waldek Hebisch
18 Dec 24  i ii  i ii `* Re: transpiling to low level C2bart
18 Dec 24  i ii  i ii  `- Re: transpiling to low level C1Waldek Hebisch
18 Dec 24  i ii  i i`- Re: transpiling to low level C1Janis Papanagnou
17 Dec 24  i ii  i `* Re: transpiling to low level C2Keith Thompson
18 Dec 24  i ii  i  `- Re: transpiling to low level C1Janis Papanagnou
17 Dec 24  i ii  `- Re: transpiling to low level C1Janis Papanagnou
21 Dec 24  i i`* Re: transpiling to low level C55Tim Rentsch
21 Dec 24  i i `* Re: transpiling to low level C54Janis Papanagnou
21 Dec 24  i i  +* Re: transpiling to low level C2Tim Rentsch
22 Dec 24  i i  i`- Re: transpiling to low level C1Janis Papanagnou
21 Dec 24  i i  +* Re: transpiling to low level C18Michael S
22 Dec 24  i i  i+* Re: transpiling to low level C14Janis Papanagnou
22 Dec 24  i i  ii`* Re: transpiling to low level C13Michael S
22 Dec 24  i i  ii `* Re: transpiling to low level C12Janis Papanagnou
22 Dec 24  i i  ii  `* Re: transpiling to low level C11Michael S
22 Dec 24  i i  ii   +* Re: transpiling to low level C8Janis Papanagnou
23 Dec 24  i i  ii   i`* Re: transpiling to low level C7Tim Rentsch
23 Dec 24  i i  ii   i `* Re: transpiling to low level C6Waldek Hebisch
23 Dec 24  i i  ii   i  +* Re: transpiling to low level C3David Brown
25 Dec 24  i i  ii   i  i`* Re: transpiling to low level C2BGB
28 Dec 24  i i  ii   i  i `- Re: transpiling to low level C1Tim Rentsch
4 Jan21:12  i i  ii   i  `* Re: transpiling to low level C2Tim Rentsch
4 Jan21:53  i i  ii   i   `- Re: transpiling to low level C1Chris M. Thomasson
22 Dec 24  i i  ii   `* Re: transpiling to low level C2James Kuyper
22 Dec 24  i i  ii    `- Re: transpiling to low level C1Janis Papanagnou
23 Dec 24  i i  i`* Re: transpiling to low level C3Tim Rentsch
23 Dec 24  i i  i `* Re: transpiling to low level C2Chris M. Thomasson
24 Dec 24  i i  i  `- Re: transpiling to low level C1Chris M. Thomasson
22 Dec 24  i i  +* Re: transpiling to low level C27Waldek Hebisch
22 Dec 24  i i  i+* Re: transpiling to low level C2Michael S
22 Dec 24  i i  ii`- Re: transpiling to low level C1bart
22 Dec 24  i i  i+* Re: transpiling to low level C3Tim Rentsch
22 Dec 24  i i  ii`* Re: transpiling to low level C2Waldek Hebisch
4 Jan20:18  i i  ii `- Re: transpiling to low level C1Tim Rentsch
22 Dec 24  i i  i`* Re: transpiling to low level C21Janis Papanagnou
22 Dec 24  i i  i +* Re: transpiling to low level C4Michael S
23 Dec 24  i i  i i+- Re: transpiling to low level C1bart
23 Dec 24  i i  i i+- Re: transpiling to low level C1Michael S
23 Dec 24  i i  i i`- Re: transpiling to low level C1Tim Rentsch
23 Dec 24  i i  i +- Re: transpiling to low level C1Waldek Hebisch
23 Dec 24  i i  i +* Re: transpiling to low level C14David Brown
23 Dec 24  i i  i i+* Re: transpiling to low level C2bart
23 Dec 24  i i  i ii`- Re: transpiling to low level C1David Brown
23 Dec 24  i i  i i+* Re: transpiling to low level C10Michael S
23 Dec 24  i i  i ii+- Re: transpiling to low level C1David Brown
23 Dec 24  i i  i ii`* Re: transpiling to low level C8Tim Rentsch
24 Dec 24  i i  i ii +* Re: transpiling to low level C2Ben Bacarisse
25 Dec 24  i i  i ii `* Re: transpiling to low level C5BGB
23 Dec 24  i i  i i`- Re: transpiling to low level C1Chris M. Thomasson
23 Dec 24  i i  i `- Re: transpiling to low level C1Tim Rentsch
22 Dec 24  i i  +* Re: transpiling to low level C2Ben Bacarisse
22 Dec 24  i i  `* Re: transpiling to low level C4Kaz Kylheku
16 Dec 24  i `* Re: transpiling to low level C13Lawrence D'Oliveiro
16 Dec 24  `* Re: transpiling to low level C2Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal