Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
sgidefs.h
Go to the documentation of this file.
00001 
00002 /*
00003 
00004   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00005 
00006   This program is free software; you can redistribute it and/or modify it
00007   under the terms of version 2 of the GNU General Public License as
00008   published by the Free Software Foundation.
00009 
00010   This program is distributed in the hope that it would be useful, but
00011   WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00013 
00014   Further, this software is distributed without any warranty that it is
00015   free of the rightful claim of any third person regarding infringement 
00016   or the like.  Any license provided herein, whether implied or 
00017   otherwise, applies only to this software file.  Patent licenses, if 
00018   any, provided herein do not apply to combinations of this program with 
00019   other software, or any other product whatsoever.  
00020 
00021   You should have received a copy of the GNU General Public License along
00022   with this program; if not, write the Free Software Foundation, Inc., 59
00023   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00024 
00025   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00026   Mountain View, CA 94043, or:
00027 
00028   http://www.sgi.com
00029 
00030   For further information regarding this notice, see:
00031 
00032   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00033 
00034 */
00035 
00036 #ifndef __SGIDEFS_H__
00037 #define __SGIDEFS_H__
00038 
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042 
00043 
00044 /*
00045  * sgidefs.h - SGI/MIPS basic software generation system constants & types
00046  *
00047  * This file MUST be includable in any language
00048  * and in the 'C' case must be ANSI compliant
00049  * In particular this means NO long long ...
00050  *
00051  * Constants and types defined here are to support
00052  * multi-isa (instruction set architecture) coding
00053  *
00054  * Each catagory has a define that the compilation system will set
00055  * based on the environment the compile is initiated in. Programs
00056  * can test the define using the manifest constants defined here.
00057  * (e.g. #if (_MIPS_FPSET == 16) )
00058  */
00059 
00060 /*
00061  * Floating Point register set
00062  * Define:
00063  *      _MIPS_FPSET
00064  * Can take on the values 16 or 32
00065  */
00066 
00067 /*
00068  * Instruction Set Architecture
00069  * Define:
00070  *      _MIPS_ISA
00071  */
00072 #define _MIPS_ISA_MIPS1 1       /* R2/3K */
00073 #define _MIPS_ISA_MIPS2 2       /* R4K/6K */
00074 #define _MIPS_ISA_MIPS3 3       /* R4K */
00075 #define _MIPS_ISA_MIPS4 4       /* TFP */
00076 
00077 /*
00078  * Subprogram Interface Model
00079  * Define:
00080  *      _MIPS_SIM
00081  */
00082 #define _MIPS_SIM_ABI32         1       /* MIPS MSIG calling convention */
00083 #define _MIPS_SIM_NABI32        2       /* MIPS new 32-bit abi */
00084                 /* NABI32 is 64bit calling convention but 32bit type sizes) */
00085 #define _MIPS_SIM_ABI64         3       /* MIPS 64 calling convention */
00086 
00087 /*
00088  * Data Types Sizes (C and C++)
00089  * Defines:
00090  *      _MIPS_SZINT
00091  *      _MIPS_SZLONG
00092  *      _MIPS_SZPTR
00093  *
00094  * These can take on the values: 32, 64, 128
00095  */
00096 
00097 /*
00098  * Compilation Environments
00099  *      The compiler can offer a set of different compilation environments.
00100  *      Each one will pre-define the above defines appropriately.
00101  *      If you use the _MIPS_* defines, you should include this header file.
00102  *      In order to avoid problems when sgidefs.h is not included, the driver
00103  *      predefines _MIPS_ISA and _MIPS_SIM to be the actual values (1-4) 
00104  *      rather than the _MIPS_* names (otherwise, if sgidefs.h is not 
00105  *      included, we would be defining _MIPS_SIM to be an undefined value).
00106  * 
00107  * The following #if conditions will be true in each environment:
00108  *      The MIPS ABI (-o32) environment:
00109  *      _MIPS_ISA == _MIPS_ISA_MIPS1 or _MIPS_ISA_MIPS2
00110  *      _MIPS_SIM == _MIPS_SIM_ABI32
00111  *      _MIPS_FPSET == 16
00112  *      _MIPS_SZINT == 32
00113  *      _MIPS_SZLONG == 32
00114  *      _MIPS_SZPTR == 32
00115  *
00116  *      The new MIPS 32-bit ABI (-n32) environment:
00117  *      _MIPS_ISA == _MIPS_ISA_MIPS3 or _MIPS_ISA_MIPS4
00118  *      _MIPS_SIM == _MIPS_SIM_NABI32
00119  *      _MIPS_FPSET == 32
00120  *      _MIPS_SZINT == 32
00121  *      _MIPS_SZLONG == 32
00122  *      _MIPS_SZPTR == 32
00123  *
00124  *      The MIPS 64-bit ABI (-64) environment:
00125  *      _MIPS_ISA == _MIPS_ISA_MIPS3 or _MIPS_ISA_MIPS4
00126  *      _MIPS_SIM == _MIPS_SIM_ABI64
00127  *      _MIPS_FPSET == 32
00128  *      _MIPS_SZINT == 32
00129  *      _MIPS_SZLONG == 64
00130  *      _MIPS_SZPTR == 64 
00131  */
00132 
00133 /*
00134  * Language Specific
00135  * Type __psint_t - a pointer sized int - this can be used:
00136  *      a) when casting a pointer so can perform e.g. a bit operation
00137  *      b) as a return code for functions incorrectly typed as int but
00138  *         return a pointer.
00139  * User level code can also use the ANSI std ptrdiff_t, defined in stddef.h
00140  *      in place of __psint_t
00141  * Type __scint_t - a 'scaling' int - used when in fact one wants an 'int'
00142  *      that scales when moving to say 64 bit. (e.g. byte counts, bit lens)
00143  */
00144 
00145 #if (defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS))
00146 
00147 /*
00148  * assumes int is 32 -
00149  * otherwise there must be some other compiler basic type
00150  */
00151 #if (_MIPS_SZINT != 32)
00152 #ifdef _MIPS_SZINT
00153 ERROR -- the macro "_MIPS_SZINT" is set to _MIPS_SZINT -- should be 32
00154 #else
00155 ERROR -- the macro "_MIPS_SZINT" is unset (currently, must be set to 32)
00156 #endif
00157 #endif
00158 
00159 typedef int __int32_t;
00160 typedef unsigned  __uint32_t;
00161 
00162 #if (_MIPS_SZLONG == 64)
00163 
00164 typedef long __int64_t;
00165 typedef unsigned long __uint64_t;
00166 
00167 #else
00168 
00169 /*
00170  *      64-bit integer types
00171  *
00172  *  (1) In Irix6.1, the compiler implements a new internal type
00173  *      called  __long_long.   It's purpose is to allow SGI to
00174  *      define  __int64_t  and __uint64_t  without using
00175  *      long long or structs or unions.  
00176  *
00177  *      The reason for this is that several types in Irix are
00178  *      being (or will be) promoted to 64-bit integers and will
00179  *      be typedef'd as either __int64_t  or __uint64_t.  If
00180  *      these types are defined using  long long, then ANSI 
00181  *      requires the C compiler to complain because long long
00182  *      is not standard conforming.  If these types are defined
00183  *      using a struct or a union, then the programmer can not
00184  *      use them in arithmetic statements.  The solution we
00185  *      adopted was to create a new internal type,  __long_long,
00186  *      that is a synonym for  long long, but whose use does
00187  *      not violate ANSI rules.
00188  *
00189  *      NOTE:   __long_long should not be used anyplace other than
00190  *              in this header file.  All other 64-bit integer
00191  *              types should be defined in terms of __int64_t 
00192  *              or __uint64_t.
00193  *
00194  *      
00195  *  (2) The reason for the messy set of defines that follow is
00196  *      that some compilers (old CFRONT, and cc68k) do not
00197  *      use __long_long.  Therefore, we allow each to choose
00198  *      which of the following three definitions of 64-bit ints
00199  *      they want to use:
00200  *              1.      long long
00201  *              2.      __long_long
00202  *              3.      struct { ... }
00203  */
00204 #if defined(_LONGLONG)
00205         /*  Its alright to use long long in definitions  */
00206 typedef long long __int64_t;
00207 typedef unsigned long long  __uint64_t;
00208 
00209 #else
00210 #if (defined(__cplusplus) && !defined(__EDG)) || defined(m68000)
00211         /*  old cfront and cc68k can handle neither 
00212          *  long long nor __long_long, so we must use
00213          *  a structure definition
00214          */
00215 typedef union {
00216         struct {        
00217                 int hi32;
00218                 int lo32;
00219         } hilo;
00220         double align;           /* to force 64-bit alignment */
00221 } __int64_t;
00222 typedef union {
00223         struct {
00224                 unsigned int hi32;
00225                 unsigned int lo32;
00226         } hilo;
00227         double align;           /* to force 64-bit alignment */
00228 } __uint64_t;
00229 
00230 #else
00231 
00232 /* __long_long is a hidden builtin, ansi-compliant 64-bit type */
00233 typedef __long_long __int64_t;
00234 typedef unsigned __long_long __uint64_t;
00235 
00236 #endif /* __cplusplus */
00237 #endif /* _LONGLONG */
00238 
00239 #endif /* _MIPS_SZLONG */
00240 
00241 #if (_MIPS_SZPTR == 32)
00242 typedef __int32_t __psint_t;
00243 typedef __uint32_t __psunsigned_t;
00244 #endif
00245 
00246 #if (_MIPS_SZPTR == 64)
00247 typedef __int64_t __psint_t;
00248 typedef __uint64_t __psunsigned_t;
00249 #endif
00250 
00251 /*
00252  * If any fundamental type is 64 bit, then set the scaling type
00253  * to 64 bit
00254  */
00255 #if (_MIPS_SZPTR == 64) || (_MIPS_SZLONG == 64) || (_MIPS_SZINT == 64)
00256 
00257 /* there exists some large fundamental type */
00258 typedef __int64_t __scint_t;
00259 typedef __uint64_t __scunsigned_t;
00260 
00261 #else
00262 
00263 /* a 32 bit world */
00264 typedef __int32_t __scint_t;
00265 typedef __uint32_t __scunsigned_t;
00266 
00267 #endif 
00268 
00269 #endif /* C || C++ */
00270 
00271 #ifdef __cplusplus
00272 }
00273 #endif
00274 
00275 #endif /* !__SGIDEFS_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines