Home | History | Annotate | Download | only in java
      1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
      2 /* ***** BEGIN LICENSE BLOCK *****
      3  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
      4  *
      5  * The contents of this file are subject to the Netscape Public License
      6  * Version 1.1 (the "License"); you may not use this file except in
      7  * compliance with the License. You may obtain a copy of the License at
      8  * http://www.mozilla.org/NPL/
      9  *
     10  * Software distributed under the License is distributed on an "AS IS" basis,
     11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
     12  * for the specific language governing rights and limitations under the
     13  * License.
     14  *
     15  * The Original Code is mozilla.org code.
     16  *
     17  * The Initial Developer of the Original Code is
     18  * Netscape Communications Corporation.
     19  * Portions created by the Initial Developer are Copyright (C) 1998
     20  * the Initial Developer. All Rights Reserved.
     21  *
     22  * Contributor(s):
     23  *
     24  * Alternatively, the contents of this file may be used under the terms of
     25  * either the GNU General Public License Version 2 or later (the "GPL"), or
     26  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
     27  * in which case the provisions of the GPL or the LGPL are applicable instead
     28  * of those above. If you wish to allow use of your version of this file only
     29  * under the terms of either the GPL or the LGPL, and not to allow others to
     30  * use your version of this file under the terms of the NPL, indicate your
     31  * decision by deleting the provisions above and replace them with the notice
     32  * and other provisions required by the GPL or the LGPL. If you do not delete
     33  * the provisions above, a recipient may use your version of this file under
     34  * the terms of any one of the NPL, the GPL or the LGPL.
     35  *
     36  * ***** END LICENSE BLOCK ***** */
     37 
     38 /*******************************************************************************
     39  * Java Runtime Interface - Machine Dependent Types
     40  ******************************************************************************/
     41 
     42 #ifndef JRI_MD_H
     43 #define JRI_MD_H
     44 
     45 #include <assert.h>
     46 #include "prtypes.h" /* Needed for HAS_LONG_LONG ifdefs */
     47 
     48 #ifdef __cplusplus
     49 extern "C" {
     50 #endif
     51 
     52 /*******************************************************************************
     53  * WHAT'S UP WITH THIS FILE?
     54  *
     55  * This is where we define the mystical JRI_PUBLIC_API macro that works on all
     56  * platforms. If you're running with Visual C++, Symantec C, or Borland's
     57  * development environment on the PC, you're all set. Or if you're on the Mac
     58  * with Metrowerks, Symantec or MPW with SC you're ok too. For UNIX it shouldn't
     59  * matter.
     60  *
     61  * On UNIX though you probably care about a couple of other symbols though:
     62  *	IS_LITTLE_ENDIAN must be defined for little-endian systems
     63  *	HAVE_LONG_LONG must be defined on systems that have 'long long' integers
     64  *	HAVE_ALIGNED_LONGLONGS must be defined if long-longs must be 8 byte aligned
     65  *	HAVE_ALIGNED_DOUBLES must be defined if doubles must be 8 byte aligned
     66  *	IS_64 must be defined on 64-bit machines (like Dec Alpha)
     67  ******************************************************************************/
     68 
     69 /* DLL Entry modifiers... */
     70 
     71 /* PC */
     72 #if defined(XP_OS2)
     73 #  ifdef XP_OS2_VACPP
     74 #	  define JRI_PUBLIC_API(ResultType)	    ResultType _Optlink
     75 #	  define JRI_PUBLIC_VAR(VarType)        VarType
     76 #     define JRI_CALLBACK
     77 #  else
     78 #	  define JRI_PUBLIC_API(ResultType)	    ResultType
     79 #	  define JRI_PUBLIC_VAR(VarType)        VarType
     80 #     define JRI_CALLBACK
     81 #  endif
     82 #elif defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32)
     83 #	include <windows.h>
     84 #	if defined(_MSC_VER) || defined(__GNUC__)
     85 #		if defined(WIN32) || defined(_WIN32)
     86 #			define JRI_PUBLIC_API(ResultType)  __declspec(dllexport) ResultType
     87 #			define JRI_PUBLIC_VAR(VarType)	   VarType
     88 #			define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType
     89 #			define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType
     90 #			define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType
     91 #			define JRI_CALLBACK
     92 #		else /* !_WIN32 */
     93 #		    if defined(_WINDLL)
     94 #			define JRI_PUBLIC_API(ResultType)	ResultType __cdecl __export __loadds
     95 #			define JRI_PUBLIC_VAR(VarType)		VarType
     96 #			define JRI_PUBLIC_VAR_EXP(VarType)	JRI_PUBLIC_VAR(VarType)
     97 #			define JRI_PUBLIC_VAR_IMP(VarType)	JRI_PUBLIC_VAR(VarType)
     98 #			define JRI_NATIVE_STUB(ResultType)	ResultType __cdecl __loadds
     99 #			define JRI_CALLBACK			__loadds
    100 #		else /* !WINDLL */
    101 #			define JRI_PUBLIC_API(ResultType)	ResultType __cdecl __export
    102 #			define JRI_PUBLIC_VAR(VarType)		VarType
    103 #			define JRI_PUBLIC_VAR_EXP(VarType)	JRI_PUBLIC_VAR(VarType)
    104 #			define JRI_PUBLIC_VAR_IMP(VarType)	JRI_PUBLIC_VAR(VarType)
    105 #			define JRI_NATIVE_STUB(ResultType)	ResultType __cdecl __export
    106 #			define JRI_CALLBACK			__export
    107 #                   endif /* !WINDLL */
    108 #		endif /* !_WIN32 */
    109 #	elif defined(__BORLANDC__)
    110 #		if defined(WIN32) || defined(_WIN32)
    111 #			define JRI_PUBLIC_API(ResultType)	__export ResultType
    112 #			define JRI_PUBLIC_VAR(VarType)		VarType
    113 #			define JRI_PUBLIC_VAR_EXP(VarType)	__export VarType
    114 #			define JRI_PUBLIC_VAR_IMP(VarType)	__import VarType
    115 #			define JRI_NATIVE_STUB(ResultType)	 __export ResultType
    116 #			define JRI_CALLBACK
    117 #		else /* !_WIN32 */
    118 #			define JRI_PUBLIC_API(ResultType)	ResultType _cdecl _export _loadds
    119 #			define JRI_PUBLIC_VAR(VarType)		VarType
    120 #			define JRI_PUBLIC_VAR_EXP(VarType)	__cdecl __export VarType
    121 #			define JRI_PUBLIC_VAR_IMP(VarType)	__cdecl __import VarType
    122 #			define JRI_NATIVE_STUB(ResultType)	ResultType _cdecl _loadds
    123 #			define JRI_CALLBACK			_loadds
    124 #		endif
    125 #	else
    126 #		error Unsupported PC development environment.
    127 #	endif
    128 #	ifndef IS_LITTLE_ENDIAN
    129 #		define IS_LITTLE_ENDIAN
    130 #	endif
    131 
    132 /* Mac */
    133 #elif defined (macintosh) || Macintosh || THINK_C
    134 #	if defined(__MWERKS__)				/* Metrowerks */
    135 #		if !__option(enumsalwaysint)
    136 #			error You need to define 'Enums Always Int' for your project.
    137 #		endif
    138 #		if defined(TARGET_CPU_68K) && !TARGET_RT_MAC_CFM
    139 #			if !__option(fourbyteints)
    140 #				error You need to define 'Struct Alignment: 68k' for your project.
    141 #			endif
    142 #		endif /* !GENERATINGCFM */
    143 #		define JRI_PUBLIC_API(ResultType)	__declspec(export) ResultType
    144 #		define JRI_PUBLIC_VAR(VarType)		JRI_PUBLIC_API(VarType)
    145 #		define JRI_PUBLIC_VAR_EXP(VarType)	JRI_PUBLIC_API(VarType)
    146 #		define JRI_PUBLIC_VAR_IMP(VarType)	JRI_PUBLIC_API(VarType)
    147 #		define JRI_NATIVE_STUB(ResultType)	JRI_PUBLIC_API(ResultType)
    148 #	elif defined(__SC__)				/* Symantec */
    149 #		error What are the Symantec defines? (warren@netscape.com)
    150 #	elif macintosh && applec			/* MPW */
    151 #		error Please upgrade to the latest MPW compiler (SC).
    152 #	else
    153 #		error Unsupported Mac development environment.
    154 #	endif
    155 #	define JRI_CALLBACK
    156 
    157 /* Unix or else */
    158 #else
    159 #	define JRI_PUBLIC_API(ResultType)		ResultType
    160 #   define JRI_PUBLIC_VAR(VarType)          VarType
    161 #   define JRI_PUBLIC_VAR_EXP(VarType)		JRI_PUBLIC_VAR(VarType)
    162 #   define JRI_PUBLIC_VAR_IMP(VarType)		JRI_PUBLIC_VAR(VarType)
    163 #   define JRI_NATIVE_STUB(ResultType)		ResultType
    164 #	define JRI_CALLBACK
    165 #endif
    166 
    167 #ifndef FAR		/* for non-Win16 */
    168 #define FAR
    169 #endif
    170 
    171 /******************************************************************************/
    172 
    173 /* Java Scalar Types */
    174 
    175 #if 0	/* now in jni.h */
    176 typedef short			jchar;
    177 typedef short			jshort;
    178 typedef float			jfloat;
    179 typedef double			jdouble;
    180 typedef juint			jsize;
    181 #endif
    182 
    183 /* moved from jni.h -- Sun's new jni.h doesn't have this anymore */
    184 #ifdef __cplusplus
    185 typedef class _jobject *jref;
    186 #else
    187 typedef struct _jobject *jref;
    188 #endif
    189 
    190 typedef unsigned char	jbool;
    191 typedef signed char	jbyte;
    192 #ifdef IS_64 /* XXX ok for alpha, but not right on all 64-bit architectures */
    193 typedef unsigned int	juint;
    194 typedef int				jint;
    195 #else
    196 typedef unsigned long	juint;
    197 typedef long			jint;
    198 #endif
    199 
    200 /*******************************************************************************
    201  * jlong : long long (64-bit signed integer type) support.
    202  ******************************************************************************/
    203 
    204 /*
    205 ** Bit masking macros.  (n must be <= 31 to be portable)
    206 */
    207 #define JRI_BIT(n)			((juint)1 << (n))
    208 #define JRI_BITMASK(n)		(JRI_BIT(n) - 1)
    209 
    210 #ifdef HAVE_LONG_LONG
    211 
    212 #ifdef OSF1
    213 
    214 /* long is default 64-bit on OSF1, -std1 does not allow long long */
    215 typedef long                  jlong;
    216 typedef unsigned long         julong;
    217 #define jlong_MAXINT          0x7fffffffffffffffL
    218 #define jlong_MININT          0x8000000000000000L
    219 #define jlong_ZERO            0x0L
    220 
    221 #elif (defined(WIN32) || defined(_WIN32))
    222 
    223 typedef LONGLONG              jlong;
    224 typedef DWORDLONG             julong;
    225 #define jlong_MAXINT          0x7fffffffffffffffi64
    226 #define jlong_MININT          0x8000000000000000i64
    227 #define jlong_ZERO            0x0i64
    228 
    229 #else
    230 
    231 typedef long long             jlong;
    232 typedef unsigned long long    julong;
    233 #define jlong_MAXINT          0x7fffffffffffffffLL
    234 #define jlong_MININT          0x8000000000000000LL
    235 #define jlong_ZERO            0x0LL
    236 
    237 #endif
    238 
    239 #define jlong_IS_ZERO(a)	((a) == 0)
    240 #define jlong_EQ(a, b)		((a) == (b))
    241 #define jlong_NE(a, b)		((a) != (b))
    242 #define jlong_GE_ZERO(a)	((a) >= 0)
    243 #define jlong_CMP(a, op, b)	((a) op (b))
    244 
    245 #define jlong_AND(r, a, b)	((r) = (a) & (b))
    246 #define jlong_OR(r, a, b)	((r) = (a) | (b))
    247 #define jlong_XOR(r, a, b)	((r) = (a) ^ (b))
    248 #define jlong_OR2(r, a)		((r) = (r) | (a))
    249 #define jlong_NOT(r, a)		((r) = ~(a))
    250 
    251 #define jlong_NEG(r, a)		((r) = -(a))
    252 #define jlong_ADD(r, a, b)	((r) = (a) + (b))
    253 #define jlong_SUB(r, a, b)	((r) = (a) - (b))
    254 
    255 #define jlong_MUL(r, a, b)	((r) = (a) * (b))
    256 #define jlong_DIV(r, a, b)	((r) = (a) / (b))
    257 #define jlong_MOD(r, a, b)	((r) = (a) % (b))
    258 
    259 #define jlong_SHL(r, a, b)	((r) = (a) << (b))
    260 #define jlong_SHR(r, a, b)	((r) = (a) >> (b))
    261 #define jlong_USHR(r, a, b)	((r) = (julong)(a) >> (b))
    262 #define jlong_ISHL(r, a, b)	((r) = ((jlong)(a)) << (b))
    263 
    264 #define jlong_L2I(i, l)		((i) = (int)(l))
    265 #define jlong_L2UI(ui, l)	((ui) =(unsigned int)(l))
    266 #define jlong_L2F(f, l)		((f) = (l))
    267 #define jlong_L2D(d, l)		((d) = (l))
    268 
    269 #define jlong_I2L(l, i)		((l) = (i))
    270 #define jlong_UI2L(l, ui)	((l) = (ui))
    271 #define jlong_F2L(l, f)		((l) = (f))
    272 #define jlong_D2L(l, d)		((l) = (d))
    273 
    274 #define jlong_UDIVMOD(qp, rp, a, b)  \
    275     (*(qp) = ((julong)(a) / (b)), \
    276      *(rp) = ((julong)(a) % (b)))
    277 
    278 #else  /* !HAVE_LONG_LONG */
    279 
    280 typedef struct {
    281 #ifdef IS_LITTLE_ENDIAN
    282     juint lo, hi;
    283 #else
    284     juint hi, lo;
    285 #endif
    286 } jlong;
    287 typedef jlong				julong;
    288 
    289 extern jlong jlong_MAXINT, jlong_MININT, jlong_ZERO;
    290 
    291 #define jlong_IS_ZERO(a)	(((a).hi == 0) && ((a).lo == 0))
    292 #define jlong_EQ(a, b)		(((a).hi == (b).hi) && ((a).lo == (b).lo))
    293 #define jlong_NE(a, b)		(((a).hi != (b).hi) || ((a).lo != (b).lo))
    294 #define jlong_GE_ZERO(a)	(((a).hi >> 31) == 0)
    295 
    296 /*
    297  * NB: jlong_CMP and jlong_UCMP work only for strict relationals (<, >).
    298  */
    299 #define jlong_CMP(a, op, b)	(((int32)(a).hi op (int32)(b).hi) ||          \
    300 				 (((a).hi == (b).hi) && ((a).lo op (b).lo)))
    301 #define jlong_UCMP(a, op, b)	(((a).hi op (b).hi) ||                    \
    302 				 (((a).hi == (b).hi) && ((a).lo op (b).lo)))
    303 
    304 #define jlong_AND(r, a, b)	((r).lo = (a).lo & (b).lo,                    \
    305 				 (r).hi = (a).hi & (b).hi)
    306 #define jlong_OR(r, a, b)	((r).lo = (a).lo | (b).lo,                    \
    307 				 (r).hi = (a).hi | (b).hi)
    308 #define jlong_XOR(r, a, b)	((r).lo = (a).lo ^ (b).lo,                    \
    309 				 (r).hi = (a).hi ^ (b).hi)
    310 #define jlong_OR2(r, a)		((r).lo = (r).lo | (a).lo,                    \
    311 				 (r).hi = (r).hi | (a).hi)
    312 #define jlong_NOT(r, a)		((r).lo = ~(a).lo,	                          \
    313 				 (r).hi = ~(a).hi)
    314 
    315 #define jlong_NEG(r, a)		((r).lo = -(int32)(a).lo,                     \
    316 				 (r).hi = -(int32)(a).hi - ((r).lo != 0))
    317 #define jlong_ADD(r, a, b) {                                              \
    318     jlong _a, _b;                                                         \
    319     _a = a; _b = b;                                                       \
    320     (r).lo = _a.lo + _b.lo;                                               \
    321     (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo);                            \
    322 }
    323 
    324 #define jlong_SUB(r, a, b) {                                              \
    325     jlong _a, _b;                                                         \
    326     _a = a; _b = b;                                                       \
    327     (r).lo = _a.lo - _b.lo;                                               \
    328     (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo);                             \
    329 }                                                                         \
    330 
    331 /*
    332  * Multiply 64-bit operands a and b to get 64-bit result r.
    333  * First multiply the low 32 bits of a and b to get a 64-bit result in r.
    334  * Then add the outer and inner products to r.hi.
    335  */
    336 #define jlong_MUL(r, a, b) {                                              \
    337     jlong _a, _b;                                                         \
    338     _a = a; _b = b;                                                       \
    339     jlong_MUL32(r, _a.lo, _b.lo);                                         \
    340     (r).hi += _a.hi * _b.lo + _a.lo * _b.hi;                              \
    341 }
    342 
    343 /* XXX _jlong_lo16(a) = ((a) << 16 >> 16) is better on some archs (not on mips) */
    344 #define _jlong_lo16(a)		((a) & JRI_BITMASK(16))
    345 #define _jlong_hi16(a)		((a) >> 16)
    346 
    347 /*
    348  * Multiply 32-bit operands a and b to get 64-bit result r.
    349  * Use polynomial expansion based on primitive field element (1 << 16).
    350  */
    351 #define jlong_MUL32(r, a, b) {                                            \
    352      juint _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3;                        \
    353      _a1 = _jlong_hi16(a), _a0 = _jlong_lo16(a);                          \
    354      _b1 = _jlong_hi16(b), _b0 = _jlong_lo16(b);                          \
    355      _y0 = _a0 * _b0;                                                     \
    356      _y1 = _a0 * _b1;                                                     \
    357      _y2 = _a1 * _b0;                                                     \
    358      _y3 = _a1 * _b1;                                                     \
    359      _y1 += _jlong_hi16(_y0);                   /* can't carry */         \
    360      _y1 += _y2;                                /* might carry */         \
    361      if (_y1 < _y2) _y3 += 1 << 16;             /* propagate */           \
    362      (r).lo = (_jlong_lo16(_y1) << 16) + _jlong_lo16(_y0);                \
    363      (r).hi = _y3 + _jlong_hi16(_y1);                                     \
    364 }
    365 
    366 /*
    367  * Divide 64-bit unsigned operand a by 64-bit unsigned operand b, setting *qp
    368  * to the 64-bit unsigned quotient, and *rp to the 64-bit unsigned remainder.
    369  * Minimize effort if one of qp and rp is null.
    370  */
    371 #define jlong_UDIVMOD(qp, rp, a, b)	jlong_udivmod(qp, rp, a, b)
    372 
    373 extern JRI_PUBLIC_API(void)
    374 jlong_udivmod(julong *qp, julong *rp, julong a, julong b);
    375 
    376 #define jlong_DIV(r, a, b) {                                              \
    377     jlong _a, _b;                                                         \
    378     juint _negative = (int32)(a).hi < 0;                                  \
    379     if (_negative) {                                                      \
    380 	jlong_NEG(_a, a);                                                     \
    381     } else {                                                              \
    382 	_a = a;                                                               \
    383     }                                                                     \
    384     if ((int32)(b).hi < 0) {                                              \
    385 	_negative ^= 1;                                                       \
    386 	jlong_NEG(_b, b);                                                     \
    387     } else {                                                              \
    388 	_b = b;                                                               \
    389     }                                                                     \
    390     jlong_UDIVMOD(&(r), 0, _a, _b);                                       \
    391     if (_negative)                                                        \
    392 	jlong_NEG(r, r);                                                      \
    393 }
    394 
    395 #define jlong_MOD(r, a, b) {                                              \
    396     jlong _a, _b;                                                         \
    397     juint _negative = (int32)(a).hi < 0;                                  \
    398     if (_negative) {                                                      \
    399 	jlong_NEG(_a, a);                                                     \
    400     } else {                                                              \
    401 	_a = a;                                                               \
    402     }                                                                     \
    403     if ((int32)(b).hi < 0) {                                              \
    404 	jlong_NEG(_b, b);                                                     \
    405     } else {                                                              \
    406 	_b = b;                                                               \
    407     }                                                                     \
    408     jlong_UDIVMOD(0, &(r), _a, _b);                                       \
    409     if (_negative)                                                        \
    410 	jlong_NEG(r, r);                                                      \
    411 }
    412 
    413 /*
    414  * NB: b is a juint, not jlong or julong, for the shift ops.
    415  */
    416 #define jlong_SHL(r, a, b) {                                              \
    417     if (b) {                                                              \
    418 	jlong _a;                                                             \
    419         _a = a;                                                           \
    420         if ((b) < 32) {                                                   \
    421 	    (r).lo = _a.lo << (b);                                            \
    422 	    (r).hi = (_a.hi << (b)) | (_a.lo >> (32 - (b)));                  \
    423 	} else {                                                              \
    424 	    (r).lo = 0;                                                       \
    425 	    (r).hi = _a.lo << ((b) & 31);                                     \
    426 	}                                                                     \
    427     } else {                                                              \
    428 	(r) = (a);                                                            \
    429     }                                                                     \
    430 }
    431 
    432 /* a is an int32, b is int32, r is jlong */
    433 #define jlong_ISHL(r, a, b) {                                             \
    434     if (b) {                                                              \
    435 	jlong _a;                                                             \
    436 	_a.lo = (a);                                                          \
    437 	_a.hi = 0;                                                            \
    438         if ((b) < 32) {                                                   \
    439 	    (r).lo = (a) << (b);                                              \
    440 	    (r).hi = ((a) >> (32 - (b)));                                     \
    441 	} else {                                                              \
    442 	    (r).lo = 0;                                                       \
    443 	    (r).hi = (a) << ((b) & 31);                                       \
    444 	}                                                                     \
    445     } else {                                                              \
    446 	(r).lo = (a);                                                         \
    447 	(r).hi = 0;                                                           \
    448     }                                                                     \
    449 }
    450 
    451 #define jlong_SHR(r, a, b) {                                              \
    452     if (b) {                                                              \
    453 	jlong _a;                                                             \
    454         _a = a;                                                           \
    455 	if ((b) < 32) {                                                       \
    456 	    (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b));                  \
    457 	    (r).hi = (int32)_a.hi >> (b);                                     \
    458 	} else {                                                              \
    459 	    (r).lo = (int32)_a.hi >> ((b) & 31);                              \
    460 	    (r).hi = (int32)_a.hi >> 31;                                      \
    461 	}                                                                     \
    462     } else {                                                              \
    463 	(r) = (a);                                                            \
    464     }                                                                     \
    465 }
    466 
    467 #define jlong_USHR(r, a, b) {                                             \
    468     if (b) {                                                              \
    469 	jlong _a;                                                             \
    470         _a = a;                                                           \
    471 	if ((b) < 32) {                                                       \
    472 	    (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b));                  \
    473 	    (r).hi = _a.hi >> (b);                                            \
    474 	} else {                                                              \
    475 	    (r).lo = _a.hi >> ((b) & 31);                                     \
    476 	    (r).hi = 0;                                                       \
    477 	}                                                                     \
    478     } else {                                                              \
    479 	(r) = (a);                                                            \
    480     }                                                                     \
    481 }
    482 
    483 #define jlong_L2I(i, l)		((i) = (l).lo)
    484 #define jlong_L2UI(ui, l)	((ui) = (l).lo)
    485 #define jlong_L2F(f, l)		{ double _d; jlong_L2D(_d, l); (f) = (float) _d; }
    486 
    487 #define jlong_L2D(d, l) {                                                 \
    488     int32 _negative;                                                      \
    489     jlong _absval;                                                        \
    490                                                                           \
    491     _negative = (l).hi >> 31;                                             \
    492     if (_negative) {                                                      \
    493 	jlong_NEG(_absval, l);                                                \
    494     } else {                                                              \
    495 	_absval = l;                                                          \
    496     }                                                                     \
    497     (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo;                \
    498     if (_negative)                                                        \
    499 	(d) = -(d);                                                           \
    500 }
    501 
    502 #define jlong_I2L(l, i)		((l).hi = (i) >> 31, (l).lo = (i))
    503 #define jlong_UI2L(l, ui)	((l).hi = 0, (l).lo = (ui))
    504 #define jlong_F2L(l, f)		{ double _d = (double) f; jlong_D2L(l, _d); }
    505 
    506 #define jlong_D2L(l, d) {                                                 \
    507     int _negative;                                                        \
    508     double _absval, _d_hi;                                                \
    509     jlong _lo_d;                                                          \
    510                                                                           \
    511     _negative = ((d) < 0);                                                \
    512     _absval = _negative ? -(d) : (d);                                     \
    513                                                                           \
    514     (l).hi = (juint)(_absval / 4.294967296e9);                            \
    515     (l).lo = 0;                                                           \
    516     jlong_L2D(_d_hi, l);                                                  \
    517     _absval -= _d_hi;                                                     \
    518     _lo_d.hi = 0;                                                         \
    519     if (_absval < 0) {                                                    \
    520 	_lo_d.lo = (juint) -_absval;                                          \
    521 	jlong_SUB(l, l, _lo_d);                                               \
    522     } else {                                                              \
    523 	_lo_d.lo = (juint) _absval;                                           \
    524 	jlong_ADD(l, l, _lo_d);                                               \
    525     }                                                                     \
    526                                                                           \
    527     if (_negative)                                                        \
    528 	jlong_NEG(l, l);                                                      \
    529 }
    530 
    531 #endif /* !HAVE_LONG_LONG */
    532 
    533 /******************************************************************************/
    534 
    535 #ifdef HAVE_ALIGNED_LONGLONGS
    536 #define JRI_GET_INT64(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \
    537                               ((_t).x[1] = ((jint*)(_addr))[1]),      \
    538                               (_t).l )
    539 #define JRI_SET_INT64(_t, _addr, _v) ( (_t).l = (_v),                \
    540                                    ((jint*)(_addr))[0] = (_t).x[0], \
    541                                    ((jint*)(_addr))[1] = (_t).x[1] )
    542 #else
    543 #define JRI_GET_INT64(_t,_addr) (*(jlong*)(_addr))
    544 #define JRI_SET_INT64(_t, _addr, _v) (*(jlong*)(_addr) = (_v))
    545 #endif
    546 
    547 /* If double's must be aligned on doubleword boundaries then define this */
    548 #ifdef HAVE_ALIGNED_DOUBLES
    549 #define JRI_GET_DOUBLE(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \
    550                                ((_t).x[1] = ((jint*)(_addr))[1]),      \
    551                                (_t).d )
    552 #define JRI_SET_DOUBLE(_t, _addr, _v) ( (_t).d = (_v),                \
    553                                     ((jint*)(_addr))[0] = (_t).x[0], \
    554                                     ((jint*)(_addr))[1] = (_t).x[1] )
    555 #else
    556 #define JRI_GET_DOUBLE(_t,_addr) (*(jdouble*)(_addr))
    557 #define JRI_SET_DOUBLE(_t, _addr, _v) (*(jdouble*)(_addr) = (_v))
    558 #endif
    559 
    560 /******************************************************************************/
    561 #ifdef __cplusplus
    562 }
    563 #endif
    564 #endif /* JRI_MD_H */
    565 /******************************************************************************/
    566