blob: e15138c7dd37a8d29d0ab7ede8c676736d305d6d [file] [log] [blame]
Patrick Georgi55189c92020-05-10 20:09:31 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer6540ae52007-07-12 16:35:42 +00002
Uwe Hermann6e565942008-03-01 19:06:32 +00003#ifndef COMMON_H
4#define COMMON_H
Stefan Reinauer6540ae52007-07-12 16:35:42 +00005
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 Reinauer90b96b62010-01-13 21:00:23 +000028#define OK 0 /* 0 is used universally to indicate success. */
Stefan Reinauer6540ae52007-07-12 16:35:42 +000029
30#define LINE_EOF (COMMON_RESULT_START + 0)
31#define LINE_TOO_LONG (COMMON_RESULT_START + 1)
32
Zheng Bao54516722012-10-22 16:41:42 +080033#ifdef __MINGW32__
34#define PROT_READ 1
35#define PROT_WRITE 2
36#define MAP_PRIVATE 1
37
38void *win32_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
39int 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 Zinoviev79f7fcc2020-01-11 01:26:54 +030048#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
49#define noreturn _Noreturn
50#else
51#define noreturn
52#endif
53
Stefan Reinauer6540ae52007-07-12 16:35:42 +000054/* basename of this program, as reported by argv[0] */
55extern const char prog_name[];
56
57/* version of this program */
58extern const char prog_version[];
59
Stefan Reinauer90b96b62010-01-13 21:00:23 +000060int get_line_from_file(FILE * f, char line[], int line_buf_size);
Evgeny Zinoviev79f7fcc2020-01-11 01:26:54 +030061noreturn void out_of_memory(void);
Stefan Reinauer90b96b62010-01-13 21:00:23 +000062void usage(FILE * outfile);
Stefan Reinauer6540ae52007-07-12 16:35:42 +000063
Stefan Reinauer90b96b62010-01-13 21:00:23 +000064#endif /* COMMON_H */