summaryrefslogtreecommitdiffstats
path: root/board/MAI/bios_emulator/scitech/include/scitech.h
blob: 1dbfface0dcc31538f9188825730a53fd9a6e76b (plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/****************************************************************************
*
*                   SciTech Multi-platform Graphics Library
*
*  ========================================================================
*
*    The contents of this file are subject to the SciTech MGL Public
*    License Version 1.0 (the "License"); you may not use this file
*    except in compliance with the License. You may obtain a copy of
*    the License at http://www.scitechsoft.com/mgl-license.txt
*
*    Software distributed under the License is distributed on an
*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
*    implied. See the License for the specific language governing
*    rights and limitations under the License.
*
*    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
*
*    The Initial Developer of the Original Code is SciTech Software, Inc.
*    All Rights Reserved.
*
*  ========================================================================
*
* Language:     ANSI C
* Environment:  any
*
* Description:  General header file for operating system portable code.
*
****************************************************************************/

#ifndef __SCITECH_H
#define __SCITECH_H

/* We have the following defines to identify the compilation environment:
 *
 *  __16BIT__       Compiling for 16 bit code (any environment)
 *  __32BIT__       Compiling for 32 bit code (any environment)
 *  __MSDOS__       Compiling for MS-DOS (includes __WINDOWS16__, __WIN386__)
 *  __REALDOS__     Compiling for MS-DOS (excludes __WINDOWS16__)
 *  __MSDOS16__     Compiling for 16 bit MS-DOS
 *  __MSDOS32__     Compiling for 32 bit MS-DOS
 *  __WINDOWS__     Compiling for Windows
 *  __WINDOWS16__   Compiling for 16 bit Windows (__MSDOS__ also defined)
 *  __WINDOWS32__   Compiling for 32 bit Windows
 *  __WIN32_VXD__   Compiling for a 32-bit C based VxD
 *  __NT_DRIVER__   Compiling for a 32-bit C based NT device driver
 *  __OS2__         Compiling for OS/2
 *  __OS2_16__      Compiling for 16 bit OS/2
 *  __OS2_32__      Compiling for 32 bit OS/2
 *  __UNIX__        Compiling for Unix
 *  __QNX__         Compiling for the QNX realtime OS (Unix compatible)
 *  __LINUX__       Compiling for the Linux OS (Unix compatible)
 *  __FREEBSD__     Compiling for the FreeBSD OS (Unix compatible)
 *  __BEOS__        Compiling for the BeOS (Unix compatible)
 *  __SMX32__       Compiling for the SMX 32-bit Real Time OS
 *  __ENEA_OSE__    Compiling for the OSE embedded OS
 *  __RTTARGET__    Compiling for the RTTarget 32-bit embedded OS
 *  __MACOS__       Compiling for the MacOS platform (PowerPC)
 *  __DRIVER__      Compiling for a 32-bit binary compatible driver
 *  __CONSOLE__     Compiling for a fullscreen OS console mode
 *  __SNAP__        Compiling as a Snap executeable or dynamic library
 *
 *  __INTEL__       Compiling for Intel CPU's
 *  __ALPHA__       Compiling for DEC Alpha CPU's
 *  __MIPS__        Compiling for MIPS CPU's
 *  __PPC__         Compiling for PowerPC CPU's
 *  __MC68K__       Compiling for Motorola 680x0
 *
 *  __BIG_ENDIAN__  Compiling for a big endian processor
 *
 */

#ifdef  __SC__
#if     __INTSIZE == 4
#define __SC386__
#endif
#endif

/* Determine some things that are compiler specific */

#ifdef  __GNUC__
#ifdef  __cplusplus
// G++ currently fucks this up!
#define __cdecl
#define __stdcall
#else
#undef  __cdecl
#undef  __stdcall
#define __cdecl     __attribute__ ((cdecl))
#define __stdcall   __attribute__ ((stdcall))
#endif
#define __FLAT__            /* GCC is always 32 bit flat model          */
#define __HAS_BOOL__        /* Latest GNU C++ has ibool type            */
#define __HAS_LONG_LONG__   /* GNU C supports long long type            */
#include <stdio.h>          /* Bring in for definition of NULL          */
#endif

#ifdef  __BORLANDC__
#if (__BORLANDC__ >= 0x500) || defined(CLASSLIB_DEFS_H)
#define __HAS_BOOL__        /* Borland C++ 5.0 defines ibool type       */
#endif
#if (__BORLANDC__ >= 0x502) && !defined(VTOOLSD) && !defined(__SMX32__)
#define __HAS_INT64__       /* Borland C++ 5.02 supports __int64 type   */
#endif
#endif

#if defined(_MSC_VER) && !defined(__SC__) && !defined(VTOOLSD) && !defined(__SMX32__)
#define __HAS_INT64__       /* Visual C++ supports __int64 type         */
#endif

#if defined(__WATCOMC__) && (__WATCOMC__ >= 1100) && !defined(VTOOLSD) && !defined(__SMX32__)
#define __HAS_INT64__       /* Watcom C++ 11.0 supports __int64 type    */
#endif

/*---------------------------------------------------------------------------
 * Determine the compile time environment. This must be done for each
 * supported platform so that we can determine at compile time the target
 * environment, hopefully without requiring #define's from the user.
 *-------------------------------------------------------------------------*/

/* 32-bit binary compatible driver. Compiled as Win32, but as OS neutral */
#ifdef  __DRIVER__
#ifndef __32BIT__
#define __32BIT__
#endif
#undef  __WINDOWS__
#undef  _WIN32
#undef  __WIN32__
#undef  __NT__

/* 32-bit Snap exe or dll. Compiled as Win32, but as OS neutral */
#elif   defined(__SNAP__)
#ifndef __32BIT__
#define __32BIT__
#endif
#undef  __WINDOWS__
#undef  _WIN32
#undef  __WIN32__
#undef  __NT__

/* 32-bit Windows VxD compile environment */
#elif   defined(__vtoolsd_h_) || defined(VTOOLSD)
#include <vtoolsc.h>
#define __WIN32_VXD__
#ifndef __32BIT__
#define __32BIT__
#endif
#define _MAX_PATH   256
#undef __WINDOWS32__

/* 32-bit Windows NT driver compile environment: TODO!! */
#elif   defined(__NT_DRIVER__)
#include "ntdriver.h"
#ifndef __32BIT__
#define __32BIT__
#endif
#define _MAX_PATH   256
#undef __WINDOWS32__

/* 32-bit SMX compile environment */
#elif   defined(__SMX32__)
#ifndef __MSDOS__
#define __MSDOS__
#endif
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __CONSOLE__
#define __CONSOLE__
#endif

/* 32-bit Enea OSE environment */
#elif   defined(__ENEA_OSE__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __CONSOLE__
#define __CONSOLE__
#endif

/* 32-bit RTTarget-32 environment */
#elif   defined(__RTTARGET__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __CONSOLE__
#define __CONSOLE__
#endif

/* 32-bit extended DOS compile environment */
#elif   defined(__MSDOS__) || defined(__MSDOS32__) || defined(__DOS__) || defined(__DPMI32__) || (defined(M_I86) && (!defined(__SC386__) && !defined(M_I386))) || defined(TNT)
#ifndef __MSDOS__
#define __MSDOS__
#endif
#if     defined(__MSDOS32__) || defined(__386__) || defined(__FLAT__) || defined(__NT__) || defined(__SC386__)
#ifndef __MSDOS32__
#define __MSDOS32__
#endif
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __REALDOS__
#define __REALDOS__
#endif
#ifndef __CONSOLE__
#define __CONSOLE__
#endif

/* 16-bit Windows compile environment */
#elif   (defined(_Windows) || defined(_WINDOWS)) && !defined(__DPMI16__)
#ifndef __16BIT__
#define __16BIT__
#endif
#ifndef __WINDOWS16__
#define __WINDOWS16__
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#ifndef __MSDOS__
#define __MSDOS__
#endif

/* 16-bit DOS compile environment */
#else
#ifndef __16BIT__
#define __16BIT__
#endif
#ifndef __MSDOS16__
#define __MSDOS16__
#endif
#ifndef __REALDOS__
#define __REALDOS__
#endif
#ifndef __CONSOLE__
#define __CONSOLE__
#endif
#endif

/* 32-bit Windows compile environment */
#elif   defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __WINDOWS32__
#define __WINDOWS32__
#endif
#ifndef _WIN32
#define _WIN32                  /* Microsoft Win32 SDK headers use _WIN32 */
#endif
#ifndef WIN32
#define WIN32                   /* OpenGL headers use WIN32 */
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif

/* 32-bit OS/2 VDD compile environment */
/* We're assuming (for now) that CL386 must be used */
#elif   defined(MSDOS) && defined(M_I386)
/* fixes necessary to compile with CL386 */
#define __cdecl  _cdecl
typedef unsigned int size_t;

#include <mvdm.h>

/* This should probably be somewhere else...                 */
/* Inline eligible functions (we have no CRT libs for CL386) */
#pragma intrinsic (strcpy, strcmp, strlen, strcat)
#pragma intrinsic (memcmp, memcpy, memset)

#define __OS2_VDD__
#ifndef __32BIT__
#define __32BIT__
#endif
#define CCHMAXPATH  256
#define _MAX_PATH   256
#ifndef __OS2__
#define __OS2__
#endif
#ifndef __OS2_32__
#define __OS2_32__
#endif

/* 16-bit OS/2 compile environment */
#elif   defined(__OS2_16__)
#ifndef __OS2__
#define __OS2__
#endif
#ifndef __16BIT__
#define __16BIT__
#endif
#ifndef __OS2_PM__
#ifndef __CONSOLE__
#define __CONSOLE__
#endif
#endif

/* 32-bit OS/2 compile environment */
#elif   defined(__OS2__) || defined(__OS2_32__)
#ifndef __OS2__
#define __OS2__
#endif
#ifndef __OS2_32__
#define __OS2_32__
#endif
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __OS2_PM__
#ifndef __CONSOLE__
#define __CONSOLE__
#endif
#endif

/* 32-bit QNX compile environment */
#elif   defined(__QNX__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __UNIX__
#define __UNIX__
#endif
#ifdef  __GNUC__
#define stricmp strcasecmp
#endif
#if !defined(__PHOTON__) && !defined(__X11__)
#ifndef __CONSOLE__
#define __CONSOLE__
#endif
#endif

/* 32-bit Linux compile environment */
#elif   defined(__LINUX__) || defined(linux)
#ifndef __LINUX__
#define __LINUX__
#endif
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __UNIX__
#define __UNIX__
#endif
#ifdef  __GNUC__
#define stricmp strcasecmp
#endif
#ifndef __X11__
#ifndef __CONSOLE__
#define __CONSOLE__
#endif
#endif

/* 32-bit FreeBSD compile environment */
#elif   defined(__FREEBSD__)
#ifndef __FREEBSD__
#define __FREEBSD__
#endif
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __UNIX__
#define __UNIX__
#endif
#ifdef  __GNUC__
#define stricmp strcasecmp
#endif
#ifndef __X11__
#ifndef __CONSOLE__
#define __CONSOLE__
#endif
#endif

/* 32-bit BeOS compile environment */
#elif   defined(__BEOS__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __UNIX__
#define __UNIX__
#endif
#ifdef  __GNUC__
#define stricmp strcasecmp
#endif

/* Unsupported OS! */
#else
#error  This platform is not currently supported!
#endif

/* Determine the CPU type that we are compiling for */

#if     defined(__M_ALPHA) || defined(__ALPHA_) || defined(__ALPHA) || defined(__alpha)
#ifndef __ALPHA__
#define __ALPHA__
#endif
#elif   defined(__M_PPC) || defined(__POWERC)
#ifndef __PPC__
#define __PPC__
#endif
#elif   defined(__M_MRX000)
#ifndef __MIPS__
#define __MIPS__
#endif
#else
#ifndef __INTEL__
#define __INTEL__               /* Assume Intel if nothing found */
#endif
#endif

/* We have the following defines to define the calling conventions for
 * publicly accesible functions:
 *
 *  _PUBAPI  - Compiler default calling conventions for all public 'C' functions
 *  _ASMAPI  - Calling conventions for all public assembler functions
 *  _VARAPI  - Modifiers for variables; Watcom C++ mangles C++ globals
 *  _STDCALL - Win32 __stdcall where possible, __cdecl if not supported
 */

#if defined(_MSC_VER) && defined(_WIN32) && !defined(__SC__)
#define __PASCAL    __stdcall
#else
#define __PASCAL    __pascal
#endif

#if defined(NO_STDCALL)
#define _STDCALL    __cdecl
#else
#define _STDCALL    __stdcall
#endif

#ifdef  __WATCOMC__
#if (__WATCOMC__ >= 1050)
#define _VARAPI     __cdecl
#else
#define _VARAPI
#endif
#else
#define _VARAPI
#endif

#if defined(__IBMC__) || defined(__IBMCPP__)
#define PTR_DECL_IN_FRONT
#endif

/* Define the calling conventions for all public functions. For simplicity
 * we define all public functions as __cdecl calling conventions, so that
 * they are the same across all compilers and runtime DLL's.
 */

#define _PUBAPI __cdecl
#define _ASMAPI __cdecl

/* Determine the syntax for declaring a function pointer with a
 * calling conventions override. Most compilers require the calling
 * convention to be declared in front of the '*', but others require
 * it to be declared after the '*'. We handle both in here depending
 * on what the compiler requires.
 */

#ifdef  PTR_DECL_IN_FRONT
#define _PUBAPIP    * _PUBAPI
#define _ASMAPIP    * _ASMAPI
#else
#define _PUBAPIP    _PUBAPI *
#define _ASMAPIP    _ASMAPI *
#endif

/* Useful macros */

#define PRIVATE static
#define PUBLIC

/* This HAS to be 0L for 16-bit real mode code to work!!! */

#ifndef NULL
#       define _NULL 0L
#       define NULL _NULL
#endif

#ifndef MAX
#       define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#       define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
#endif
#ifndef ABS
#       define ABS(a)   ((a) >= 0 ? (a) : -(a))
#endif
#ifndef SIGN
#       define SIGN(a)  ((a) > 0 ? 1 : -1)
#endif

/* General typedefs */

#ifndef __GENDEFS
#define __GENDEFS
#if defined(__BEOS__)
#include <SupportDefs.h>
#else
#ifdef __LINUX__
#include <sys/types.h>
#ifdef __STRICT_ANSI__
typedef unsigned short      ushort;
typedef unsigned long       ulong;
typedef unsigned int        uint;
#endif
#ifdef  __KERNEL__
#define __GENDEFS_2
#endif
#else
#if !(defined(__QNXNTO__) && defined(GENERAL_STRUCT))
typedef unsigned short      ushort;
typedef unsigned long       ulong;
#endif
typedef unsigned int        uint;
#endif
typedef unsigned char       uchar;
#endif
typedef int                 ibool;      /* Integer boolean type         */
#ifdef  USE_BOOL                        /* Only for older code          */
#ifndef __cplusplus
#define bool                ibool       /* Standard C                   */
#else
#ifndef __HAS_BOOL__
#define bool                ibool       /* Older C++ compilers          */
#endif
#endif  /* __cplusplus */
#endif  /* USE_BOOL */
#endif  /* __GENDEFS */

/* More general typedefs compatible with Linux kernel code */

#ifndef __GENDEFS_2
#define __GENDEFS_2
typedef char                s8;
typedef unsigned char       u8;
typedef short               s16;
typedef unsigned short      u16;
#ifdef  __16BIT__
typedef long                s32;
typedef unsigned long       u32;
#else
typedef int                 s32;
typedef unsigned int        u32;
#endif
typedef struct {
    u32 low;
    s32 high;
    } __i64;
#ifdef  __HAS_LONG_LONG__
#define __NATIVE_INT64__
typedef long long           s64;
typedef unsigned long long  u64;
#elif   defined(__HAS_INT64__) && !defined(__16BIT__)
#define __NATIVE_INT64__
typedef __int64             s64;
typedef unsigned __int64    u64;
#else
typedef __i64               s64;
typedef __i64               u64;
#endif
#endif

/* Boolean truth values */

#undef  false
#undef  true
#undef  NO
#undef  YES
#undef  FALSE
#undef  TRUE
#define false       0
#define true        1
#define NO          0
#define YES         1
#define FALSE       0
#define TRUE        1

/* Inline debugger interrupts for Watcom C++ and Borland C++ */

#ifdef  __WATCOMC__
void DebugInt(void);
#pragma aux DebugInt =              \
    "int    3";
void DebugVxD(void);
#pragma aux DebugVxD =              \
    "int    1";
#elif   defined(__BORLANDC__)
#define DebugInt()  __emit__(0xCC)
#define DebugVxD()  {__emit__(0xCD); __emit__(0x01);}
#elif   defined(_MSC_VER)
#define DebugInt()  _asm int 0x3
#define DebugVxD()  _asm int 0x1
#elif   defined(__GNUC__)
#define DebugInt()  asm volatile ("int $0x3")
#define DebugVxD()  asm volatile ("int $0x1")
#else
void _ASMAPI DebugInt(void);
void _ASMAPI DebugVxD(void);
#endif

/* Macros to break once and never break again */

#define DebugIntOnce()              \
{                                   \
    static ibool firstTime = true;  \
    if (firstTime) {                \
        firstTime = false;          \
        DebugInt();                 \
        }                           \
}

#define DebugVxDOnce()              \
{                                   \
    static ibool firstTime = true;  \
    if (firstTime) {                \
        firstTime = false;          \
        DebugVxD();                 \
        }                           \
}

/* Macros for linux string compatibility functions */

#ifdef  __LINUX__
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif

/* Macros for NT driver string compatibility functions */

#ifdef __NT_DRIVER__
#define stricmp _stricmp
#define strnicmp _strnicmp
#endif

/* Get rid of some helaciously annoying Visual C++ warnings! */

#if defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__SC__)
#pragma warning(disable:4761)   // integral size mismatch in argument; conversion supplied
#pragma warning(disable:4244)   // conversion from 'unsigned short ' to 'unsigned char ', possible loss of data
#pragma warning(disable:4018)   // '<' : signed/unsigned mismatch
#pragma warning(disable:4305)   // 'initializing' : truncation from 'const double' to 'float'
#endif

/*---------------------------------------------------------------------------
 * Set of debugging macros used by the libraries. If the debug flag is
 * set, they are turned on depending on the setting of the flag. User code
 * can override the default functions called when a check fails, and the
 * MGL does this so it can restore the system from graphics mode to display
 * an error message. These functions also log information to the
 * scitech.log file in the root directory of the hard drive when problems
 * show up.
 *
 * If you set the value of CHECKED to be 2, it will also enable code to
 * insert hard coded debugger interrupt into the source code at the line of
 * code where the check fail. This is useful if you run the code under a
 * debugger as it will break inside the debugger before exiting with a
 * failure condition.
 *
 * Also for code compiled to run under Windows, we also call the
 * OutputDebugString function to send the message to the system debugger
 * such as Soft-ICE or WDEB386. Hence if you get any non-fatal warnings you
 * will see those on the debugger terminal as well as in the log file.
 *-------------------------------------------------------------------------*/

#ifdef  __cplusplus
extern "C" {            /* Use "C" linkage when in C++ mode */
#endif

extern void (*_CHK_fail)(int fatal,const char *msg,const char *cond,const char *file,int line);
void _CHK_defaultFail(int fatal,const char *msg,const char *cond,const char *file,int line);

#ifdef  CHECKED
#       define  CHK(x)      x
#if     CHECKED > 1
#       define  CHECK(p)                                            \
        ((p) ? (void)0 : DebugInt(),                                \
            _CHK_fail(1,"Check failed: '%s', file %s, line %d\n",   \
            #p, __FILE__, __LINE__))
#       define  WARN(p)                                             \
        ((p) ? (void)0 : DebugInt(),                                \
            _CHK_fail(0,"Warning: '%s', file %s, line %d\n",        \
            #p, __FILE__, __LINE__))
#else
#       define  CHECK(p)                                            \
        ((p) ? (void)0 :                                            \
            _CHK_fail(1,"Check failed: '%s', file %s, line %d\n",   \
            #p, __FILE__, __LINE__))
#       define  WARN(p)                                             \
        ((p) ? (void)0 :                                            \
            _CHK_fail(0,"Warning: '%s', file %s, line %d\n",        \
            #p, __FILE__, __LINE__))
#endif
#       define  LOGFATAL(msg)                                       \
            _CHK_fail(1,"Fatal error: '%s', file %s, line %d\n",    \
            msg, __FILE__, __LINE__)
#       define  LOGWARN(msg)                                        \
            _CHK_fail(0,"Warning: '%s', file %s, line %d\n",        \
            msg, __FILE__, __LINE__)
#else
#       define  CHK(x)
#       define  CHECK(p)        ((void)0)
#       define  WARN(p)         ((void)0)
#       define  LOGFATAL(msg)   ((void)0)
#       define  LOGWARN(msg)    ((void)0)
#endif

#ifdef  __cplusplus
}                       /* End of "C" linkage for C++   */
#endif

#endif  /* __SCITECH_H */
OpenPOWER on IntegriCloud