... it breaks C99 aliasing rules and GCC rightfully warns about it.
If we ever want to do such type checking, we might use
#define CAST(f) ((f)->is_fastbuf, (struct xxxx *)(f))
but I guess it is of little use anyway, so I am removing it.
struct conv_context ctxt;
byte buf[BUFSIZE];
};
-#define FB_CC(f) ((struct fb_charconv *)(f)->is_fastbuf)
+#define FB_CC(f) ((struct fb_charconv *)(f))
static void
fb_cc_spout(struct fastbuf *f)
* for how it works.
**/
struct fastbuf {
- byte is_fastbuf[0]; /* Dummy field for checking of type casts */
byte *bptr, *bstop; /* State of the buffer */
byte *buffer, *bufend; /* Start and end of the buffer */
char *name; /* File name (used for error messages) */
byte *expected_max_bptr;
uns slack_size;
};
-#define FB_ATOMIC(f) ((struct fb_atomic *)(f)->is_fastbuf)
/**
* Open an atomic fastbuf.
#endif
+#define FB_ATOMIC(f) ((struct fb_atomic *)(f))
#define TRACE(m...) do { if(trace) msg(L_DEBUG, "FB_ATOMIC: " m); } while(0)
struct fb_atomic_file {
enum fbdir_mode mode;
byte name[0];
};
-#define FB_DIRECT(f) ((struct fb_direct *)(f)->is_fastbuf)
+#define FB_DIRECT(f) ((struct fb_direct *)(f))
#ifndef TEST
uns fbdir_cheat;
ucw_off_t wpos; /* Real file position */
uns wlen; /* Window size */
};
-#define FB_FILE(f) ((struct fb_file *)(f)->is_fastbuf)
+#define FB_FILE(f) ((struct fb_file *)(f))
#define FB_BUFFER(f) (byte *)(FB_FILE(f) + 1)
static int
struct mempool *mp;
byte *end;
};
-#define FB_GBUF(f) ((struct fb_gbuf *)(f)->is_fastbuf)
+#define FB_GBUF(f) ((struct fb_gbuf *)(f))
static int fbgrow_refill(struct fastbuf *b)
{
int fd; /* File descriptor */
int limit;
};
-#define FB_LIMFD(f) ((struct fb_limfd *)(f)->is_fastbuf)
+#define FB_LIMFD(f) ((struct fb_limfd *)(f))
#define FB_BUFFER(f) (byte *)(FB_LIMFD(f) + 1)
static int
struct memstream *stream;
struct msblock *block;
};
-#define FB_MEM(f) ((struct fb_mem *)(f)->is_fastbuf)
+#define FB_MEM(f) ((struct fb_mem *)(f))
static int
fbmem_refill(struct fastbuf *f)
uns window_size;
int mode;
};
-#define FB_MMAP(f) ((struct fb_mmap *)(f)->is_fastbuf)
+#define FB_MMAP(f) ((struct fb_mmap *)(f))
static void
bfmm_map_window(struct fastbuf *f)
#include <stdio.h>
#include <stdlib.h>
-#define FB_POOL(f) ((struct fbpool *)(f)->is_fastbuf)
+#define FB_POOL(f) ((struct fbpool *)(f))
static void
fbpool_spout(struct fastbuf *b)
byte buf[0];
};
-#define FB_SOCK(f) ((struct fb_sock *)(f)->is_fastbuf)
+#define FB_SOCK(f) ((struct fb_sock *)(f))
static int
fbs_refill(struct fastbuf *f)