From 2829298de7b4df367369dc4d0363032e7b64d988 Mon Sep 17 00:00:00 2001 From: Emily Hudson Date: Mon, 21 Oct 2019 02:15:43 +0100 Subject: [PATCH] live: Fix MSVC hot code reloading (#2460) --- vlib/compiler/live.v | 8 ++++++++ vlib/os/os.v | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/vlib/compiler/live.v b/vlib/compiler/live.v index 7f286d4d7e..e8dc83f89b 100644 --- a/vlib/compiler/live.v +++ b/vlib/compiler/live.v @@ -29,6 +29,14 @@ fn (v &V) generate_hotcode_reloading_declarations() { } else { if v.pref.is_so { cgen.genln('HANDLE live_fn_mutex;') + cgen.genln(' +void pthread_mutex_lock(HANDLE *m) { + WaitForSingleObject(*m, INFINITE); +} + +void pthread_mutex_unlock(HANDLE *m) { + ReleaseMutex(*m); +}') } if v.pref.is_live { cgen.genln('HANDLE live_fn_mutex = 0;') diff --git a/vlib/os/os.v b/vlib/os/os.v index 77b040f0a4..f866fe0487 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -660,8 +660,10 @@ pub fn write_file(path, text string) { } pub fn clear() { - C.printf('\x1b[2J') - C.printf('\x1b[H') + $if !windows { + C.printf('\x1b[2J') + C.printf('\x1b[H') + } } fn on_segfault(f voidptr) {