diff options
| author | Jakob Kaivo <jkk@ung.org> | 2024-02-02 13:25:45 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2024-02-02 13:25:45 -0500 |
| commit | 24f39222098253da4ad1a9cd8ddef5b9b0152ba1 (patch) | |
| tree | 36eede312e7dcb4a9afe49342fba996ef273549d /src/stdio/_stdio.h | |
| parent | 6aebe0dbfc24f0af73eb422b4748a9b35df5b435 (diff) | |
use UNDEFINED() instead of directly calling __undefined()
Diffstat (limited to 'src/stdio/_stdio.h')
| -rw-r--r-- | src/stdio/_stdio.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h index 516ce659..d47ac5dd 100644 --- a/src/stdio/_stdio.h +++ b/src/stdio/_stdio.h @@ -22,6 +22,23 @@ #define GCC_SSE_HACK __attribute__((noinline, target("no-sse"))) +#define ORIENT_WIDE (1) +#define ORIENT_BYTE (-1) + +#define OP_INPUT (1) +#define OP_OUTPUT (2) + +#ifdef NDEBUG +#define ASSERT_STREAM(__stream, __orientation, __operation) +#else +#define ASSERT_STREAM(__stream, __orientation, __operation) do { \ + ASSERT_NONNULL(__stream); \ + if (((__orientation) && stream->orientation) && ((__orientation) != stream->orientation)) { \ + UNDEFINED("In call to %s(): Requested %s operation on %s oriented stream", __func__, (__orientation) > 0 ? "wide" : "byte", (stream->orientation) > 0 ? "wide" : "byte"); \ + } \ + } while (0) +#endif + struct __FILE { fpos_t pos; @@ -38,14 +55,15 @@ struct __FILE { int fd; /* the backing file descriptor */ - int orientation; /* 0 = undetermind, < 0 = byte, > 0 = wide */ - - int eof; /* eof indicator */ - int err; /* error indicator */ - int nlocks; /* in multithreaded, used by flockfile() */ int thread; /* the owning thread if locked */ + int orientation:2; /* 0 = undetermind, < 0 = byte, > 0 = wide */ + int operation; /* TODO: previous operation, NONE, INPUT, OUTPUT (are there others?) */ + int eof:1; /* eof indicator */ + int err:1; /* error indicator */ + int text:1; /* is this a text file? */ + #ifdef _POSIX_C_SOURCE pid_t pipe_pid; /* if stream is a pipe, the child pid */ #endif |
