Back to index

lightning-sunbird  0.9+nobinonly
jri_md.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 /*******************************************************************************
00039  * Java Runtime Interface - Machine Dependent Types
00040  ******************************************************************************/
00041  
00042 #ifndef JRI_MD_H
00043 #define JRI_MD_H
00044 
00045 #include <assert.h>
00046 #include "prtypes.h" /* Needed for HAS_LONG_LONG ifdefs */
00047 
00048 #ifdef __cplusplus
00049 extern "C" {
00050 #endif
00051 
00052 /*******************************************************************************
00053  * WHAT'S UP WITH THIS FILE?
00054  * 
00055  * This is where we define the mystical JRI_PUBLIC_API macro that works on all
00056  * platforms. If you're running with Visual C++, Symantec C, or Borland's 
00057  * development environment on the PC, you're all set. Or if you're on the Mac
00058  * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't
00059  * matter.
00060  *
00061  * On UNIX though you probably care about a couple of other symbols though:
00062  *     IS_LITTLE_ENDIAN must be defined for little-endian systems
00063  *     HAVE_LONG_LONG must be defined on systems that have 'long long' integers
00064  *     HAVE_ALIGNED_LONGLONGS must be defined if long-longs must be 8 byte aligned
00065  *     HAVE_ALIGNED_DOUBLES must be defined if doubles must be 8 byte aligned
00066  *     IS_64 must be defined on 64-bit machines (like Dec Alpha)
00067  ******************************************************************************/
00068 
00069 /* DLL Entry modifiers... */
00070 
00071 /* PC */
00072 #if defined(XP_OS2)
00073 #  ifdef XP_OS2_VACPP
00074 #        define JRI_PUBLIC_API(ResultType)           ResultType _Optlink
00075 #        define JRI_PUBLIC_VAR(VarType)        VarType
00076 #     define JRI_CALLBACK
00077 #  else
00078 #        define JRI_PUBLIC_API(ResultType)           ResultType
00079 #        define JRI_PUBLIC_VAR(VarType)        VarType
00080 #     define JRI_CALLBACK
00081 #  endif
00082 #elif defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32)
00083 #      include <windows.h>
00084 #      if defined(_MSC_VER) || defined(__GNUC__)
00085 #             if defined(WIN32) || defined(_WIN32)
00086 #                    define JRI_PUBLIC_API(ResultType)  __declspec(dllexport) ResultType
00087 #                    define JRI_PUBLIC_VAR(VarType)        VarType
00088 #                    define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType
00089 #                    define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType
00090 #                    define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType
00091 #                    define JRI_CALLBACK
00092 #             else /* !_WIN32 */
00093 #                 if defined(_WINDLL)
00094 #                    define JRI_PUBLIC_API(ResultType)  ResultType __cdecl __export __loadds 
00095 #                    define JRI_PUBLIC_VAR(VarType)            VarType
00096 #                    define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType)
00097 #                    define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType)
00098 #                    define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __loadds
00099 #                    define JRI_CALLBACK                __loadds
00100 #             else /* !WINDLL */
00101 #                    define JRI_PUBLIC_API(ResultType)  ResultType __cdecl __export
00102 #                    define JRI_PUBLIC_VAR(VarType)            VarType
00103 #                    define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType)
00104 #                    define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType)
00105 #                    define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __export
00106 #                    define JRI_CALLBACK                __export
00107 #                   endif /* !WINDLL */
00108 #             endif /* !_WIN32 */
00109 #      elif defined(__BORLANDC__)
00110 #             if defined(WIN32) || defined(_WIN32)
00111 #                    define JRI_PUBLIC_API(ResultType)  __export ResultType
00112 #                    define JRI_PUBLIC_VAR(VarType)            VarType
00113 #                    define JRI_PUBLIC_VAR_EXP(VarType) __export VarType
00114 #                    define JRI_PUBLIC_VAR_IMP(VarType) __import VarType
00115 #                    define JRI_NATIVE_STUB(ResultType)  __export ResultType
00116 #                    define JRI_CALLBACK
00117 #             else /* !_WIN32 */
00118 #                    define JRI_PUBLIC_API(ResultType)  ResultType _cdecl _export _loadds 
00119 #                    define JRI_PUBLIC_VAR(VarType)            VarType
00120 #                    define JRI_PUBLIC_VAR_EXP(VarType) __cdecl __export VarType
00121 #                    define JRI_PUBLIC_VAR_IMP(VarType) __cdecl __import VarType
00122 #                    define JRI_NATIVE_STUB(ResultType) ResultType _cdecl _loadds
00123 #                    define JRI_CALLBACK                _loadds
00124 #             endif
00125 #      else
00126 #             error Unsupported PC development environment.    
00127 #      endif
00128 #      ifndef IS_LITTLE_ENDIAN
00129 #             define IS_LITTLE_ENDIAN
00130 #      endif
00131 
00132 /* Mac */
00133 #elif defined (macintosh) || Macintosh || THINK_C
00134 #      if defined(__MWERKS__)                           /* Metrowerks */
00135 #             if !__option(enumsalwaysint)
00136 #                    error You need to define 'Enums Always Int' for your project.
00137 #             endif
00138 #             if defined(TARGET_CPU_68K) && !TARGET_RT_MAC_CFM 
00139 #                    if !__option(fourbyteints) 
00140 #                           error You need to define 'Struct Alignment: 68k' for your project.
00141 #                    endif
00142 #             endif /* !GENERATINGCFM */
00143 #             define JRI_PUBLIC_API(ResultType)  __declspec(export) ResultType
00144 #             define JRI_PUBLIC_VAR(VarType)            JRI_PUBLIC_API(VarType)
00145 #             define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_API(VarType)
00146 #             define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_API(VarType)
00147 #             define JRI_NATIVE_STUB(ResultType) JRI_PUBLIC_API(ResultType)
00148 #      elif defined(__SC__)                      /* Symantec */
00149 #             error What are the Symantec defines? (warren@netscape.com)
00150 #      elif macintosh && applec                  /* MPW */
00151 #             error Please upgrade to the latest MPW compiler (SC).
00152 #      else
00153 #             error Unsupported Mac development environment.
00154 #      endif
00155 #      define JRI_CALLBACK
00156 
00157 /* Unix or else */
00158 #else
00159 #      define JRI_PUBLIC_API(ResultType)         ResultType
00160 #   define JRI_PUBLIC_VAR(VarType)          VarType
00161 #   define JRI_PUBLIC_VAR_EXP(VarType)           JRI_PUBLIC_VAR(VarType)
00162 #   define JRI_PUBLIC_VAR_IMP(VarType)           JRI_PUBLIC_VAR(VarType)
00163 #   define JRI_NATIVE_STUB(ResultType)           ResultType
00164 #      define JRI_CALLBACK
00165 #endif
00166 
00167 #ifndef FAR          /* for non-Win16 */
00168 #define FAR
00169 #endif
00170 
00171 /******************************************************************************/
00172 
00173 /* Java Scalar Types */
00174 
00175 #if 0  /* now in jni.h */
00176 typedef short               jchar;
00177 typedef short               jshort;
00178 typedef float               jfloat;
00179 typedef double                     jdouble;
00180 typedef juint               jsize;
00181 #endif
00182 
00183 /* moved from jni.h -- Sun's new jni.h doesn't have this anymore */
00184 #ifdef __cplusplus
00185 typedef class _jobject *jref;
00186 #else
00187 typedef struct _jobject *jref;
00188 #endif
00189 
00190 typedef unsigned char       jbool;
00191 typedef signed char  jbyte;
00192 #ifdef IS_64 /* XXX ok for alpha, but not right on all 64-bit architectures */
00193 typedef unsigned int juint;
00194 typedef int                        jint;
00195 #else
00196 typedef unsigned long       juint;
00197 typedef long                jint;
00198 #endif
00199 
00200 /*******************************************************************************
00201  * jlong : long long (64-bit signed integer type) support.
00202  ******************************************************************************/
00203 
00204 /*
00205 ** Bit masking macros.  (n must be <= 31 to be portable)
00206 */
00207 #define JRI_BIT(n)                 ((juint)1 << (n))
00208 #define JRI_BITMASK(n)             (JRI_BIT(n) - 1)
00209 
00210 #ifdef HAVE_LONG_LONG
00211 
00212 #ifdef OSF1
00213 
00214 /* long is default 64-bit on OSF1, -std1 does not allow long long */
00215 typedef long                  jlong;
00216 typedef unsigned long         julong;
00217 #define jlong_MAXINT          0x7fffffffffffffffL
00218 #define jlong_MININT          0x8000000000000000L
00219 #define jlong_ZERO            0x0L
00220 
00221 #elif (defined(WIN32) || defined(_WIN32))
00222 
00223 typedef LONGLONG              jlong;
00224 typedef DWORDLONG             julong;
00225 #define jlong_MAXINT          0x7fffffffffffffffi64
00226 #define jlong_MININT          0x8000000000000000i64
00227 #define jlong_ZERO            0x0i64
00228 
00229 #else
00230 
00231 typedef long long             jlong;
00232 typedef unsigned long long    julong;
00233 #define jlong_MAXINT          0x7fffffffffffffffLL
00234 #define jlong_MININT          0x8000000000000000LL
00235 #define jlong_ZERO            0x0LL
00236 
00237 #endif
00238 
00239 #define jlong_IS_ZERO(a)    ((a) == 0)
00240 #define jlong_EQ(a, b)             ((a) == (b))
00241 #define jlong_NE(a, b)             ((a) != (b))
00242 #define jlong_GE_ZERO(a)    ((a) >= 0)
00243 #define jlong_CMP(a, op, b) ((a) op (b))
00244 
00245 #define jlong_AND(r, a, b)  ((r) = (a) & (b))
00246 #define jlong_OR(r, a, b)   ((r) = (a) | (b))
00247 #define jlong_XOR(r, a, b)  ((r) = (a) ^ (b))
00248 #define jlong_OR2(r, a)            ((r) = (r) | (a))
00249 #define jlong_NOT(r, a)            ((r) = ~(a))
00250 
00251 #define jlong_NEG(r, a)            ((r) = -(a))
00252 #define jlong_ADD(r, a, b)  ((r) = (a) + (b))
00253 #define jlong_SUB(r, a, b)  ((r) = (a) - (b))
00254 
00255 #define jlong_MUL(r, a, b)  ((r) = (a) * (b))
00256 #define jlong_DIV(r, a, b)  ((r) = (a) / (b))
00257 #define jlong_MOD(r, a, b)  ((r) = (a) % (b))
00258 
00259 #define jlong_SHL(r, a, b)  ((r) = (a) << (b))
00260 #define jlong_SHR(r, a, b)  ((r) = (a) >> (b))
00261 #define jlong_USHR(r, a, b) ((r) = (julong)(a) >> (b))
00262 #define jlong_ISHL(r, a, b) ((r) = ((jlong)(a)) << (b))
00263 
00264 #define jlong_L2I(i, l)            ((i) = (int)(l))
00265 #define jlong_L2UI(ui, l)   ((ui) =(unsigned int)(l))
00266 #define jlong_L2F(f, l)            ((f) = (l))
00267 #define jlong_L2D(d, l)            ((d) = (l))
00268 
00269 #define jlong_I2L(l, i)            ((l) = (i))
00270 #define jlong_UI2L(l, ui)   ((l) = (ui))
00271 #define jlong_F2L(l, f)            ((l) = (f))
00272 #define jlong_D2L(l, d)            ((l) = (d))
00273 
00274 #define jlong_UDIVMOD(qp, rp, a, b)  \
00275     (*(qp) = ((julong)(a) / (b)), \
00276      *(rp) = ((julong)(a) % (b)))
00277 
00278 #else  /* !HAVE_LONG_LONG */
00279 
00280 typedef struct {
00281 #ifdef IS_LITTLE_ENDIAN
00282     juint lo, hi;
00283 #else
00284     juint hi, lo;
00285 #endif
00286 } jlong;
00287 typedef jlong                      julong;
00288 
00289 extern jlong jlong_MAXINT, jlong_MININT, jlong_ZERO;
00290 
00291 #define jlong_IS_ZERO(a)    (((a).hi == 0) && ((a).lo == 0))
00292 #define jlong_EQ(a, b)             (((a).hi == (b).hi) && ((a).lo == (b).lo))
00293 #define jlong_NE(a, b)             (((a).hi != (b).hi) || ((a).lo != (b).lo))
00294 #define jlong_GE_ZERO(a)    (((a).hi >> 31) == 0)
00295 
00296 /*
00297  * NB: jlong_CMP and jlong_UCMP work only for strict relationals (<, >).
00298  */
00299 #define jlong_CMP(a, op, b) (((int32)(a).hi op (int32)(b).hi) ||          \
00300                              (((a).hi == (b).hi) && ((a).lo op (b).lo)))
00301 #define jlong_UCMP(a, op, b)       (((a).hi op (b).hi) ||                    \
00302                              (((a).hi == (b).hi) && ((a).lo op (b).lo)))
00303 
00304 #define jlong_AND(r, a, b)  ((r).lo = (a).lo & (b).lo,                    \
00305                              (r).hi = (a).hi & (b).hi)
00306 #define jlong_OR(r, a, b)   ((r).lo = (a).lo | (b).lo,                    \
00307                              (r).hi = (a).hi | (b).hi)
00308 #define jlong_XOR(r, a, b)  ((r).lo = (a).lo ^ (b).lo,                    \
00309                              (r).hi = (a).hi ^ (b).hi)
00310 #define jlong_OR2(r, a)            ((r).lo = (r).lo | (a).lo,                    \
00311                              (r).hi = (r).hi | (a).hi)
00312 #define jlong_NOT(r, a)            ((r).lo = ~(a).lo,                             \
00313                              (r).hi = ~(a).hi)
00314 
00315 #define jlong_NEG(r, a)            ((r).lo = -(int32)(a).lo,                     \
00316                              (r).hi = -(int32)(a).hi - ((r).lo != 0))
00317 #define jlong_ADD(r, a, b) {                                              \
00318     jlong _a, _b;                                                         \
00319     _a = a; _b = b;                                                       \
00320     (r).lo = _a.lo + _b.lo;                                               \
00321     (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo);                            \
00322 }
00323 
00324 #define jlong_SUB(r, a, b) {                                              \
00325     jlong _a, _b;                                                         \
00326     _a = a; _b = b;                                                       \
00327     (r).lo = _a.lo - _b.lo;                                               \
00328     (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo);                             \
00329 }                                                                         \
00330 
00331 /*
00332  * Multiply 64-bit operands a and b to get 64-bit result r.
00333  * First multiply the low 32 bits of a and b to get a 64-bit result in r.
00334  * Then add the outer and inner products to r.hi.
00335  */
00336 #define jlong_MUL(r, a, b) {                                              \
00337     jlong _a, _b;                                                         \
00338     _a = a; _b = b;                                                       \
00339     jlong_MUL32(r, _a.lo, _b.lo);                                         \
00340     (r).hi += _a.hi * _b.lo + _a.lo * _b.hi;                              \
00341 }
00342 
00343 /* XXX _jlong_lo16(a) = ((a) << 16 >> 16) is better on some archs (not on mips) */
00344 #define _jlong_lo16(a)             ((a) & JRI_BITMASK(16))
00345 #define _jlong_hi16(a)             ((a) >> 16)
00346 
00347 /*
00348  * Multiply 32-bit operands a and b to get 64-bit result r.
00349  * Use polynomial expansion based on primitive field element (1 << 16).
00350  */
00351 #define jlong_MUL32(r, a, b) {                                            \
00352      juint _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3;                        \
00353      _a1 = _jlong_hi16(a), _a0 = _jlong_lo16(a);                          \
00354      _b1 = _jlong_hi16(b), _b0 = _jlong_lo16(b);                          \
00355      _y0 = _a0 * _b0;                                                     \
00356      _y1 = _a0 * _b1;                                                     \
00357      _y2 = _a1 * _b0;                                                     \
00358      _y3 = _a1 * _b1;                                                     \
00359      _y1 += _jlong_hi16(_y0);                   /* can't carry */         \
00360      _y1 += _y2;                                /* might carry */         \
00361      if (_y1 < _y2) _y3 += 1 << 16;             /* propagate */           \
00362      (r).lo = (_jlong_lo16(_y1) << 16) + _jlong_lo16(_y0);                \
00363      (r).hi = _y3 + _jlong_hi16(_y1);                                     \
00364 }
00365 
00366 /*
00367  * Divide 64-bit unsigned operand a by 64-bit unsigned operand b, setting *qp
00368  * to the 64-bit unsigned quotient, and *rp to the 64-bit unsigned remainder.
00369  * Minimize effort if one of qp and rp is null.
00370  */
00371 #define jlong_UDIVMOD(qp, rp, a, b)       jlong_udivmod(qp, rp, a, b)
00372 
00373 extern JRI_PUBLIC_API(void)
00374 jlong_udivmod(julong *qp, julong *rp, julong a, julong b);
00375 
00376 #define jlong_DIV(r, a, b) {                                              \
00377     jlong _a, _b;                                                         \
00378     juint _negative = (int32)(a).hi < 0;                                  \
00379     if (_negative) {                                                      \
00380        jlong_NEG(_a, a);                                                     \
00381     } else {                                                              \
00382        _a = a;                                                               \
00383     }                                                                     \
00384     if ((int32)(b).hi < 0) {                                              \
00385        _negative ^= 1;                                                       \
00386        jlong_NEG(_b, b);                                                     \
00387     } else {                                                              \
00388        _b = b;                                                               \
00389     }                                                                     \
00390     jlong_UDIVMOD(&(r), 0, _a, _b);                                       \
00391     if (_negative)                                                        \
00392        jlong_NEG(r, r);                                                      \
00393 }
00394 
00395 #define jlong_MOD(r, a, b) {                                              \
00396     jlong _a, _b;                                                         \
00397     juint _negative = (int32)(a).hi < 0;                                  \
00398     if (_negative) {                                                      \
00399        jlong_NEG(_a, a);                                                     \
00400     } else {                                                              \
00401        _a = a;                                                               \
00402     }                                                                     \
00403     if ((int32)(b).hi < 0) {                                              \
00404        jlong_NEG(_b, b);                                                     \
00405     } else {                                                              \
00406        _b = b;                                                               \
00407     }                                                                     \
00408     jlong_UDIVMOD(0, &(r), _a, _b);                                       \
00409     if (_negative)                                                        \
00410        jlong_NEG(r, r);                                                      \
00411 }
00412 
00413 /*
00414  * NB: b is a juint, not jlong or julong, for the shift ops.
00415  */
00416 #define jlong_SHL(r, a, b) {                                              \
00417     if (b) {                                                              \
00418        jlong _a;                                                             \
00419         _a = a;                                                           \
00420         if ((b) < 32) {                                                   \
00421            (r).lo = _a.lo << (b);                                            \
00422            (r).hi = (_a.hi << (b)) | (_a.lo >> (32 - (b)));                  \
00423        } else {                                                              \
00424            (r).lo = 0;                                                       \
00425            (r).hi = _a.lo << ((b) & 31);                                     \
00426        }                                                                     \
00427     } else {                                                              \
00428        (r) = (a);                                                            \
00429     }                                                                     \
00430 }
00431 
00432 /* a is an int32, b is int32, r is jlong */
00433 #define jlong_ISHL(r, a, b) {                                             \
00434     if (b) {                                                              \
00435        jlong _a;                                                             \
00436        _a.lo = (a);                                                          \
00437        _a.hi = 0;                                                            \
00438         if ((b) < 32) {                                                   \
00439            (r).lo = (a) << (b);                                              \
00440            (r).hi = ((a) >> (32 - (b)));                                     \
00441        } else {                                                              \
00442            (r).lo = 0;                                                       \
00443            (r).hi = (a) << ((b) & 31);                                       \
00444        }                                                                     \
00445     } else {                                                              \
00446        (r).lo = (a);                                                         \
00447        (r).hi = 0;                                                           \
00448     }                                                                     \
00449 }
00450 
00451 #define jlong_SHR(r, a, b) {                                              \
00452     if (b) {                                                              \
00453        jlong _a;                                                             \
00454         _a = a;                                                           \
00455        if ((b) < 32) {                                                       \
00456            (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b));                  \
00457            (r).hi = (int32)_a.hi >> (b);                                     \
00458        } else {                                                              \
00459            (r).lo = (int32)_a.hi >> ((b) & 31);                              \
00460            (r).hi = (int32)_a.hi >> 31;                                      \
00461        }                                                                     \
00462     } else {                                                              \
00463        (r) = (a);                                                            \
00464     }                                                                     \
00465 }
00466 
00467 #define jlong_USHR(r, a, b) {                                             \
00468     if (b) {                                                              \
00469        jlong _a;                                                             \
00470         _a = a;                                                           \
00471        if ((b) < 32) {                                                       \
00472            (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b));                  \
00473            (r).hi = _a.hi >> (b);                                            \
00474        } else {                                                              \
00475            (r).lo = _a.hi >> ((b) & 31);                                     \
00476            (r).hi = 0;                                                       \
00477        }                                                                     \
00478     } else {                                                              \
00479        (r) = (a);                                                            \
00480     }                                                                     \
00481 }
00482 
00483 #define jlong_L2I(i, l)            ((i) = (l).lo)
00484 #define jlong_L2UI(ui, l)   ((ui) = (l).lo)
00485 #define jlong_L2F(f, l)            { double _d; jlong_L2D(_d, l); (f) = (float) _d; }
00486 
00487 #define jlong_L2D(d, l) {                                                 \
00488     int32 _negative;                                                      \
00489     jlong _absval;                                                        \
00490                                                                           \
00491     _negative = (l).hi >> 31;                                             \
00492     if (_negative) {                                                      \
00493        jlong_NEG(_absval, l);                                                \
00494     } else {                                                              \
00495        _absval = l;                                                          \
00496     }                                                                     \
00497     (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo;                \
00498     if (_negative)                                                        \
00499        (d) = -(d);                                                           \
00500 }
00501 
00502 #define jlong_I2L(l, i)            ((l).hi = (i) >> 31, (l).lo = (i))
00503 #define jlong_UI2L(l, ui)   ((l).hi = 0, (l).lo = (ui))
00504 #define jlong_F2L(l, f)            { double _d = (double) f; jlong_D2L(l, _d); }
00505 
00506 #define jlong_D2L(l, d) {                                                 \
00507     int _negative;                                                        \
00508     double _absval, _d_hi;                                                \
00509     jlong _lo_d;                                                          \
00510                                                                           \
00511     _negative = ((d) < 0);                                                \
00512     _absval = _negative ? -(d) : (d);                                     \
00513                                                                           \
00514     (l).hi = (juint)(_absval / 4.294967296e9);                            \
00515     (l).lo = 0;                                                           \
00516     jlong_L2D(_d_hi, l);                                                  \
00517     _absval -= _d_hi;                                                     \
00518     _lo_d.hi = 0;                                                         \
00519     if (_absval < 0) {                                                    \
00520        _lo_d.lo = (juint) -_absval;                                          \
00521        jlong_SUB(l, l, _lo_d);                                               \
00522     } else {                                                              \
00523        _lo_d.lo = (juint) _absval;                                           \
00524        jlong_ADD(l, l, _lo_d);                                               \
00525     }                                                                     \
00526                                                                           \
00527     if (_negative)                                                        \
00528        jlong_NEG(l, l);                                                      \
00529 }
00530 
00531 #endif /* !HAVE_LONG_LONG */
00532 
00533 /******************************************************************************/
00534 
00535 #ifdef HAVE_ALIGNED_LONGLONGS
00536 #define JRI_GET_INT64(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \
00537                               ((_t).x[1] = ((jint*)(_addr))[1]),      \
00538                               (_t).l )
00539 #define JRI_SET_INT64(_t, _addr, _v) ( (_t).l = (_v),                \
00540                                    ((jint*)(_addr))[0] = (_t).x[0], \
00541                                    ((jint*)(_addr))[1] = (_t).x[1] )
00542 #else
00543 #define JRI_GET_INT64(_t,_addr) (*(jlong*)(_addr))
00544 #define JRI_SET_INT64(_t, _addr, _v) (*(jlong*)(_addr) = (_v))
00545 #endif
00546 
00547 /* If double's must be aligned on doubleword boundaries then define this */
00548 #ifdef HAVE_ALIGNED_DOUBLES
00549 #define JRI_GET_DOUBLE(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \
00550                                ((_t).x[1] = ((jint*)(_addr))[1]),      \
00551                                (_t).d )
00552 #define JRI_SET_DOUBLE(_t, _addr, _v) ( (_t).d = (_v),                \
00553                                     ((jint*)(_addr))[0] = (_t).x[0], \
00554                                     ((jint*)(_addr))[1] = (_t).x[1] )
00555 #else
00556 #define JRI_GET_DOUBLE(_t,_addr) (*(jdouble*)(_addr))
00557 #define JRI_SET_DOUBLE(_t, _addr, _v) (*(jdouble*)(_addr) = (_v))
00558 #endif
00559 
00560 /******************************************************************************/
00561 #ifdef __cplusplus
00562 }
00563 #endif
00564 #endif /* JRI_MD_H */
00565 /******************************************************************************/