SVF
Macros | Typedefs | Functions | Variables
util.h File Reference
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>

Go to the source code of this file.

Macros

#define UTIL_INLINE
 
#define UTIL_UNUSED
 
#define SIZEOF_VOID_P   4
 
#define SIZEOF_INT   4
 
#define SIZEOF_LONG   4
 
#define strsav   util_strsav
 
#define NIL(type)   ((type *) 0)
 
#define ALLOC(type, num)   ((type *) MMalloc((long) sizeof(type) * (long) (num)))
 
#define REALLOC(type, obj, num)   ((type *) MMrealloc((char *) (obj), (long) sizeof(type) * (long) (num)))
 
#define FREE(obj)   ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
 
#define VOID_OR_INT   int
 
#define VOID_OR_CHAR   char
 
#define assert(ex)
 
#define fail(why)
 
#define ABS(a)   ((a) < 0 ? -(a) : (a))
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 

Typedefs

typedef int util_ptrint
 

Functions

FILE * popen ()
 
FILE * tmpfile ()
 
int pclose ()
 
VOID_OR_INT abort ()
 
VOID_OR_INT exit ()
 
VOID_OR_INT free (void *)
 
VOID_OR_CHARmalloc ()
 
VOID_OR_CHARrealloc ()
 
char * getenv ()
 
int system ()
 
double atof ()
 
char * strcpy ()
 
char * strncpy ()
 
char * strcat ()
 
char * strncat ()
 
char * strerror ()
 
char * strpbrk ()
 
char * strtok ()
 
char * strchr ()
 
char * strrchr ()
 
char * strstr ()
 
int strcoll ()
 
int strxfrm ()
 
int strncmp ()
 
int strlen ()
 
int strspn ()
 
int strcspn ()
 
char * memmove ()
 
char * memccpy ()
 
char * memchr ()
 
char * memcpy ()
 
char * memset ()
 
int memcmp ()
 
int strcmp ()
 
char * MMalloc (long)
 
void MMout_of_memory (long)
 
char * MMrealloc (char *, long)
 
long util_cpu_time (void)
 
char * util_path_search (char const *)
 
char * util_file_search (char const *, char *, char const *)
 
int util_pipefork (char *const *, FILE **, FILE **, int *)
 
void util_print_cpu_stats (FILE *)
 
char * util_print_time (unsigned long)
 
int util_save_image (char const *, char const *)
 
char * util_strsav (char const *)
 
char * util_tilde_expand (char const *)
 
void util_restart (char const *, char const *, int)
 
unsigned long getSoftDataLimit (void)
 

Variables

void(* MMoutOfMemory )(long)
 

Macro Definition Documentation

◆ ABS

#define ABS (   a)    ((a) < 0 ? -(a) : (a))

Definition at line 174 of file util.h.

◆ ALLOC

#define ALLOC (   type,
  num 
)    ((type *) MMalloc((long) sizeof(type) * (long) (num)))

Definition at line 76 of file util.h.

◆ assert

#define assert (   ex)
Value:
{\
if (! (ex)) {\
(void) fprintf(stderr,\
"Assertion failed: file %s, line %d\n\"%s\"\n",\
__FILE__, __LINE__, "ex");\
(void) fflush(stdout);\
abort();\
}\
}

Definition at line 141 of file util.h.

◆ fail

#define fail (   why)
Value:
{\
(void) fprintf(stderr, "Fatal error: file %s, line %d\n%s\n",\
__FILE__, __LINE__, why);\
(void) fflush(stdout);\
abort();\
}

Definition at line 156 of file util.h.

◆ FREE

#define FREE (   obj)    ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)

Definition at line 80 of file util.h.

◆ MAX

#define MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 175 of file util.h.

◆ MIN

#define MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 176 of file util.h.

◆ NIL

#define NIL (   type)    ((type *) 0)

Definition at line 44 of file util.h.

◆ REALLOC

#define REALLOC (   type,
  obj,
  num 
)    ((type *) MMrealloc((char *) (obj), (long) sizeof(type) * (long) (num)))

Definition at line 78 of file util.h.

◆ SIZEOF_INT

#define SIZEOF_INT   4

Definition at line 26 of file util.h.

◆ SIZEOF_LONG

#define SIZEOF_LONG   4

Definition at line 29 of file util.h.

◆ SIZEOF_VOID_P

#define SIZEOF_VOID_P   4

Definition at line 23 of file util.h.

◆ strsav

#define strsav   util_strsav

Definition at line 41 of file util.h.

◆ UTIL_INLINE

#define UTIL_INLINE

Definition at line 18 of file util.h.

◆ UTIL_UNUSED

#define UTIL_UNUSED

Definition at line 19 of file util.h.

◆ VOID_OR_CHAR

#define VOID_OR_CHAR   char

Definition at line 91 of file util.h.

◆ VOID_OR_INT

#define VOID_OR_INT   int

Definition at line 90 of file util.h.

Typedef Documentation

◆ util_ptrint

typedef int util_ptrint

Definition at line 35 of file util.h.

Function Documentation

◆ abort()

VOID_OR_INT abort ( )

◆ atof()

double atof ( )

◆ exit()

VOID_OR_INT exit ( )

◆ free()

VOID_OR_INT free ( void *  )

◆ getenv()

char* getenv ( )

◆ getSoftDataLimit()

unsigned long getSoftDataLimit ( void  )

Definition at line 35 of file datalimit.c.

36 {
37 #if HAVE_SYS_RESOURCE_H == 1 && HAVE_GETRLIMIT == 1 && defined(RLIMIT_DATA)
38  struct rlimit rl;
39  int result;
40 
41  result = getrlimit(RLIMIT_DATA, &rl);
42  if (result != 0 || rl.rlim_cur == RLIM_INFINITY)
43  return((unsigned long) RLIMIT_DATA_DEFAULT);
44  else
45  return((unsigned long) rl.rlim_cur);
46 #else
47  return((unsigned long) RLIMIT_DATA_DEFAULT);
48 #endif
49 
50 } /* end of getSoftDataLimit */
static int result
Definition: cuddGenetic.c:121
#define RLIMIT_DATA_DEFAULT
Definition: datalimit.c:21

◆ malloc()

VOID_OR_CHAR* malloc ( )

◆ memccpy()

char * memccpy ( )

◆ memchr()

char * memchr ( )

◆ memcmp()

int memcmp ( )

◆ memcpy()

char * memcpy ( )

◆ memmove()

char* memmove ( )

◆ memset()

char * memset ( )

◆ MMalloc()

char * MMalloc ( long  size)

Definition at line 51 of file safe_mem.c.

52 {
53  char *p;
54 
55 #ifdef IBMPC
56  if (size > 65000L) {
57  if (MMoutOfMemory != (void (*)(long)) 0 ) (*MMoutOfMemory)(size);
58  return NIL(char);
59  }
60 #endif
61  if (size == 0) size = sizeof(long);
62  if ((p = (char *) malloc((unsigned long) size)) == NIL(char)) {
63  if (MMoutOfMemory != 0 ) (*MMoutOfMemory)(size);
64  return NIL(char);
65  }
66  return p;
67 }
void(* MMoutOfMemory)(long)
Definition: safe_mem.c:32
#define NIL(type)
Definition: util.h:44
VOID_OR_CHAR * malloc()

◆ MMout_of_memory()

void MMout_of_memory ( long  size)

Definition at line 41 of file safe_mem.c.

42 {
43  (void) fflush(stdout);
44  (void) fprintf(stderr, "\nout of memory allocating %lu bytes\n",
45  (unsigned long) size);
46  exit(1);
47 }
VOID_OR_INT exit()

◆ MMrealloc()

char * MMrealloc ( char *  obj,
long  size 
)

Definition at line 71 of file safe_mem.c.

72 {
73  char *p;
74 
75 #ifdef IBMPC
76  if (size > 65000L) {
77  if (MMoutOfMemory != 0 ) (*MMoutOfMemory)(size);
78  return NIL(char);
79  }
80 #endif
81  if (obj == NIL(char)) return MMalloc(size);
82  if (size <= 0) size = sizeof(long);
83  if ((p = (char *) realloc(obj, (unsigned long) size)) == NIL(char)) {
84  if (MMoutOfMemory != 0 ) (*MMoutOfMemory)(size);
85  return NIL(char);
86  }
87  return p;
88 }
void(* MMoutOfMemory)(long)
Definition: safe_mem.c:32
#define NIL(type)
Definition: util.h:44
VOID_OR_CHAR * realloc()
char * MMalloc(long)
Definition: safe_mem.c:51

◆ pclose()

int pclose ( )

◆ popen()

FILE* popen ( )

◆ realloc()

VOID_OR_CHAR * realloc ( )

◆ strcat()

char * strcat ( )

◆ strchr()

char * strchr ( )

◆ strcmp()

int strcmp ( )

◆ strcoll()

int strcoll ( )

◆ strcpy()

char* strcpy ( )

◆ strcspn()

int strcspn ( )

◆ strerror()

char * strerror ( )

◆ strlen()

int strlen ( )

◆ strncat()

char * strncat ( )

◆ strncmp()

int strncmp ( )

◆ strncpy()

char * strncpy ( )

◆ strpbrk()

char* strpbrk ( )

◆ strrchr()

char * strrchr ( )

◆ strspn()

int strspn ( )

◆ strstr()

char * strstr ( )

◆ strtok()

char * strtok ( )

◆ strxfrm()

int strxfrm ( )

◆ system()

int system ( )

◆ tmpfile()

FILE * tmpfile ( )

◆ util_cpu_time()

long util_cpu_time ( void  )

Definition at line 34 of file cpu_time.c.

35 {
36  long t = 0;
37 
38 #ifdef BSD
39  struct rusage rusage;
40  (void) getrusage(RUSAGE_SELF, &rusage);
41  t = (long) rusage.ru_utime.tv_sec*1000 + rusage.ru_utime.tv_usec/1000;
42 #endif
43 
44 #ifdef IBMPC
45  long ltime;
46  (void) time(&ltime);
47  t = ltime * 1000;
48 #endif
49 
50 #ifdef UNIX60 /* times() with 60 Hz resolution */
51  struct tms buffer;
52  times(&buffer);
53  t = buffer.tms_utime * 16.6667;
54 #endif
55 
56 #ifdef UNIX100
57  struct tms buffer; /* times() with 100 Hz resolution */
58  times(&buffer);
59  t = buffer.tms_utime * 10;
60 #endif
61 
62 #ifdef __CYGWIN32__
63  /* Works under Windows NT but not Windows 95. */
64  struct tms buffer; /* times() with 1000 Hz resolution */
65  times(&buffer);
66  t = buffer.tms_utime;
67 #endif
68 
69 #ifdef vms
70  tbuffer_t buffer; /* times() with 100 Hz resolution */
71  times(&buffer);
72  t = buffer.proc_user_time * 10;
73 #endif
74 
75  return t;
76 }

◆ util_file_search()

char* util_file_search ( char const *  ,
char *  ,
char const *   
)

◆ util_path_search()

char* util_path_search ( char const *  )

◆ util_pipefork()

int util_pipefork ( char *const *  ,
FILE **  ,
FILE **  ,
int *   
)

◆ util_print_cpu_stats()

void util_print_cpu_stats ( FILE *  )

◆ util_print_time()

char* util_print_time ( unsigned  long)

◆ util_restart()

void util_restart ( char const *  ,
char const *  ,
int   
)

◆ util_save_image()

int util_save_image ( char const *  ,
char const *   
)

◆ util_strsav()

char* util_strsav ( char const *  )

◆ util_tilde_expand()

char* util_tilde_expand ( char const *  )

Variable Documentation

◆ MMoutOfMemory

void(* MMoutOfMemory) (long)

Definition at line 32 of file safe_mem.c.