home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / java.z / typedefs.h < prev    next >
C/C++ Source or Header  |  1996-05-03  |  3KB  |  81 lines

  1. /*
  2.  * @(#)typedefs.h    1.10 95/11/29  
  3.  *
  4.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software
  7.  * and its documentation for NON-COMMERCIAL purposes and without
  8.  * fee is hereby granted provided that this copyright notice
  9.  * appears in all copies. Please refer to the file "copyright.html"
  10.  * for further important copyright and licensing information.
  11.  *
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  13.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  14.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  15.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  16.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  17.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  18.  */
  19.  
  20. #ifndef    _TYPEDEFS_H_
  21. #define    _TYPEDEFS_H_
  22.  
  23. #include "typedefs_md.h"    /* for int64_t */
  24.  
  25. /*
  26.  * Macros to deal with the JavaVM's stack alignment. Many machines
  27.  * require doublewords to be double aligned.  This union is used by
  28.  * code in math.h as a more portable way do alingnment on machines
  29.  * that require it.  This union and the macros that use it came from
  30.  * Netscape.
  31.  */
  32.  
  33. typedef union Java8Str {
  34.     int32_t x[2];
  35.     double d;
  36.     int64_t l;
  37.     void *p;
  38. } Java8;
  39.  
  40.  
  41. #ifdef HAVE_ALIGNED_LONGLONGS
  42. #define GET_INT64(_t,_addr) ( ((_t).x[0] = ((int32_t*)(_addr))[0]), \
  43.                               ((_t).x[1] = ((int32_t*)(_addr))[1]), \
  44.                               (_t).l )
  45. #define SET_INT64(_t, _addr, _v) ( (_t).l = (_v),                    \
  46.                                    ((int32_t*)(_addr))[0] = (_t).x[0], \
  47.                                    ((int32_t*)(_addr))[1] = (_t).x[1] )
  48. #else
  49. #define GET_INT64(_t,_addr) (*(int64_t*)(_addr))
  50. #define SET_INT64(_t, _addr, _v) (*(int64_t*)(_addr) = (_v))
  51. #endif
  52.  
  53. /* If double's must be aligned on doubleword boundaries then define this */
  54. #ifdef HAVE_ALIGNED_DOUBLES
  55. #define GET_DOUBLE(_t,_addr) ( ((_t).x[0] = ((int32_t*)(_addr))[0]), \
  56.                                ((_t).x[1] = ((int32_t*)(_addr))[1]), \
  57.                                (_t).d )
  58. #define SET_DOUBLE(_t, _addr, _v) ( (_t).d = (_v),                    \
  59.                                     ((int32_t*)(_addr))[0] = (_t).x[0], \
  60.                                     ((int32_t*)(_addr))[1] = (_t).x[1] )
  61. #else
  62. #define GET_DOUBLE(_t,_addr) (*(double*)(_addr))
  63. #define SET_DOUBLE(_t, _addr, _v) (*(double*)(_addr) = (_v))
  64. #endif
  65.  
  66. /* If pointers are 64bits then define this */
  67. #ifdef HAVE_64BIT_POINTERS
  68. #define GET_HANDLE(_t,_addr) ( ((_t).x[0] = ((int32_t*)(_addr))[0]), \
  69.                                ((_t).x[1] = ((int32_t*)(_addr))[1]), \
  70.                                (_t).p )
  71. #define SET_HANDLE(_t, _addr, _v) ( (_t).p = (_v),                    \
  72.                                     ((int32_t*)(_addr))[0] = (_t).x[0], \
  73.                                     ((int32_t*)(_addr))[1] = (_t).x[1] )
  74. #else
  75. #define GET_HANDLE(_t,_addr) (*(JHandle*)(_addr))
  76. #define SET_HANDLE(_t, _addr, _v) (*(JHandle*)(_addr) = (_v))
  77. #endif
  78.  
  79.  
  80. #endif    /* !_TYPEDEFS_H_ */
  81.