libsc 2.8.5.210-64a7
The SC library provides support for parallel scientific applications.
sc_uint128.h
Go to the documentation of this file.
1/*
2 This file is part of the SC Library.
3 The SC Library provides support for parallel scientific applications.
4
5 Copyright (C) 2019 individual authors
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
28*/
29
30#ifndef SC_UINT128_H
31#define SC_UINT128_H
32
39#include <sc.h>
40
42typedef struct sc_uint128
43{
44 uint64_t high_bits;
45 uint64_t low_bits;
46}
48
56int sc_uint128_compare (const void *a, const void *b);
57
65 const sc_uint128_t * b);
66
74 uint64_t high, uint64_t low);
75
85 int exponent);
86
94void sc_uint128_set_bit (sc_uint128_t * a, int exponent);
95
103void sc_uint128_copy (const sc_uint128_t * input,
104 sc_uint128_t * output);
105
115 const sc_uint128_t * b,
116 sc_uint128_t * result);
117
128 const sc_uint128_t * b,
129 sc_uint128_t * result);
130
139 sc_uint128_t * result);
140
151 const sc_uint128_t * b,
152 sc_uint128_t * result);
153
164 const sc_uint128_t * b,
165 sc_uint128_t * result);
166
178 int shift_count,
179 sc_uint128_t * result);
180
192 int shift_count,
193 sc_uint128_t * result);
194
202 const sc_uint128_t * b);
203
212 const sc_uint128_t * b);
213
221 const sc_uint128_t * b);
222
230 const sc_uint128_t * b);
231
232#endif /* !SC_UINT128_H */
Support for process management (memory allocation, logging, etc.)
void sc_uint128_copy(const sc_uint128_t *input, sc_uint128_t *output)
Copies an initialized sc_uint128_t to a sc_uint128_t.
int sc_uint128_compare(const void *a, const void *b)
Compare the sc_uint128_t a and the sc_uint128_t b.
void sc_uint128_add_inplace(sc_uint128_t *a, const sc_uint128_t *b)
Adds the uint128 b to the uint128_t a.
void sc_uint128_bitwise_and_inplace(sc_uint128_t *a, const sc_uint128_t *b)
Calculates the bitwise and of the uint128_t a and the uint128_t b.
void sc_uint128_bitwise_neg(const sc_uint128_t *a, sc_uint128_t *result)
Calculates the bitwise negation of the uint128_t a.
void sc_uint128_bitwise_or(const sc_uint128_t *a, const sc_uint128_t *b, sc_uint128_t *result)
Calculates the bitwise or of the uint128_t a and b.
void sc_uint128_add(const sc_uint128_t *a, const sc_uint128_t *b, sc_uint128_t *result)
Adds the uint128_t b to the uint128_t a.
void sc_uint128_shift_right(const sc_uint128_t *input, int shift_count, sc_uint128_t *result)
Calculates the bit right shift of uint128_t input by shift_count bits.
void sc_uint128_shift_left(const sc_uint128_t *input, int shift_count, sc_uint128_t *result)
Calculates the bit left shift of uint128_t input by shift_count bits.
struct sc_uint128 sc_uint128_t
An unsigned 128 bit integer represented as two uint64_t.
void sc_uint128_bitwise_and(const sc_uint128_t *a, const sc_uint128_t *b, sc_uint128_t *result)
Calculates the bitwise and of the uint128_t a and the uint128_t b.
void sc_uint128_bitwise_or_inplace(sc_uint128_t *a, const sc_uint128_t *b)
Calculates the bitwise or of the uint128_t a and the uint128_t b.
void sc_uint128_sub_inplace(sc_uint128_t *a, const sc_uint128_t *b)
Subtracts the uint128_t b from the uint128_t a.
int sc_uint128_chk_bit(const sc_uint128_t *input, int exponent)
Returns the bit_number-th bit of input.
void sc_uint128_set_bit(sc_uint128_t *a, int exponent)
Sets the exponent-th bit of a to one and keep all other bits.
void sc_uint128_sub(const sc_uint128_t *a, const sc_uint128_t *b, sc_uint128_t *result)
Subtracts the uint128_t b from the uint128_t a.
int sc_uint128_is_equal(const sc_uint128_t *a, const sc_uint128_t *b)
Checks if the sc_uint128_t a and the sc_uint128_t b are equal.
void sc_uint128_init(sc_uint128_t *a, uint64_t high, uint64_t low)
Initializes an unsigned 128 bit integer to a given value.
An unsigned 128 bit integer represented as two uint64_t.
Definition: sc_uint128.h:43
uint64_t high_bits
The more significant 64 bits.
Definition: sc_uint128.h:44
uint64_t low_bits
The less significant 64 bits.
Definition: sc_uint128.h:45