Skip to content

Commit c466346

Browse files
committed
add mi_cdecl to functions to avoid errors when compiling with a different calling convention, see PR microsoft#592
1 parent 698bb2c commit c466346

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/init.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void _mi_heap_set_default_direct(mi_heap_t* heap) {
448448
// --------------------------------------------------------
449449
// Run functions on process init/done, and thread init/done
450450
// --------------------------------------------------------
451-
static void mi_process_done(void);
451+
static void mi_cdecl mi_process_done(void);
452452

453453
static bool os_preloading = true; // true until this module is initialized
454454
static bool mi_redirected = false; // true if malloc redirects to mi_malloc
@@ -479,8 +479,8 @@ mi_decl_export void _mi_redirect_entry(DWORD reason) {
479479
mi_thread_done();
480480
}
481481
}
482-
__declspec(dllimport) bool mi_allocator_init(const char** message);
483-
__declspec(dllimport) void mi_allocator_done(void);
482+
__declspec(dllimport) bool mi_cdecl mi_allocator_init(const char** message);
483+
__declspec(dllimport) void mi_cdecl mi_allocator_done(void);
484484
#ifdef __cplusplus
485485
}
486486
#endif
@@ -579,7 +579,7 @@ void mi_process_init(void) mi_attr_noexcept {
579579
}
580580

581581
// Called when the process is done (through `at_exit`)
582-
static void mi_process_done(void) {
582+
static void mi_cdecl mi_process_done(void) {
583583
// only shutdown if we were initialized
584584
if (!_mi_process_is_initialized) return;
585585
// ensure we are called once

src/options.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void mi_option_disable(mi_option_t option) {
169169
}
170170

171171

172-
static void mi_out_stderr(const char* msg, void* arg) {
172+
static void mi_cdecl mi_out_stderr(const char* msg, void* arg) {
173173
MI_UNUSED(arg);
174174
if (msg == NULL) return;
175175
#ifdef _WIN32
@@ -202,7 +202,7 @@ static void mi_out_stderr(const char* msg, void* arg) {
202202
static char out_buf[MI_MAX_DELAY_OUTPUT+1];
203203
static _Atomic(size_t) out_len;
204204

205-
static void mi_out_buf(const char* msg, void* arg) {
205+
static void mi_cdecl mi_out_buf(const char* msg, void* arg) {
206206
MI_UNUSED(arg);
207207
if (msg==NULL) return;
208208
if (mi_atomic_load_relaxed(&out_len)>=MI_MAX_DELAY_OUTPUT) return;
@@ -234,7 +234,7 @@ static void mi_out_buf_flush(mi_output_fun* out, bool no_more_buf, void* arg) {
234234

235235
// Once this module is loaded, switch to this routine
236236
// which outputs to stderr and the delayed output buffer.
237-
static void mi_out_buf_stderr(const char* msg, void* arg) {
237+
static void mi_cdecl mi_out_buf_stderr(const char* msg, void* arg) {
238238
mi_out_stderr(msg,arg);
239239
mi_out_buf(msg,arg);
240240
}

src/stats.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static void mi_buffered_flush(buffered_t* buf) {
267267
buf->used = 0;
268268
}
269269

270-
static void mi_buffered_out(const char* msg, void* arg) {
270+
static void mi_cdecl mi_buffered_out(const char* msg, void* arg) {
271271
buffered_t* buf = (buffered_t*)arg;
272272
if (msg==NULL || buf==NULL) return;
273273
for (const char* src = msg; *src != 0; src++) {

0 commit comments

Comments
 (0)