%error, %warning out on the final pass, add %fatal
[nasm/avx512.git] / saa.h
blob32fae2b164f28c2bf86c3fea6c1c72e1c7bf6b0d
1 #ifndef NASM_SAA_H
2 #define NASM_SAA_H
4 #include "compiler.h"
6 /*
7 * Routines to manage a dynamic sequential-access array, under the
8 * same restriction on maximum mallocable block. This array may be
9 * written to in two ways: a contiguous chunk can be reserved of a
10 * given size with a pointer returned OR single-byte data may be
11 * written. The array can also be read back in the same two ways:
12 * as a series of big byte-data blocks or as a list of structures
13 * of a given size.
16 struct SAA {
18 * members `end' and `elem_len' are only valid in first link in
19 * list; `rptr' and `rpos' are used for reading
21 size_t elem_len; /* Size of each element */
22 size_t blk_len; /* Size of each allocation block */
23 size_t nblks; /* Total number of allocated blocks */
24 size_t nblkptrs; /* Total number of allocation block pointers */
25 size_t length; /* Total allocated length of the array */
26 size_t datalen; /* Total data length of the array */
27 char **wblk; /* Write block pointer */
28 size_t wpos; /* Write position inside block */
29 size_t wptr; /* Absolute write position */
30 char **rblk; /* Read block pointer */
31 size_t rpos; /* Read position inside block */
32 size_t rptr; /* Absolute read position */
33 char **blk_ptrs; /* Pointer to pointer blocks */
36 struct SAA *saa_init(size_t elem_len); /* 1 == byte */
37 void saa_free(struct SAA *);
38 void *saa_wstruct(struct SAA *); /* return a structure of elem_len */
39 void saa_wbytes(struct SAA *, const void *, size_t); /* write arbitrary bytes */
40 void saa_rewind(struct SAA *); /* for reading from beginning */
41 void *saa_rstruct(struct SAA *); /* return NULL on EOA */
42 const void *saa_rbytes(struct SAA *, size_t *); /* return 0 on EOA */
43 void saa_rnbytes(struct SAA *, void *, size_t); /* read a given no. of bytes */
44 /* random access */
45 void saa_fread(struct SAA *, size_t, void *, size_t);
46 void saa_fwrite(struct SAA *, size_t, const void *, size_t);
48 /* dump to file */
49 void saa_fpwrite(struct SAA *, FILE *);
51 /* Write specific-sized values */
52 void saa_write8(struct SAA *s, uint8_t v);
53 void saa_write16(struct SAA *s, uint16_t v);
54 void saa_write32(struct SAA *s, uint32_t v);
55 void saa_write64(struct SAA *s, uint64_t v);
56 void saa_wleb128u(struct SAA *, int); /* write unsigned LEB128 value */
57 void saa_wleb128s(struct SAA *, int); /* write signed LEB128 value */
59 #endif /* NASM_SAA_H */