| 1 |
|
| 2 |
|
| 3 |
#ifndef COMMON_H |
| 4 |
#define COMMON_H |
| 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 |
|
| 28 |
#define OK 0 |
| 29 |
|
| 30 |
#define LINE_EOF (COMMON_RESULT_START + 0) |
| 31 |
#define LINE_TOO_LONG (COMMON_RESULT_START + 1) |
| 32 |
|
| 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 |
|
| 48 |
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L |
| 49 |
#define noreturn _Noreturn |
| 50 |
#else |
| 51 |
#define noreturn |
| 52 |
#endif |
| 53 |
|
| 54 |
|
| 55 |
extern const char prog_name[]; |
| 56 |
|
| 57 |
|
| 58 |
extern const char prog_version[]; |
| 59 |
|
| 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); |
| 63 |
|
| 64 |
#endif |