diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-05-11 13:25:26 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-05-12 10:35:20 +0000 |
commit | cc22df198d0ccb64dfdfe0c2f247f7d86b7fd750 (patch) | |
tree | e6cd8aaa33c161bc0f72a9b35e763372b20f910d /rbutil/jztool/src/context.c | |
parent | 3748117ee3623437d63ba2016637fd532dbdd4b9 (diff) | |
download | rockbox-cc22df198d0ccb64dfdfe0c2f247f7d86b7fd750.tar.gz rockbox-cc22df198d0ccb64dfdfe0c2f247f7d86b7fd750.zip |
jztool: Support new M3K bootloader
Change-Id: Ia2d96893a9a5c77deb71c1fe32ae5a0585093f5b
Diffstat (limited to 'rbutil/jztool/src/context.c')
-rw-r--r-- | rbutil/jztool/src/context.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/rbutil/jztool/src/context.c b/rbutil/jztool/src/context.c index 94b21b5196..d269d1eece 100644 --- a/rbutil/jztool/src/context.c +++ b/rbutil/jztool/src/context.c | |||
@@ -27,6 +27,10 @@ | |||
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <time.h> | 28 | #include <time.h> |
29 | 29 | ||
30 | #ifdef WIN32 | ||
31 | # include <windows.h> | ||
32 | #endif | ||
33 | |||
30 | /** \brief Allocate a library context | 34 | /** \brief Allocate a library context |
31 | * \returns New context or NULL if out of memory | 35 | * \returns New context or NULL if out of memory |
32 | */ | 36 | */ |
@@ -137,13 +141,18 @@ void jz_log_cb_stderr(jz_log_level lev, const char* msg) | |||
137 | */ | 141 | */ |
138 | void jz_sleepms(int ms) | 142 | void jz_sleepms(int ms) |
139 | { | 143 | { |
144 | #ifdef WIN32 | ||
145 | Sleep(ms); | ||
146 | #else | ||
140 | struct timespec ts; | 147 | struct timespec ts; |
141 | long ns = ms % 1000; | 148 | long ns = ms % 1000; |
142 | ts.tv_nsec = ns * 1000 * 1000; | 149 | ts.tv_nsec = ns * 1000 * 1000; |
143 | ts.tv_sec = ms / 1000; | 150 | ts.tv_sec = ms / 1000; |
144 | nanosleep(&ts, NULL); | 151 | nanosleep(&ts, NULL); |
152 | #endif | ||
145 | } | 153 | } |
146 | 154 | ||
155 | /** \brief Add reference to libusb context, allocating it if necessary */ | ||
147 | int jz_context_ref_libusb(jz_context* jz) | 156 | int jz_context_ref_libusb(jz_context* jz) |
148 | { | 157 | { |
149 | if(jz->usb_ctxref == 0) { | 158 | if(jz->usb_ctxref == 0) { |
@@ -158,6 +167,7 @@ int jz_context_ref_libusb(jz_context* jz) | |||
158 | return JZ_SUCCESS; | 167 | return JZ_SUCCESS; |
159 | } | 168 | } |
160 | 169 | ||
170 | /** \brief Remove reference to libusb context, freeing if it hits zero */ | ||
161 | void jz_context_unref_libusb(jz_context* jz) | 171 | void jz_context_unref_libusb(jz_context* jz) |
162 | { | 172 | { |
163 | if(--jz->usb_ctxref == 0) { | 173 | if(--jz->usb_ctxref == 0) { |