diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2024-08-03 16:11:57 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2024-08-22 00:01:06 +0100 |
commit | 44902cb49cd51e2bb2f1cef05cb3c0e799b83434 (patch) | |
tree | b64af413b10c32173aa535df22b5ee4162eb0290 /src/build/mkentprops.c | |
parent | 01ec55edd9f767bebb1222c88f0e53e9cf8b2d59 (diff) |
Rework OS abstractions
- As much as possible avoid dragging system headers into translation
units. This should avoid namespace pollution and, hopefully, speed up
builds a little bit.
- Avoid leaning on the UCRT so much on Windows - prefer native win32
calls and native file handles except where doing so is inconvenient
(in particular, for stat(), which we might try and replace later).
- Also, switch from SystemFunction036 to ProcessPrng on Windows. This
requires us to generate a stub for bcryptprimitives.dll because
Microsoft haven't bothered to provide a link library, but the function
is better-documented and seems to be a more direct under-the-hood call
as well. Apparently it's what's used by the major web browsers these
days, which seems like a good indication it's stable and trusted.
- Lastly, remove a bunch of functions and macros and stuff that weren't
actually being used. It seems good to try and keep the scope of
OS-dependent stuff relatively contained and only add to it when
actually required.
Diffstat (limited to 'src/build/mkentprops.c')
-rw-r--r-- | src/build/mkentprops.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/build/mkentprops.c b/src/build/mkentprops.c index 0781f25..2043a9b 100644 --- a/src/build/mkentprops.c +++ b/src/build/mkentprops.c @@ -174,13 +174,13 @@ _( "}") int OS_MAIN(int argc, os_char *argv[]) { for (++argv; *argv; ++argv) { - int fd = os_open(*argv, O_RDONLY); - if (fd == -1) die("couldn't open file"); + int f = os_open_read(*argv); + if (f == -1) die("couldn't open file"); struct kv_parser kv = {0}; struct parsestate state = {*argv, &kv}; char buf[1024]; int nread; - while (nread = read(fd, buf, sizeof(buf))) { + while (nread = os_read(f, buf, sizeof(buf))) { if (nread == -1) die("couldn't read file"); if (!kv_parser_feed(&kv, buf, nread, &kv_cb, &state)) goto ep; } @@ -189,7 +189,7 @@ ep: fprintf(stderr, "mkentprops: %" fS ":%d:%d: bad syntax: %s\n", *argv, kv.line, kv.col, kv.errmsg); exit(1); } - close(fd); + os_close(f); } FILE *out = fopen(".build/include/entprops.gen.h", "wb"); |