jri_md.h 26 KB

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