home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / typedefs.h < prev    next >
C/C++ Source or Header  |  1997-11-24  |  3KB  |  84 lines

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