File: scstd.h

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (907 lines) | stat: -rw-r--r-- 24,926 bytes parent folder | download
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
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
/*
 * SCSTD.H - standard header for PACT codes
 *         - designed with portability, uniformity, and consistency
 *         - in mind
 *
 * Source Version: 2.0
 * Software Release #92-0043
 *
 */

#ifndef PCK_STD

#define PCK_STD

#include "cpyright.h"

/*--------------------------------------------------------------------------*/

/*                        STANDARD CONFIGURATIONS                           */

/*--------------------------------------------------------------------------*/

/* Intel Paragon predefines __PARAGON__ */
#ifdef __PARAGON__
# define PARAGON
#endif

/* SGI predefines __sgi */
#ifdef __sgi
# define SGI
#endif

/* CRI predefines _UNICOS */
#ifdef _UNICOS
# define UNICOS
#endif

/* SUN predefines sun */
#ifdef sun
# ifndef SOLARIS
#  define SUN
# endif
#endif

/* Borland predefines __BORLANDC__ */
#ifdef __BORLANDC__
# define TURBOC
#endif

/* MPW C predefines applec */
#ifdef applec
# define MPW
#endif

/* Think C compiler defines THINK_C; CodeWarrior defines __MWERKS__ */
#ifdef __MWERKS__
# include "scconfig.mac"
#endif

#ifdef THINK_C
# include "scconfig.mac"
#endif

#ifdef MPW
# include "scconfig.mpw"
#endif

#ifndef MAC
# include <scconfig.h>
#endif

#ifndef BINARY_MODE_R
# define BINARY_MODE_R         "rb"
#endif

#ifndef BINARY_MODE_W
# define BINARY_MODE_W         "wb"
#endif

#ifndef BINARY_MODE_A
# define BINARY_MODE_A         "ab"
#endif

#ifndef BINARY_MODE_RPLUS
# define BINARY_MODE_RPLUS     "r+b"
#endif

#ifndef BINARY_MODE_WPLUS
# define BINARY_MODE_WPLUS     "w+b"
#endif

#ifndef BINARY_MODE_APLUS
# define BINARY_MODE_APLUS     "a+b"
#endif

#ifdef __GNUC__
# define DEBUG_FUNC
#else
# define DEBUG_FUNC static
#endif

#ifdef NO_CONST
# define const
#endif

/*--------------------------------------------------------------------------*/

/*                          STANDARD INCLUDES                               */

/*--------------------------------------------------------------------------*/

#if ((defined PTHREAD_POSIX) || (defined PTHREAD_DRAFT4))
# include <pthread.h>
# define HAVE_THREADS
#endif

#include <stdio.h>
#include <string.h>

#ifdef UNIX
# include <unistd.h>
# include <sys/stat.h>
#endif

/* CodeWarrior plays silly games with math header files... */
#ifdef __MWERKS__
# include <fp.h>
# include <fenv.h>
#else
# include <math.h>
#endif

#include <ctype.h>
#include <signal.h>
#include <setjmp.h>
#include <time.h>

#ifdef ANSI
# include <stdlib.h>
# include <stddef.h>
# include <stdarg.h>
# include <limits.h>
# include <errno.h>
# include <float.h>
#endif

#ifdef PCC
# ifndef BBN
#  include <malloc.h>
# else
#  include <errno.h>
# endif
# include <sys/types.h>
# include <varargs.h>
#endif

#ifdef MSC
# include <conio.h>
# include <malloc.h>
# include <sys\stat.h>
#endif

#ifdef TURBOC
# include <conio.h>
# include <alloc.h>
# include <sys\stat.h>
#endif

#ifdef MAC
# include <unix.h>
# include <console.h>
#endif

#ifdef MM_CONFIG

#define N_DOUBLES_MD  3

#else

#ifndef MAC
# include <scdecls.h>
#endif

#endif

/*--------------------------------------------------------------------------*/

/*                           STANDARD PRAGMAS                               */

/*--------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------*/

/*                      STANDARD CONSTANT MACROS                            */

/*--------------------------------------------------------------------------*/

#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
 
#ifndef ON
# undef OFF
# define ON  1
# define OFF 0
#endif

#define SMALL   1.0e-100
#undef HUGE
#define HUGE    1.0e100

#ifdef LONG_MAX
# define HUGE_INT LONG_MAX
#else
# define HUGE_INT ((1 << (sizeof(long)-1)) - 1)
#endif

#define SC_BITS_BYTE      8

#define SC_CHAR_I        1
#define SC_SHORT_I       2
#define SC_INTEGER_I     3
#define SC_LONG_I        4
#define SC_FLOAT_I       5
#define SC_DOUBLE_I      6
#define SC_REAL_I        7
#define SC_STRING_I      8
#define SC_POINTER_I     9
#define SC_PCONS_P_I     10
#define SC_VOID_I        11
#define SC_SHORT_P_I     12
#define SC_INTEGER_P_I   13
#define SC_LONG_P_I      14
#define SC_FLOAT_P_I     15
#define SC_REAL_P_I      16
#define SC_DOUBLE_P_I    17
#define SC_PCONS_I       18
#define SC_STRUCT_I      19   /* is this pointer type? */
#define SC_UNKNOWN_I     20
#define SC_CHAR_8_I      21   /* for F77 users and interfacers */
#define SC_USER_I        22   /* first user defined index available */

#ifndef SEEK_SET
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif

#undef MAXLINE
#define MAXLINE 255

#define LRG_TXT_BUFFER 4096

#define ABS fabs

#ifndef POW
# define POW pow
#endif

/* get the ticks per second for clock straight */

#ifndef TICKS_SECOND
# ifdef CLOCKS_PER_SEC
#  define TICKS_SECOND CLOCKS_PER_SEC
# else
#  ifdef CLK_TCK
#   define TICKS_SECOND CLK_TCK
#  else
#   define TICKS_SECOND 1000000
#  endif
# endif
#endif


/* UNIX Constants */

#ifdef UNIX
# define directory_delim "/"
# define directory_delim_c '/'
#endif

/* DOS Constants */

#ifdef DOS
# define directory_delim "\\"
# define directory_delim_c '\\'
#endif

/* MAC Constants */

#ifdef MAC
# define directory_delim ":"
# define directory_delim_c ':'
#endif

#ifndef FIXNUM
# define FIXNUM long
#endif

#ifdef __cplusplus
# define FUNCTION_POINTER(t, n) typedef t n(...)
#else
# define FUNCTION_POINTER(t, n) typedef t n()
#endif

/*--------------------------------------------------------------------------*/

/*                           STANDARD TYPEDEFS                              */

/*--------------------------------------------------------------------------*/

FUNCTION_POINTER(void, (*PFVoid));

FUNCTION_POINTER(char, (*PFChar));
FUNCTION_POINTER(int, (*PFInt));
FUNCTION_POINTER(long, (*PFLong));
FUNCTION_POINTER(float, (*PFFloat));
FUNCTION_POINTER(double, (*PFDouble));
FUNCTION_POINTER(byte, (*PFByte));

FUNCTION_POINTER(char, *(*PFPChar));
FUNCTION_POINTER(int, *(*PFPInt));
FUNCTION_POINTER(long, *(*PFPLong));
FUNCTION_POINTER(float, *(*PFPFloat));
FUNCTION_POINTER(double, *(*PFPDouble));
FUNCTION_POINTER(byte, *(*PFPByte));
FUNCTION_POINTER(void, *(*PFPVoid));

FUNCTION_POINTER(char, **(*PFPPChar));

#ifdef SGI
# ifdef __cplusplus
   typedef void (*PFSignal_handler)(...);
#  define SIGNAL_HANDLER_DEFINED
# endif
#endif

#ifdef ANSI
# ifndef SIGNAL_HANDLER_DEFINED
   typedef void (*PFSignal_handler)(int sig);
#  define SIGNAL_HANDLER_DEFINED
# endif
#endif

#ifndef SIGNAL_HANDLER_DEFINED
# ifdef __cplusplus
  typedef void (*PFSignal_handler)(int sig);
# else
  typedef void (*PFSignal_handler)();
# endif
#endif

#undef SIGNAL_HANDLER_DEFINED

#ifndef MAC
# ifndef DOS
typedef char *CONST * CONST_STRINGS;
# else
typedef char ** CONST_STRINGS;
# endif
#endif

/*--------------------------------------------------------------------------*/

/*                       STANDARD PROCEDURAL MACROS                         */

/*--------------------------------------------------------------------------*/

/* DECLARE - space and error saving function declaration alternative */

#ifdef ANSI

#define DECLARE(n, a) n a
#define SC_DECLARE(n, a) n a
#define DECLFPTR(t, n, a) t (*n) a

#else

#define DECLARE(n, a) n()
#define SC_DECLARE(n, a) n()
#define DECLFPTR(t, n, a) t (*n)()

#endif

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* DEREF - dereference a pointer */

#define DEREF(x) (*(char **) (x))

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* MAKE - memory allocation and bookkeeping macro */

#define MAKE(x)                                                              \
    (SC_mem_stats_acc((long) sizeof(x), 0L), (x *) calloc(1, sizeof(x)))

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* MAKE_N - allocate a block of type x and return a pointer to it */

#define MAKE_N(x, n)                                                         \
    (SC_mem_stats_acc((long) n*sizeof(x), 0L), (x *) calloc(n, sizeof(x)))

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* REMAKE - memory reallocation and bookkeeping macro 
 *        - no book keeping here since we don't have sufficient info
 */

#define REMAKE(p, x) ((x *) realloc(p, (long) sizeof(x)))

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* REMAKE_N - reallocate a block of type x and return a pointer to it
 *          - no book keeping here since we don't have sufficient info
 */

#define REMAKE_N(p, x, n) ((x *) realloc(p, n*sizeof(x)))

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* SFREE - release memory and do bookkeeping */

#define SFREE(x)                                                             \
   {SC_mem_stats_acc(0L, (long) sizeof(*x));                                 \
    free(x);                                                                 \
    x = NULL;}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* SFREE_N - release memory and do bookkeeping on arrays */

#define SFREE_N(x, n)                                                        \
   {SC_mem_stats_acc(0L, (long) n*sizeof(*x));                               \
    free(x);                                                                 \
    x = NULL;}

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* MAX - the oft wanted maximum */

#ifndef max
# define max(a, b) ((a > b) ? a : b)
#endif

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* MIN - companion to max */

#ifndef min
# define min(a, b) ((a < b) ? a : b)
#endif

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* FOREIGN - attempt a uniform declaration for mixed languages
 *         - example of declaration
 *         -
 *         - FOREIGN(fortran)
 *         -  foo();
 */

#ifdef CRAY
# define FOREIGN(x)  x
#else
# define FOREIGN(x)  extern
#endif

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* F77_ID - attempt a uniform naming of FORTRAN 77 functions which 
 *        - gets around loader naming conventions
 *        -
 *        - F77_ID(foo_, foo, FOO)(x, y, z)
 */

#ifdef ANSI_F77
# define F77_ID(x_, x, X)  X
#endif

#ifndef __GNUC__

# ifdef AIX
#  define F77_ID(x_, x, X)  x
# endif

# ifdef HPUX
#  define F77_ID(x_, x, X)  x
# endif

#endif

#ifndef F77_ID
# define F77_ID(x_, x, X)  x_
#endif

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

/* F77_STRING - get around the problem of C and F77 vendors who can't
 *            - agree on what a string is
 *            - NOTE: Scot Futral contributed info and code here
 */

#ifdef UNICOS

# ifndef __cplusplus
#  include <fortran.h>

typedef _fcd F77_string;

#  define SC_F77_C_STRING(f) _fcdtocp(f)
#  define SC_C_F77_STRING(c) _cptofcd(c, (c ? strlen(c) : 0))

# else

typedef char *F77_string;

#  define SC_F77_C_STRING(f) ((char *) f)
#  define SC_C_F77_STRING(c) ((char *) c)

# endif

#else

typedef char *F77_string;

#define SC_F77_C_STRING(f) ((char *) f)
#define SC_C_F77_STRING(c) ((char *) c)

#endif

#define SC_FORTRAN_STR_C(c_string, f_string, n_chars)                        \
   {strncpy(c_string, SC_F77_C_STRING(f_string), n_chars);                   \
    c_string[n_chars] = '\0';}

#if ((defined PTHREAD_POSIX) || (defined PTHREAD_DRAFT4))

# define SC_thread                      pthread_t
# define SC_thread_key                  pthread_key_t
# define SC_THREAD_SELF()               pthread_self()
# ifdef AIX
#  define SC_CREATE_ATTACHED            PTHREAD_CREATE_UNDETACHED
# else
#  define SC_CREATE_ATTACHED            PTHREAD_CREATE_JOINABLE
# endif
# define SC_CREATE_DETACHED             PTHREAD_CREATE_DETACHED
# define SC_THREAD_JOIN(thread, status) pthread_join(thread, status)
# define SC_LOCKOFF(lock)               pthread_mutex_unlock(&lock)
# define SC_COND_WAIT(condv, lock)      pthread_cond_wait(&condv, &lock)

#  define SC_DECLARE_THREAD_CONDV(condv) extern pthread_cond_t condv
#  define SC_THREAD_CONDV(condv)                                             \
     pthread_cond_t condv = PTHREAD_COND_INITIALIZER
#  define SC_THREAD_SIGNAL(condv)        pthread_cond_signal(&condv)
#  define SC_THREAD_BROADCAST(condv)     pthread_cond_broadcast(&condv)

# define SC_localtime(t, tm)             (localtime_r(&t, &tm), &tm)
# define SC_strtok(s, d, n)                                                  \
    (n = (s != NULL) ? NULL : n, strtok_r(s, d, &n))
# define SC_ttyname(fd, buf, len)        (ttyname_r(fd, buf, len), buf)

# if (defined PTHREAD_POSIX)

typedef void *(*pthread_startroutine_t)(void *x);

#  define SC_DECLARE_THREAD_ATTR(attr)                                       \
     extern pthread_attr_t attr;                                             \
     extern void SC_DECLARE(attr##_init, (byte));                            \
     extern pthread_once_t attr##_once_block

#  define SC_THREAD_ATTR(attr)                                               \
     pthread_attr_t attr;                                                    \
     void attr##_init(byte)                                                  \
        {pthread_attr_init(&attr);                                           \
         pthread_attr_setdetachstate(&attr, SC_CREATE_DETACHED);             \
         return;}                                                            \
     pthread_once_t attr##_once_block = PTHREAD_ONCE_INIT

#  define SC_THREAD_CREATE(thread, attr, func, arg)                          \
     (pthread_once(&attr##_once_block, attr##_init),                         \
      pthread_create(&thread, &attr,                                         \
                     (pthread_startroutine_t) func, (void *) &arg))

#  define SC_DECLARE_THREAD_LOCK(lock)   extern pthread_mutex_t lock
#  define SC_THREAD_LOCK(lock)                                               \
     pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER

#  define SC_LOCKON(lock)                pthread_mutex_lock(&lock)
#  define SC_CREATE_KEY(key, dest)       pthread_key_create(&key, dest)
#  define SC_SET_KEY(type, key, addr)    pthread_setspecific(key, addr)
#  define SC_GET_KEY(type, key, value)                                       \
     (value = *((type *) pthread_getspecific(key)))

#  define SC_ctime(t, buf, len)          (ctime_r(&t, buf), buf)
#  define SC_rand(seed, value)                                               \
      (rand_r((unsigned int *) &(seed), &value), value)

# else

#  define SC_DECLARE_THREAD_ATTR(attr)   extern pthread_attr_t *attr
#  define SC_THREAD_ATTR(attr)                                               \
     pthread_attr_t *attr = &pthread_attr_default

#  define SC_THREAD_CREATE(thread, attr, func, arg)                          \
     pthread_create(&thread, *attr,                                          \
                    (pthread_startroutine_t) func, (void *) &arg)

#  define SC_DECLARE_THREAD_LOCK(lock)                                       \
     extern pthread_mutex_t lock;                                            \
     extern void *SC_DECLARE(lock##_init, (byte));                           \
     extern pthread_once_t lock##_once_block

#  define SC_THREAD_LOCK(lock)                                               \
     pthread_mutex_t lock;                                                   \
     void *lock##_init(byte)                                                 \
        {pthread_mutex_init(&lock, pthread_mutexattr_default);               \
         return;}                                                            \
     pthread_once_t lock##_once_block = pthread_once_init

#  define SC_LOCKON(lock)                                                    \
     (pthread_once(&lock##_once_block, (pthread_initroutine_t) lock##_init), \
      pthread_mutex_lock(&lock))

#  define SC_CREATE_KEY(key, dest)       pthread_keycreate(&key, dest)
#  define SC_SET_KEY(type, key, addr)                                        \
     pthread_setspecific(key, (pthread_addr_t) addr)

#  define SC_GET_KEY(type, key, value)                                       \
     {pthread_addr_t pv = &value;                                            \
      pthread_getspecific(key, &pv);                                         \
      value = *((type *) pv);}

#  define SC_ctime(tm, buf, len)         (ctime_r(&tm, buf, len), buf)
#  define SC_rand(seed, value)                                               \
      (value = rand_r((unsigned int *) &(seed)))

# endif

#else

# define SC_thread                       int
# define SC_DECLARE_THREAD_ATTR(attr)    extern int attr
# define SC_THREAD_ATTR(attr)            int attr
# define SC_THREAD_SELF()                0
# define SC_THREAD_CREATE(thread, attr, func, arg)                           \
    (thread = 1,                                                             \
     (*func)(&arg))
# define SC_THREAD_JOIN(thread, status)  (thread = 0)
# define SC_DECLARE_THREAD_LOCK(lock)    extern int lock
# define SC_THREAD_LOCK(lock)            int lock
# define SC_LOCKON(lock)
# define SC_LOCKOFF(lock)

# define SC_COND_WAIT(condv, lock)
# define SC_DECLARE_THREAD_CONDV(condv)  extern int condv
# define SC_THREAD_CONDV(condv)          int condv
# define SC_THREAD_SIGNAL(condv)
# define SC_THREAD_BROADCAST(condv)

# define SC_thread_key                   int
# define SC_CREATE_KEY(key, dest)
# define SC_SET_KEY(type, key, addr)     (key = *((int *) (addr)))
# define SC_GET_KEY(int, key, value)     (value = key)

# define SC_ctime(tm, buf, len)          strcpy(buf, ctime(&tm))
# define SC_localtime(t, tm)             (tm = *localtime(&t), &tm)
# define SC_rand(seed, value)            (value = rand())
# define SC_strtok(s, d, n)              (n = strtok(s, d))
# define SC_ttyname(fd, buf, len)        strcpy(buf, ttyname(fd))

#endif

/*--------------------------------------------------------------------------*/

/*                SCORE VARIABLE ARGUMENT LIST MACROS                       */

/*--------------------------------------------------------------------------*/

#ifdef ANSI

#define SC_VA_START(x)                                                       \
   {va_list __a__;                                                           \
    va_start(__a__, x)

#endif

#ifdef PCC

#define SC_VA_START(x)                                                       \
   {va_list __a__;                                                           \
    va_start(__a__)

#endif

#define SC_VA_ARG(x)      va_arg(__a__, x)

#define SC_VSPRINTF(s, f) vsprintf(s, f, __a__)

#define SC_VFPRINTF(s, f) vfprintf(s, f, __a__)

#define SC_VA_END                                                            \
    va_end(__a__);}

/* thanks to Lee Taylor */

#define SC_VA_VAR __a__

#define SC_VA_SAVE(x)                                                        \
    {va_list __a__;                                                          \
     __a__ = *x
 
#define SC_VA_RESTORE(x)                                                     \
     *x = __a__;}


#ifdef __cplusplus
extern "C" {
#endif

/*--------------------------------------------------------------------------*/

/*                    STANDARD VARIABLE DECLARATIONS                        */

/*--------------------------------------------------------------------------*/

extern int
 *LAST;

/*--------------------------------------------------------------------------*/

/*                    STANDARD FUNCTION DECLARATIONS                        */

/*--------------------------------------------------------------------------*/

#ifdef __GNUC__

/*--------------------------------- Linux ----------------------------------*/

# ifdef LINUX

#  ifndef HAVE_GNU_LIBC_6
extern int
 SC_DECLARE(rexec, (char **ahost, int inport, const char *user,
                 const char *passwd,
		 const char *cmd, int *fd2p)),
 SC_DECLARE(bsd_ioctl, (int fildes, int request, ...)),
 SC_DECLARE(ioctl, (int fildes, int request, ...));

#  endif

extern int
 SC_DECLARE(wait, (void *p));

extern unsigned long
 SC_DECLARE(inet_addr, (char *cp));

# endif

/*---------------------------------- AIX -----------------------------------*/

# ifdef AIX

#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/socketvar.h>

extern int
 SC_DECLARE(gethostname, (char *name, int len)),
 SC_DECLARE(rexec, (char **ahost, int inport, const char *user,
                 const char *passwd,
		 const char *cmd, int *fd2p)),
 SC_DECLARE(ioctl, (int fildes, int request, ...)),
 SC_DECLARE(wait, (void *p)),
 SC_DECLARE(getrusage, (int who, struct rusage *rusage)),
 SC_DECLARE(gettimeofday, (struct timeval *tp, struct timezone *tzp)),
 SC_DECLARE(socketpair, (int domain, int type, int prot, int sv[2])),
 SC_DECLARE(socket, (int af, int type, int prot)),
 SC_DECLARE(bind, (int sockfd, struct sockaddr *addr, int addrlen)),
 SC_DECLARE(getsockname, (int sock, struct sockaddr *name, int *len)),
 SC_DECLARE(listen, (int sock, int backlog)),
 SC_DECLARE(accept, (int sock, struct sockaddr *addr, int *len)),
 SC_DECLARE(connect, (int sock, struct sockaddr *name, int len));


extern void
 SC_DECLARE(bzero, (char *b, int length));

extern unsigned long
 SC_DECLARE(inet_addr, (char *cp));

# endif

/*--------------------------------- SunOS ----------------------------------*/

# ifdef SUN
#  ifndef __GNUC__

extern int
 SC_DECLARE(rexec, (char **ahost, unsigned short inport, char *user,
		 char *passwd,
                 char *cmd, int *fd2p)),
 SC_DECLARE(select, (int nfds, fd_set *readfds, fd_set *writefds,
                  fd_set *exceptfds, struct timeval *timeout)),
 SC_DECLARE(ioctl, (int fildes, int request, ...)),
 SC_DECLARE(wait, (void *p));

extern void
 SC_DECLARE(bzero, (char *b, int length));

extern unsigned long
 SC_DECLARE(inet_addr, (char *cp));

#  endif
# endif

/*--------------------------------- HP UX ----------------------------------*/

# ifdef HPUX

extern int
 SC_DECLARE(rexec, (char **ahost, int inport, const char *user,
		 const char *passwd,
	         const char *cmd, int *fd2p)),
 SC_DECLARE(select, (size_t nfds, int *readfds, int *writefds,
	          int *exceptfds, const struct timeval *timeout)),
 SC_DECLARE(ioctl, (int fildes, int request, ...)),
 SC_DECLARE(wait, (void *p));

extern void
 SC_DECLARE(bzero, (char *b, int length));

extern unsigned long
 SC_DECLARE(inet_addr, (char *cp));

# endif

/*-------------------------------- SGI IRIX --------------------------------*/

# ifdef SGI

#include <sys/types.h>
#include <sys/time.h>

extern int
 SC_DECLARE(rexec, (char **ahost, int inport, const char *user,
		 const char *passwd,
	         const char *cmd, int *fd2p)),
 SC_DECLARE(select, (int nfds, fd_set *readfds, fd_set *writefds,
	          fd_set *exceptfds, struct timeval *timeout)),
 SC_DECLARE(gethostname, (char *name, int namelen)),
 SC_DECLARE(ioctl, (int fildes, int request, ...)),
 SC_DECLARE(wait, (void *p));

extern void
 SC_DECLARE(bzero, (char *b, int length));

extern unsigned long
 SC_DECLARE(inet_addr, (char *cp));

# endif

/*------------------------------- POTENTIAL --------------------------------*/

# if 0

extern int
 SC_DECLARE(getpid, (void)),
 SC_DECLARE(pipe, (int *p)),
 SC_DECLARE(dup2, (int s, int t)),
 SC_DECLARE(close, (int f)),
 SC_DECLARE(read, (int f, void *p, unsigned int n)),
 SC_DECLARE(write, (int f, const void *p, unsigned int n)),
 SC_DECLARE(execvp, (char *s, char **a)),
 SC_DECLARE(fork, (void));

extern unsigned int
 SC_DECLARE(alarm, (unsigned int i));

# endif

#endif

/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifdef __cplusplus
}
#endif

#endif