/* * @(#) chase.h 1.3@(#) * * Chase Research Standard Software * ================================ * * Module: Standard_header * File: chase.h * Author: R.J.Dunlop * Version:1.02 * Created:15 Mar 89 * * Copyright 1989 Chase Research Limited. * All rights reserved. * * Standard header file * * This header file should be #included in all Chase Research source files. * It contains standard types and other declarations. * It should be included after any files as it may * contain some items in duplicate. * * Revision History * * When Who What and Why * ==== === ============ * 21 Mar 89 R.J.Dunlop Revison to align with Coding Standards Guideline * STD/003/001 (17 Mar 89) * 22 May 89 R.J.Dunlop Added dummy #def for "signed" to the ANSI * compatable qualifiers section * 14 Sep 90 R.J.Dunlop Added CHASE_H #def as guard against multiple * inclusion and flag for these type being valid. * 24 Sep 90 R.J.Dunlop Added Min(), Max() and Num_elements() macros */ #ifndef CHASE_H #define CHASE_H 1 /* * Basic types * =========== * * Fixed size types. * * These types have the same size on all machines, they should always be * used when transfering data between different machines. Only the size * of these types is guaranteed in particular the signed and unsigned * nature of the types is not guaranteed. (See varient types that follow) * * When stored in files or transfered one byte at a time the low byte * should be transfered or stored first. * Words must be on a two byte boundry and quads on a four byte boundry. * Explicit padding must be used to achieve this alignement if necessary. */ typedef char Byte; /* Single byte */ typedef short Word; /* Two bytes */ typedef long Quad; /* Four bytes */ /* * Signed varients of fixed size types. * * These types should only be used when it is essential that the type * be signed. */ typedef char Sbyte; /* -127 to 127 */ typedef short Sword; /* -32767 to 32767 */ typedef long Squad; /* -2147483647 to 2147483647 */ /* * Unsigned varients of fixed size types. * * These types should only be used when it is essential that the type * be unsigned. */ typedef unsigned char Ubyte; /* 0 to 255 */ typedef unsigned short Uword; /* 0 to 65535 */ typedef unsigned long Uquad; /* 0 to 4294967295 */ /* * The boolean type. * * This type only contains one bit of information but uses the machines * natural word size for speed. The definitions for TRUE and FALSE match * the C convention for boolean expressions. * * enum { FALSE, TRUE } bool; is not used as the type checking on most * compilers throws a fit when given expressions like * if ( bool1 && bool2 ) * in place of * if ( bool1 == TRUE && bool2 == TRUE ) * most compilers whould accept "if ( bool1 )" however ? */ typedef int Bool; /* May be TRUE or FALSE */ #ifndef TRUE # define TRUE 1 # define FALSE 0 #endif /* * The pointer to a non-existant object. * * Some machines will trap references via this pointer but this is not * guaranteed. Also in some circumstances this pointer may be valid for * some special machine structures (186 interrupt vectors etc). * * Never assume that NULL is 0. In particular avoid expressions like * if ( ptr ) * it should be * if ( ptr != NULL ) * * A better definition for NULL is ((void *)0) but to many compilers fall * over at present. */ #ifndef NULL # define NULL 0 #endif /* * Additional storage qualifiers and classes. * ========================================== * * ANSI compatable qualifiers * * These #defines will be removed when we get a compiler that supports the * qualifiers. */ #define const /* Constant data */ /* Non-Optimised access for data changable by outside * forces */ #define volatile /* Volatile data */ #define signed /* Signed data */ /* * Inline procedure * * The procedure is a candidate for being replaced by inline code. * It does not guarantee that the code will be expanded inline, like * register it is only a hint for possible optimisation. * * NOTE: This should only be used to mark small procedures where the cost * of the function call is considerably higher than the cost of * repeating the code inline. * * NOTE: The procedure should always be file local with no forward * references. */ #define inline /* Inline Expanded */ /* * File local procedure or data * * This class is used to indicate that a procedure or data item is local to * a single source file. * * NOTE: This locality may be removed for debugging purposes so care must * be taken to prevent name clashes with other source files. * NOTE: Never use this class for items declared inside compound * statements, it is not a replacement for "static". */ #if CSW_NO_LOCALS # define local /* Local disabled */ #else # define local static #endif /* * Forward declaration of a procedure. * * As all procedures that are visable outside a file are declared in the * corresponding header file the only time a forward declaration will be * needed is when the procedure is local. * * NOTE: This class specifier cannot be used for the forward declaration of * data items but this should never be necessary. */ #if CSW_NO_LOCALS # define forward extern /* Local disabled */ #else # define forward local #endif /* * Useful macros * ============= * * Minimum and maximum values * NOTE: Type of comparision depends on type of arguments */ #ifndef Min # define Min(A,B) ((A) < (B) ? (A) : (B)) # define Max(A,B) ((A) > (B) ? (A) : (B)) #endif /* * Number of elements in an array */ #define Num_elements(A) ( sizeof ( A ) / sizeof ( A[0] )) #endif /* CHASE_H */