⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 long.h

📁 This is a java virtual machine implement in c
💻 H
字号:
/*0001*//*
/*0002./ * Copyright (c) 1998 Sun Microsystems, Inc. All Rights Reserved.
/*0003./ * 
/*0004./ * This software is the confidential and proprietary information of Sun
/*0005./ * Microsystems, Inc. ("Confidential Information").  You shall not
/*0006./ * disclose such Confidential Information and shall use it only in
/*0007./ * accordance with the terms of the license agreement you entered into
/*0008./ * with Sun.
/*0009./ * 
/*0010./ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
/*0011./ * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/*0012./ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/*0013./ * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
/*0014./ * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
/*0015./ * THIS SOFTWARE OR ITS DERIVATIVES.
/*0016./ * 
/*0017./ */
/*0018*/
/*0019*//*=========================================================================
/*0020./ * SYSTEM:    KVM
/*0021./ * SUBSYSTEM: 64-bit arithmetic
/*0022./ * FILE:      long.h
/*0023./ * OVERVIEW:  Definitions needed for supporting 64-bit arithmetic
/*0024./ *            in a portable fashion.
/*0025./ * AUTHOR:    Frank Yellin
/*0026./ *=======================================================================*/
/*0027*/
/*0028*//*=========================================================================
/*0029./ * Definitions and declarations
/*0030./ *=======================================================================*/
/*0031*/
/*0032*/#undef long64
/*0033*/#undef ulong64
/*0034*/
/*0035*/#if !COMPILER_SUPPORTS_LONG
/*0036*/
/*0037*/  #if BIG_ENDIAN
/*0038*/    typedef struct { unsigned long high; unsigned long low; } long64;
/*0039*/    typedef struct { unsigned long high; unsigned long low; } ulong64;
/*0040*/  #else
/*0041*/  # undef LITTLE_ENDIAN
/*0042*/  # define LITTLE_ENDIAN 1
/*0043*/    typedef struct { unsigned long low; unsigned long high; } long64;
/*0044*/    typedef struct { unsigned long low; unsigned long high; } ulong64;
/*0045*/  #endif /* BIG_ENDIAN */
/*0046*/
/*0047*/  long64  ll_mul(long64, long64);
/*0048*/  long64  ll_div(long64, long64);
/*0049*/  long64  ll_rem(long64, long64);
/*0050*/  long64  ll_shl(long64, int);
/*0051*/  long64  ll_shr(long64, int);
/*0052*/  long64  ll_ushr(long64, int);
/*0053*/
/*0054*/  long64  float2ll(float);
/*0055*/  long64  double2ll(double);
/*0056*/  float   ll2float(long64);
/*0057*/  double  ll2double(long64);
/*0058*/
/*0059*/#else /* COMPILER_SUPPORTS_LONG */
/*0060*/
/*0061*/  #define ll_mul(a, b)    ((long64)(a) * (long64)(b))
/*0062*/  #define ll_div(a, b)    ((long64)(a) / (long64)(b))
/*0063*/  #define ll_rem(a,b)     ((long64)(a) % (long64)(b))
/*0064*/  #define ll_shl(a, n)    ((long64)(a) << (n))
/*0065*/  #define ll_shr(a, n)    ((long64)(a) >> (n))
/*0066*/  #define ll_ushr(a, n)   ((ulong64)(a) >>(n))
/*0067*/
/*0068*/  #define float2ll(a)     ((long64)a)
/*0069*/  #define double2ll(a)    ((long64)a)
/*0070*/
/*0071*/  #define ll2float(a)     ((float) (a))
/*0072*/  #define ll2double(a)    ((double) (a))
/*0073*/
/*0074*/#endif /* !COMPILER_SUPPORTS_LONG */
/*0075*/
/*0076*//* Here are the functions that we create the definitions for machines
/*0077./ * that don't support longs.
/*0078./ *
/*0079./ * For all three-operand arguments, the result cannot be the same location
/*0080./ * as either of the operands */
/*0081*/
/*0082*/#if COMPILER_SUPPORTS_LONG
/*0083*/
/*0084*/  #define ll_setZero(a)        ((a) = 0)
/*0085*/  #define ll_inc(a,b)          ((a) += (b))
/*0086*/  #define ll_dec(a,b)          ((a) -= (b))
/*0087*/  #define ll_negate(a)         ((a) = (-a))
/*0088*/
/*0089*//* The following weird definition fixes a bug in one particular compiler */
/*0090*/  #define ll_uint_to_long(a,b) ((a) = (ulong64)(unsigned long)b)
/*0091*/  #define ll_int_to_long(a,b)  ((a) = (signed long)b)
/*0092*/  #define ll_long_to_uint(a,b) (b = (unsigned int)(a))
/*0093*/
/*0094*/  #define ll_compare_lt(a, b)  ((a) < (b))
/*0095*/  #define ll_compare_eq(a, b)  ((a) == (b))
/*0096*/  #define ll_compare_gt(a, b)  ((a) > (b))
/*0097*/
/*0098*/  #define ll_zero_lt(a)        (a < 0)
/*0099*/  #define ll_zero_eq(a)        (a == 0)
/*0100*/  #define ll_zero_gt(a)        (a > 0)
/*0101*/
/*0102*/#else
/*0103*/
/*0104*/  #define ll_setZero(a)        ((a).high = (a).low = 0)
/*0105*/  #define ll_inc(a,b)          ((a).low += (b).low, \
/*0106*/                               (a).high += (b).high + ((a).low < (b).low));
/*0107*/  #define ll_dec(a,b)          ((a).high -= ((b).high + ((a).low < (b).low)), \
/*0108*/                               (a).low  -= (b).low)
/*0109*/  #define ll_negate(a)         ((a).low = -(a).low, \
/*0110*/                               (a).high = -((a).high + ((a).low != 0)))
/*0111*/
/*0112*/  #define ll_uint_to_long(a,b) ((a).high = 0, (a).low = b)
/*0113*/  #define ll_int_to_long(a,b)  ((a).low = b; (a).high = ((signed long)b) >> 31)
/*0114*/  #define ll_long_to_uint(a,b) (b = (unsigned int)((a).low))
/*0115*/
/*0116*/  #define ll_compare_lt(a, b)  (((a).high < (b).high) || \
/*0117*/                               (((a).high == (b).high) && ((a).low < (b).low)))
/*0118*/  #define ll_compare_eq(a, b)  (((a).high == (b).high) && ((a).low == (b).low))
/*0119*/  #define ll_compare_gt(a, b)  ll_compare_lt(b, a)
/*0120*/
/*0121*/  #define ll_zero_lt(a)        ((a).high < 0)
/*0122*/  #define ll_zero_eq(a)        (((a).high | (a).low) == 0)
/*0123*/  #define ll_zero_gt(a)        (!(ll_zero_lt(a) || ll_zero_eq(a)))
/*0124*/
/*0125*/#endif /* COMPILER_SUPPORTS_LONG */
/*0126*/
/*0127*/#define ll_compare_le(a,b)     (!ll_compare_gt(a,b))
/*0128*/#define ll_compare_ne(a,b)     (!ll_compare_eq(a,b))
/*0129*/#define ll_compare_ge(a,b)     (!ll_compare_lt(a,b))
/*0130*/
/*0131*/#define ll_zero_le(a)          (!ll_zero_gt(a))
/*0132*/#define ll_zero_ne(a)          (!ll_zero_eq(a))
/*0133*/#define ll_zero_ge(a)          (!ll_zero_lt(a))
/*0134*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -