]> git.proxmox.com Git - qemu.git/blobdiff - osdep.c
vnc: rename vnc-encoding-* vnc-enc-*
[qemu.git] / osdep.c
diff --git a/osdep.c b/osdep.c
index 9e4b17bd480f8a96dcd72ae612458aff71bff43a..dbf872aea79b999312f9d1d590c92ef0e4fef009 100644 (file)
--- a/osdep.c
+++ b/osdep.c
@@ -167,6 +167,13 @@ int qemu_create_pidfile(const char *filename)
 
 #ifdef _WIN32
 
+/* mingw32 needs ffs for compilations without optimization. */
+int ffs(int i)
+{
+    /* Use gcc's builtin ffs. */
+    return __builtin_ffs(i);
+}
+
 /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
 #define _W32_FT_OFFSET (116444736000000000ULL)
 
@@ -261,6 +268,11 @@ int qemu_open(const char *name, int flags, ...)
  *
  * Return the number of bytes transferred.
  * Set errno if fewer than `count' bytes are written.
+ *
+ * This function don't work with non-blocking fd's.
+ * Any of the possibilities with non-bloking fd's is bad:
+ *   - return a short write (then name is wrong)
+ *   - busy wait adding (errno == EAGAIN) to the loop
  */
 ssize_t qemu_write_full(int fd, const void *buf, size_t count)
 {
@@ -289,9 +301,9 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count)
  */
 int qemu_eventfd(int fds[2])
 {
+#ifdef CONFIG_EVENTFD
     int ret;
 
-#ifdef CONFIG_EVENTFD
     ret = eventfd(0, 0);
     if (ret >= 0) {
         fds[0] = ret;