Patrick Georgi | 55189c9 | 2020-05-10 20:09:31 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 2 | |
Uwe Hermann | 6e56594 | 2008-03-01 19:06:32 +0000 | [diff] [blame] | 3 | #ifndef COMMON_H |
| 4 | #define COMMON_H |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 5 | |
| 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> |
| 17 | |
| 18 | #define FALSE 0 |
| 19 | #define TRUE 1 |
| 20 | |
| 21 | #define BUG() assert(0) |
| 22 | |
| 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 |
| 27 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 28 | #define OK 0 /* 0 is used universally to indicate success. */ |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 29 | |
| 30 | #define LINE_EOF (COMMON_RESULT_START + 0) |
| 31 | #define LINE_TOO_LONG (COMMON_RESULT_START + 1) |
| 32 | |
Zheng Bao | 5451672 | 2012-10-22 16:41:42 +0800 | [diff] [blame] | 33 | #ifdef __MINGW32__ |
| 34 | #define PROT_READ 1 |
| 35 | #define PROT_WRITE 2 |
| 36 | #define MAP_PRIVATE 1 |
| 37 | |
| 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); |
| 40 | |
| 41 | #define mmap win32_mmap |
| 42 | #define munmap win32_munmap |
| 43 | |
| 44 | #define MAP_FAILED ((void *)-1) |
| 45 | #define MAP_SHARED 1 |
| 46 | #endif |
| 47 | |
Evgeny Zinoviev | 79f7fcc | 2020-01-11 01:26:54 +0300 | [diff] [blame] | 48 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
| 49 | #define noreturn _Noreturn |
| 50 | #else |
| 51 | #define noreturn |
| 52 | #endif |
| 53 | |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 54 | /* basename of this program, as reported by argv[0] */ |
| 55 | extern const char prog_name[]; |
| 56 | |
| 57 | /* version of this program */ |
| 58 | extern const char prog_version[]; |
| 59 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 60 | int get_line_from_file(FILE * f, char line[], int line_buf_size); |
Evgeny Zinoviev | 79f7fcc | 2020-01-11 01:26:54 +0300 | [diff] [blame] | 61 | noreturn void out_of_memory(void); |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 62 | void usage(FILE * outfile); |
Stefan Reinauer | 6540ae5 | 2007-07-12 16:35:42 +0000 | [diff] [blame] | 63 | |
Stefan Reinauer | 90b96b6 | 2010-01-13 21:00:23 +0000 | [diff] [blame] | 64 | #endif /* COMMON_H */ |