00001 #ifndef _jrtypes_h_included_ 00002 #define _jrtypes_h_included_ 00003 00004 /*! 00005 * @file jrtypes.h 00006 * 00007 * @brief Java architecture types, including those defined 00008 * by @c @b <jni.h>, plus real machine mappings of Java types. 00009 * 00010 * Convenient typedefs of both categories are also defined here. 00011 * 00012 * These definitions distinguish between Java types and real machine 00013 * types so as to keep the developer organized as to which is which 00014 * in processing scenarios. The Java types begin with @p @b j and the 00015 * real machine types begin with @p @b r. 00016 * 00017 * The main exception to this is the JVM class file definitions from 00018 * the JVM spec, section 4, as implemented by 00019 * @link jvm/src/classfile.h classfile.h@endlink. These 00020 * are followed without exception. In fact, a number of common 00021 * type definitions are based on them. The 00022 * @link #jvm_class_index jvm_XXX_index@endlink types 00023 * are typically either direct class file references (such as 00024 * @link #jvm_object_hash jvm_object_hash@endlink or 00025 * @link #jvm_field_index jvm_field_index@endlink) or are real machine 00026 * definitions that directly support JVM processing structures 00027 * (such as @link #jvm_class_index jvm_class_index@endlink or 00028 * @link #jvm_field_lookup_index jvm_field_lookup_index@endlink). 00029 * 00030 * The other common usage of a prefix is for variables. It is not 00031 * related to this issue at all. In this situation, the letter @b p 00032 * will typically be prefixed to pointers to/of any type in either 00033 * processing domain. 00034 * 00035 * The use of raw, native, 'C' language types such as @c @b int should 00036 * be restricted to system calls and library references such as 00037 * @c @b open(2) or @c @b strcmp(3), respectively-- also the command 00038 * line @c @b main() parameters, which get propagated into 00039 * @link #argv_helpmsg() argv_XXX()@endlink functions. 00040 * Let the compiler perform any typing and sizing, which is unlikely, 00041 * but keep @e all other usages to the Java @c @b jTYPEDEF and real 00042 * machine @c @b rTYPEDEF representations. This single exception should 00043 * be obvious when it occurs, and developers should be aware that this 00044 * convention is used ubiquitously throughout the code. 00045 * 00046 * Although definitions used by the JNI interface are found here, 00047 * JNI is kept as a STRICTLY SEPARATE part of the code, and 00048 * @c @b <jni.h> is ONLY used there, namely in the @b ../include 00049 * area. 00050 * 00051 * @note The @e only place that JNI definitions are used is in the 00052 * @c @b JniSomeJavaClassWithNativeMethods.c source file as 00053 * found in its @c @b some.java.class.with.native.methods 00054 * directory. For example, the Java class 00055 * @c @b java.lang.Object has its Java source file stored 00056 * in @link jni/src/harmony/generic/0.0/src/java/lang/Object.java 00057 jni/src/vendor/product/version/src/java/lang/Object.java@endlink, 00058 * with its native support found in the 'C' source file 00059 * @link jni/src/harmony/generic/0.0/src/java_lang_Object.c 00060 jni/src/vendor/product/version/src/java_lang_Object.c@endlink. 00061 * The JNI header used to access this native 00062 * @c @b java.lang.Object code is found in the related 00063 * @b include directory as 00064 * @link jni/src/harmony/generic/0.0/include/java_lang_Object.h 00065 jni/src/vendor/product/version/include/java_lang_Object.h@endlink. 00066 * 00067 * 00068 * @section Control 00069 * 00070 * \$URL: https://svn.apache.org/path/name/jrtypes.h $ \$Id: jrtypes.h 0 09/28/2005 dlydick $ 00071 * 00072 * Copyright 2005 The Apache Software Foundation 00073 * or its licensors, as applicable. 00074 * 00075 * Licensed under the Apache License, Version 2.0 ("the License"); 00076 * you may not use this file except in compliance with the License. 00077 * You may obtain a copy of the License at 00078 * 00079 * http://www.apache.org/licenses/LICENSE-2.0 00080 * 00081 * Unless required by applicable law or agreed to in writing, 00082 * software distributed under the License is distributed on an 00083 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 00084 * either express or implied. 00085 * 00086 * See the License for the specific language governing permissions 00087 * and limitations under the License. 00088 * 00089 * @version \$LastChangedRevision: 0 $ 00090 * 00091 * @date \$LastChangedDate: 09/28/2005 $ 00092 * 00093 * @author \$LastChangedBy: dlydick $ 00094 * Original code contributed by Daniel Lydick on 09/28/2005. 00095 * 00096 * @section Reference 00097 * 00098 */ 00099 00100 ARCH_COPYRIGHT_APACHE(jrtypes, h, "$URL: https://svn.apache.org/path/name/jrtypes.h $ $Id: jrtypes.h 0 09/28/2005 dlydick $"); 00101 00102 00103 /*! 00104 * @name Java architecture primative types. 00105 * 00106 * @brief Real machine implementation of Java primative types. 00107 */ 00108 00109 /*@{ */ /* Begin grouped definitions */ 00110 00111 #define JBITS 8 /**< Number of bits per byte in JVM*/ 00112 00113 typedef signed char jbyte; /**< Java @c @b (byte) */ 00114 00115 typedef unsigned char jboolean; /**< Java @c @b (boolean) */ 00116 00117 typedef signed short jshort; /**< Java @c @b (short) */ 00118 00119 typedef unsigned short jchar; /**< Java @c @b (char) */ 00120 00121 typedef signed int jint; /**< Java @c @b (int) */ 00122 00123 #ifdef CONFIG_WORDWIDTH64 00124 00125 typedef signed long jlong; /**< Java @c @b (long) */ 00126 00127 #else 00128 00129 typedef signed long long jlong; /**< Java @c @b (long) */ 00130 00131 #endif 00132 00133 typedef float jfloat; /**< Java @c @b (float) */ 00134 00135 typedef double jdouble; /**< Java @c @b (double) */ 00136 00137 typedef void jvoid; /**< Java @c @b (void) 00138 * is @e not found in 00139 * @c @b <jni.h> !!! It is used 00140 * here to be consistent with 00141 * separation of Java vs real 00142 * machine data types. Also defined 00143 * for our JNI purposes in @link 00144 jvm/include/jlObject.h 00145 jlObject.h@endlink 00146 */ 00147 00148 /*@} */ /* End of grouped definitions */ 00149 00150 00151 /*! 00152 * @name Java keywords 00153 * 00154 * @brief Real machine implementation of selected Java keywords. 00155 */ 00156 00157 /*@{ */ /* Begin grouped definitions */ 00158 00159 extern const jvoid *jnull; /**< Java constant 00160 * @c @b null */ 00161 00162 extern const jboolean jfalse; /**< Java constant 00163 * @c @b false */ 00164 00165 extern const jboolean jtrue; /**< Java constant 00166 * @c @b true */ 00167 00168 /*@} */ /* End of grouped definitions */ 00169 00170 00171 /*! 00172 * @name Java Native Interface definitions. 00173 * 00174 * @brief Selected JNI definitions needed by this implementation for 00175 * JNI interface purposes, but @e never used in the core code. 00176 */ 00177 00178 /*@{ */ /* Begin grouped definitions */ 00179 00180 #define JNI_FALSE 0 /**< Defined by <jni.h> 00181 * (@e never used in core code) */ 00182 00183 #define JNI_TRUE 1 /**< Defined by <jni.h> 00184 * (@e never used in core code) */ 00185 00186 /*@} */ /* End of grouped definitions */ 00187 00188 00189 /*! 00190 * @name Unsigned equivalents to Java primative types. 00191 * 00192 * @brief Convenient workarounds for unsigned typesthat are 00193 * really @e not in Java. 00194 * 00195 * These types are really @e faux, but are needed for internal 00196 * implementation convenience or for more refined semantic 00197 * interpretation of JVM spec fields. 00198 */ 00199 00200 /*@{ */ /* Begin grouped definitions */ 00201 00202 typedef unsigned char jubyte; /**< Unsigned equivalent of 00203 * Java (byte) */ 00204 00205 typedef unsigned short jushort; /**< Unsigned equivalent of 00206 * Java (short) */ 00207 00208 typedef unsigned int juint; /**< Unsigned equivalent of 00209 * Java (int) */ 00210 00211 #ifdef CONFIG_WORDWIDTH64 00212 00213 typedef unsigned long julong; /**< Unsigned equivalent of 00214 * Java (long) */ 00215 00216 #else 00217 00218 typedef unsigned long long julong; /**< Unsigned equivalent of 00219 * Java (long) */ 00220 00221 #endif 00222 00223 /*@} */ /* End of grouped definitions */ 00224 00225 00226 /*! 00227 * @name Classfile primative types. 00228 * 00229 * @brief Streams of unsigned bytes in the Java class file. 00230 * 00231 * The definitions of @link #u1 u1@endlink and @link #u2 u2@endlink 00232 * and @link #u4 u4@endlink are here so a to decouple these ubiquitous 00233 * symbols from class file work. 00234 * 00235 * Notice that, depending on context, these three definitions 00236 * may be either signed or unsigned. For this implementation, 00237 * there will be no further distinction made other than the 00238 * @c @b unsigned declarations of these symbols. In most cases in 00239 * the spec, usage is unsigned, namely counts, lengths, indices, 00240 * enumerations, JDK program counter values, etc. The only 00241 * significant exception is the CONSTANT_Integer_info.bytes 00242 * structure, which is still not adjusted for real machine 00243 * byte ordering, also CONSTANT_Float_info.bytes and their 00244 * (long) and (double) equivalents, having two u4 items. 00245 * 00246 */ 00247 00248 /*@{ */ /* Begin grouped definitions */ 00249 00250 typedef jubyte u1; /**< Single byte */ 00251 00252 typedef jushort u2; /**< Two bytes, like an 00253 <b><code>unsigned short</code></b> */ 00254 00255 typedef juint u4; /**< Four bytes, like an 00256 <b><code>unsigned int</code></b> */ 00257 00258 /*@} */ /* End of grouped definitions */ 00259 00260 00261 /*! 00262 * @name Real machine types. 00263 * 00264 * @brief Real machine abstraction of real machine primative types. 00265 * With the exception of library(3) and system(2) calls, which use 00266 * the types mandated in their man pages, @e all real machine 00267 * primative types use these abstractions. This should significantly 00268 * ease portability problems. 00269 */ 00270 00271 /*@{ */ /* Begin grouped definitions */ 00272 00273 typedef signed char rchar; /**< Normal 8-bit 'C' character */ 00274 00275 typedef unsigned char rbyte; /**< 8-bit byte for any purpose */ 00276 00277 typedef unsigned char rboolean; /**< Boolean for any purpose */ 00278 00279 typedef signed short rshort; /**< Signed 16-bit integer */ 00280 00281 typedef unsigned short rushort; /**< Unsigned 16-bit integer */ 00282 00283 typedef signed int rint; /**< Signed 32-bit integer */ 00284 00285 typedef unsigned int ruint; /**< Unsigned 32-bit integer */ 00286 00287 00288 #ifdef CONFIG_WORDWIDTH64 00289 00290 typedef signed long rlong; /**< Signed 64-bit integer */ 00291 00292 typedef unsigned long rulong; /**< Unsigned 64-bit integer */ 00293 00294 #else 00295 00296 typedef signed long long rlong; /**< Signed 64-bit integer */ 00297 00298 typedef unsigned long long rulong; /**< Unsigned 64-bit integer */ 00299 00300 #endif 00301 00302 typedef float rfloat; /**< Real machine 00303 * @c @b (float) */ 00304 00305 typedef double rdouble; /**< Real machine 00306 * @c @b (double) */ 00307 00308 typedef void rvoid; /**< Real machine 00309 * @c @b (void), 00310 * for pointers, 00311 * @c @b (void *), 00312 * untyped */ 00313 00314 /*@} */ /* End of grouped definitions */ 00315 00316 00317 /*! 00318 * @name Selected manifest constants. 00319 * 00320 * @brief Common macros used commonly in 'C' code. 00321 * Only permit use of @c @b \#define's in constant 00322 * definition source file, in static initialization, 00323 * and in selected @c @b switch statements. 00324 * 00325 * Most of these constants are found in some @b /usr/include directories 00326 * on some platforms, but not others, and not regularly defined between 00327 * platforms. Also, remove misc. inconsistencies in @c @b \#define 00328 * usage amongst compilers. 00329 */ 00330 00331 /*@{ */ /* Begin grouped definitions */ 00332 00333 #ifndef ERROR0 00334 00335 #define ERROR0 0 /**< Typically found in <errno.h> 00336 * or <sys/errno.h> 00337 */ 00338 00339 #endif 00340 00341 /*! 00342 * @internal Destroy any pre-existing version (or even conflicting 00343 * versions) of several common symbols, then define them explicitly 00344 * for this compile environment. 00345 */ 00346 #ifdef NULL 00347 #undef NULL 00348 #endif 00349 00350 #ifdef TRUE 00351 #undef TRUE 00352 #endif 00353 00354 #ifdef FALSE 00355 #undef FALSE 00356 #endif 00357 00358 /*! 00359 * @name Symbols to avoid. 00360 * 00361 * In order to keep away from definitions of @c @B TRUE, @c @b FALSE, 00362 * and @c @b NULL that may be defined all over the place, these 00363 * symbols have been replaced in the real machine domain with 00364 * @link #rtrue rtrue@endlink, @link #rfalse rfalse@endlink, and 00365 * @link #rnull rnull@endlink. They have been replaced in the 00366 * Java virtual machine domain by 00367 * @link #jtrue jtrue@endlink, @link #jfalse jfalse@endlink, and 00368 * @link #jnull jnull@endlink. 00369 * 00370 */ 00371 00372 /*@{ */ /* Begin grouped definitions */ 00373 00374 #define TRUE DO_NOT_USE_TRUE /**< Please use either @link #rtrue 00375 rtrue@endlink for real machine 00376 @c @b TRUE cases or @link #jtrue 00377 jtrue@endlink for Java virtual 00378 machine @c @b TRUE cases */ 00379 00380 #define FALSE DO_NOT_USE_FALSE /**< Please use either @link #rfalse 00381 rfalse@endlink for real machine 00382 @c @b FALSE cases or @link #jfalse 00383 jfalse@endlink for Java virtual 00384 machine @c @b FALSE cases */ 00385 00386 #define NULL DO_NOT_USE_NULL /**< Please use @link #rnull 00387 rnull@endlink for real machine 00388 @c @b NULL cases or @link #jnull 00389 jnull@endlink for Java virtual 00390 machine @c @b NULL cases */ 00391 00392 /*@} */ /* End of grouped definitions */ 00393 00394 #ifdef I_AM_JRTYPES_C 00395 #undef NULL 00396 #define NULL ((rvoid *) 0) /**< Null pointer value */ 00397 00398 #undef TRUE 00399 #define TRUE ((rboolean) 1) /**< Boolean "true" value */ 00400 00401 #undef FALSE 00402 #define FALSE ((rboolean) 0) /**< Boolean "false" value */ 00403 00404 #define NEITHER_TRUE_NOR_FALSE ((rboolean) 2) /**< Value for 00405 * initializing a boolean to 00406 * "not initialized, that is, 00407 * neither TRUE nor FALSE". 00408 */ 00409 00410 #endif 00411 00412 #define CHEAT_AND_USE_FALSE_TO_INITIALIZE ((rboolean) 0) /**< 00413 * Permit boolean "false" manifest 00414 * constant for initializing static 00415 * and global storage. 00416 */ 00417 00418 #define CHEAT_AND_USE_TRUE_TO_INITIALIZE ((rboolean) 1) /**< 00419 * Permit boolean "true" manifest 00420 * constant for initializing static 00421 * and global storage. 00422 */ 00423 00424 #define CHEAT_AND_USE_NULL_TO_INITIALIZE ((rvoid *) 0) /**< 00425 * Permit null pointer manifest 00426 * constant for initializing static 00427 * and global storage. 00428 */ 00429 00430 #define CHEAT_AND_ALLOW_NULL_CLASS_INDEX ((jvm_class_index) 0) /**< 00431 * Permit null class index manifest 00432 * constant for initializing static 00433 * and global storage. 00434 */ 00435 00436 #define CHEAT_AND_ALLOW_NULL_OBJECT_HASH ((jvm_object_hash) 0) /**< 00437 * Permit null object hash manifest 00438 * constant for initializing static 00439 * and global storage. 00440 */ 00441 00442 #define CHEAT_AND_ALLOW_NULL_THREAD_INDEX ((jvm_thread_index) 0) /**< 00443 * Permit null thread index manifest 00444 * constant for initializing static 00445 * and global storage. 00446 */ 00447 00448 /*@} */ /* End of grouped definitions */ 00449 00450 00451 /*! 00452 * @name Real machine constants. 00453 * 00454 * @brief Real machine implementation of common industry keywords. 00455 * 00456 * Instead of permitting unrestrained and potentially misuse and 00457 * abuse of the common macros @c @b NULL, @c @b TRUE, 00458 * and @c @b FALSE, including conflicting definitions in 00459 * various header files, these symbols have been declared explicitly 00460 * for this program and stored into global constants. This should 00461 * also help in development for more accurate typing of expressions, 00462 * paramters, and return values. A boolean "not initialized" value 00463 * is also defined. 00464 * 00465 * Use @link #rnull rnull@endlink in all cases except 00466 * static initalization. Use @link #rtrue rtrue@endlink and 00467 * $@link #rfalse rfalse@endlink in all cases except static 00468 * initialization and @c @b while(TRUE) constructions just 00469 * before end of function definitions (some compilers complain about 00470 * missing return statements, see several examples). 00471 * In this manner, it will @e always be very clear as to whether a 00472 * @c @b NULL pointer is a Java null pointer or a real 00473 * machine null pointer, likewise a Java boolean or a real machine 00474 * boolean. 00475 */ 00476 00477 /*@{ */ /* Begin grouped definitions */ 00478 00479 extern const void *rnull; /**< Real machine constant 00480 * @c @b NULL 00481 */ 00482 00483 extern const rboolean rfalse; /**< Real machine constant 00484 * @c @b FALSE 00485 */ 00486 00487 extern const rboolean rtrue; /**< Real machine constant 00488 * @c @b TRUE 00489 */ 00490 00491 extern const rboolean rneither_true_nor_false; /**< 00492 * Real machine constant @b neither. 00493 * Typically used during 00494 * initialization to indicate a 00495 * boolean is not ready. 00496 */ 00497 00498 /*@} */ /* End of grouped definitions */ 00499 00500 #endif /* _jrtypes_h_included_ */ 00501 00502 00503 /* EOF */ 00504