Skip to content

Commit d9cfb72

Browse files
committed
change to enum
1 parent 53d3200 commit d9cfb72

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

cpp/Kun/CApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ KUN_API KunStatus kunCreateStreamEx(KunExecutorHandle exec,
137137
}
138138

139139
KUN_API KunStatus kunStreamSerializeStates(KunStreamContextHandle context,
140-
size_t dump_kind,
140+
KunStateBufferKind dump_kind,
141141
char *path_or_buffer,
142142
size_t *size) {
143143
auto ctx = reinterpret_cast<kun::StreamContext *>(context);

cpp/Kun/CApi.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,27 @@ extern "C" {
1414

1515
#define KUN_API_VERSION 1
1616

17-
#define KUN_INIT_NONE 0
18-
#define KUN_INIT_FILE 1
19-
#define KUN_INIT_MEMORY 2
20-
21-
typedef int KunStatus;
22-
23-
#define KUN_SUCCESS 0
24-
#define KUN_INIT_ERROR 1
25-
#define KUN_INVALID_ARGUMENT 2
17+
typedef enum {
18+
KUN_INIT_NONE = 0,
19+
KUN_INIT_FILE,
20+
KUN_INIT_MEMORY,
21+
} KunStateBufferKind;
22+
23+
typedef enum {
24+
KUN_SUCCESS = 0,
25+
KUN_INIT_ERROR,
26+
KUN_INVALID_ARGUMENT,
27+
} KunStatus;
2628

2729
typedef struct {
28-
size_t version; // version of the KunQuant C API, must be set to
29-
// KUN_API_VERSION
30-
size_t init_kind; // KUN_INIT_NONE KUN_INIT_FILE KUN_INIT_MEMORY
30+
size_t version; // version of the KunQuant C API, must be set to
31+
// KUN_API_VERSION
32+
KunStateBufferKind init_kind; // KUN_INIT_NONE KUN_INIT_FILE KUN_INIT_MEMORY
3133
union {
3234
const char *path; // path to stream state dump file
3335
struct {
34-
const char *buffer; // name of the stream state dump file
35-
size_t size; // size of the stream state dump file
36+
const char *buffer; // buffer for stream state dump
37+
size_t size; // size of the stream state dump file in bytes
3638
} memory; // memory buffer for stream state dump
3739
} init;
3840
} KunStreamExtraArgs;
@@ -189,7 +191,7 @@ KUN_API KunStatus kunCreateStreamEx(KunExecutorHandle exec, KunModuleHandle m,
189191
* is not KUN_INIT_FILE or KUN_INIT_MEMORY.
190192
*/
191193
KUN_API KunStatus kunStreamSerializeStates(KunStreamContextHandle context,
192-
size_t dump_kind,
194+
KunStateBufferKind dump_kind,
193195
char *path_or_buffer, size_t *size);
194196

195197
/**

0 commit comments

Comments
 (0)