-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompiler.h
82 lines (62 loc) · 1.81 KB
/
compiler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//
//
// Copyright (C) 2023-2024 Frenkel Smeijers
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef __COMPILER__
#define __COMPILER__
#if defined _M_I86
//16-bit
#include <i86.h>
#define D_MK_FP MK_FP
#define D_FP_SEG FP_SEG
#if defined __WATCOMC__
#define D_FP_OFF FP_OFF
#else
#define D_FP_OFF(p) ((uint16_t)((uint32_t)(p)))
#endif
typedef uint16_t segment_t;
#define SIZE_OF_SEGMENT_T 2
#if defined elks
#include <stddef.h>
void __far* _fmemcpy(void __far* destination, const void __far* source, size_t num);
void __far* _fmemset(void __far* str, int c, size_t n);
int16_t abs(int16_t v);
int32_t labs(int32_t v);
#endif
#else
//32-bit
#define D_MK_FP(s,o) (void*)((s<<4)+o)
#define D_FP_SEG(p) (((uint32_t)p)>>4)
#define D_FP_OFF(p) (((uint32_t)p)&15)
typedef uint32_t segment_t;
#define SIZE_OF_SEGMENT_T 4
#define __far
#define _fmemcpy memcpy
#define _fmemset memset
#endif
#if defined __DJGPP__
//DJGPP
#include <sys/nearptr.h>
//DJGPP doesn't inline inp, outp and outpw,
//but it does inline inportb, outportb and outportw
#define inp(port) inportb(port)
#define outp(port,data) outportb(port,data)
#else
//Watcom and gcc-ia16
#define __djgpp_nearptr_enable()
#define __djgpp_conventional_base 0
#endif
#endif