Skip to content

Commit 3ea3cb3

Browse files
committed
Update---static inline
1 parent 1c870ce commit 3ea3cb3

File tree

10 files changed

+36
-36
lines changed

10 files changed

+36
-36
lines changed

include/binsparse/array.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ typedef struct bsp_array_t {
2020
bsp_allocator_t allocator;
2121
} bsp_array_t;
2222

23-
inline bsp_array_t bsp_construct_default_array_t() {
23+
static inline bsp_array_t bsp_construct_default_array_t() {
2424
bsp_array_t array;
2525
array.data = NULL;
2626
array.size = 0;
2727
array.allocator = bsp_default_allocator;
2828
return array;
2929
}
3030

31-
inline bsp_array_t bsp_construct_array_t(size_t size, bsp_type_t type) {
31+
static inline bsp_array_t bsp_construct_array_t(size_t size, bsp_type_t type) {
3232
size_t byte_size = size * bsp_type_size(type);
3333

3434
bsp_array_t array;
@@ -41,14 +41,14 @@ inline bsp_array_t bsp_construct_array_t(size_t size, bsp_type_t type) {
4141
return array;
4242
}
4343

44-
inline bsp_array_t bsp_copy_construct_array_t(bsp_array_t other) {
44+
static inline bsp_array_t bsp_copy_construct_array_t(bsp_array_t other) {
4545
bsp_array_t array = bsp_construct_array_t(other.size, other.type);
4646
memcpy(array.data, other.data, other.size * bsp_type_size(other.type));
4747

4848
return array;
4949
}
5050

51-
inline bsp_array_t bsp_complex_array_to_fp(bsp_array_t other) {
51+
static inline bsp_array_t bsp_complex_array_to_fp(bsp_array_t other) {
5252
assert(other.type == BSP_COMPLEX_FLOAT32 ||
5353
other.type == BSP_COMPLEX_FLOAT64);
5454

@@ -66,7 +66,7 @@ inline bsp_array_t bsp_complex_array_to_fp(bsp_array_t other) {
6666
return array;
6767
}
6868

69-
inline bsp_array_t bsp_fp_array_to_complex(bsp_array_t other) {
69+
static inline bsp_array_t bsp_fp_array_to_complex(bsp_array_t other) {
7070
assert(other.type == BSP_FLOAT32 || other.type == BSP_FLOAT64);
7171

7272
bsp_array_t array;
@@ -83,11 +83,11 @@ inline bsp_array_t bsp_fp_array_to_complex(bsp_array_t other) {
8383
return array;
8484
}
8585

86-
inline void bsp_destroy_array_t(bsp_array_t array) {
86+
static inline void bsp_destroy_array_t(bsp_array_t array) {
8787
array.allocator.free(array.data);
8888
}
8989

90-
inline bool bsp_array_equal(bsp_array_t x, bsp_array_t y) {
90+
static inline bool bsp_array_equal(bsp_array_t x, bsp_array_t y) {
9191
if (x.size != y.size) {
9292
return false;
9393
}

include/binsparse/detail/declamp_values.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <binsparse/matrix.h>
1010
#include <math.h>
1111

12-
inline double bsp_suitesparse_declamp_impl_(double value) {
12+
static inline double bsp_suitesparse_declamp_impl_(double value) {
1313
const double HUGE_DOUBLE = 1e308;
1414
if (value >= HUGE_DOUBLE) {
1515
return INFINITY;
@@ -26,7 +26,7 @@ inline double bsp_suitesparse_declamp_impl_(double value) {
2626
// Here, we "declamp" these values to restore them to infinity.
2727
// This allows the `bsp_matrix_minimize_values` to properly minimize
2828
// matrices that have infinity values.
29-
inline void bsp_matrix_declamp_values(bsp_matrix_t matrix) {
29+
static inline void bsp_matrix_declamp_values(bsp_matrix_t matrix) {
3030
if (matrix.values.type == BSP_FLOAT64) {
3131
double* values = (double*) matrix.values.data;
3232

include/binsparse/detail/parse_dataset.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ typedef struct {
1313
char* dataset;
1414
} bsp_fdataset_info_t;
1515

16-
inline bsp_fdataset_info_t bsp_parse_fdataset_string(char* str) {
16+
static inline bsp_fdataset_info_t bsp_parse_fdataset_string(char* str) {
1717
size_t len = strlen(str);
1818

1919
int split = -1;
@@ -41,7 +41,7 @@ inline bsp_fdataset_info_t bsp_parse_fdataset_string(char* str) {
4141
}
4242
}
4343

44-
inline const char* bsp_get_file_extension(const char* file_name) {
44+
static inline const char* bsp_get_file_extension(const char* file_name) {
4545
int64_t len = strlen(file_name);
4646
for (int64_t i = len - 1; i >= 0; i--) {
4747
if (file_name[i] == '.') {

include/binsparse/detail/shm_tools.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef struct {
2020
size_t size;
2121
} bsp_shm_t;
2222

23-
inline bsp_shm_t bsp_shm_new(size_t size) {
23+
static inline bsp_shm_t bsp_shm_new(size_t size) {
2424
bsp_shm_t shm;
2525
shm.size = size;
2626

@@ -32,11 +32,11 @@ inline bsp_shm_t bsp_shm_new(size_t size) {
3232
return shm;
3333
}
3434

35-
inline void bsp_shm_delete(bsp_shm_t shm) {
35+
static inline void bsp_shm_delete(bsp_shm_t shm) {
3636
shmctl(shm.id, IPC_RMID, 0);
3737
}
3838

39-
inline void* bsp_shm_attach(bsp_shm_t shm) {
39+
static inline void* bsp_shm_attach(bsp_shm_t shm) {
4040
void* data;
4141

4242
if ((data = shmat(shm.id, NULL, 0)) == (void*) -1) {
@@ -46,11 +46,11 @@ inline void* bsp_shm_attach(bsp_shm_t shm) {
4646
return data;
4747
}
4848

49-
inline void bsp_shm_detach(void* data) {
49+
static inline void bsp_shm_detach(void* data) {
5050
shmdt(data);
5151
}
5252

53-
inline void* bsp_shm_malloc(size_t size) {
53+
static inline void* bsp_shm_malloc(size_t size) {
5454
bsp_shm_t shm_id = bsp_shm_new(size);
5555

5656
void* ptr = bsp_shm_attach(shm_id);
@@ -60,7 +60,7 @@ inline void* bsp_shm_malloc(size_t size) {
6060
return ptr;
6161
}
6262

63-
inline void bsp_shm_free(void* ptr) {
63+
static inline void bsp_shm_free(void* ptr) {
6464
bsp_shm_detach(ptr);
6565
}
6666

include/binsparse/generate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <binsparse/matrix.h>
1010

11-
inline void bsp_array_fill_random(bsp_array_t array, size_t bound) {
11+
static inline void bsp_array_fill_random(bsp_array_t array, size_t bound) {
1212
if (array.type == BSP_UINT8) {
1313
uint8_t* values = (uint8_t*) array.data;
1414
for (size_t i = 0; i < array.size; i++) {
@@ -67,9 +67,9 @@ inline void bsp_array_fill_random(bsp_array_t array, size_t bound) {
6767
}
6868
}
6969

70-
inline bsp_matrix_t bsp_generate_coo(size_t m, size_t n, size_t nnz,
71-
bsp_type_t value_type,
72-
bsp_type_t index_type) {
70+
static inline bsp_matrix_t bsp_generate_coo(size_t m, size_t n, size_t nnz,
71+
bsp_type_t value_type,
72+
bsp_type_t index_type) {
7373
bsp_matrix_t matrix = bsp_construct_default_matrix_t();
7474
matrix.nrows = m;
7575
matrix.ncols = n;

include/binsparse/matrix.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef struct bsp_matrix_t {
2626
bsp_structure_t structure;
2727
} bsp_matrix_t;
2828

29-
inline bsp_matrix_t bsp_construct_default_matrix_t() {
29+
static inline bsp_matrix_t bsp_construct_default_matrix_t() {
3030
bsp_matrix_t mat;
3131
mat.values = bsp_construct_default_array_t();
3232
mat.indices_0 = bsp_construct_default_array_t();
@@ -38,14 +38,14 @@ inline bsp_matrix_t bsp_construct_default_matrix_t() {
3838
return mat;
3939
}
4040

41-
inline void bsp_destroy_matrix_t(bsp_matrix_t matrix) {
41+
static inline void bsp_destroy_matrix_t(bsp_matrix_t matrix) {
4242
bsp_destroy_array_t(matrix.values);
4343
bsp_destroy_array_t(matrix.indices_0);
4444
bsp_destroy_array_t(matrix.indices_1);
4545
bsp_destroy_array_t(matrix.pointers_to_1);
4646
}
4747

48-
inline size_t bsp_matrix_nbytes(bsp_matrix_t mat) {
48+
static inline size_t bsp_matrix_nbytes(bsp_matrix_t mat) {
4949
size_t nbytes = 0;
5050
if (mat.values.size > 0) {
5151
nbytes += mat.values.size * bsp_type_size(mat.values.type);
@@ -66,7 +66,7 @@ inline size_t bsp_matrix_nbytes(bsp_matrix_t mat) {
6666
return nbytes;
6767
}
6868

69-
inline void bsp_print_matrix_info(bsp_matrix_t matrix) {
69+
static inline void bsp_print_matrix_info(bsp_matrix_t matrix) {
7070
printf("%lu x %lu matrix with %lu nnz.\n", matrix.nrows, matrix.ncols,
7171
matrix.nnz);
7272
printf("%s format with %s structure\n",

include/binsparse/matrix_formats.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef enum bsp_matrix_format_t {
2424
BSP_INVALID_FORMAT = 21
2525
} bsp_matrix_format_t;
2626

27-
inline char* bsp_get_matrix_format_string(bsp_matrix_format_t format) {
27+
static inline char* bsp_get_matrix_format_string(bsp_matrix_format_t format) {
2828
if (format == BSP_DVEC) {
2929
return (char*) "DVEC";
3030
} else if (format == BSP_DMAT) {
@@ -48,7 +48,7 @@ inline char* bsp_get_matrix_format_string(bsp_matrix_format_t format) {
4848
}
4949
}
5050

51-
inline bsp_matrix_format_t bsp_get_matrix_format(char* format) {
51+
static inline bsp_matrix_format_t bsp_get_matrix_format(char* format) {
5252
if (strcmp("DVEC", format) == 0) {
5353
return BSP_DVEC;
5454
} else if (strcmp("DMAT", format) == 0) {

include/binsparse/minimize_values.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
// Given a matrix `matrix`, store its values using the smallest type possible
1313
// without losing precision.
14-
inline bsp_matrix_t bsp_matrix_minimize_values(bsp_matrix_t matrix) {
14+
static inline bsp_matrix_t bsp_matrix_minimize_values(bsp_matrix_t matrix) {
1515
if (matrix.values.type == BSP_FLOAT64) {
1616
bool float32_representable = true;
1717

include/binsparse/structure.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef enum bsp_structure_t {
2222
BSP_INVALID_STRUCTURE = 106
2323
} bsp_structure_t;
2424

25-
inline char* bsp_get_structure_string(bsp_structure_t structure) {
25+
static inline char* bsp_get_structure_string(bsp_structure_t structure) {
2626
if (structure == BSP_GENERAL) {
2727
return (char*) "general";
2828
} else if (structure == BSP_SYMMETRIC_LOWER) {
@@ -42,7 +42,7 @@ inline char* bsp_get_structure_string(bsp_structure_t structure) {
4242
}
4343
}
4444

45-
inline bsp_structure_t bsp_get_structure(char* structure) {
45+
static inline bsp_structure_t bsp_get_structure(char* structure) {
4646
if (strcmp(structure, "symmetric_lower") == 0) {
4747
return BSP_SYMMETRIC_LOWER;
4848
} else if (strcmp(structure, "symmetric_upper") == 0) {

include/binsparse/types.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ typedef enum bsp_type_t {
2626
BSP_INVALID_TYPE = 13
2727
} bsp_type_t;
2828

29-
inline char* bsp_get_type_string(bsp_type_t type) {
29+
static inline char* bsp_get_type_string(bsp_type_t type) {
3030
if (type == BSP_UINT8) {
3131
return (char*) "uint8";
3232
} else if (type == BSP_UINT16) {
@@ -58,7 +58,7 @@ inline char* bsp_get_type_string(bsp_type_t type) {
5858
}
5959
}
6060

61-
inline size_t bsp_type_size(bsp_type_t type) {
61+
static inline size_t bsp_type_size(bsp_type_t type) {
6262
if (type == BSP_UINT8) {
6363
return sizeof(uint8_t);
6464
} else if (type == BSP_UINT16) {
@@ -90,7 +90,7 @@ inline size_t bsp_type_size(bsp_type_t type) {
9090
}
9191
}
9292

93-
inline hid_t bsp_get_hdf5_standard_type(bsp_type_t type) {
93+
static inline hid_t bsp_get_hdf5_standard_type(bsp_type_t type) {
9494
if (type == BSP_UINT8) {
9595
return H5T_STD_U8LE;
9696
} else if (type == BSP_UINT16) {
@@ -118,7 +118,7 @@ inline hid_t bsp_get_hdf5_standard_type(bsp_type_t type) {
118118
}
119119
}
120120

121-
inline bsp_type_t bsp_get_bsp_type(hid_t type) {
121+
static inline bsp_type_t bsp_get_bsp_type(hid_t type) {
122122
H5T_class_t cl = H5Tget_class(type);
123123
H5T_order_t order = H5Tget_order(type);
124124
H5T_sign_t sign = H5Tget_sign(type);
@@ -166,7 +166,7 @@ inline bsp_type_t bsp_get_bsp_type(hid_t type) {
166166
// NOTE: This code is a bit silly, but it seems to be the only
167167
// way to generically determine the HDF5 native types for
168168
// stdint's fixed width integer types.
169-
inline hid_t bsp_get_hdf5_native_type(bsp_type_t type) {
169+
static inline hid_t bsp_get_hdf5_native_type(bsp_type_t type) {
170170
if (type == BSP_INT8 || type == BSP_BINT8) {
171171
if (sizeof(int8_t) == sizeof(char)) {
172172
return H5T_NATIVE_CHAR;
@@ -290,7 +290,7 @@ inline hid_t bsp_get_hdf5_native_type(bsp_type_t type) {
290290

291291
// Given the maximum value `max_value` that must be stored,
292292
// pick an unsigned integer type for indices.
293-
inline bsp_type_t bsp_pick_integer_type(size_t max_value) {
293+
static inline bsp_type_t bsp_pick_integer_type(size_t max_value) {
294294
if (max_value < (size_t) UINT8_MAX) {
295295
return BSP_UINT8;
296296
} else if (max_value < (size_t) UINT16_MAX) {

0 commit comments

Comments
 (0)