ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
util_old.h
Go to the documentation of this file.
1/*
2 * Revision Control Information
3 *
4 * $Source: /vol/opua/opua2/sis/sis-1.2/common/src/sis/util/RCS/util.h,v $
5 * $Author: sis $
6 * $Revision: 1.9 $
7 * $Date: 1993/06/07 21:04:07 $
8 *
9 */
10#ifndef ABC__misc__espresso__util_old_h
11#define ABC__misc__espresso__util_old_h
12
13#if defined(_IBMR2)
14#ifndef _POSIX_SOURCE
15#define _POSIX_SOURCE /* Argh! IBM strikes again */
16#endif
17#ifndef _ALL_SOURCE
18#define _ALL_SOURCE /* Argh! IBM strikes again */
19#endif
20#ifndef _ANSI_C_SOURCE
21#define _ANSI_C_SOURCE /* Argh! IBM strikes again */
22#endif
23#endif
24
25#if defined(__STDC__) || defined(sprite) || defined(_IBMR2) || defined(__osf__)
26#include <unistd.h>
27#endif
28
29#if defined(_IBMR2) && !defined(__STDC__)
30#define _BSD
31#endif
32
33#include "ansi.h" /* since some files don't include sis.h */
34
35/* This was taken out and defined at compile time in the SIS Makefile
36 that uses the OctTools. When the OctTools are used, USE_MM is defined,
37 because the OctTools contain libmm.a. Otherwise, USE_MM is not defined,
38 since the mm package is not distributed with SIS, only with Oct. */
39
40/* #define USE_MM */ /* choose libmm.a as the memory allocator */
41
42#define NIL(type) ((type *) 0)
43
44#ifdef USE_MM
45/*
46 * assumes the memory manager is libmm.a
47 * - allows malloc(0) or realloc(obj, 0)
48 * - catches out of memory (and calls MMout_of_memory())
49 * - catch free(0) and realloc(0, size) in the macros
50 */
51#define ALLOC(type, num) \
52 ((type *) malloc(sizeof(type) * (num)))
53#define REALLOC(type, obj, num) \
54 (obj) ? ((type *) realloc((char *) obj, sizeof(type) * (num))) : \
55 ((type *) malloc(sizeof(type) * (num)))
56#define FREE(obj) \
57 ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
58#else
59/*
60 * enforce strict semantics on the memory allocator
61 * - when in doubt, delete the '#define USE_MM' above
62 */
63#define ALLOC(type, num) \
64 ((type *) MMalloc((long) sizeof(type) * (long) (num)))
65#define REALLOC(type, obj, num) \
66 ((type *) MMrealloc((char *) (obj), (long) sizeof(type) * (long) (num)))
67#define FREE(obj) \
68 ((obj) ? (free((void *) (obj)), (obj) = 0) : 0)
69#endif
70
71
72/* Ultrix (and SABER) have 'fixed' certain functions which used to be int */
73#if defined(ultrix) || defined(SABER) || defined(aiws) || defined(__hpux) || defined(__STDC__) || defined(apollo)
74#define VOID_HACK void
75#else
76#define VOID_HACK int
77#endif
78
79
80/* No machines seem to have much of a problem with these */
81#include <stdio.h>
82#include <ctype.h>
83
84
85/* Some machines fail to define some functions in stdio.h */
86#if !defined(__STDC__) && !defined(sprite) && !defined(_IBMR2) && !defined(__osf__)
87extern FILE *popen(), *tmpfile();
88extern int pclose();
89#ifndef clearerr /* is a macro on many machines, but not all */
91#endif
92#ifndef rewind
94#endif
95#endif
96
97#ifndef PORT_H
98#include <sys/types.h>
99#include <signal.h>
100#if defined(ultrix)
101#if defined(_SIZE_T_)
102#define ultrix4
103#else
104#if defined(SIGLOST)
105#define ultrix3
106#else
107#define ultrix2
108#endif
109#endif
110#endif
111#endif
112
113/* most machines don't give us a header file for these */
114#if defined(__STDC__) || defined(sprite) || defined(_IBMR2) || defined(__osf__) || defined(sunos4) || defined(__hpux)
115#include <stdlib.h>
116#if defined(__hpux)
117#include <errno.h> /* For perror() defininition */
118#endif /* __hpux */
119#else
120extern VOID_HACK abort(), free(), exit(), perror();
121extern char *getenv();
122#ifdef ultrix4
123extern void *malloc(), *realloc(), *calloc();
124#else
125extern char *malloc(), *realloc(), *calloc();
126#endif
127#if defined(aiws)
128extern int sprintf();
129#else
130#ifndef _IBMR2
131extern char *sprintf();
132#endif
133#endif
134extern int system();
135extern double atof();
136#endif
137
138#ifndef PORT_H
139#if defined(ultrix3) || defined(sunos4) || defined(_IBMR2) || defined(__STDC__)
140#define SIGNAL_FN void
141#else
142/* sequent, ultrix2, 4.3BSD (vax, hp), sunos3 */
143#define SIGNAL_FN int
144#endif
145#endif
146
147/* some call it strings.h, some call it string.h; others, also have memory.h */
148#if defined(__STDC__) || defined(sprite)
149#include <string.h>
150#else
151#if defined(ultrix4) || defined(__hpux)
152#include <strings.h>
153#else
154#if defined(_IBMR2) || defined(__osf__)
155#include<string.h>
156#include<strings.h>
157#else
158/* ANSI C string.h -- 1/11/88 Draft Standard */
159/* ugly, awful hack */
160#ifndef PORT_H
161extern char *strcpy(), *strncpy(), *strcat(), *strncat(), *strerror();
162extern char *strpbrk(), *strtok(), *strchr(), *strrchr(), *strstr();
163extern int strcoll(), strxfrm(), strncmp(), strlen(), strspn(), strcspn();
164extern char *memmove(), *memccpy(), *memchr(), *memcpy(), *memset();
165extern int memcmp(), strcmp();
166#endif
167#endif
168#endif
169#endif
170
171/* a few extras */
172#if defined(__hpux)
173#define random() lrand48()
174#define srandom(a) srand48(a)
175#define bzero(a,b) memset(a, 0, b)
176#else
177#if !defined(__osf__) && !defined(linux)
178/* these are defined as macros in stdlib.h */
180extern long random();
181#endif
182#endif
183
184/* code from sis-1.3 commented out below
185#if defined(__STDC__) || defined(sprite)
186#include <assert.h>
187#else
188#ifndef NDEBUG
189#define assert(ex) {\
190 if (! (ex)) {\
191 (void) fprintf(stderr,\
192 "Assertion failed: file %s, line %d\n\"%s\"\n",\
193 __FILE__, __LINE__, "ex");\
194 (void) fflush(stdout);\
195 abort();\
196 }\
197}
198#else
199#define assert(ex) {ex;}
200#endif
201#endif
202*/
203
204 /* Sunil 5/3/97:
205 sis-1.4: dont let the assert call go to the OS, since
206 much of the code in SIS has actual computation done in
207 the assert function. %$#$@@#! The OS version of assert
208 will do nothing if NDEBUG is set. We cant let that happen...
209 */
210# ifdef NDEBUG
211# define assert(ex) {ex;}
212# else
213# define assert(ex) {\
214 if (! (ex)) {\
215 (void) fprintf(stderr,\
216 "Assertion failed: file %s, line %d\n\"%s\"\n",\
217 __FILE__, __LINE__, "ex");\
218 (void) fflush(stdout);\
219 abort();\
220 }\
221}
222# endif
223
224
225#define fail(why) {\
226 (void) fprintf(stderr, "Fatal error: file %s, line %d\n%s\n",\
227 __FILE__, __LINE__, why);\
228 (void) fflush(stdout);\
229 abort();\
230}
231
232
233#ifdef lint
234#undef putc /* correct lint '_flsbuf' bug */
235#undef ALLOC /* allow for lint -h flag */
236#undef REALLOC
237#define ALLOC(type, num) (((type *) 0) + (num))
238#define REALLOC(type, obj, num) ((obj) + (num))
239#endif
240
241/*
242#if !defined(__osf__)
243#define MAXPATHLEN
244 1024
245#endif
246*/
247
248/* These arguably do NOT belong in util.h */
249#ifndef ABS
250#define ABS(a) ((a) < 0 ? -(a) : (a))
251#endif
252#ifndef MAX
253#define MAX(a,b) ((a) > (b) ? (a) : (b))
254#endif
255#ifndef MIN
256#define MIN(a,b) ((a) < (b) ? (a) : (b))
257#endif
258
259
260#ifndef USE_MM
261EXTERN void MMout_of_memory ARGS((long));
262EXTERN char *MMalloc ARGS((long));
263EXTERN char *MMrealloc ARGS((char *, long));
264EXTERN void MMfree ARGS((char *));
265#endif
266
267EXTERN void util_print_cpu_stats ARGS((FILE *));
269EXTERN void util_getopt_reset ARGS((void));
270EXTERN int util_getopt ARGS((int, char **, char *));
271EXTERN char *util_path_search ARGS((char *));
272EXTERN char *util_file_search ARGS((char *, char *, char *));
273EXTERN int util_pipefork ARGS((char **, FILE **, FILE **, int *));
274EXTERN char *util_print_time ARGS((long));
275EXTERN int util_save_image ARGS((char *, char *));
276EXTERN char *util_strsav ARGS((char *));
277EXTERN int util_do_nothing ARGS((void));
278EXTERN char *util_tilde_expand ARGS((char *));
279EXTERN char *util_tempnam ARGS((char *, char *));
280EXTERN FILE *util_tmpfile ARGS((void));
282
283#define ptime() util_cpu_time()
284#define print_time(t) util_print_time(t)
285
286/* util_getopt() global variables (ack !) */
287extern int util_optind;
288extern char *util_optarg;
289
290#include <math.h>
291#ifndef HUGE_VAL
292#ifndef HUGE
293#define HUGE 8.9884656743115790e+307
294#endif
295#define HUGE_VAL HUGE
296#endif
297#ifndef MAXINT
298#define MAXINT (1 << 30)
299#endif
300
301#include <varargs.h>
302
304
305
306
308
309#endif
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
#define EXTERN
Definition avl.h:17
#define ARGS(protos)
Definition avl.h:20
int util_getopt()
#define util_cpu_time
Definition util_hack.h:36
int pclose()
char * memccpy()
int strncmp()
VOID_HACK clearerr()
char * memcpy()
VOID_HACK srandom()
VOID_HACK perror()
char * calloc()
VOID_HACK abort()
char * strrchr()
char * memset()
char * strncat()
char * strerror()
int strcspn()
int strlen()
char * util_optarg
int util_optind
char * strncpy()
#define VOID_HACK
Definition util_old.h:76
EXTERN long getSoftDataLimit()
char * memchr()
int memcmp()
int system()
int strcmp()
int strcoll()
int strxfrm()
char * sprintf()
char * strtok()
char * memmove()
char * strstr()
char * strcpy()
VOID_HACK free()
char * strpbrk()
char * getenv()
VOID_HACK rewind()
VOID_HACK exit()
long random()
char * strchr()
double atof()
FILE * popen()
char * strcat()
char * malloc()
char * realloc()
FILE * tmpfile()
int strspn()