annotate lib/u64.h @ 17409:26a04e61f560

stdio: use __REDIRECT for fwrite, fwrite_unlocked * lib/stdio.in.h (fwrite): When working around bug 11959, use __REDIRECT rather than '#define fwrite(...) ... fwrite (...) ...'. This is a more-targeted way to fix the -Wunused-value issue with clang, and it works with GCC too. Problem with targeting reported by Eric Blake in <http://lists.gnu.org/archive/html/bug-gnulib/2013-05/msg00067.html>. (fwrite_unlocked): Treat like fwrite. I ran into this issue while debugging the fwrite issue.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 15 May 2013 15:52:42 -0700
parents e542fd46ad6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 17028
diff changeset
3 Copyright (C) 2006, 2009-2013 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
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
22 _GL_INLINE_HEADER_BEGIN
17028
ce2683fe3994 Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17025
diff changeset
23 #ifndef _GL_U64_INLINE
ce2683fe3994 Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17025
diff changeset
24 # define _GL_U64_INLINE _GL_INLINE
ce2683fe3994 Keep the extern-inline macros closer together.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17025
diff changeset
25 #endif
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
26
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
27 /* 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
28 #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
29
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
30 #ifdef UINT64_MAX
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
31
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
32 /* 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
33 these operations do. */
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
34 typedef uint64_t u64;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
35 # 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
36 # define u64init(hi, lo) u64hilo (hi, lo)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
37 # define u64lo(x) ((u64) (x))
16861
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
38 # define u64size(x) u64lo (x)
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
39 # define u64lt(x, y) ((x) < (y))
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
40 # define u64and(x, y) ((x) & (y))
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
41 # define u64or(x, y) ((x) | (y))
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
42 # define u64xor(x, y) ((x) ^ (y))
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
43 # define u64plus(x, y) ((x) + (y))
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
44 # define u64shl(x, n) ((x) << (n))
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
45 # define u64shr(x, n) ((x) >> (n))
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
46
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
47 #else
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
48
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
49 /* 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
50 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
51 initializer contexts. */
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
52 # ifdef WORDS_BIGENDIAN
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
53 typedef struct { uint32_t hi, lo; } u64;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
54 # define u64init(hi, lo) { hi, lo }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
55 # else
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
56 typedef struct { uint32_t lo, hi; } u64;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
57 # define u64init(hi, lo) { lo, hi }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
58 # endif
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
59
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
60 /* 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
61 value representing (HI << 32) + LO. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
62 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
63 u64hilo (uint32_t hi, uint32_t lo)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
64 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
65 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
66 r.hi = hi;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
67 r.lo = lo;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
68 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
69 }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
70
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
71 /* Return a u64 value representing LO. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
72 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
73 u64lo (uint32_t lo)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
74 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
75 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
76 r.hi = 0;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
77 r.lo = lo;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
78 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
79 }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
80
16861
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
81 /* Return a u64 value representing SIZE. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
82 _GL_U64_INLINE u64
16861
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
83 u64size (size_t size)
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
84 {
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
85 u64 r;
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
86 r.hi = size >> 31 >> 1;
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
87 r.lo = size;
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
88 return r;
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
89 }
660cb8105779 crypto: fix bug in large buffer handling
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
90
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
91 /* Return X < Y. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
92 _GL_U64_INLINE int
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
93 u64lt (u64 x, u64 y)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
94 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
95 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
96 }
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 & Y. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
99 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
100 u64and (u64 x, u64 y)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
101 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
102 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
103 r.hi = x.hi & y.hi;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
104 r.lo = x.lo & y.lo;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
105 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
106 }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
107
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
108 /* Return X | Y. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
109 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
110 u64or (u64 x, u64 y)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
111 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
112 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
113 r.hi = x.hi | y.hi;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
114 r.lo = x.lo | y.lo;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
115 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
116 }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
117
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
118 /* Return X ^ Y. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
119 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
120 u64xor (u64 x, u64 y)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
121 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
122 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
123 r.hi = x.hi ^ y.hi;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
124 r.lo = x.lo ^ y.lo;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
125 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
126 }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
127
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
128 /* Return X + Y. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
129 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
130 u64plus (u64 x, u64 y)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
131 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
132 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
133 r.lo = x.lo + y.lo;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
134 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
135 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
136 }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
137
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
138 /* Return X << N. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
139 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
140 u64shl (u64 x, int n)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
141 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
142 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
143 if (n < 32)
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 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
146 r.lo = x.lo << n;
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 else
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
149 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
150 r.hi = x.lo << (n - 32);
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
151 r.lo = 0;
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 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
154 }
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 X >> N. */
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
157 _GL_U64_INLINE u64
10058
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
158 u64shr (u64 x, int n)
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
159 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
160 u64 r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
161 if (n < 32)
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 r.hi = x.hi >> n;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
164 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
165 }
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
166 else
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
167 {
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
168 r.hi = 0;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
169 r.lo = x.hi >> (n - 32);
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 return r;
e65afb893b33 New modules: crypto/sha256, crypto/sha512 (from coreutils)
Jim Meyering <meyering@redhat.com>
parents:
diff changeset
172 }
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 #endif
17025
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
175
ca76418cc04d u64: use extern-inline
Paul Eggert <eggert@cs.ucla.edu>
parents: 16861
diff changeset
176 _GL_INLINE_HEADER_END