home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
sybase
/
starbuck
/
java.z
/
typedefs.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-05-03
|
3KB
|
81 lines
/*
* @(#)typedefs.h 1.10 95/11/29
*
* Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
#ifndef _TYPEDEFS_H_
#define _TYPEDEFS_H_
#include "typedefs_md.h" /* for int64_t */
/*
* Macros to deal with the JavaVM's stack alignment. Many machines
* require doublewords to be double aligned. This union is used by
* code in math.h as a more portable way do alingnment on machines
* that require it. This union and the macros that use it came from
* Netscape.
*/
typedef union Java8Str {
int32_t x[2];
double d;
int64_t l;
void *p;
} Java8;
#ifdef HAVE_ALIGNED_LONGLONGS
#define GET_INT64(_t,_addr) ( ((_t).x[0] = ((int32_t*)(_addr))[0]), \
((_t).x[1] = ((int32_t*)(_addr))[1]), \
(_t).l )
#define SET_INT64(_t, _addr, _v) ( (_t).l = (_v), \
((int32_t*)(_addr))[0] = (_t).x[0], \
((int32_t*)(_addr))[1] = (_t).x[1] )
#else
#define GET_INT64(_t,_addr) (*(int64_t*)(_addr))
#define SET_INT64(_t, _addr, _v) (*(int64_t*)(_addr) = (_v))
#endif
/* If double's must be aligned on doubleword boundaries then define this */
#ifdef HAVE_ALIGNED_DOUBLES
#define GET_DOUBLE(_t,_addr) ( ((_t).x[0] = ((int32_t*)(_addr))[0]), \
((_t).x[1] = ((int32_t*)(_addr))[1]), \
(_t).d )
#define SET_DOUBLE(_t, _addr, _v) ( (_t).d = (_v), \
((int32_t*)(_addr))[0] = (_t).x[0], \
((int32_t*)(_addr))[1] = (_t).x[1] )
#else
#define GET_DOUBLE(_t,_addr) (*(double*)(_addr))
#define SET_DOUBLE(_t, _addr, _v) (*(double*)(_addr) = (_v))
#endif
/* If pointers are 64bits then define this */
#ifdef HAVE_64BIT_POINTERS
#define GET_HANDLE(_t,_addr) ( ((_t).x[0] = ((int32_t*)(_addr))[0]), \
((_t).x[1] = ((int32_t*)(_addr))[1]), \
(_t).p )
#define SET_HANDLE(_t, _addr, _v) ( (_t).p = (_v), \
((int32_t*)(_addr))[0] = (_t).x[0], \
((int32_t*)(_addr))[1] = (_t).x[1] )
#else
#define GET_HANDLE(_t,_addr) (*(JHandle*)(_addr))
#define SET_HANDLE(_t, _addr, _v) (*(JHandle*)(_addr) = (_v))
#endif
#endif /* !_TYPEDEFS_H_ */