path: root/oslib-posix.c
diff options
authorAlexandre Raymond <[email protected]>2011-06-06 23:34:10 -0400
committerAndreas Färber <[email protected]>2011-06-14 03:10:47 +0200
commitf97742d0d36810ea72a2bd40b3abb890589ea3b8 (patch)
tree4e1548536ff67cdc341830d99c97311cee24dee8 /oslib-posix.c
parent7fee199cf9704587d4ed9eb23044970f2206debc (diff)
Darwin: Fix compilation warning regarding the deprecated daemon() function
Changes since v1: create a wrapper function named qemu_daemon() in oslib-posix.c instead of putting the OS specific workaround in qemu-nbd.c directly. On OSX >= 10.5, daemon() is deprecated, resulting in the following warning: ----8<---- qemu-nbd.c: In function ‘main’: qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at /usr/include/stdlib.h:289) ----8<---- The following trick, used in mDNSResponder, takes care of this warning: On OSX, it temporarily renames the daemon() function before including stdlib.h and declares it manually as an extern function. This way, the compiler does not see the declaration from stdlib.h and thus does not display the warning. Signed-off-by: Alexandre Raymond <[email protected]> Cc: Blue Swirl <[email protected]> Signed-off-by: Andreas Färber <[email protected]>
Diffstat (limited to 'oslib-posix.c')
1 files changed, 16 insertions, 0 deletions
diff --git a/oslib-posix.c b/oslib-posix.c
index 7bc5f7cf0..3a18e865f 100644
--- a/oslib-posix.c
+++ b/oslib-posix.c
@@ -26,11 +26,27 @@
+/* The following block of code temporarily renames the daemon() function so the
+ compiler does not see the warning associated with it in stdlib.h on OSX */
+#ifdef __APPLE__
+#define daemon qemu_fake_daemon_function
+#include <stdlib.h>
+#undef daemon
+extern int daemon(int, int);
#include "config-host.h"
#include "sysemu.h"
#include "trace.h"
#include "qemu_socket.h"
+int qemu_daemon(int nochdir, int noclose)
+ return daemon(nochdir, noclose);
void *qemu_oom_check(void *ptr)
if (ptr == NULL) {