Skip to content

Commit c10f1f3

Browse files
Tony Ricciarditony-ricciardi
authored andcommitted
pd.h: Change static to static inline.
- Allows including `pd.h` in test sources without adding `-Wno-unused-function`. - See #91
1 parent 418edba commit c10f1f3

File tree

1 file changed

+11
-11
lines changed
  • program/src/oracle

1 file changed

+11
-11
lines changed

program/src/oracle/pd.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern "C" {
66

77
#define PD_SCALE9 (1000000000L)
88
#define PD_EMA_MAX_DIFF 4145 // maximum slots before reset
9-
#define PD_EMA_EXPO -9 // exponent of temporary storage
9+
#define PD_EMA_EXPO (-9) // exponent of temporary storage
1010
#define PD_EMA_DECAY (-117065) // 1e9*-log(2)/5921
1111
#define PC_FACTOR_SIZE 18
1212

@@ -24,15 +24,15 @@ typedef struct pd
2424
int64_t v_;
2525
} pd_t;
2626

27-
static void pd_scale( pd_t *n )
27+
static inline void pd_scale( pd_t *n )
2828
{
2929
int const neg = n->v_ < 0L;
3030
int64_t v = neg ? -n->v_ : n->v_; // make v positive for loop condition
3131
for( ; v >= ( 1L << 28 ); v /= 10L, ++n->e_ );
3232
n->v_ = neg ? -v : v;
3333
}
3434

35-
static bool pd_store( int64_t *r, pd_t const *n )
35+
static inline bool pd_store( int64_t *r, pd_t const *n )
3636
{
3737
int64_t v = n->v_;
3838
int32_t e = n->e_;
@@ -65,7 +65,7 @@ void pd_load( pd_t *r, int64_t const n )
6565
pd_scale( r );
6666
}
6767

68-
static void pd_adjust( pd_t *n, int e, const int64_t *p )
68+
static inline void pd_adjust( pd_t *n, int e, const int64_t *p )
6969
{
7070
int64_t v = n->v_;
7171
int d = n->e_ - e;
@@ -78,14 +78,14 @@ static void pd_adjust( pd_t *n, int e, const int64_t *p )
7878
pd_new( n, v, e );
7979
}
8080

81-
static void pd_mul( pd_t *r, const pd_t *n1, const pd_t *n2 )
81+
static inline void pd_mul( pd_t *r, const pd_t *n1, const pd_t *n2 )
8282
{
8383
r->v_ = n1->v_ * n2->v_;
8484
r->e_ = n1->e_ + n2->e_;
8585
pd_scale( r );
8686
}
8787

88-
static void pd_div( pd_t *r, pd_t *n1, pd_t *n2 )
88+
static inline void pd_div( pd_t *r, pd_t *n1, pd_t *n2 )
8989
{
9090
if ( n1->v_ == 0 ) { pd_set( r, n1 ); return; }
9191
int64_t v1 = n1->v_, v2 = n2->v_;
@@ -100,7 +100,7 @@ static void pd_div( pd_t *r, pd_t *n1, pd_t *n2 )
100100
pd_scale( r );
101101
}
102102

103-
static void pd_add( pd_t *r, const pd_t *n1, const pd_t *n2, const int64_t *p )
103+
static inline void pd_add( pd_t *r, const pd_t *n1, const pd_t *n2, const int64_t *p )
104104
{
105105
int d = n1->e_ - n2->e_;
106106
if ( d==0 ) {
@@ -126,7 +126,7 @@ static void pd_add( pd_t *r, const pd_t *n1, const pd_t *n2, const int64_t *p )
126126
pd_scale( r );
127127
}
128128

129-
static void pd_sub( pd_t *r, const pd_t *n1, const pd_t *n2, const int64_t *p )
129+
static inline void pd_sub( pd_t *r, const pd_t *n1, const pd_t *n2, const int64_t *p )
130130
{
131131
int d = n1->e_ - n2->e_;
132132
if ( d==0 ) {
@@ -152,21 +152,21 @@ static void pd_sub( pd_t *r, const pd_t *n1, const pd_t *n2, const int64_t *p )
152152
pd_scale( r );
153153
}
154154

155-
static int pd_lt( const pd_t *n1, const pd_t *n2, const int64_t *p )
155+
static inline int pd_lt( const pd_t *n1, const pd_t *n2, const int64_t *p )
156156
{
157157
pd_t r[1];
158158
pd_sub( r, n1, n2, p );
159159
return r->v_ < 0L;
160160
}
161161

162-
static int pd_gt( const pd_t *n1, const pd_t *n2, const int64_t *p )
162+
static inline int pd_gt( const pd_t *n1, const pd_t *n2, const int64_t *p )
163163
{
164164
pd_t r[1];
165165
pd_sub( r, n1, n2, p );
166166
return r->v_ > 0L;
167167
}
168168

169-
static void pd_sqrt( pd_t *r, pd_t *val, const int64_t *f )
169+
static inline void pd_sqrt( pd_t *r, pd_t *val, const int64_t *f )
170170
{
171171
pd_t t[1], x[1], hlf[1];
172172
pd_set( t, val );

0 commit comments

Comments
 (0)