34
34
#include <inttypes.h>
35
35
#endif
36
36
37
-
38
37
#if __GNUC_GNU_INLINE__ && !defined(__cplusplus )
39
38
#error Nonstandard GNU inlining semantics. Compile with -std=c99 or better.
40
39
#endif
@@ -53,7 +52,7 @@ extern "C" {
53
52
uint64_t low ;
54
53
} pcg128_t ;
55
54
56
- inline pcg128_t PCG_128BIT_CONSTANT (uint64_t high , uint64_t low ) {
55
+ static inline pcg128_t PCG_128BIT_CONSTANT (uint64_t high , uint64_t low ) {
57
56
pcg128_t result ;
58
57
result .high = high ;
59
58
result .low = low ;
@@ -80,22 +79,22 @@ extern "C" {
80
79
{ PCG_128BIT_CONSTANT(0x979c9a98d8462005ULL, 0x7d3e9cb6cfe0549bULL), \
81
80
PCG_128BIT_CONSTANT(0x0000000000000001ULL, 0xda3e39cb94b95bdbULL) }
82
81
83
- inline uint64_t pcg_rotr_64 (uint64_t value , unsigned int rot )
82
+ static inline uint64_t pcg_rotr_64 (uint64_t value , unsigned int rot )
84
83
{
85
84
return (value >> rot ) | (value << ((- rot ) & 63 ));
86
85
}
87
86
88
87
#ifdef PCG_EMULATED_128BIT_MATH
89
88
90
- inline pcg128_t _pcg128_add (pcg128_t a , pcg128_t b ) {
89
+ static inline pcg128_t _pcg128_add (pcg128_t a , pcg128_t b ) {
91
90
pcg128_t result ;
92
91
93
92
result .low = a .low + b .low ;
94
93
result .high = a .high + b .high + (result .low < b .low );
95
94
return result ;
96
95
}
97
96
98
- inline void _pcg_mult64 (uint64_t x , uint64_t y , uint64_t * z1 , uint64_t * z0 ) {
97
+ static inline void _pcg_mult64 (uint64_t x , uint64_t y , uint64_t * z1 , uint64_t * z0 ) {
99
98
uint64_t x0 , x1 , y0 , y1 ;
100
99
uint64_t w0 , w1 , w2 , t ;
101
100
/* Lower 64 bits are straightforward clock-arithmetic. */
@@ -113,7 +112,7 @@ extern "C" {
113
112
* z1 = x1 * y1 + w2 + (w1 >> 32 );
114
113
}
115
114
116
- inline pcg128_t _pcg128_mult (pcg128_t a , pcg128_t b ) {
115
+ static inline pcg128_t _pcg128_mult (pcg128_t a , pcg128_t b ) {
117
116
uint64_t h1 ;
118
117
pcg128_t result ;
119
118
@@ -123,18 +122,18 @@ extern "C" {
123
122
return result ;
124
123
}
125
124
126
- inline void pcg_setseq_128_step_r (pcg_state_setseq_128 * rng )
125
+ static inline void pcg_setseq_128_step_r (pcg_state_setseq_128 * rng )
127
126
{
128
127
rng -> state = _pcg128_add (_pcg128_mult (rng -> state , PCG_DEFAULT_MULTIPLIER_128 ), rng -> inc );
129
128
}
130
129
131
- inline uint64_t pcg_output_xsl_rr_128_64 (pcg128_t state )
130
+ static inline uint64_t pcg_output_xsl_rr_128_64 (pcg128_t state )
132
131
{
133
132
return pcg_rotr_64 (state .high ^ state .low ,
134
133
state .high >> 58u );
135
134
}
136
135
137
- inline void pcg_setseq_128_srandom_r (pcg_state_setseq_128 * rng ,
136
+ static inline void pcg_setseq_128_srandom_r (pcg_state_setseq_128 * rng ,
138
137
pcg128_t initstate , pcg128_t initseq )
139
138
{
140
139
rng -> state = PCG_128BIT_CONSTANT (0ULL , 0ULL );
@@ -148,18 +147,18 @@ extern "C" {
148
147
149
148
#else /* PCG_EMULATED_128BIT_MATH */
150
149
151
- inline void pcg_setseq_128_step_r (pcg_state_setseq_128 * rng )
150
+ static inline void pcg_setseq_128_step_r (pcg_state_setseq_128 * rng )
152
151
{
153
152
rng -> state = rng -> state * PCG_DEFAULT_MULTIPLIER_128 + rng -> inc ;
154
153
}
155
154
156
- inline uint64_t pcg_output_xsl_rr_128_64 (pcg128_t state )
155
+ static inline uint64_t pcg_output_xsl_rr_128_64 (pcg128_t state )
157
156
{
158
157
return pcg_rotr_64 (((uint64_t )(state >> 64u )) ^ (uint64_t )state ,
159
158
state >> 122u );
160
159
}
161
160
162
- inline void pcg_setseq_128_srandom_r (pcg_state_setseq_128 * rng ,
161
+ static inline void pcg_setseq_128_srandom_r (pcg_state_setseq_128 * rng ,
163
162
pcg128_t initstate , pcg128_t initseq )
164
163
{
165
164
rng -> state = 0U ;
@@ -172,14 +171,14 @@ extern "C" {
172
171
#endif /* PCG_EMULATED_128BIT_MATH */
173
172
174
173
175
- inline uint64_t
174
+ static inline uint64_t
176
175
pcg_setseq_128_xsl_rr_64_random_r (pcg_state_setseq_128 * rng )
177
176
{
178
177
pcg_setseq_128_step_r (rng );
179
178
return pcg_output_xsl_rr_128_64 (rng -> state );
180
179
}
181
180
182
- inline uint64_t
181
+ static inline uint64_t
183
182
pcg_setseq_128_xsl_rr_64_boundedrand_r (pcg_state_setseq_128 * rng ,
184
183
uint64_t bound )
185
184
{
@@ -194,7 +193,7 @@ extern "C" {
194
193
extern pcg128_t pcg_advance_lcg_128 (pcg128_t state , pcg128_t delta , pcg128_t cur_mult ,
195
194
pcg128_t cur_plus );
196
195
197
- inline void pcg_setseq_128_advance_r (pcg_state_setseq_128 * rng , pcg128_t delta )
196
+ static inline void pcg_setseq_128_advance_r (pcg_state_setseq_128 * rng , pcg128_t delta )
198
197
{
199
198
rng -> state = pcg_advance_lcg_128 (rng -> state , delta ,
200
199
PCG_DEFAULT_MULTIPLIER_128 , rng -> inc );
@@ -211,4 +210,4 @@ extern "C" {
211
210
}
212
211
#endif
213
212
214
- #endif /* PCG64_H_INCLUDED */
213
+ #endif /* PCG64_H_INCLUDED */
0 commit comments