]> git.sesse.net Git - vlc/commitdiff
Win32: correctly implement flockfile() et al
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 18 Oct 2012 10:58:25 +0000 (13:58 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 18 Oct 2012 15:41:51 +0000 (18:41 +0300)
This should fix gibberish interlaced log messages.

compat/flockfile.c
configure.ac

index dc2a09c4d87106f206c96a253311ac9f9b7db8e1..f0b61bb070eef1133a59f09c81c32f74b5ad2cd4 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * flockfile.c: POSIX unlocked I/O stream stubs
  *****************************************************************************
- * Copyright © 2011 Rémi Denis-Courmont
+ * Copyright © 2011-2012 Rémi Denis-Courmont
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published by
 
 #include <stdio.h>
 
-/* There is no way to implement this for real. We just pretend it works and
- * hope for the best (especially when outputting to stderr). */
+#ifdef WIN32
+# ifndef HAVE__LOCK_FILE
+#  warning Broken SDK: VLC logs will be garbage.
+#  define _lock_file(s) ((void)(s))
+#  define _unlock_file(s) ((void)(s))
+# endif
 
 void flockfile (FILE *stream)
 {
-    (void) stream;
+    _lock_file (stream);
 }
 
 int ftrylockfile (FILE *stream)
 {
-    (void) stream;
+    flockfile (stream); /* Move along people, there is nothing to see here. */
     return 0;
 }
 
 void funlockfile (FILE *stream)
 {
-    (void) stream;
+    _unlock_file (stream);
 }
 
 int getc_unlocked (FILE *stream)
 {
-    return getc (stream);
+    return _getc_nolock (stream);
 }
 
 int getchar_unlocked (void)
 {
-    return getchar ();
+    return _getchar_nolock ();
 }
 
 int putc_unlocked (int c, FILE *stream)
 {
-    return putc (c, stream);
+    return _putc_nolock (c, stream);
 }
 
 int putchar_unlocked (int c)
 {
-    return putchar (c);
+    return _putchar_nolock (c);
 }
+
+#else
+# error flockfile not implemented on your platform!
+#endif
index 2a9c92da962280e0ea5000d28e835c5803c76d6c..1a02878988b9203732325197645ad3c0fb80945b 100644 (file)
@@ -535,6 +535,9 @@ case "$SYS" in
   "linux")
     AC_CHECK_FUNCS([accept4 pipe2 eventfd vmsplice sched_getaffinity])
     ;;
+  "mingw32")
+    AC_CHECK_FUNCS([_lock_file])
+    ;;
 esac
 
 AH_BOTTOM([#include <vlc_fixups.h>])