region: Turn region_end() into an inclusive region_last()
[coreboot.git] / util / nvramtool / common.h
blobe15138c7dd37a8d29d0ab7ede8c676736d305d6d
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef COMMON_H
4 #define COMMON_H
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <assert.h>
9 #include <errno.h>
10 #include <unistd.h>
11 #include <fcntl.h>
12 #include <stdint.h>
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <string.h>
16 #include <ctype.h>
18 #define FALSE 0
19 #define TRUE 1
21 #define BUG() assert(0)
23 #define COMMON_RESULT_START 0x10000
24 #define LAYOUT_RESULT_START 0x20000
25 #define CMOS_RESULT_START 0x30000
26 #define CMOS_OP_RESULT_START 0x40000
28 #define OK 0 /* 0 is used universally to indicate success. */
30 #define LINE_EOF (COMMON_RESULT_START + 0)
31 #define LINE_TOO_LONG (COMMON_RESULT_START + 1)
33 #ifdef __MINGW32__
34 #define PROT_READ 1
35 #define PROT_WRITE 2
36 #define MAP_PRIVATE 1
38 void *win32_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
39 int win32_munmap(void *start, size_t length);
41 #define mmap win32_mmap
42 #define munmap win32_munmap
44 #define MAP_FAILED ((void *)-1)
45 #define MAP_SHARED 1
46 #endif
48 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
49 #define noreturn _Noreturn
50 #else
51 #define noreturn
52 #endif
54 /* basename of this program, as reported by argv[0] */
55 extern const char prog_name[];
57 /* version of this program */
58 extern const char prog_version[];
60 int get_line_from_file(FILE * f, char line[], int line_buf_size);
61 noreturn void out_of_memory(void);
62 void usage(FILE * outfile);
64 #endif /* COMMON_H */