PageRenderTime 39ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/gecko_api/include/jri_md.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 574 lines | 416 code | 62 blank | 96 comment | 77 complexity | fcc80007abda83f71a4ddc301a2d9fa4 MD5 | raw file
  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  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 MPL, 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 MPL, 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. /* Windows */
  65. #if defined(XP_WIN) || defined(_WINDOWS) || defined(WIN32) || defined(_WIN32)
  66. # include <windows.h>
  67. # if defined(_MSC_VER) || defined(__GNUC__)
  68. # if defined(WIN32) || defined(_WIN32)
  69. # define JRI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType
  70. # define JRI_PUBLIC_VAR(VarType) VarType
  71. # define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType
  72. # define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType
  73. # define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType
  74. # define JRI_CALLBACK
  75. # else /* !_WIN32 */
  76. # if defined(_WINDLL)
  77. # define JRI_PUBLIC_API(ResultType) ResultType __cdecl __export __loadds
  78. # define JRI_PUBLIC_VAR(VarType) VarType
  79. # define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType)
  80. # define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType)
  81. # define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __loadds
  82. # define JRI_CALLBACK __loadds
  83. # else /* !WINDLL */
  84. # define JRI_PUBLIC_API(ResultType) ResultType __cdecl __export
  85. # define JRI_PUBLIC_VAR(VarType) VarType
  86. # define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType)
  87. # define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType)
  88. # define JRI_NATIVE_STUB(ResultType) ResultType __cdecl __export
  89. # define JRI_CALLBACK __export
  90. # endif /* !WINDLL */
  91. # endif /* !_WIN32 */
  92. # elif defined(__BORLANDC__)
  93. # if defined(WIN32) || defined(_WIN32)
  94. # define JRI_PUBLIC_API(ResultType) __export ResultType
  95. # define JRI_PUBLIC_VAR(VarType) VarType
  96. # define JRI_PUBLIC_VAR_EXP(VarType) __export VarType
  97. # define JRI_PUBLIC_VAR_IMP(VarType) __import VarType
  98. # define JRI_NATIVE_STUB(ResultType) __export ResultType
  99. # define JRI_CALLBACK
  100. # else /* !_WIN32 */
  101. # define JRI_PUBLIC_API(ResultType) ResultType _cdecl _export _loadds
  102. # define JRI_PUBLIC_VAR(VarType) VarType
  103. # define JRI_PUBLIC_VAR_EXP(VarType) __cdecl __export VarType
  104. # define JRI_PUBLIC_VAR_IMP(VarType) __cdecl __import VarType
  105. # define JRI_NATIVE_STUB(ResultType) ResultType _cdecl _loadds
  106. # define JRI_CALLBACK _loadds
  107. # endif
  108. # else
  109. # error Unsupported PC development environment.
  110. # endif
  111. # ifndef IS_LITTLE_ENDIAN
  112. # define IS_LITTLE_ENDIAN
  113. # endif
  114. /* OS/2 */
  115. #elif defined(XP_OS2)
  116. # ifdef XP_OS2_VACPP
  117. # define JRI_PUBLIC_API(ResultType) ResultType _Optlink
  118. # define JRI_PUBLIC_VAR(VarType) VarType
  119. # define JRI_CALLBACK
  120. # elif defined(__declspec)
  121. # define JRI_PUBLIC_API(ResultType) __declspec(dllexport) ResultType
  122. # define JRI_PUBLIC_VAR(VarType) VarType
  123. # define JRI_PUBLIC_VAR_EXP(VarType) __declspec(dllexport) VarType
  124. # define JRI_PUBLIC_VAR_IMP(VarType) __declspec(dllimport) VarType
  125. # define JRI_NATIVE_STUB(ResultType) __declspec(dllexport) ResultType
  126. # define JRI_CALLBACK
  127. # else
  128. # define JRI_PUBLIC_API(ResultType) ResultType
  129. # define JRI_PUBLIC_VAR(VarType) VarType
  130. # define JRI_CALLBACK
  131. # endif
  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. /* Unix or else */
  157. #else
  158. # define JRI_PUBLIC_API(ResultType) ResultType
  159. # define JRI_PUBLIC_VAR(VarType) VarType
  160. # define JRI_PUBLIC_VAR_EXP(VarType) JRI_PUBLIC_VAR(VarType)
  161. # define JRI_PUBLIC_VAR_IMP(VarType) JRI_PUBLIC_VAR(VarType)
  162. # define JRI_NATIVE_STUB(ResultType) ResultType
  163. # define JRI_CALLBACK
  164. #endif
  165. #ifndef FAR /* for non-Win16 */
  166. #define FAR
  167. #endif
  168. /******************************************************************************/
  169. /* Java Scalar Types */
  170. #if 0 /* now in jni.h */
  171. typedef short jchar;
  172. typedef short jshort;
  173. typedef float jfloat;
  174. typedef double jdouble;
  175. typedef juint jsize;
  176. #endif
  177. /* moved from jni.h -- Sun's new jni.h doesn't have this anymore */
  178. #ifdef __cplusplus
  179. typedef class _jobject *jref;
  180. #else
  181. typedef struct _jobject *jref;
  182. #endif
  183. typedef unsigned char jbool;
  184. typedef signed char jbyte;
  185. #ifdef IS_64 /* XXX ok for alpha, but not right on all 64-bit architectures */
  186. typedef unsigned int juint;
  187. typedef int jint;
  188. #else
  189. typedef unsigned long juint;
  190. typedef long jint;
  191. #endif
  192. /*******************************************************************************
  193. * jlong : long long (64-bit signed integer type) support.
  194. ******************************************************************************/
  195. /*
  196. ** Bit masking macros. (n must be <= 31 to be portable)
  197. */
  198. #define JRI_BIT(n) ((juint)1 << (n))
  199. #define JRI_BITMASK(n) (JRI_BIT(n) - 1)
  200. #ifdef HAVE_LONG_LONG
  201. #ifdef OSF1
  202. /* long is default 64-bit on OSF1, -std1 does not allow long long */
  203. typedef long jlong;
  204. typedef unsigned long julong;
  205. #define jlong_MAXINT 0x7fffffffffffffffL
  206. #define jlong_MININT 0x8000000000000000L
  207. #define jlong_ZERO 0x0L
  208. #elif (defined(WIN32) || defined(_WIN32))
  209. typedef LONGLONG jlong;
  210. typedef DWORDLONG julong;
  211. #define jlong_MAXINT 0x7fffffffffffffffi64
  212. #define jlong_MININT 0x8000000000000000i64
  213. #define jlong_ZERO 0x0i64
  214. #else
  215. typedef long long jlong;
  216. typedef unsigned long long julong;
  217. #define jlong_MAXINT 0x7fffffffffffffffLL
  218. #define jlong_MININT 0x8000000000000000LL
  219. #define jlong_ZERO 0x0LL
  220. #endif
  221. #define jlong_IS_ZERO(a) ((a) == 0)
  222. #define jlong_EQ(a, b) ((a) == (b))
  223. #define jlong_NE(a, b) ((a) != (b))
  224. #define jlong_GE_ZERO(a) ((a) >= 0)
  225. #define jlong_CMP(a, op, b) ((a) op (b))
  226. #define jlong_AND(r, a, b) ((r) = (a) & (b))
  227. #define jlong_OR(r, a, b) ((r) = (a) | (b))
  228. #define jlong_XOR(r, a, b) ((r) = (a) ^ (b))
  229. #define jlong_OR2(r, a) ((r) = (r) | (a))
  230. #define jlong_NOT(r, a) ((r) = ~(a))
  231. #define jlong_NEG(r, a) ((r) = -(a))
  232. #define jlong_ADD(r, a, b) ((r) = (a) + (b))
  233. #define jlong_SUB(r, a, b) ((r) = (a) - (b))
  234. #define jlong_MUL(r, a, b) ((r) = (a) * (b))
  235. #define jlong_DIV(r, a, b) ((r) = (a) / (b))
  236. #define jlong_MOD(r, a, b) ((r) = (a) % (b))
  237. #define jlong_SHL(r, a, b) ((r) = (a) << (b))
  238. #define jlong_SHR(r, a, b) ((r) = (a) >> (b))
  239. #define jlong_USHR(r, a, b) ((r) = (julong)(a) >> (b))
  240. #define jlong_ISHL(r, a, b) ((r) = ((jlong)(a)) << (b))
  241. #define jlong_L2I(i, l) ((i) = (int)(l))
  242. #define jlong_L2UI(ui, l) ((ui) =(unsigned int)(l))
  243. #define jlong_L2F(f, l) ((f) = (l))
  244. #define jlong_L2D(d, l) ((d) = (l))
  245. #define jlong_I2L(l, i) ((l) = (i))
  246. #define jlong_UI2L(l, ui) ((l) = (ui))
  247. #define jlong_F2L(l, f) ((l) = (f))
  248. #define jlong_D2L(l, d) ((l) = (d))
  249. #define jlong_UDIVMOD(qp, rp, a, b) \
  250. (*(qp) = ((julong)(a) / (b)), \
  251. *(rp) = ((julong)(a) % (b)))
  252. #else /* !HAVE_LONG_LONG */
  253. typedef struct {
  254. #ifdef IS_LITTLE_ENDIAN
  255. juint lo, hi;
  256. #else
  257. juint hi, lo;
  258. #endif
  259. } jlong;
  260. typedef jlong julong;
  261. extern jlong jlong_MAXINT, jlong_MININT, jlong_ZERO;
  262. #define jlong_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0))
  263. #define jlong_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo))
  264. #define jlong_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo))
  265. #define jlong_GE_ZERO(a) (((a).hi >> 31) == 0)
  266. /*
  267. * NB: jlong_CMP and jlong_UCMP work only for strict relationals (<, >).
  268. */
  269. #define jlong_CMP(a, op, b) (((int32)(a).hi op (int32)(b).hi) || \
  270. (((a).hi == (b).hi) && ((a).lo op (b).lo)))
  271. #define jlong_UCMP(a, op, b) (((a).hi op (b).hi) || \
  272. (((a).hi == (b).hi) && ((a).lo op (b).lo)))
  273. #define jlong_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \
  274. (r).hi = (a).hi & (b).hi)
  275. #define jlong_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \
  276. (r).hi = (a).hi | (b).hi)
  277. #define jlong_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \
  278. (r).hi = (a).hi ^ (b).hi)
  279. #define jlong_OR2(r, a) ((r).lo = (r).lo | (a).lo, \
  280. (r).hi = (r).hi | (a).hi)
  281. #define jlong_NOT(r, a) ((r).lo = ~(a).lo, \
  282. (r).hi = ~(a).hi)
  283. #define jlong_NEG(r, a) ((r).lo = -(int32)(a).lo, \
  284. (r).hi = -(int32)(a).hi - ((r).lo != 0))
  285. #define jlong_ADD(r, a, b) { \
  286. jlong _a, _b; \
  287. _a = a; _b = b; \
  288. (r).lo = _a.lo + _b.lo; \
  289. (r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \
  290. }
  291. #define jlong_SUB(r, a, b) { \
  292. jlong _a, _b; \
  293. _a = a; _b = b; \
  294. (r).lo = _a.lo - _b.lo; \
  295. (r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \
  296. } \
  297. /*
  298. * Multiply 64-bit operands a and b to get 64-bit result r.
  299. * First multiply the low 32 bits of a and b to get a 64-bit result in r.
  300. * Then add the outer and inner products to r.hi.
  301. */
  302. #define jlong_MUL(r, a, b) { \
  303. jlong _a, _b; \
  304. _a = a; _b = b; \
  305. jlong_MUL32(r, _a.lo, _b.lo); \
  306. (r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \
  307. }
  308. /* XXX _jlong_lo16(a) = ((a) << 16 >> 16) is better on some archs (not on mips) */
  309. #define _jlong_lo16(a) ((a) & JRI_BITMASK(16))
  310. #define _jlong_hi16(a) ((a) >> 16)
  311. /*
  312. * Multiply 32-bit operands a and b to get 64-bit result r.
  313. * Use polynomial expansion based on primitive field element (1 << 16).
  314. */
  315. #define jlong_MUL32(r, a, b) { \
  316. juint _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \
  317. _a1 = _jlong_hi16(a), _a0 = _jlong_lo16(a); \
  318. _b1 = _jlong_hi16(b), _b0 = _jlong_lo16(b); \
  319. _y0 = _a0 * _b0; \
  320. _y1 = _a0 * _b1; \
  321. _y2 = _a1 * _b0; \
  322. _y3 = _a1 * _b1; \
  323. _y1 += _jlong_hi16(_y0); /* can't carry */ \
  324. _y1 += _y2; /* might carry */ \
  325. if (_y1 < _y2) _y3 += 1 << 16; /* propagate */ \
  326. (r).lo = (_jlong_lo16(_y1) << 16) + _jlong_lo16(_y0); \
  327. (r).hi = _y3 + _jlong_hi16(_y1); \
  328. }
  329. /*
  330. * Divide 64-bit unsigned operand a by 64-bit unsigned operand b, setting *qp
  331. * to the 64-bit unsigned quotient, and *rp to the 64-bit unsigned remainder.
  332. * Minimize effort if one of qp and rp is null.
  333. */
  334. #define jlong_UDIVMOD(qp, rp, a, b) jlong_udivmod(qp, rp, a, b)
  335. extern JRI_PUBLIC_API(void)
  336. jlong_udivmod(julong *qp, julong *rp, julong a, julong b);
  337. #define jlong_DIV(r, a, b) { \
  338. jlong _a, _b; \
  339. juint _negative = (int32)(a).hi < 0; \
  340. if (_negative) { \
  341. jlong_NEG(_a, a); \
  342. } else { \
  343. _a = a; \
  344. } \
  345. if ((int32)(b).hi < 0) { \
  346. _negative ^= 1; \
  347. jlong_NEG(_b, b); \
  348. } else { \
  349. _b = b; \
  350. } \
  351. jlong_UDIVMOD(&(r), 0, _a, _b); \
  352. if (_negative) \
  353. jlong_NEG(r, r); \
  354. }
  355. #define jlong_MOD(r, a, b) { \
  356. jlong _a, _b; \
  357. juint _negative = (int32)(a).hi < 0; \
  358. if (_negative) { \
  359. jlong_NEG(_a, a); \
  360. } else { \
  361. _a = a; \
  362. } \
  363. if ((int32)(b).hi < 0) { \
  364. jlong_NEG(_b, b); \
  365. } else { \
  366. _b = b; \
  367. } \
  368. jlong_UDIVMOD(0, &(r), _a, _b); \
  369. if (_negative) \
  370. jlong_NEG(r, r); \
  371. }
  372. /*
  373. * NB: b is a juint, not jlong or julong, for the shift ops.
  374. */
  375. #define jlong_SHL(r, a, b) { \
  376. if (b) { \
  377. jlong _a; \
  378. _a = a; \
  379. if ((b) < 32) { \
  380. (r).lo = _a.lo << (b); \
  381. (r).hi = (_a.hi << (b)) | (_a.lo >> (32 - (b))); \
  382. } else { \
  383. (r).lo = 0; \
  384. (r).hi = _a.lo << ((b) & 31); \
  385. } \
  386. } else { \
  387. (r) = (a); \
  388. } \
  389. }
  390. /* a is an int32, b is int32, r is jlong */
  391. #define jlong_ISHL(r, a, b) { \
  392. if (b) { \
  393. jlong _a; \
  394. _a.lo = (a); \
  395. _a.hi = 0; \
  396. if ((b) < 32) { \
  397. (r).lo = (a) << (b); \
  398. (r).hi = ((a) >> (32 - (b))); \
  399. } else { \
  400. (r).lo = 0; \
  401. (r).hi = (a) << ((b) & 31); \
  402. } \
  403. } else { \
  404. (r).lo = (a); \
  405. (r).hi = 0; \
  406. } \
  407. }
  408. #define jlong_SHR(r, a, b) { \
  409. if (b) { \
  410. jlong _a; \
  411. _a = a; \
  412. if ((b) < 32) { \
  413. (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b)); \
  414. (r).hi = (int32)_a.hi >> (b); \
  415. } else { \
  416. (r).lo = (int32)_a.hi >> ((b) & 31); \
  417. (r).hi = (int32)_a.hi >> 31; \
  418. } \
  419. } else { \
  420. (r) = (a); \
  421. } \
  422. }
  423. #define jlong_USHR(r, a, b) { \
  424. if (b) { \
  425. jlong _a; \
  426. _a = a; \
  427. if ((b) < 32) { \
  428. (r).lo = (_a.hi << (32 - (b))) | (_a.lo >> (b)); \
  429. (r).hi = _a.hi >> (b); \
  430. } else { \
  431. (r).lo = _a.hi >> ((b) & 31); \
  432. (r).hi = 0; \
  433. } \
  434. } else { \
  435. (r) = (a); \
  436. } \
  437. }
  438. #define jlong_L2I(i, l) ((i) = (l).lo)
  439. #define jlong_L2UI(ui, l) ((ui) = (l).lo)
  440. #define jlong_L2F(f, l) { double _d; jlong_L2D(_d, l); (f) = (float) _d; }
  441. #define jlong_L2D(d, l) { \
  442. int32 _negative; \
  443. jlong _absval; \
  444. \
  445. _negative = (l).hi >> 31; \
  446. if (_negative) { \
  447. jlong_NEG(_absval, l); \
  448. } else { \
  449. _absval = l; \
  450. } \
  451. (d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \
  452. if (_negative) \
  453. (d) = -(d); \
  454. }
  455. #define jlong_I2L(l, i) ((l).hi = (i) >> 31, (l).lo = (i))
  456. #define jlong_UI2L(l, ui) ((l).hi = 0, (l).lo = (ui))
  457. #define jlong_F2L(l, f) { double _d = (double) f; jlong_D2L(l, _d); }
  458. #define jlong_D2L(l, d) { \
  459. int _negative; \
  460. double _absval, _d_hi; \
  461. jlong _lo_d; \
  462. \
  463. _negative = ((d) < 0); \
  464. _absval = _negative ? -(d) : (d); \
  465. \
  466. (l).hi = (juint)(_absval / 4.294967296e9); \
  467. (l).lo = 0; \
  468. jlong_L2D(_d_hi, l); \
  469. _absval -= _d_hi; \
  470. _lo_d.hi = 0; \
  471. if (_absval < 0) { \
  472. _lo_d.lo = (juint) -_absval; \
  473. jlong_SUB(l, l, _lo_d); \
  474. } else { \
  475. _lo_d.lo = (juint) _absval; \
  476. jlong_ADD(l, l, _lo_d); \
  477. } \
  478. \
  479. if (_negative) \
  480. jlong_NEG(l, l); \
  481. }
  482. #endif /* !HAVE_LONG_LONG */
  483. /******************************************************************************/
  484. #ifdef HAVE_ALIGNED_LONGLONGS
  485. #define JRI_GET_INT64(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \
  486. ((_t).x[1] = ((jint*)(_addr))[1]), \
  487. (_t).l )
  488. #define JRI_SET_INT64(_t, _addr, _v) ( (_t).l = (_v), \
  489. ((jint*)(_addr))[0] = (_t).x[0], \
  490. ((jint*)(_addr))[1] = (_t).x[1] )
  491. #else
  492. #define JRI_GET_INT64(_t,_addr) (*(jlong*)(_addr))
  493. #define JRI_SET_INT64(_t, _addr, _v) (*(jlong*)(_addr) = (_v))
  494. #endif
  495. /* If double's must be aligned on doubleword boundaries then define this */
  496. #ifdef HAVE_ALIGNED_DOUBLES
  497. #define JRI_GET_DOUBLE(_t,_addr) ( ((_t).x[0] = ((jint*)(_addr))[0]), \
  498. ((_t).x[1] = ((jint*)(_addr))[1]), \
  499. (_t).d )
  500. #define JRI_SET_DOUBLE(_t, _addr, _v) ( (_t).d = (_v), \
  501. ((jint*)(_addr))[0] = (_t).x[0], \
  502. ((jint*)(_addr))[1] = (_t).x[1] )
  503. #else
  504. #define JRI_GET_DOUBLE(_t,_addr) (*(jdouble*)(_addr))
  505. #define JRI_SET_DOUBLE(_t, _addr, _v) (*(jdouble*)(_addr) = (_v))
  506. #endif
  507. /******************************************************************************/
  508. #ifdef __cplusplus
  509. }
  510. #endif
  511. #endif /* JRI_MD_H */
  512. /******************************************************************************/