machine.h File Reference

This header file defines all the fundamental data types (lower case names, created with "typedef") and fundamental manifest constants (upper case, created with "#define") used throughout the BRL-CAD Package. Virtually all other BRL-CAD header files depend on this header file being included first. More...

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

Include dependency graph for machine.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MACHINE_H   seen
#define FOPEN_MAX   32
#define LOCAL   static
#define FAST   LOCAL
#define BITV_SHIFT   5
#define MAX_PSW   4
#define DEFAULT_PSW   bu_avail_cpus()
#define BIG_ENDIAN   1
#define BITV_MASK   ((1<<BITV_SHIFT)-1)
#define MAX_FASTF   1.0e73
#define SQRT_MAX_FASTF   1.0e36
#define SMALL_FASTF   1.0e-77
#define SQRT_SMALL_FASTF   1.0e-39
#define SMALL   SQRT_SMALL_FASTF
#define GENPTR_NULL   ((genptr_t)0)
#define BOOL_T   int
#define bzero(str, n)   memset( str, 0, n )
#define bcopy(from, to, count)   memcpy( to, from, count )
#define HIDDEN

Typedefs

typedef double fastf_t
typedef long bitv_t
typedef char * genptr_t


Detailed Description

This header file defines all the fundamental data types (lower case names, created with "typedef") and fundamental manifest constants (upper case, created with "#define") used throughout the BRL-CAD Package. Virtually all other BRL-CAD header files depend on this header file being included first.

Many of these fundamental data types are machine (vendor) dependent. Some may assume different values on the same machine, depending on which version of the compiler is being used.

Additions will need to be made here when porting BRL-CAD to a new machine which is anything but a 32-bit big-endian uniprocessor.

General Symbols and Types Defined -

genptr_t - A portable way of declaring a "generic" pointer that is wide enough to point to anything, which can be used on both ANSI C and K&R C environments. On some machines, pointers to functions can be wider than pointers to data bytes, so a declaration of "char *" isn't generic enough.

fastf_t - Intended to be the fastest floating point data type on the current machine, with at least 64 bits of precision. On 16 and 32 bit machine, this is typically "double", but on 64 bit machines, it is often "float". Virtually all floating point variables (and more complicated data types, like vect_t and mat_t) are defined as fastf_t. The one exception is when a subroutine return is a floating point value; that is always declared as "double".

LOCAL - The fastest storage class for local variables within a subroutine. On parallel machines, this needs to be "auto", but on serial machines there can sometimes be a performance advantage to using "static".

FAST - The fastest storage class for fastf_t variables. On most machines with abundant registers, this is "register", but on machines like the VAX with only 3 "register double"s available to C programmers, it is set to LOCAL. Thus, declaring a fast temporary fastf_t variable is done like: FAST fastf_t var;

HIDDEN - Functions intended to be local to one module should be declared HIDDEN. For production use, and lint, it will be defined as "static", but for debugging it can be defined as NIL, so that the routine names can be made available to the debugger.

MAX_FASTF - Very close to the largest value that can be held by a fastf_t without overflow. Typically specified as an integer power of ten, to make the value easy to spot when printed.

SQRT_MAX_FASTF - sqrt(MAX_FASTF), or slightly smaller. Any number larger than this, if squared, can be expected to produce an overflow.

SMALL_FASTF - Very close to the smallest value that can be represented while still being greater than zero. Any number smaller than this (and non-negative) can be considered to be zero; dividing by such a number can be expected to produce a divide-by-zero error. All divisors should be checked against this value before actual division is performed.

SQRT_SMALL_FASTF - sqrt(SMALL_FASTF), or slightly larger. The value of this is quite a lot larger than that of SMALL_FASTF. Any number smaller than this, when squared, can be expected to produce a zero result.

bzero(ptr,n) - Defined to be the fasted system-specific method for zeroing a block of 'n' bytes, where the pointer has arbitrary byte alignment.

bcopy(from,to,n) - Defined to be the fastest system-specific method for copying a block of 'n' bytes, where both the "from" and "to" pointers have arbitrary byte alignment.

bitv_t - The widest fast integer type available, used to implement bit vectors. On most machines, this is "long", but on some machines a vendor-specific type such as "long long" can give access to wider integers.

BITV_SHIFT - log2( bits_wide(bitv_t) ). Used to determine how many bits of a bit-vector subscript are index-of-bit in bitv_t word, and how many bits of the subscript are for word index. On a 32-bit machine, BITV_SHIFT is 5.

XXX The BYTE_ORDER handling needs to change to match the POSIX XXX recommendations.

PARALLEL Symbols Defined - These are used only for applications linked with LIBRT, and interact heavily with the support routines in librt/machine.c XXX These are likely to get new, more descriptive names sometime.

PARALLEL - When defined, the code is being compiled for a parallel processor. This has implications for signal handling, math library exception handling, etc.

MAX_PSW - The maximum number of processors that can be expected on this hardware. Used to allocate application-specific per-processor tables. The actual number of processors is found at runtime by calling rt_avail_cpus().

DEFAULT_PSW - The number of processors to use when the user has not specifically indicated the number of processors desired. On some machines like the Alliant, this should be MAX_PSW, because the parallel complex is allocated as a unit. On timesharing machines like the Cray, this should be 1, because running multi-tasking consumes special resources (and sometimes requires special queues/privs), so ordinary runs should just stay serial.

MALLOC_NOT_MP_SAFE - Defined when the system malloc() routine can not be safely used in a multi-processor (MP) execution. If defined, LIBBU will protect with BU_SEM_SYSCALL.

Author:
Michael John Muuss
Source
The U. S. Army Research Laboratory Aberdeen Proving Ground, Maryland 21005
Include Sequencing - # include "machine.h"
# include "bu.h"

Libraries Used - LIBBU LIBBU_LIBES -lm -lc

Header
/cvsroot/brlcad/brlcad/include/machine.h,v 14.20 2006/09/18 05:24:07 lbutler Exp

Definition in file machine.h.


Generated on Mon Sep 18 01:24:59 2006 for BRL-CAD by  doxygen 1.4.6