cudd
3.0.0
The University of Colorado Decision Diagram Package
|
Low-level utilities. More...
#include "config.h"
#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
Go to the source code of this file.
Macros | |
#define | PRIszt "zu" |
Format string for a size_t value. | |
#define | UTIL_UNUSED |
Macro to tell gcc that a variable is intentionally unused. | |
#define | NIL(type) ((type *) 0) |
Type-decorated NULL (for documentation). | |
#define | ALLOC(type, num) ((type *) MMalloc(sizeof(type) * (size_t) (num))) |
Wrapper for either malloc or MMalloc. More... | |
#define | REALLOC(type, obj, num) ((type *) MMrealloc((obj), sizeof(type) * (size_t) (num))) |
Wrapper for either realloc or MMrealloc. More... | |
#define | FREE(obj) (free(obj), (obj) = 0) |
Wrapper for free. More... | |
#define | fail(why) |
Prints message and terminates execution. More... | |
#define | ABS(a) ((a) < 0 ? -(a) : (a)) |
Computes the absolute value of its argument. | |
#define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
Computes the maximum of its two arguments. | |
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
Computes the minimum of its two arguments. | |
Typedefs | |
typedef int(* | QSFP) (void const *, void const *) |
Type of comparison functions for util_qsort. | |
Functions | |
void * | MMalloc (size_t) |
malloc replacement. | |
void * | MMrealloc (void *, size_t) |
realloc replacement. | |
void | MMout_of_memory (size_t) |
Out of memory for lazy people: flush and exit. | |
long | util_cpu_time (void) |
returns a long which represents the elapsed processor time in milliseconds since some constant reference. | |
long | util_cpu_ctime (void) |
returns a long which represents the elapsed processor time in milliseconds since some constant reference. It includes waited-for terminated children. | |
char * | util_path_search (char const *) |
Looks for a program in the directories specified by PATH. | |
char * | util_file_search (char const *, char *, char const *) |
Searches for a file given a set of paths. | |
void | util_print_cpu_stats (FILE *) |
Prints CPU statistics. More... | |
char * | util_print_time (unsigned long) |
Massages a long that represents a time interval in milliseconds into a string suitable for output. More... | |
char * | util_strsav (char const *) |
Returns a copy of a string. | |
char * | util_tilde_expand (char const *) |
Expands tilde in a file name. | |
size_t | getSoftDataLimit (void) |
Gets the soft datasize limit. | |
void | util_qsort (void *vbase, int n, int size, QSFP compar) |
Implements the quicksort algorithm. More... | |
int | util_pipefork (char *const *argv, FILE **toCommand, FILE **fromCommand, int *pid) |
Forks a command and sets up pipes to and from. More... | |
Variables | |
void(* | MMoutOfMemory )(size_t) |
Global out-of-memory handler. | |
Low-level utilities.
Copyright (c) 1994-1998 The Regents of the Univ. of California. All rights reserved.
Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
Copyright (c) 1999-2015, Regents of the University of Colorado
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define ALLOC | ( | type, | |
num | |||
) | ((type *) MMalloc(sizeof(type) * (size_t) (num))) |
Wrapper for either malloc or MMalloc.
Which function is wrapped depends on whether USE_MM is defined.
#define fail | ( | why | ) |
Prints message and terminates execution.
#define FREE | ( | obj | ) | (free(obj), (obj) = 0) |
Wrapper for free.
Sets its argument to 0 after freeing.
#define REALLOC | ( | type, | |
obj, | |||
num | |||
) | ((type *) MMrealloc((obj), sizeof(type) * (size_t) (num))) |
Wrapper for either realloc or MMrealloc.
Which function is wrapped depends on whether USE_MM is defined.
int util_pipefork | ( | char *const * | argv, |
FILE ** | toCommand, | ||
FILE ** | fromCommand, | ||
int * | pid | ||
) |
Forks a command and sets up pipes to and from.
argv | normal argv argument list |
toCommand | pointer to the sending stream |
fromCommand | pointer to the reading stream |
pid | process ID |
void util_print_cpu_stats | ( | FILE * | fp | ) |
Prints CPU statistics.
The amount of detail printed depends on the host operating system.
char* util_print_time | ( | unsigned long | t | ) |
Massages a long that represents a time interval in milliseconds into a string suitable for output.
Hack for IBM/PC – avoids using floating point.
void util_qsort | ( | void * | vbase, |
int | n, | ||
int | size, | ||
QSFP | compar | ||
) |
Implements the quicksort algorithm.
First, set up some global parameters for qst to share. Then, quicksort with qst(), and then a cleanup insertion sort ourselves. Sound simple? It's not...
vbase | start address of array |
n | number of items |
size | size of each item |
compar | comparison function |