diff options
| author | Warner Losh <imp@FreeBSD.org> | 2024-02-21 03:31:50 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2024-04-16 19:54:25 +0000 |
| commit | 67d21468bfafc489194ee2b88180baefd2b83a2a (patch) | |
| tree | 3ff85e682b20343c40ed920dbb038a02935a17cd | |
| parent | d6a4e4842943fb525061cfee34bc37a098cb7433 (diff) | |
loader: For the mini-stdio we have for lua, #define them to something else
To make it easier to port lua and some of the lua modules, we have a
series of routines to implement the stdio routines, even though we don't
normally implement them in the boot loader. Add a comment to this effect.
Also, some tools, like sanitizers and static analysis tools, make
unwarranted assumptions about these, so #define them to a different name
so they stop.
Sponsored by: Netflix
(cherry picked from commit 9a5aaa97cbae024f90bb626f78c3dbde28653c58)
| -rw-r--r-- | stand/liblua/lstd.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/stand/liblua/lstd.h b/stand/liblua/lstd.h index 05a8b8843d9c..ce3aef4bc5fc 100644 --- a/stand/liblua/lstd.h +++ b/stand/liblua/lstd.h @@ -34,6 +34,15 @@ #include <string.h> #include <machine/stdarg.h> +/* + * Mini stdio FILE and DIR routines. These are the minimal routines needed by + * the lfs module and lua's base code. We define them minimally here so we don't + * have to modify lua on every import. Further, since they aren't completely + * standard, we #define them to other names so they don't conflict with other + * tooling that makes assumptions about these routines that might not be, in + * fact, correct. + */ + typedef struct FILE { int fd; @@ -46,6 +55,18 @@ typedef struct DIR int fd; } DIR; +#define fopen lua_loader_fopen +#define freopen lua_loader_freopen +#define fread lua_loader_fread +#define fwrite lua_loader_fwrite +#define fclose lua_loader_fclose +#define ferror lua_loader_ferror +#define feof lua_loader_feof +#define getc lua_loader_getc +#define opendir lua_loader_opendir +#define fdopendir lua_loader_fdopendir +#define closedir lua_loader_closedir + FILE *fopen(const char *filename, const char *mode); FILE *freopen( const char *filename, const char *mode, FILE *stream); size_t fread(void *ptr, size_t size, size_t count, FILE *stream); |
