Skip to content

Commit 6a046c4

Browse files
committed
windows Timer
1 parent 293899f commit 6a046c4

6 files changed

Lines changed: 16 additions & 20 deletions

File tree

‎include/utils/Timer.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ typedef struct
5858
(double) ((timer).end.tv_nsec - (timer).start.tv_nsec) / 1e9)
5959
#endif
6060

61-
#endif // TIMER_H
61+
#endif // TIMER_H

‎include/utils/Vec_macros.h‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@
2424
#include <stdlib.h>
2525
#include <string.h>
2626

27+
// Portable UNUSED macro
28+
#if defined(_MSC_VER)
29+
#define PSLP_UNUSED
30+
#else
31+
#define PSLP_UNUSED __attribute__((unused))
32+
#endif
33+
2734
// Macro to define a generic vector class
2835
#define DEFINE_VECTOR(TYPE, TYPE_NAME) \
2936
typedef struct TYPE_NAME##Vec \
3037
{ \
3138
TYPE *data; \
32-
size_t len; \
33-
size_t capacity; \
39+
int len; \
40+
int capacity; \
3441
} TYPE_NAME##Vec; \
3542
\
36-
__attribute__((unused)) static TYPE_NAME##Vec *TYPE_NAME##Vec_new( \
37-
size_t capacity) \
43+
PSLP_UNUSED static TYPE_NAME##Vec *TYPE_NAME##Vec_new(size_t capacity) \
3844
{ \
3945
assert(capacity > 0); \
4046
TYPE_NAME##Vec *vec = (TYPE_NAME##Vec *) malloc(sizeof(TYPE_NAME##Vec)); \
@@ -83,11 +89,11 @@
8389
} \
8490
\
8591
static inline void TYPE_NAME##Vec_append_array(TYPE_NAME##Vec *vec, \
86-
const TYPE *values, size_t n) \
92+
const TYPE *values, int n) \
8793
{ \
8894
if (vec->len + n > vec->capacity) \
8995
{ \
90-
size_t new_capacity = vec->capacity > 0 ? vec->capacity : 1; \
96+
int new_capacity = vec->capacity > 0 ? vec->capacity : 1; \
9197
while (vec->len + n > new_capacity) \
9298
{ \
9399
new_capacity *= 2; \
@@ -108,10 +114,10 @@
108114
memcpy(vec->data + vec->len, values, n * sizeof(TYPE)); \
109115
vec->len += n; \
110116
} \
111-
__attribute__((unused)) static int TYPE_NAME##Vec_contains( \
112-
const TYPE_NAME##Vec *vec, TYPE value) \
117+
PSLP_UNUSED static int TYPE_NAME##Vec_contains(const TYPE_NAME##Vec *vec, \
118+
TYPE value) \
113119
{ \
114-
for (size_t i = 0; i < vec->len; ++i) \
120+
for (int i = 0; i < vec->len; ++i) \
115121
{ \
116122
if (vec->data[i] == value) \
117123
{ \

‎src/affine/add.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,5 @@ expr *new_add(expr *left, expr *right)
101101
expr_retain(left);
102102
expr_retain(right);
103103

104-
// just for debugging, should be removed
105-
strcpy(node->name, "add");
106-
107104
return node;
108105
}

‎src/bivariate/const_scalar_mult.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,5 @@ expr *new_const_scalar_mult(double a, expr *child)
110110
mult_node->a = a;
111111
expr_retain(child);
112112

113-
// just for debugging, should be removed
114-
strcpy(node->name, "const_scalar_mult");
115-
116113
return node;
117114
}

‎src/elementwise_univariate/exp.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,5 @@ expr *new_exp(expr *child)
5151
node->local_jacobian = local_jacobian;
5252
node->local_wsum_hess = local_wsum_hess;
5353

54-
// just for debugging, should be removed
55-
strcpy(node->name, "exp");
5654
return node;
5755
}

‎src/elementwise_univariate/log.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,5 @@ expr *new_log(expr *child)
5656
node->local_jacobian = local_jacobian;
5757
node->local_wsum_hess = local_wsum_hess;
5858

59-
// just for debugging, should be removed
60-
strcpy(node->name, "log");
6159
return node;
6260
}

0 commit comments

Comments
 (0)