Mercurial > hg > octave-nkf > gnulib-hg
annotate lib/u64.h @ 17935:0ad1f4c9eed5 default tip
tests: support stderr verification with returns_()
* tests/init.sh (returns_): Disable tracing for this wrapper
function, so that stderr of the wrapped command is unchanged,
allowing for verification of the contents.
author | Pádraig Brady <P@draigBrady.com> |
---|---|
date | Mon, 16 Feb 2015 17:20:39 +0000 |
parents | ab58d4870664 |
children |
rev | line source |
---|---|
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
1 /* uint64_t-like operations that work even on hosts lacking uint64_t |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
2 |
17848 | 3 Copyright (C) 2006, 2009-2015 Free Software Foundation, Inc. |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
4 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
7 the Free Software Foundation, either version 3 of the License, or |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
8 (at your option) any later version. |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
9 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
14 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
17 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
18 /* Written by Paul Eggert. */ |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
19 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
20 #include <stdint.h> |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
21 |
17484
1f9070ef79b0
headers: check that _GL_INLINE_HEADER_BEGIN is defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
22 #ifndef _GL_INLINE_HEADER_BEGIN |
1f9070ef79b0
headers: check that _GL_INLINE_HEADER_BEGIN is defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
23 #error "Please include config.h first." |
1f9070ef79b0
headers: check that _GL_INLINE_HEADER_BEGIN is defined
Paul Eggert <eggert@cs.ucla.edu>
parents:
17249
diff
changeset
|
24 #endif |
17025 | 25 _GL_INLINE_HEADER_BEGIN |
17028
ce2683fe3994
Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents:
17025
diff
changeset
|
26 #ifndef _GL_U64_INLINE |
ce2683fe3994
Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents:
17025
diff
changeset
|
27 # define _GL_U64_INLINE _GL_INLINE |
ce2683fe3994
Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents:
17025
diff
changeset
|
28 #endif |
17025 | 29 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
30 /* Return X rotated left by N bits, where 0 < N < 64. */ |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
31 #define u64rol(x, n) u64or (u64shl (x, n), u64shr (x, 64 - n)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
32 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
33 #ifdef UINT64_MAX |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
34 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
35 /* Native implementations are trivial. See below for comments on what |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
36 these operations do. */ |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
37 typedef uint64_t u64; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
38 # define u64hilo(hi, lo) ((u64) (((u64) (hi) << 32) + (lo))) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
39 # define u64init(hi, lo) u64hilo (hi, lo) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
40 # define u64lo(x) ((u64) (x)) |
16861
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
41 # define u64size(x) u64lo (x) |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
42 # define u64lt(x, y) ((x) < (y)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
43 # define u64and(x, y) ((x) & (y)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
44 # define u64or(x, y) ((x) | (y)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
45 # define u64xor(x, y) ((x) ^ (y)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
46 # define u64plus(x, y) ((x) + (y)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
47 # define u64shl(x, n) ((x) << (n)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
48 # define u64shr(x, n) ((x) >> (n)) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
49 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
50 #else |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
51 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
52 /* u64 is a 64-bit unsigned integer value. |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
53 u64init (HI, LO), is like u64hilo (HI, LO), but for use in |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
54 initializer contexts. */ |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
55 # ifdef WORDS_BIGENDIAN |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
56 typedef struct { uint32_t hi, lo; } u64; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
57 # define u64init(hi, lo) { hi, lo } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
58 # else |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
59 typedef struct { uint32_t lo, hi; } u64; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
60 # define u64init(hi, lo) { lo, hi } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
61 # endif |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
62 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
63 /* Given the high and low-order 32-bit quantities HI and LO, return a u64 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
64 value representing (HI << 32) + LO. */ |
17025 | 65 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
66 u64hilo (uint32_t hi, uint32_t lo) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
67 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
68 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
69 r.hi = hi; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
70 r.lo = lo; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
71 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
72 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
73 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
74 /* Return a u64 value representing LO. */ |
17025 | 75 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
76 u64lo (uint32_t lo) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
77 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
78 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
79 r.hi = 0; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
80 r.lo = lo; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
81 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
82 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
83 |
16861
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
84 /* Return a u64 value representing SIZE. */ |
17025 | 85 _GL_U64_INLINE u64 |
16861
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
86 u64size (size_t size) |
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
87 { |
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
88 u64 r; |
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
89 r.hi = size >> 31 >> 1; |
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
90 r.lo = size; |
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
91 return r; |
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
92 } |
660cb8105779
crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
93 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
94 /* Return X < Y. */ |
17025 | 95 _GL_U64_INLINE int |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
96 u64lt (u64 x, u64 y) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
97 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
98 return x.hi < y.hi || (x.hi == y.hi && x.lo < y.lo); |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
99 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
100 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
101 /* Return X & Y. */ |
17025 | 102 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
103 u64and (u64 x, u64 y) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
104 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
105 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
106 r.hi = x.hi & y.hi; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
107 r.lo = x.lo & y.lo; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
108 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
109 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
110 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
111 /* Return X | Y. */ |
17025 | 112 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
113 u64or (u64 x, u64 y) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
114 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
115 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
116 r.hi = x.hi | y.hi; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
117 r.lo = x.lo | y.lo; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
118 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
119 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
120 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
121 /* Return X ^ Y. */ |
17025 | 122 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
123 u64xor (u64 x, u64 y) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
124 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
125 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
126 r.hi = x.hi ^ y.hi; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
127 r.lo = x.lo ^ y.lo; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
128 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
129 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
130 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
131 /* Return X + Y. */ |
17025 | 132 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
133 u64plus (u64 x, u64 y) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
134 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
135 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
136 r.lo = x.lo + y.lo; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
137 r.hi = x.hi + y.hi + (r.lo < x.lo); |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
138 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
139 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
140 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
141 /* Return X << N. */ |
17025 | 142 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
143 u64shl (u64 x, int n) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
144 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
145 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
146 if (n < 32) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
147 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
148 r.hi = (x.hi << n) | (x.lo >> (32 - n)); |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
149 r.lo = x.lo << n; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
150 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
151 else |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
152 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
153 r.hi = x.lo << (n - 32); |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
154 r.lo = 0; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
155 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
156 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
157 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
158 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
159 /* Return X >> N. */ |
17025 | 160 _GL_U64_INLINE u64 |
10058
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
161 u64shr (u64 x, int n) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
162 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
163 u64 r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
164 if (n < 32) |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
165 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
166 r.hi = x.hi >> n; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
167 r.lo = (x.hi << (32 - n)) | (x.lo >> n); |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
168 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
169 else |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
170 { |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
171 r.hi = 0; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
172 r.lo = x.hi >> (n - 32); |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
173 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
174 return r; |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
175 } |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
176 |
e65afb893b33
New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
177 #endif |
17025 | 178 |
179 _GL_INLINE_HEADER_END |