~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/nbody-java/xmlvm-number.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-06-11 15:45:24 UTC
  • mfrom: (1.2.1) (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130611154524-rppb3w6tixlegv4n
Tags: 1.4.7~20130611~a1eb425-1
* New snapshot release
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 *  contributor license agreements.  See the NOTICE file distributed with
 
4
 *  this work for additional information regarding copyright ownership.
 
5
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 *  (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
 *
 
9
 *     http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
11
 *  Unless required by applicable law or agreed to in writing, software
 
12
 *  distributed under the License is distributed on an "AS IS" BASIS,
 
13
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 *  See the License for the specific language governing permissions and
 
15
 *  limitations under the License.
 
16
 *
 
17
 *  cbigint.c has been adapted for xmlvm
 
18
 */
 
19
#ifndef __XMLVM_NUMBER_H__
 
20
#define __XMLVM_NUMBER_H__
 
21
 
 
22
#include <string.h>
 
23
#include <math.h>
 
24
#include "xmlvm-hy.h"
 
25
#include "hycomp.h"
 
26
 
 
27
#define LONG_LO_OFFSET                  0
 
28
#define LONG_HI_OFFSET                  1
 
29
 
 
30
#define LOW_U32_FROM_LONG64_PTR(long64ptr) (((U64U32DBL *)(long64ptr))->u32val[LONG_LO_OFFSET])
 
31
#define HIGH_U32_FROM_LONG64_PTR(long64ptr) (((U64U32DBL *)(long64ptr))->u32val[LONG_HI_OFFSET])
 
32
#define LOW_U32_FROM_VAR(u64)     LOW_U32_FROM_LONG64_PTR(&(u64))
 
33
#define LOW_U32_FROM_PTR(u64ptr)  LOW_U32_FROM_LONG64_PTR(u64ptr)
 
34
#define HIGH_U32_FROM_VAR(u64)    HIGH_U32_FROM_LONG64_PTR(&(u64))
 
35
#define HIGH_U32_FROM_PTR(u64ptr) HIGH_U32_FROM_LONG64_PTR(u64ptr)
 
36
 
 
37
 
 
38
#define HIGH_IN_U64(u64) ((u64) >> 32)
 
39
#if defined(USE_LL)
 
40
#define LOW_IN_U64(u64) ((u64) & 0x00000000FFFFFFFFLL)
 
41
#else
 
42
#if defined(USE_L)
 
43
#define LOW_IN_U64(u64) ((u64) & 0x00000000FFFFFFFFL)
 
44
#else
 
45
#define LOW_IN_U64(u64) ((u64) & 0x00000000FFFFFFFF)
 
46
#endif /* USE_L */
 
47
#endif /* USE_LL */
 
48
 
 
49
typedef union u64u32dbl_tag {
 
50
        U_64    u64val;
 
51
        U_32    u32val[2];
 
52
    I_32    i32val[2];
 
53
        double  dval;
 
54
} U64U32DBL;
 
55
 
 
56
#if defined(USE_LL)
 
57
#define TEN_E1 (0xALL)
 
58
#define TEN_E2 (0x64LL)
 
59
#define TEN_E3 (0x3E8LL)
 
60
#define TEN_E4 (0x2710LL)
 
61
#define TEN_E5 (0x186A0LL)
 
62
#define TEN_E6 (0xF4240LL)
 
63
#define TEN_E7 (0x989680LL)
 
64
#define TEN_E8 (0x5F5E100LL)
 
65
#define TEN_E9 (0x3B9ACA00LL)
 
66
#define TEN_E19 (0x8AC7230489E80000LL)
 
67
#else
 
68
#if defined(USE_L)
 
69
#define TEN_E1 (0xAL)
 
70
#define TEN_E2 (0x64L)
 
71
#define TEN_E3 (0x3E8L)
 
72
#define TEN_E4 (0x2710L)
 
73
#define TEN_E5 (0x186A0L)
 
74
#define TEN_E6 (0xF4240L)
 
75
#define TEN_E7 (0x989680L)
 
76
#define TEN_E8 (0x5F5E100L)
 
77
#define TEN_E9 (0x3B9ACA00L)
 
78
#define TEN_E19 (0x8AC7230489E80000L)
 
79
#else
 
80
#define TEN_E1 (0xA)
 
81
#define TEN_E2 (0x64)
 
82
#define TEN_E3 (0x3E8)
 
83
#define TEN_E4 (0x2710)
 
84
#define TEN_E5 (0x186A0)
 
85
#define TEN_E6 (0xF4240)
 
86
#define TEN_E7 (0x989680)
 
87
#define TEN_E8 (0x5F5E100)
 
88
#define TEN_E9 (0x3B9ACA00)
 
89
#define TEN_E19 (0x8AC7230489E80000)
 
90
#endif /* USE_L */
 
91
#endif /* USE_LL */
 
92
 
 
93
#define TIMES_TEN(x) (((x) << 3) + ((x) << 1))
 
94
 
 
95
U_32 simpleMultiplyHighPrecision (U_64 * arg1, IDATA length, U_64 arg2);
 
96
void simpleShiftLeftHighPrecision (U_64 * arg1, IDATA length, IDATA arg2);
 
97
U_64 simpleMultiplyHighPrecision64 (U_64 * arg1, IDATA length, U_64 arg2);
 
98
U_32 simpleAppendDecimalDigitHighPrecision (U_64 * arg1, IDATA length, U_64 digit);
 
99
IDATA timesTenToTheEHighPrecision (U_64 * result, IDATA length, JAVA_INT e);
 
100
IDATA addHighPrecision (U_64 * arg1, IDATA length1, U_64 * arg2, IDATA length2);
 
101
IDATA compareHighPrecision (U_64 * arg1, IDATA length1, U_64 * arg2, IDATA length2);
 
102
IDATA simpleAddHighPrecision (U_64 * arg1, IDATA length, U_64 arg2);
 
103
void subtractHighPrecision (U_64 * arg1, IDATA length1, U_64 * arg2, IDATA length2);
 
104
 
 
105
#endif