File: portable.h

package info (click to toggle)
dosemu-freedos 1%3A0.0.b9r5a%2Betch.1-0etch1
  • links: PTS
  • area: contrib
  • in suites: etch
  • size: 19,744 kB
  • ctags: 23,279
  • sloc: ansic: 143,864; asm: 20,397; makefile: 3,868; perl: 1,106; yacc: 690; sh: 553; pascal: 297; xml: 150; cpp: 67
file content (144 lines) | stat: -rw-r--r-- 3,959 bytes parent folder | download | duplicates (2)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
    This file is part of SUPPL - the supplemental library for DOS
    Copyright (C) 1996-2000 Steffen Kaiser

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: PORTABLE.H 1.2 1998/08/19 07:27:05 ska Exp ska $
   $Locker: ska $	$Name:  $	$State: Exp $


*/

#ifndef __PORTABLE_H
#define __PORTABLE_H

#include <regproto.h>
#define NUL '\0'
#define MK_OSVERS(major,minor) ((major << 8) | (minor))

#ifdef FARDATA
#undef FARDATA
#endif
#ifdef FARCODE
#undef FARCODE
#endif

#ifdef _MICROC_

#include <p-mc.h>

#else	/* no _MICROC_ */

#if defined(__HUGE__) || defined(__LARGE__) || defined(__COMPACT__)
#define FARDATA
#endif
#if defined(__HUGE__) || defined(__LARGE__) || defined(__MEDIUM__)
#define FARCODE
#endif

/*
 *	Currently supported:
 *		Borland C/C++ v2+
 *		Pacific C v7.51
 *		Watcom v10.6
 */

#define iM(q)			/* if Micro-C */
#define nM(q)	q		/* not Mirco-C */
#define inM(q,w)	w	/* if-not Micro-C */
#define aF(fct) (fct)		/* address of function */
#define aS(structure) &(structure)	/* address of structure */
#define cS(strucType) (strucType)	/* casting of a structure */


/* Handling of pointers to structures */
#define sInc(poi) ++(poi)
#define sDec(poi) --(poi)
#define sIdx(array,index) ((array) + (index))
#define sAdd(poi,displacement) ((poi) += (displacement))
#define sSub(poi,displacement) ((poi) -= (displacement))

/* far pointer variable handling */
#define TO_FP(var) ((void far*) (var))	/* cast variable to far pointer */
#define FARARG(var,type) type far* var
#define COPYFARARG(var) var

/* DWORD variables handling */
#define setDW(var,seg,ofs) ((var) = (dword)MK_FP(seg,ofs))
#define setDWP(varP,seg,ofs) (*(varP) = (dword)MK_FP(seg,ofs))
#define DW_LO(var) ((word)(var))
#define DW_HI(var) ((word)((var) >> 16))
#define DWP_LO(var) ((word)(var))
#define DWP_HI(var) ((word)((var) >> 16))
#define DWARG dword

/* Simulate long constants and long arguments */
#define TO_LONG(num) (unsigned long)(num)
#define MK_LONG(hi,lo) (((unsigned long)(hi) << 16) | (unsigned)(lo))


#ifndef NULL
#ifdef FARDATA
#define NULL (0L)
#else
#define NULL (0)
#endif
#endif

/* LONGMATH */
#define longcpy(a,b) ((a) = (b))
#define longset(a,b) ((a) = (b))
#define longmul(a,b) ((a) *= (b))
#define longdiv(a,b) ((a) /= (b))
#define longadd(a,b) ((a) += (b))
#define longsub(a,b) ((a) -= (b))
#define longtst(a) (!!(a))
int longcmp(long d1, long d2);
#define longcmp1(a,b) ((signed long)(a) - (signed long)(b))

#define longseti(a,b) ((a) = (int)(b))
#define longmuli(a,b) ((a) *= (int)(b))
#define longdivi(a,b) ((a) /= (int)(b))
#define longaddi(a,b) ((a) += (int)(b))
#define longsubi(a,b) ((a) -= (int)(b))

#define longsetu(a,b) ((a) = (unsigned)(b))
#define longmulu(a,b) ((a) *= (unsigned)(b))
#define longdivu(a,b) ((a) /= (unsigned)(b))
#define longaddu(a,b) ((a) += (unsigned)(b))
#define longsubu(a,b) ((a) -= (unsigned)(b))


/* Source In compiler specific settings */
#ifdef __TURBOC__
#include "p-bc.h"
#endif

#ifdef HI_TECH_C
#include "p-pac.h"
#endif

#ifdef __WATCOMC__
#include "p-watcom.h"
#endif

#endif	/* _MICROC_ */

#ifndef strend
#define strend(s)	strchr((s), '\0')
#endif

#endif