Main Page | Modules | Files | Functions | Code Elements | Data Structures | Deprecated

unidefs.h

Go to the documentation of this file.
00001 /*HEAD UNIDEFS HHH INCLUDE */
00002 
00003 #ifndef UNIDEFS_H_INCLUDED
00004 #define UNIDEFS_H_INCLUDED
00005 
00006 /*
00007  *  Common definitions for Unigraphics programming.
00008  *
00009  *  NOTE: This file is for use with ANSI compliant (or nearly so in the VMS
00010  *        case) compilers.  Keywords like "const" are always available and
00011  *        function prototyping is now expected to work.
00012  *
00013  *  See the "C Programming Standards" for details about the types and symbols
00014  *  defined here.
00015  *
00016  *  REVISIONS -
00017  *   RV DATE    WHO PR    REASON FOR CHANGE
00018  *   01 16MAR88 RDB       ADD NULENT, PI, TWOPI, RADEG, DEGRA
00019  *   02 14SEP88 RDB       Add EXIT_SUCCESS, EXIT_FAILURE and Upper case
00020  *            names for UG types
00021  *   03 06JUN89 RDB       Correct definitions of FLOGICAL and FTRUE
00022  *   04 30MAY90 kdh       define FTCOMMON
00023  *   05 11JUN90 RDB       Add typedef for PVOID, define DEC and PROTO
00024  *   06 28JUN90 RDB       Combine all versions into one, using sysident.h,
00025  *                        and define BIG_ENDIAN or LITTLE_ENDIAN
00026  *   07 06JUL90 RDB       Remove lower case typedefs, disable prototypes on HP
00027  *   08 16JUL90 JLM       Restore lower case typedefs for one phase (II)
00028  *   09 05SEP90 KEJ       Remove EXIT_... definitions, add "const" {by corvese}
00029  *   10 09OCT90 KEJ       Correctly ifdef'ed FENTRY, added FCALL {by corvese}
00030  *   11 01NOV90 KEJ       Added SET_FPTR() and USE_FPTR() to be used when
00031  *                        passing a func to a FTN callable routine {by corvese}
00032  *   12 13NOV90 KEJ       Redid *_FPTR for dumb AOSVS C compiler {by corvese}
00033  *   13 04DEC90 KEJ       Support S700 (S300 front end compiler) {by corvese}
00034  *   14 30MAY91 TRS       DG Macro corrections (by smith)
00035  *   15 06JUN91 CVK       Add typedef for FSINGLE
00036  *   16 16SEP91 JLM       Add FTN macro for Fortran callability
00037  *   16 16SEP91 JLM       Add conditional inclusion for UNIDEFS
00038  *   16 23OCT91 JLM       Convert to 32 bit integers
00039  *   17 28FEB92 JLM       Make basic types 'int' instead of 'long'
00040  *   17 28FEB92 JLM       Add FSHORTINT type
00041  *   18 06MAR92 JLM       Make FENTITY unsigned
00042  *   19 03APR92 JLM       FTRUE s/b 1 instead of ~0 on HP Risc
00043  *   20 06APR92 JLM       Change FLONGINT to 'int' from 'long'
00044  *   21 04JUN92 RDB       Map the PROTO macro into a real prototype whenever
00045  *                           __STDC__ is 1;  remove AOSVS stuff
00046  *   22 13Jul92 jeh       Add typedef for caddr_t
00047  *   23 13Jul92 sch       check if type caddr_t defined or not before
00048  *                        doing typedef for it
00049  *   24 06Apr93 cdc       Used ANSI constructs to clean up definitions, fixed
00050  *                        SET_FPTR and USE_FPTR for ANSI, removed "extern" in
00051  *                        FT_COMMON(), created generic token pasting macro,
00052  *                        removed const define, always set PROTO() to work,
00053  *                        remove SYS card, and added IBM RS6000 dependencies.
00054  *   25 02May93 dn        Include stddef.h and do not define NULL here
00055  *   26 15May93 Reger     Removed BIG_ENDIAN/LITTLE_ENDIAN defines (use
00056  *                        DMAN/MACH code instead)
00057  *   27 26jun93 kdh       make it work on vms remove backslash
00058  *   28 03Jul93 Reger     OSF needs underscores from FTN macro
00059  *      21Jul93 BJS       Add logical, byte and tag typedefs
00060  *   29 23Sep93 KDH       For V10.2 remove sysident.h, use compile line switches
00061  *   29 29Sep93 KDH       Use intrinsic symbols where possible for machine type
00062  *   30 11oct93 kdh       change sgi to __sgi - sgi is only defined in K&R land
00063  *   31 13oct93 kdh       Workaround VAXC problem with FTRUE and FFALSE
00064  *   32 19Jul94 kdh       define TRUE and FALSE as 1 and 0
00065  *   33 25Jul94 jlm       remove _SOLARIS_SOURCE and _IRIX_SOURCE
00066  *   33                   condition token pasting on __STDC__ not VMS
00067  *   33                   do not mask redefinition of MACHINE_KNOWN
00068  *   33                   if qaz/lint define FLOGICAL as on VAX
00069  *   33                   remove hp +ppu compilation support
00070  *      24Jun94 MRA       Add date_t, true, false, constant, generic_routine_t
00071  *                                    conditional definitions (ready for obsoletion of basic.h)
00072  *                                    Also pick up definitions for SunOS (still used by IMan)
00073  *      29Jun94 MRA       Move null_date into clock.h to prevent shared library problems
00074  *      04Jul94 MRA       Don't define constant macro
00075  *      08Aug94 DRD       ip1 integration
00076  *      09Aug94 DRD       Macro paste done by comment hack on SunOS
00077  *      16Aug94 BJS       Add MAX and MIN macros
00078  *                          Force this to be "needed" for cc_check's dependency analysis
00079  *      26Aug94 MRA       Remove UNI_PASTE per Jack Marr
00080  *   34 05Aug94 dn        Remove extern modifier from FTCOMMON, thereby
00081  *                        restoring the FORTRAN COMMON storage model for
00082  *                        FCOMMON's within C object files: this is needed
00083  *                        by loadable modules
00084  *      30Aug94 DRD       define SUN to __sun on Solaris
00085  *   35 23Sep94 JLM       Windows NT (WNT) port
00086  *   36 02May95 Wei Liu   Redefine FTN()
00087  *   37 31May95 Wei Liu   Replace the definition of FTCOMMON for Bernie Solomon
00088  *   38 31May95 Wei Liu   Give a number -- 1 to WNT
00089  *   39 20Jun95 JLM       Add N_ELEMENTS macro
00090  *   40 30Jun95 JLM       Windows NT Intel port
00091  *   41 16Aug95 kdh       change msgtxt definition so that cc_check won't
00092  *            complain, also drop logical cast from true and false
00093  *   42 10Aug95 JLM       WNTI: convert to append '_' in FTN
00094  *   43 17Jan96 kdh       Add CHECKING stuff
00095  *   44 16Aug96 BJS       Revise FLOGICAL types for qaz purposes
00096  *   45 10Apr97 Reger     Add F2C friendly definitions for tags
00097  *   46 24Sep97 JLM       Move FTCOMMON to ugextern.h, include that here
00098  *   47 24Feb98 Reger     Obsolete FSINGLE as a data type
00099  *   48 30May98 Reger     Remove checks for HP/CISC, SunOS, and VMS (all
00100  *                        obsolete); remove 'FCALL'/'fcall', 'FENTRY/fentry',
00101  *                        'USE_FPTR', 'SET_FPTR', 'FSHORTINT',
00102  *                        'FULONGINT/fulongint', 'FUINTEGER/fuinteger',
00103  *                        'flogical'
00104  *   49 16Jun98 Reger     Remove 'flongint'/'fentity'/'freal'
00105  *   50 31Jul98 Reger     Remove 'finteger'
00106  *   51 26Aug98 Reger     Remove 'FLONGINT'
00107  *   52 12Jan99 Reger     Remove 'FENTITY'
00108  *   53 14Jan99 JLM       Remove 'PROTO'
00109  *   54 21Jan99 JLM       Add qaz/cc_check definition of logical
00110  *   55 17Feb99 Reger     Add 'UGEXPORT' for Windows/NT
00111  *   56 22Mar99 Reger     Remove 'FINTEGER'/'FREAL'
00112  *   57 16Aug99 Reger     Relocate to generic INCLUDE product
00113  *   58 15Oct99 Reger     Remove 'ugextern.h' and 'checking.h'
00114  *   59 07Jun00 Jaskot    Added code for IA64 port
00115  *   60 25Oct2000 Reger   Obsolete WNTA; abandon WNTI -- use WNT instead;
00116  *                        abandon UGEXPORT in favor of DLL specific decorators
00117  *   61 25Oct00 JLM       Warn about nested inclusion
00118  *   62 05Jun01 HRT       Define HP64 for 64 bit
00119  *   63 24Jul2001 Reger   Retire OSF
00120  *   64 10Sep01 JLM       Add tag_pc_t
00121 08-Apr-2003  Steve Kunkee            ARCH0015a: C++ compatibility
00122                                      add code to set up C_LINKAGE and C_LINKAGE_CPP
00123 16-Apr-2003  Steve Kunkee            change CPLUSPLUS_COMPILE to __cplusplus
00124 03-Jun-2003  KHafen                  Remove F2C_FILE
00125 10-Jun-2003   Jack Marr              Test for wnt platform via _WIN32/_WIN64
00126 24-Jul-2003  Jack Marr               Add HP IPF platform as HPI
00127 24-Mar-2004  Keith Jaskot            Ported to x64 platform
00128 03-Sep-2004  Jack Marr               Define FORCEINLINE
00129 10-Sep-2004  jdh                     logical to bool project
00130 20-Sep-2004  jdh                     more logical to bool project
00131 21-Sep-2004  jdh                     fix comments for FTN macro
00132 02-Nov-2004  Keith Jaskot        Ported to SUSE Linux
00133  *$HISTORY$
00134  */
00135 
00136 /*  <BJS> 15-Aug-94
00137     Force cc_check's dependency analysis to always assume
00138     unidefs.h is needed so it never warns to remove it.
00139     <JLM> 13-Sep-00
00140     The UG C Standards (Appendix C) require that unidefs.h be included by
00141     source files.  The top_level_only pragma will cause an error if the 
00142     first time this file is included is via nested header.  Fix this by
00143     including unidefs.h first in your source file (or after extended_source.h
00144     in those few files where that is required).  Eventually we'll 
00145     want to move the top_level_only pragma outside of the #ifndef 
00146     UNIDEFS_H_INCLUDED clause so as to warn about every nested inclusion, 
00147     not just when a source file doesn't directly include it.
00148 */
00149 #ifdef __lint
00150 #pragma uginclude needed
00151 #pragma uginclude top_level_only
00152 #pragma uginclude after_only "extended_source.h";
00153 #endif
00154 
00155 #include <stddef.h>
00156 
00157 /* use the command line definition of symbols to define the platform we're on */
00158 #if defined(__hpux)
00159 /* We are on an HPUX system, define UNX and either HPP (PA-RISC) or HPI (Itanium) */
00160 #define UNX         1
00161 #define HPUX        1
00162 #define MACHINE_KNOWN   1
00163 
00164 /* <JLM> 18-Jun-02  Distinguish PA-RISC and IPF (Itanium Processor Family) */
00165 #if defined(__hppa)
00166 #define HPP             1
00167 #elif defined(__ia64)
00168 #define HPI             1
00169 #else
00170 #error Unknown flavor of HP-UX
00171 #endif
00172 
00173 /* <HRT> 05-Jun-01 
00174    This is for 64 bit HP Unix for all HP supported architectures.  This should only be defined 
00175    when +DA2.0W compile flag is used.
00176    <JLM> 17-Aug-01
00177    Move this bit inside of HPP test.  Also define HPP32.
00178    <JLM> 18-Jun-02
00179    HPP64 should be defined when +DA2.0W or +DD64 compile flags are used.
00180  */
00181 #ifdef __LP64__
00182 #define HPP64
00183 #else
00184 #define HPP32
00185 #endif
00186 
00187 #endif
00188 
00189 #ifdef __sgi
00190 /* We are on an SGI system, define UNX and SGI */
00191 #ifndef SGI
00192 #define SGI             6
00193 #endif
00194 #ifndef UNX
00195 #define UNX         1
00196 #endif
00197 #define MACHINE_KNOWN 1
00198 #endif
00199 
00200 #ifdef __sun
00201 /* We are on a Solaris system, define UNX, SUN and SOLARIS */
00202 #ifndef SUN
00203 #define SUN             __sun
00204 #endif
00205 #ifndef SOLARIS
00206 #define SOLARIS         1
00207 #endif
00208 #ifndef UNX
00209 #define UNX         1
00210 #endif
00211 #define MACHINE_KNOWN 1
00212 
00213 /* <JLM> 17-Aug-01  Symbols to reveal data model. */
00214 #ifdef _LP64
00215 #define SOL64
00216 #else
00217 #define SOL32
00218 #endif
00219 
00220 #endif
00221 
00222 #ifdef _AIX
00223 /* We are on an IBM system, define UNX and IBM_AIX */
00224 #ifndef IBM_AIX
00225 #define IBM_AIX         5
00226 #endif
00227 #ifndef UNX
00228 #define UNX         1
00229 #endif
00230 #define MACHINE_KNOWN 1
00231 #endif
00232 
00233 /*
00234  Windows NT definitions
00235 
00236  WNT        - All Windows NT platforms (IA32 (Intel Pentium 32 bit),
00237               IA64 (Intel Itanium 64 bit)
00238  WNTI32     - Windows NT IA32 Pentium 32 bit ONLY
00239  WNTI64     - Windows NT IA64 Itanium 64 bit ONLY
00240  WNTX64     - Windows NT x64 Opteron or Coyote 64 bit ONLY
00241 */
00242 
00243 /* <JLM> 10-Jun-03  
00244  * Changed test back to _WIN32 vs _WIN64 in order to support other 
00245  * compilers, specifically the gcc/g++ compiler used for qxdb generation 
00246  * and eventually qaz checking.  _WIN64 needs to be tested first since
00247  * _WIN32 is defined in both the _M_IX86 and _M_IA64 regimes.
00248  */
00249 
00250 #if defined(_WIN64)
00251 #if defined(_M_IA64)
00252 /* We are on a 64 bit Itanium Intel system, define WNT and WNTI64 */
00253 #define WNT           1
00254 #define WNTI64      1
00255 #define MACHINE_KNOWN 1
00256 
00257 #elif defined(_M_AMD64)
00258 /* We are on a 64 bit Opteron system, define WNT and WNTX64 */
00259 #define WNT           1
00260 #define WNTX64      1
00261 #define MACHINE_KNOWN 1
00262 #endif
00263 
00264 #elif defined(_WIN32)
00265 /* We are on a 32 bit Pentium Intel system, define WNT and WNTI32 */
00266 #define WNT           1
00267 #define WNTI32      1
00268 #define MACHINE_KNOWN 1
00269 #endif
00270 
00271 /*
00272  SUSE Linux Definitions
00273 
00274  UNX Unix or Linux
00275  LNX64 SUSE Linux x86_64 only
00276 */
00277 
00278 #if defined(__linux__) && defined(__x86_64__)
00279 #define UNX             1
00280 #define LNX64           1
00281 #define MACHINE_KNOWN   1
00282 #endif
00283 
00284 #ifndef MACHINE_KNOWN
00285 #error Sorry, you have to change unidefs.h to make this work on this machine
00286 #endif
00287 
00288 /* Using strict POSIX compliance on HP's, the caddr_t typedef is hidden. 
00289  * However it is defined in the Posix.1 namespace on all of our other platforms
00290  * and is used fairly widely, so we opt to explicitly define it here for hp.
00291  */
00292 #if defined(HPP) && !defined(_CADDR_T)
00293 #define _CADDR_T
00294 typedef char *caddr_t;
00295 #elif defined(WNT)
00296 typedef char *caddr_t;
00297 #endif
00298 
00299 #ifndef TAG_T_DEFINED
00300 #define TAG_T_DEFINED
00301 
00302 typedef unsigned int tag_t, *tag_p_t;
00303 
00304 typedef const tag_t * tag_pc_t;
00305 
00306 #endif
00307 
00308 /* <JLM> 25-Jul-94
00309  * For qaz/lint let's use the VMS definition of FLOGICAL
00310  * so as to catch circumvention of the typedef
00311  * <BJS> 16-Aug-96
00312  * Revise qaz/lint version of FLOGICAL to use special
00313  * type known to cc_check
00314  */
00315 #if defined(__lint)
00316 typedef __FLOGICAL      FLOGICAL;
00317 #elif defined(WNT)
00318 typedef int             FLOGICAL;
00319 #else
00320 typedef unsigned int    FLOGICAL;
00321 #endif
00322 
00323 /* Definition of TRUE and FALSE for FORTRAN when used from C */
00324 /* <BJS> 16-Aug-96
00325  * Revise qaz/lint version of FTRUE/FFALSE to use special
00326  * definition known to cc_check
00327  */
00328 #if defined(__lint)
00329 #define FTRUE           __FTRUE
00330 #define FFALSE          __FFALSE
00331 #else
00332 #define FTRUE           ((FLOGICAL) 1)
00333 #define FFALSE          ((FLOGICAL) 0)
00334 #endif
00335 
00336 typedef void *PVOID;
00337 
00338 /*  <BJS> 21-Jul-93
00339     The typedefs for logical, tag_t and byte have been copied
00340     here from basic.h and are individually protected against
00341     multiple definition. Reduces reliance on basic.h.
00342     <JLM> 20-Jan-99
00343     Use special definition of logical for cc_check purposes.
00344     <JDH> 06-sep-2004
00345     Change over to bool type.
00346 */
00347 #ifndef LOGICAL_DEFINED
00348 #define LOGICAL_DEFINED
00349 #ifdef __cplusplus
00350 typedef bool logical;
00351 #else
00352 typedef unsigned char logical;
00353 #endif /* __cplusplus */
00354 #endif /* LOGICAL_DEFINED */
00355 
00356 #ifndef BYTE_DEFINED
00357 #define BYTE_DEFINED
00358 typedef unsigned char byte;
00359 #endif
00360 
00361 /* Postpend an '_' on FORTRAN symbols referenced from C (if needed) and QAZ.
00362  * <JLM> 27-Oct-03
00363  * Remove FTN test so we can detect redefinition, and add symbol to minimize
00364  * need to port code that needs to know about the need for an underscore.
00365  *
00366  * <JDH> no-op the FTN macro because we no longer support FORTRAN.
00367  */
00368 #ifndef FTN
00369 #define FTN(name) name
00370 #endif
00371 
00372 /*  <MRA> 24-Jun-94
00373     Definitions of true and false copied over from basic.h
00374     ready for its obsoletion.
00375     <KDH> 06-Sep-95
00376     Drop the logical cast for true and false, so they match TRUE and FALSE
00377 */
00378 #ifndef __cplusplus
00379 #ifndef true
00380 #define true 1
00381 #endif
00382 #ifndef false
00383 #define false 0
00384 #endif
00385 #endif
00386 /*
00387     <KDH> 07-Jul-94
00388     Add definition of TRUE and FALSE
00389 */
00390 #ifndef TRUE
00391 #define TRUE  1
00392 #endif
00393 #ifndef FALSE
00394 #define FALSE 0
00395 #endif
00396 
00397 /*  <BJS> 15-Aug-94
00398     And definitions of the common MIN/MAX macros.
00399 */
00400 #ifndef MIN
00401 #define MIN(a,b) (((a)<(b))?(a):(b))
00402 #endif
00403 #ifndef MAX
00404 #define MAX(a,b) (((a)>(b))?(a):(b))
00405 #endif
00406 
00407 #define NULENT 0
00408 
00409 #define PI     3.14159265358979324
00410 #define TWOPI  6.28318530717958648
00411 #define RADEG 57.29577951308235
00412 #define DEGRA   .01745329251994328
00413 
00414 /*  <MRA> 24-Jun-94
00415     Definitions of the null tag copied over from basic.h ready
00416     for basic.h's obsoletion.
00417 */
00418 #ifndef NULL_TAG
00419 #define NULL_TAG      ((tag_t)0)
00420 #endif
00421 #ifndef null_tag
00422 #define null_tag      ((tag_t)0)
00423 #endif
00424 
00425 #ifndef DATE_T_DEFINED
00426 #define DATE_T_DEFINED
00427 /*  Structure for holding dates
00428     When saved this ought to be in GMT/UTC
00429 
00430     Now values are:
00431         year   - 1989
00432         month  - 0..11
00433         day    - 1..28/29/30/31
00434         hour   - 0..23
00435         minute - 0..59
00436         second - 0..59
00437 
00438     <MRA> 24-Jun-94
00439     Copied over from basic.h ready for basic.h's obsoletion.
00440 
00441     <MRA> 29-Jun-94
00442     null_date now in clock.h instead to prevent shared library
00443     confusion.
00444 */
00445 
00446 typedef struct date_s
00447    { short year;
00448      byte month;
00449      byte day;
00450      byte hour;
00451      byte minute;
00452      byte second;
00453    } date_t, *date_p_t;
00454 #endif
00455 
00456 /*  <ARMB>  7-May-93
00457     Casting to void* does not necessarily work for function pointers,
00458     but all function pointer types can be cast to each other, so long as they
00459     are correctly cast back before using to call.
00460     Here is a type for things that take different function pointers to be cast
00461     too.
00462 
00463     <MRA> 24-Jun-94
00464     Copied over from basic.h ready for basic.h's obsoletion.
00465 */
00466 #ifndef GENERIC_ROUTINE_T_DEFINED
00467 #define GENERIC_ROUTINE_T_DEFINED
00468 typedef void* (*generic_routine_t)(void);
00469 #endif
00470 
00471 /*  <MRA> 12-Feb-93
00472     This macro is wrapped around UG strings that need to be converted to
00473     users' native languages (NLM).  Since some of these strings are present
00474     in the OM error reporting code, the definition needs to be in a file
00475     available to all UG code and to Infomanager code too.
00476 
00477     <MRA> 24-Jun-94
00478     Copied over from basic.h ready for basic.h's obsoletion.
00479     <kdh> 16-Aug-95
00480     MSGTXT used to be defined as MSGTXT(s) (s)  This caused qaz errors, so
00481     we have simplified the definition.
00482     <JLM> 17-Aug-01
00483     Remove redefinition protection, since we really want to know about that.
00484 */
00485 
00486 #define MSGTXT(s) s
00487 
00488 /* 
00489  *  <JLM> 20-Jun-95
00490  *  Macro N_ELEMENTS which determines the number of elements in an
00491  *  array of any type.  Example usage:
00492  *  qsort(list, N_ELEMENTS(list), sizeof(list[0]), compare);
00493  *  for (indx=0; indx<N_ELEMENTS(list); indx++) {
00494  */
00495 #define N_ELEMENTS(array) (sizeof(array)/sizeof(array[0]))
00496 
00497 /*  <SDK> 24-Feb-2003
00498     These macros are used to ensure that under a C++ compile the symbols
00499     found in LDR_find_symbol calls are C linkage.  C_LINKAGE must always
00500     be defined, either "C" or empty.
00501 */
00502 #ifdef __cplusplus
00503 #define C_LINKAGE "C"
00504 #else
00505 #define C_LINKAGE
00506 #endif
00507 
00508 /*  <JLM> 03-Sep-04
00509  *  Macro FORCEINLINE *mandates* that a function be inlined on platforms that
00510  *  support such a feature (currently only Windows).  This macro should be 
00511  *  used sparingly.  In general you should use the "inline" keyword to *ask* 
00512  *  that a function be inlined, rather than mandate it.  
00513  *
00514  *  From the MS documentation:
00515  *  The __forceinline keyword overrides the cost/benefit analysis 
00516  *  and relies on the judgment of the programmer instead. Exercise 
00517  *  caution when using __forceinline. Indiscriminate use of 
00518  *  __forceinline can result in larger code with only marginal 
00519  *  performance gains or, in some cases, even performance losses 
00520  *  (due to increased paging of a larger executable, for example).
00521  */
00522 #ifndef FORCEINLINE
00523 #if (_MSC_VER >= 1200)
00524 #define FORCEINLINE __forceinline
00525 #elif defined(__cplusplus)
00526 #define FORCEINLINE inline
00527 #else
00528 #define FORCEINLINE
00529 #endif
00530 #endif
00531 
00532 #endif /* UNIDEFS_H_INCLUDED */