blob: 023c8905d776170497eeab43534411ce7571a473 [file] [log] [blame]
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -05001#ifndef KLUDGE_H
2#define KLUDGE_H
3
4/*
5 * Kludges for not-quite-ANSI systems.
6 * This should always be the last file included, because it may
7 * mess up some system header files.
8 */
9
10/*
11 * Some compilers complain about #if FOO if FOO isn't defined,
12 * so do the ANSI-mandated thing explicitly...
13 */
14#ifndef ASSERT_NEEDS_STDIO
15#define ASSERT_NEEDS_STDIO 0
16#endif
17#ifndef ASSERT_NEEDS_STDLIB
18#define ASSERT_NEEDS_STDLIB 0
19#endif
20#ifndef NO_STDLIB_H
21#define NO_STDLIB_H 0
22#endif
23
24/* SunOS 4.1.x <assert.h> needs "stderr" defined, and "exit" declared... */
25#ifdef assert
26#if ASSERT_NEEDS_STDIO
27#include <stdio.h>
28#endif
29#if ASSERT_NEEDS_STDLIB
30#if !NO_STDLIB_H
31#include <stdlib.h>
32#endif
33#endif
34#endif
35
36#ifndef NO_MEMMOVE
37#define NO_MEMMOVE 0
38#endif
39#if NO_MEMMOVE /* memove() not in libraries */
40#define memmove(dest,src,len) bcopy(src,dest,len)
41#endif
42
43#ifndef NO_MEMCPY
44#define NO_MEMCPY 0
45#endif
46#if NO_MEMCPY /* memcpy() not in libraries */
47#define memcpy(dest,src,len) bcopy(src,dest,len)
48#endif
49
50#ifndef MEM_PROTOS_BROKEN
51#define MEM_PROTOS_BROKEN 0
52#endif
53#if MEM_PROTOS_BROKEN
54#define memcpy(d,s,l) memcpy((void *)(d), (void const *)(s), l)
55#define memmove(d,s,l) memmove((void *)(d), (void const *)(s), l)
56#define memcmp(d,s,l) memcmp((void const *)(d), (void const *)(s), l)
57#define memset(d,v,l) memset((void *)(d), v, l)
58#endif
59
60/*
61 * If there are no prototypes for the stdio functions, use these to
62 * reduce compiler warnings. Uses EOF as a giveaway to indicate
63 * that <stdio.h> was #included.
64 */
65#ifndef NO_STDIO_PROTOS
66#define NO_STDIO_PROTOS 0
67#endif
68#if NO_STDIO_PROTOS /* Missing prototypes for "simple" functions */
69#ifdef EOF
70#ifdef __cplusplus
71extern "C" {
72#endif
73int (puts)(char const *);
74int (fputs)(char const *, FILE *);
75int (fflush)(FILE *);
76int (printf)(char const *, ...);
77int (fprintf)(FILE *, char const *, ...);
78/* If we have a sufficiently old-fashioned stdio, it probably uses these... */
79int (_flsbuf)(int, FILE *);
80int (_filbuf)(FILE *);
81#ifdef __cplusplus
82}
83#endif
84#endif /* EOF */
85#endif /* NO_STDIO_PROTOS */
86
87/*
88 * Borland C seems to think that it's a bad idea to decleare a
89 * structure tag and not declare the contents. I happen to think
90 * it's a *good* idea to use such "opaque" structures wherever
91 * possible. So shut up.
92 */
93#ifdef __BORLANDC__
94#pragma warn -stu
95#ifndef MSDOS
96#define MSDOS 1
97#endif
98#endif
99
100/* Turn off warning about negation of unsigned values */
101#ifdef _MSC_VER
102#pragma warning(disable:4146)
103#endif
104
105/* Cope with people forgetting to define the OS, if possible... */
106#ifndef MSDOS
107#ifdef __MSDOS
108#define MSDOS 1
109#endif
110#endif
111#ifndef MSDOS
112#ifdef __MSDOS__
113#define MSDOS 1
114#endif
115#endif
116
117/* By MS-DOS, we mean 16-bit brain-dead MS-DOS. Not GCC & GO32 */
118#ifdef __GO32
119#undef MSDOS
120#endif
121#ifdef __GO32__
122#undef MSDOS
123#endif
124
125#endif /* KLUDGE_H */