int result = 0;
if (overwrite || !getenv(name)) {
size_t length = strlen(name) + strlen(value) + 2;
- char *string = qemu_malloc(length);
+ char *string = g_malloc(length);
snprintf(string, length, "%s=%s", name, value);
result = putenv(string);
}
int qemu_add_polling_cb(PollingFunc *func, void *opaque)
{
PollingEntry **ppe, *pe;
- pe = qemu_mallocz(sizeof(PollingEntry));
+ pe = g_malloc0(sizeof(PollingEntry));
pe->func = func;
pe->opaque = opaque;
for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);
pe = *ppe;
if (pe->func == func && pe->opaque == opaque) {
*ppe = pe->next;
- qemu_free(pe);
+ g_free(pe);
break;
}
}
int err;
WaitObjects *w = &wait_objects;
+ qemu_mutex_unlock_iothread();
ret = WaitForMultipleObjects(w->num, w->events, FALSE, *timeout);
+ qemu_mutex_lock_iothread();
if (WAIT_OBJECT_0 + 0 <= ret && ret <= WAIT_OBJECT_0 + w->num - 1) {
if (w->func[ret - WAIT_OBJECT_0])
w->func[ret - WAIT_OBJECT_0](w->opaque[ret - WAIT_OBJECT_0]);
/* Note: cpu_interrupt() is currently not SMP safe, so we force
QEMU to run on a single CPU */
HANDLE h;
- DWORD mask, smask;
+ DWORD_PTR mask, smask;
int i;
SetConsoleCtrlHandler(qemu_ctrl_handler, TRUE);
p--;
*p = 0;
if (access(buf, R_OK) == 0) {
- return qemu_strdup(buf);
+ return g_strdup(buf);
}
return NULL;
}
if (file == INVALID_HANDLE_VALUE) {
return -1;
}
- len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
+ len = snprintf(buffer, sizeof(buffer), "%d\n", getpid());
ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len,
&overlap, NULL);
if (ret == 0) {
}
return 0;
}
+
+int qemu_get_thread_id(void)
+{
+ return GetCurrentThreadId();
+}