Skip to content

Commit ad7a3a4

Browse files
authored
fix(tsdb): enum to macro (#403)
1 parent 08c541a commit ad7a3a4

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/fdb_tsdb.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,22 @@
3838
#endif
3939

4040
// Autofill to struct sector_hdr_data
41-
enum {
42-
TSL_HDR_PADDING_SIZE = FDB_WG_ALIGN(sizeof(uint32_t)) - sizeof(uint32_t)
43-
};
41+
#define SECTOR_HDR_PADDING_SIZE (FDB_WG_ALIGN(4) - 4)
4442

4543
// Autofill to struct log_idx_data
46-
enum {
44+
#ifdef FDB_USING_TIMESTAMP_64BIT
45+
#define _TSL_FDBTIME_SIZE (8)
46+
#else
47+
#define _TSL_FDBTIME_SIZE (4)
48+
#endif
49+
4750
#ifdef FDB_TSDB_FIXED_BLOB_SIZE
48-
LOG_IDX_BASE_SIZE = TSL_STATUS_TABLE_SIZE + sizeof(fdb_time_t),
51+
#define LOG_IDX_BASE_SIZE (TSL_STATUS_TABLE_SIZE + _TSL_FDBTIME_SIZE)
4952
#else
50-
LOG_IDX_BASE_SIZE = TSL_STATUS_TABLE_SIZE + sizeof(fdb_time_t) + sizeof(uint32_t) * 2,
53+
#define LOG_IDX_BASE_SIZE (TSL_STATUS_TABLE_SIZE + _TSL_FDBTIME_SIZE + 4 * 2)
5154
#endif
52-
LOG_IDX_PADDING_SIZE = FDB_WG_ALIGN(LOG_IDX_BASE_SIZE) - LOG_IDX_BASE_SIZE
53-
};
55+
56+
#define LOG_IDX_PADDING_SIZE (FDB_WG_ALIGN(LOG_IDX_BASE_SIZE) - LOG_IDX_BASE_SIZE)
5457

5558
#define SECTOR_HDR_DATA_SIZE (FDB_WG_ALIGN(sizeof(struct sector_hdr_data)))
5659
#define LOG_IDX_DATA_SIZE (FDB_WG_ALIGN(sizeof(struct log_idx_data)))
@@ -107,8 +110,8 @@ struct sector_hdr_data {
107110
uint32_t reserved;
108111

109112
// Autofill to the FDB WRITE GRAN alignment
110-
#if TSL_HDR_PADDING_SIZE > 0
111-
uint8_t padding[TSL_HDR_PADDING_SIZE];
113+
#if SECTOR_HDR_PADDING_SIZE > 0
114+
uint8_t padding[SECTOR_HDR_PADDING_SIZE];
112115
#endif
113116
};
114117
typedef struct sector_hdr_data *sector_hdr_data_t;

0 commit comments

Comments
 (0)