]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
vmblock: fix problem with missing Panic symbol on FreeBSD
authorVMware, Inc <>
Tue, 29 Mar 2011 20:07:22 +0000 (13:07 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 20:07:22 +0000 (13:07 -0700)
We need to make sure we compile and link stubs.c so that
out Panic() resolves. And since FreeBSD does not have panic
that takes va_list arguments we need to implement one.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/modules/freebsd/vmblock/Makefile
open-vm-tools/modules/freebsd/vmblock/os.h
open-vm-tools/modules/freebsd/vmblock/os_panic.c [new file with mode: 0644]
open-vm-tools/modules/shared/vmblock/stubs.c
open-vm-tools/vmblock-fuse/os.h

index 10c0886dcf605aa2154e28663c811bdae956e574..594cba40e207e1730feac93ad748cc9d8e46e3df 100644 (file)
@@ -39,9 +39,11 @@ HEADERS += vmblock_k.h
 HEADERS += os.h
 
 CSRCS  := block.c
+CSRCS  += os_panic.c
 CSRCS  += vfsops.c
 CSRCS  += vnops.c
 CSRCS  += subr.c
+CSRCS  += stubs.c
 
 SRCS   := $(HEADERS) $(CSRCS)
 
index 615a19fb2245db2649096de7ec1f4c5403434aab..5528f2a5398f81540761754a81eb224cb93c97d8 100644 (file)
@@ -47,6 +47,7 @@
 #include <sys/proc.h>
 #include <sys/condvar.h>
 #include <vm/uma.h>
+#include <machine/stdarg.h>
 
 #include "vm_basic_types.h"
 
@@ -75,7 +76,7 @@ typedef struct file * os_blocker_id_t;
 #define OS_FMTTID                       "p"
 #define os_threadid                     curthread
 
-#define os_panic(fmt, args)             panic(fmt, args)
+extern NORETURN void os_panic(const char *fmt, va_list args);
 
 #define os_rwlock_init(lock)            sx_init(lock, "vmblock-sx")
 #define os_rwlock_destroy(lock)         sx_destroy(lock)
diff --git a/open-vm-tools/modules/freebsd/vmblock/os_panic.c b/open-vm-tools/modules/freebsd/vmblock/os_panic.c
new file mode 100644 (file)
index 0000000..94e79aa
--- /dev/null
@@ -0,0 +1,70 @@
+/*********************************************************
+ * Copyright (C) 2011 VMware, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of VMware Inc. nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission of VMware Inc.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *********************************************************/
+
+
+/*
+ * os_panic.c --
+ *
+ *     Vararg panic implementation for FreeBSD.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <machine/stdarg.h>
+
+#include "os.h"
+
+/*
+ *----------------------------------------------------------------------------
+ *
+ * os_panic --
+ *
+ *    FreeBSD panic implementation that takes va_list argument.
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    We panic.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void
+os_panic(const char *fmt,  // IN
+         va_list args)     // IN
+{
+   static char message[1024];
+
+   vsnprintf(message, sizeof message - 1, fmt, args);
+   message[sizeof message - 1] = '\0';
+
+   panic("%s", message);
+}
index 45bf7f806e54e5c0c5177d9496916bcbee5a03ce..cc284da4dea51c50090fed4926e6e0832d4141d7 100644 (file)
  *      Common stubs.
  */
 
+#if defined(__FreeBSD__)
+#include <sys/cdefs.h>
+#include <machine/stdarg.h>
+#else
 #include <stdarg.h>
+#endif
 
 #include "os.h"
+#include "vm_assert.h"
 
 /*
  *----------------------------------------------------------------------------
@@ -93,4 +99,11 @@ Panic(const char *fmt, ...)
    va_start(args, fmt);
    os_panic(fmt, args);
    va_end(args);
+
+   /*
+    * Solaris's vcmn_err() is not marked as NORETURN and thus generates a
+    * warning. I'd use NOT_REACHED(), as recommended, except that we are
+    * already in Panic().
+    */
+   INFINITE_LOOP();
 }
index 5bfc3d9cb15ac1d68432bbd1e0de672584452b6d..68afbf835e397af8a8fdca7955bdef13a3ba67aa 100644 (file)
@@ -59,7 +59,7 @@ typedef char *                          os_blocker_id_t;
 
 #define os_panic(fmt, args)             \
 ({                                      \
-   fprintf(stderr, fmt, args);          \
+   vfprintf(stderr, fmt, args);         \
    abort();                             \
 })