Hi, some people asked me to publish my current work on Haiku GA, so here
it is for the record. I'd welcome comments on it, although I know some
parts are hackish.

Currently clipboard sharing works, mouse support probably works but I
just use absolute pointer mode now, vboxsf crashes when mouting IIRC.

It depends on the GCC2 kBuild tools patch I sent in january.

François.
My current work-in-progress for gcc2 support
for Haiku Guest Additions on VirtualBox.

Building with:

./configure --build-headless --disable-python --disable-java --nofatal
source env.sh
kmk VBOX_ONLY_ADDITIONS=1 VBOX_WITH_ADDITION_DRIVERS=1 BUILD_TYPE=strict all

The install-haiku-guest-additions.sh script will install things
until proper packages are made.

MIT-licensed.

Index: Config.kmk
===================================================================
--- Config.kmk	(revision 50860)
+++ Config.kmk	(working copy)
@@ -1333,7 +1333,7 @@
   VBOX_GCC_TOOL := GXX4MACHO
  else ifeq ($(KBUILD_TARGET),haiku)
   # Haiku shouldn't pass '-r' to the linker by default
-  VBOX_GCC_TOOL := GXX3PLAIN
+  VBOX_GCC_TOOL := GXX2PLAIN
  else ifeq ($(KBUILD_TARGET),solaris)
   VBOX_GCC_TOOL := GXX3PLAIN
   VBOX_GCC32_TOOL := GXX3PLAIN
@@ -1474,8 +1474,14 @@
 ifdef VBOX_WITH_MASOCHISTIC_WARNINGS
  VBOX_GCC_WARN_PEDANTIC += -Wunused-variable -Wunused-function -Wunused-label -Wunused-parameter
 endif
-VBOX_GCC_PEDANTIC_CXX ?= -pedantic -Wshadow $(VBOX_GCC_WARN_PEDANTIC) -Wno-long-long $(VBOX_GCC_Wno-delete-non-virtual-dtor)
-VBOX_GCC_PEDANTIC_C   ?= -pedantic -Wshadow $(VBOX_GCC_WARN_PEDANTIC) -Wno-long-long -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Werror-implicit-function-declaration
+VBOX_GCC_PEDANTIC_CXX ?= -Wshadow $(VBOX_GCC_WARN_PEDANTIC) -Wno-long-long $(VBOX_GCC_Wno-delete-non-virtual-dtor)
+VBOX_GCC_PEDANTIC_C   ?= -Wshadow $(VBOX_GCC_WARN_PEDANTIC) -Wno-long-long -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Werror-implicit-function-declaration
+ifeq ($(KBUILD_TARGET),haiku)
+ # gcc2 complains about 'volatile' undeclared
+ # TODO: filter out -pedantic
+ VBOX_GCC_PEDANTIC_CXX += -D__volatile__=
+ VBOX_GCC_PEDANTIC_C   += -D__volatile__=
+endif
 ifeq ($(KBUILD_TARGET),win)
  VBOX_C_CXX_FLAGS_NO_UNUSED_PARAMETERS = #-Wdxxxx
 else
@@ -2738,17 +2744,18 @@
   # @param 1  The file to add resources to.
   # @param 2  The resource files.
   # @param 3  The target name.
-define VBOX_HAIKU_XRES_SETVER_FN
-	$(if $(2),$(call MSG_TOOL,HaikuAddResources,$(3),$(2))
-	$(QUIET)$(VBOX_HAIKU_XRESTOOL) -o $(1) $(2),)
-	$(call MSG_TOOL,HaikuSetVersion,$(3))
-	$(QUIET)$(VBOX_HAIKU_SETVERSIONTOOL) $(1) \
+#define VBOX_HAIKU_XRES_SETVER_FN
+VBOX_HAIKU_XRES_SETVER_FN ?= \
+	$$(NLTAB)$(if $(2),$(call MSG_TOOL,HaikuAddResources,$(3),$(2))\
+	$$(NLTAB)$(QUIET)$(VBOX_HAIKU_XRESTOOL) -o $(1) $(2),)\
+	$$(NLTAB)$(call MSG_TOOL,HaikuSetVersion,$(3))\
+	$$(NLTAB)$(QUIET)$(VBOX_HAIKU_SETVERSIONTOOL) $(1) \
 		-app $(VBOX_VERSION_MAJOR) $(VBOX_VERSION_MINOR) $(VBOX_VERSION_BUILD) d $(VBOX_SVN_REV) \
 		-short "$(VBOX_PRODUCT)" \
-		-long "$(VBOX_PRODUCT) $(VBOX_VERSION_STRING) $(shell /bin/echo -e '\xC2\xA9')2009-$(VBOX_C_YEAR) $(VBOX_VENDOR)"
-	$(call MSG_TOOL,HaikuMimeSet,$(3))
-	$(QUIET)$(VBOX_HAIKU_MIMESETTOOL) -f $(1)
-endef
+		-long "$(VBOX_PRODUCT) $(VBOX_VERSION_STRING) $(shell /bin/echo -e '\xC2\xA9')2009-$(VBOX_C_YEAR) $(VBOX_VENDOR)"\
+	$$(NLTAB)$(call MSG_TOOL,HaikuMimeSet,$(3))\
+	$$(NLTAB)$(QUIET)$(VBOX_HAIKU_MIMESETTOOL) -f $(1)
+#endef
 
  VBOX_HAIKU_XRES_SETVER_CMDS  ?= $(if $(eq $(tool_do),LINK_PROGRAM),$(call VBOX_HAIKU_XRES_SETVER_FN,$(out),$($(target)_RSRCS),$(target)),)
 endif
@@ -3470,7 +3477,7 @@
 
 ifeq ($(KBUILD_TARGET),haiku)
 ## The Haiku include directories
-VBOX_HAIKU_SYS_INCS ?= /boot/develop/headers/os/kernel /boot/develop/headers/os/drivers
+VBOX_HAIKU_SYS_INCS ?= /system/develop/headers/os/kernel /system/develop/headers/os/drivers
 
 TEMPLATE_VBOXR0DRV_TOOL                = $(VBOX_GCC_TOOL)
 TEMPLATE_VBOXR0DRV_LDTOOL              = $(VBOX_GCC_TOOL)
@@ -3481,13 +3488,13 @@
 TEMPLATE_VBOXR0DRV_CFLAGS              = -fno-PIC \
 	$(VBOX_GCC_WARN) -Wstrict-prototypes $(VBOX_GCC_Wno-pointer-sign) -Wno-sign-compare \
 	$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration
-TEMPLATE_VBOXR0DRV_CFLAGS.x86          = -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
-TEMPLATE_VBOXR0DRV_CFLAGS.x86          = -m32 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
+#TEMPLATE_VBOXR0DRV_CFLAGS.x86          = -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
+TEMPLATE_VBOXR0DRV_CFLAGS.x86          = 
 TEMPLATE_VBOXR0DRV_CFLAGS.amd64        = -m64 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow \
 	-fno-reorder-blocks -ffreestanding -fno-asynchronous-unwind-tables -funit-at-a-time \
 	-Wno-sign-compare -Wdeclaration-after-statement
 TEMPLATE_VBOXR0DRV_CXXFLAGS           = -fno-PIC -Wpointer-arith \
-	-Wshadow -Wuninitialized -Wunused-function -Wunused-label -Wunused-value -Wunused-variable \
+	-Wshadow -Wuninitialized \
 	-Wformat \
 	-O2 -nodefaultlibs -fno-omit-frame-pointer -fno-strict-aliasing -fno-common -fno-exceptions -fno-rtti
 TEMPLATE_VBOXR0DRV_CXXFLAGS.x86       = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86) -fno-exceptions -fno-rtti
@@ -3590,7 +3597,9 @@
 else # the gcc guys
 TEMPLATE_VBOXR3EXE_TOOL                = $(VBOX_GCC_TOOL)
 TEMPLATE_VBOXR3EXE_CXXFLAGS            = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros) $(VBOX_GCC_OPT) $(VBOX_GCC_FP) -fno-strict-aliasing $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden)
+ifneq ($(KBUILD_TARGET),haiku)
 TEMPLATE_VBOXR3EXE_CXXFLAGS.x86        = -m32
+endif
 TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64      = -m64
 TEMPLATE_VBOXR3EXE_CXXFLAGS.sparc32    = -m32
 TEMPLATE_VBOXR3EXE_CXXFLAGS.sparc64    = -m64
@@ -3612,7 +3621,9 @@
 TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.amd64   = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.amd64)
 TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.debug   = $(TEMPLATE_VBOXR3EXE_CXXFLAGS.debug)
 TEMPLATE_VBOXR3EXE_OBJCXXFLAGS.kprofile= $(TEMPLATE_VBOXR3EXE_CXXFLAGS.kprofile)
+ifneq ($(KBUILD_TARGET),haiku)
 TEMPLATE_VBOXR3EXE_LDFLAGS.x86         = -m32
+endif
 TEMPLATE_VBOXR3EXE_LDFLAGS.amd64       = -m64
 TEMPLATE_VBOXR3EXE_LDFLAGS.sparc32     = -m32
 TEMPLATE_VBOXR3EXE_LDFLAGS.sparc64     = -m64
@@ -3638,9 +3649,11 @@
    TEMPLATE_VBOXR3EXE_CXXFLAGS := $(filter-out -pedantic,$(TEMPLATE_VBOXR3EXE_CXXFLAGS)) -fdollars-in-identifiers # annoying gcc option precedence.
   endif
  else ifeq ($(KBUILD_TARGET),haiku)
-TEMPLATE_VBOXR3EXE_TOOL                = GXX3
+TEMPLATE_VBOXR3EXE_TOOL                = GXX2
 TEMPLATE_VBOXR3EXE_POST_CMDS          = $(VBOX_HAIKU_XRES_SETVER_CMDS)
-TEMPLATE_VBOXR3EXE_LIBS                = network iconv stdc++ supc++
+#TEMPLATE_VBOXR3EXE_POST_CMDS          = $(if $(eq $(tool_do),LINK_PROGRAM),$(call VBOX_HAIKU_XRES_SETVER_FN,$(out),$($(target)_RSRCS),$(target)),)
+#TEMPLATE_VBOXR3EXE_LIBS                = network iconv stdc++ supc++
+TEMPLATE_VBOXR3EXE_LIBS                = network iconv stdc++.r4
 TEMPLATE_VBOXR3EXE_LIBPATH            += \
 	/boot/common/lib
 # Haiku uses PIC by default...
@@ -4851,7 +4864,9 @@
 # (gcc of some kind )
 TEMPLATE_VBoxBldProg_TOOL                = GXX3
 TEMPLATE_VBoxBldProg_CFLAGS              = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_C) $(VBOX_GCC_Wno-variadic-macros)
+ifneq ($(KBUILD_TARGET),haiku)
 TEMPLATE_VBoxBldProg_CFLAGS.x86          = -m32
+endif
 TEMPLATE_VBoxBldProg_CFLAGS.sparc32      = -m32
 TEMPLATE_VBoxBldProg_CFLAGS.amd64        = -m64
 TEMPLATE_VBoxBldProg_CFLAGS.sparc64      = -m64
@@ -4859,7 +4874,9 @@
 TEMPLATE_VBoxBldProg_CFLAGS.profile      = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile)
 TEMPLATE_VBoxBldProg_CFLAGS.kprofile     = $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile)
 TEMPLATE_VBoxBldProg_CXXFLAGS            = -g $(VBOX_GCC_pipe) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC_Wno-variadic-macros)
+ifneq ($(KBUILD_TARGET),haiku)
 TEMPLATE_VBoxBldProg_CXXFLAGS.x86        = -m32
+endif
 TEMPLATE_VBoxBldProg_CXXFLAGS.sparc32    = -m32
 TEMPLATE_VBoxBldProg_CXXFLAGS.amd64      = -m64
 TEMPLATE_VBoxBldProg_CXXFLAGS.sparc64    = -m64
@@ -4878,7 +4895,9 @@
 TEMPLATE_VBoxBldProg_OBJCXXFLAGS.release = $(TEMPLATE_VBoxBldProg_CXXFLAGS.release)
 TEMPLATE_VBoxBldProg_OBJCXXFLAGS.profile = $(TEMPLATE_VBoxBldProg_CXXFLAGS.profile)
 TEMPLATE_VBoxBldProg_OBJCXXFLAGS.kprofile= $(TEMPLATE_VBoxBldProg_CXXFLAGS.kprofile)
+ifneq ($(KBUILD_TARGET),haiku)
 TEMPLATE_VBoxBldProg_LDFLAGS.x86         = -m32
+endif
 TEMPLATE_VBoxBldProg_LDFLAGS.sparc32     = -m32
 TEMPLATE_VBoxBldProg_LDFLAGS.amd64       = -m64
 TEMPLATE_VBoxBldProg_LDFLAGS.sparc64     = -m64
@@ -4920,7 +4939,7 @@
   endif
 TEMPLATE_VBoxBldProg_LIBS                =
  else ifeq ($(KBUILD_HOST),haiku)
-TEMPLATE_VBoxBldProg_TOOL                = GXX3
+TEMPLATE_VBoxBldProg_TOOL                = GXX2
 TEMPLATE_VBoxBldProg_LIBS                = network iconv
 TEMPLATE_VBoxBldProg_LIBPATH            += \
 	/boot/common/lib
Index: src/VBox/Runtime/VBox/log-vbox.cpp
===================================================================
--- src/VBox/Runtime/VBox/log-vbox.cpp	(revision 50860)
+++ src/VBox/Runtime/VBox/log-vbox.cpp	(working copy)
@@ -492,6 +492,11 @@
         RTLogFlags(pLogger, "enabled unbuffered tid");
         pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT;
 # endif
+# if 1 /* vboxdrv logging - ATTENTION: this is what we're referring to guys! Change to '# if 1'. */
+        RTLogGroupSettings(pLogger, "+all");
+        RTLogFlags(pLogger, "enabled unbuffered tid");
+        pLogger->fDestFlags |= RTLOGDEST_DEBUGGER | RTLOGDEST_STDOUT;
+# endif
     }
 #endif /* IN_RING0 */
     return g_pLogger = RT_SUCCESS(rc) ? pLogger : NULL;
Index: src/VBox/Runtime/r3/haiku/rtProcInitExePath-haiku.cpp
===================================================================
--- src/VBox/Runtime/r3/haiku/rtProcInitExePath-haiku.cpp	(revision 50860)
+++ src/VBox/Runtime/r3/haiku/rtProcInitExePath-haiku.cpp	(working copy)
@@ -31,6 +31,7 @@
 #ifdef RT_OS_HAIKU
 # include <image.h>
 #endif
+#include <stdio.h>
 
 #include <iprt/string.h>
 #include <iprt/assert.h>
@@ -51,6 +52,7 @@
      */
     status = get_next_image_info(0, &Cookie, &ImageInfo);
     AssertReturn((status == B_OK), VERR_INTERNAL_ERROR);
+fprintf(stderr, "p='%s'\n", ImageInfo.name);
 
     int rc = rtPathFromNativeCopy(pszPath, MIN(cchPath, MAXPATHLEN), ImageInfo.name, NULL);
     AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhxs\n", rc, pszPath, MIN(cchPath, MAXPATHLEN), pszPath), rc);
Index: src/VBox/Runtime/r3/posix/utf8-posix.cpp
===================================================================
--- src/VBox/Runtime/r3/posix/utf8-posix.cpp	(revision 50860)
+++ src/VBox/Runtime/r3/posix/utf8-posix.cpp	(working copy)
@@ -173,7 +173,7 @@
         iconv_t hIconv = (iconv_t)*phIconv;
         if (hIconv == (iconv_t)-1)
         {
-#ifdef RT_OS_SOLARIS
+#if defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS)
             /* Solaris doesn't grok empty codeset strings, so help it find the current codeset. */
             if (!*pszInputCS)
                 pszInputCS = rtStrGetLocaleCodeset();
@@ -304,7 +304,7 @@
         /*
          * Create conversion object.
          */
-#ifdef RT_OS_SOLARIS
+#if defined(RT_OS_HAIKU) || defined(RT_OS_SOLARIS)
         /* Solaris doesn't grok empty codeset strings, so help it find the current codeset. */
         if (!*pszInputCS)
             pszInputCS = rtStrGetLocaleCodeset();
Index: src/VBox/Runtime/r0drv/haiku/RTLogWriteDebugger-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/RTLogWriteDebugger-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/RTLogWriteDebugger-r0drv-haiku.c	(working copy)
@@ -36,6 +36,7 @@
 RTDECL(void) RTLogWriteDebugger(const char *pch, size_t cb)
 {
     /** @todo implement this */
+    dprintf("%.*s", (int)cb, pch);
     /*kprintf("%.*s", (int)cb, pch);*/
     return;
 }
Index: src/VBox/Runtime/r0drv/haiku/semmutex-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/semmutex-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/semmutex-r0drv-haiku.c	(working copy)
@@ -65,16 +65,19 @@
 
 RTDECL(int)  RTSemMutexCreate(PRTSEMMUTEX phMutexSem)
 {
+    PRTSEMMUTEXINTERNAL pThis;
+
     AssertCompile(sizeof(RTSEMMUTEXINTERNAL) > sizeof(void *));
+    dprintf("phMutexSem: %p\n", phMutexSem);
     AssertPtrReturn(phMutexSem, VERR_INVALID_POINTER);
 
-    PRTSEMMUTEXINTERNAL pThis = (PRTSEMMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
+    pThis = (PRTSEMMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
     if (RT_UNLIKELY(!pThis))
         return VERR_NO_MEMORY;
 
     pThis->u32Magic = RTSEMMUTEX_MAGIC;
     pThis->SemId = create_sem(0, "IPRT Mutex Semaphore");
-    if (pThis->SemId < B_OK)
+    if (pThis->SemId >= B_OK)
     {
         pThis->OwnerId = -1;
         pThis->cRecursion = 0;
@@ -215,7 +218,7 @@
     if (--pThis->cRecursion == 0)
     {
         pThis->OwnerId == -1;
-        release_sem(pThis->SemId);
+        release_sem_etc(pThis->SemId, 1, B_DO_NOT_RESCHEDULE);
     }
 
     return VINF_SUCCESS;
Index: src/VBox/Runtime/r0drv/haiku/memobj-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/memobj-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/memobj-r0drv-haiku.c	(working copy)
@@ -153,13 +153,15 @@
 static int rtR0MemObjNativeAllocArea(PPRTR0MEMOBJINTERNAL ppMem, size_t cb,
                                      bool fExecutable, RTR0MEMOBJTYPE type, RTHCPHYS PhysHighest, size_t uAlignment)
 {
-    NOREF(fExecutable);
-
     int rc;
     void *pvMap         = NULL;
     const char *pszName = NULL;
     uint32 addressSpec  = B_ANY_KERNEL_ADDRESS;
     uint32 fLock        = ~0U;
+    PRTR0MEMOBJHAIKU pMemHaiku;
+
+    NOREF(fExecutable);
+
     LogFlowFunc(("ppMem=%p cb=%u, fExecutable=%s, type=%08x, PhysHighest=%RX64 uAlignment=%u\n", ppMem,(unsigned)cb,
                  fExecutable ? "true" : "false", type, PhysHighest,(unsigned)uAlignment));
 
@@ -201,7 +203,6 @@
     }
 
     /* Create the object. */
-    PRTR0MEMOBJHAIKU pMemHaiku;
     pMemHaiku = (PRTR0MEMOBJHAIKU)rtR0MemObjNew(sizeof(RTR0MEMOBJHAIKU), type, NULL, cb);
     if (RT_UNLIKELY(!pMemHaiku))
         return VERR_NO_MEMORY;
@@ -277,11 +278,13 @@
 
 int rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
 {
+    PRTR0MEMOBJHAIKU pMemHaiku;
+
     AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_SUPPORTED);
     LogFlowFunc(("ppMem=%p Phys=%08x cb=%u uCachePolicy=%x\n", ppMem, Phys,(unsigned)cb, uCachePolicy));
 
     /* Create the object. */
-    PRTR0MEMOBJHAIKU pMemHaiku = (PRTR0MEMOBJHAIKU)rtR0MemObjNew(sizeof(*pMemHaiku), RTR0MEMOBJTYPE_PHYS, NULL, cb);
+    pMemHaiku = (PRTR0MEMOBJHAIKU)rtR0MemObjNew(sizeof(*pMemHaiku), RTR0MEMOBJTYPE_PHYS, NULL, cb);
     if (!pMemHaiku)
         return VERR_NO_MEMORY;
 
@@ -311,15 +314,16 @@
 static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTERNAL ppMem, void *pvStart, size_t cb, uint32_t fAccess,
                                      RTR0PROCESS R0Process, int fFlags)
 {
-    NOREF(fAccess);
     int rc;
     team_id TeamId = B_SYSTEM_TEAM;
+    PRTR0MEMOBJHAIKU pMemHaiku;
+    NOREF(fAccess);
 
     LogFlowFunc(("ppMem=%p pvStart=%p cb=%u fAccess=%x R0Process=%d fFlags=%x\n", ppMem, pvStart, cb, fAccess, R0Process,
                  fFlags));
 
     /* Create the object. */
-    PRTR0MEMOBJHAIKU pMemHaiku = (PRTR0MEMOBJHAIKU)rtR0MemObjNew(sizeof(*pMemHaiku), RTR0MEMOBJTYPE_LOCK, pvStart, cb);
+    pMemHaiku = (PRTR0MEMOBJHAIKU)rtR0MemObjNew(sizeof(*pMemHaiku), RTR0MEMOBJTYPE_LOCK, pvStart, cb);
     if (RT_UNLIKELY(!pMemHaiku))
         return VERR_NO_MEMORY;
 
@@ -605,10 +609,11 @@
             team_id        TeamId = B_SYSTEM_TEAM;
             physical_entry aPhysMap[2];
             int32          cPhysMap = 2;    /** @todo r=ramshankar: why not use RT_ELEMENTS? */
+            void *pb;
 
             if (pMemHaiku->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
                 TeamId = (team_id)pMemHaiku->Core.u.Lock.R0Process;
-            void *pb = pMemHaiku->Core.pv + (iPage << PAGE_SHIFT);
+            pb = pMemHaiku->Core.pv + (iPage << PAGE_SHIFT);
 
             rc = get_memory_map_etc(TeamId, pb, B_PAGE_SIZE, aPhysMap, &cPhysMap);
             if (rc < B_OK || cPhysMap < 1)
Index: src/VBox/Runtime/r0drv/haiku/spinlock-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/spinlock-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/spinlock-r0drv-haiku.c	(working copy)
@@ -66,14 +66,15 @@
 
 RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
 {
+    PRTSPINLOCKINTERNAL pSpinlockInt;
     RT_ASSERT_PREEMPTIBLE();
     NOREF(pszName);
 
     /*
      * Allocate.
      */
-    AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
-    PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAllocZ(sizeof(*pSpinlockInt));
+//    AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
+    pSpinlockInt = (PRTSPINLOCKINTERNAL)RTMemAllocZ(sizeof(*pSpinlockInt));
     if (RT_UNLIKELY(!pSpinlockInt))
         return VERR_NO_MEMORY;
 
Index: src/VBox/Runtime/r0drv/haiku/semfastmutex-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/semfastmutex-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/semfastmutex-r0drv-haiku.c	(working copy)
@@ -57,10 +57,13 @@
 
 RTDECL(int)  RTSemFastMutexCreate(PRTSEMFASTMUTEX phFastMtx)
 {
+    PRTSEMFASTMUTEXINTERNAL pThis;
+
     AssertCompile(sizeof(RTSEMFASTMUTEXINTERNAL) > sizeof(void *));
+    dprintf("phFastMtx: %p\n", phFastMtx);
     AssertPtrReturn(phFastMtx, VERR_INVALID_POINTER);
 
-    PRTSEMFASTMUTEXINTERNAL pThis = (PRTSEMFASTMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
+    pThis = (PRTSEMFASTMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
     if (RT_UNLIKELY(!pThis))
         return VERR_NO_MEMORY;
 
Index: src/VBox/Runtime/r0drv/haiku/semevent-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/semevent-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/semevent-r0drv-haiku.c	(working copy)
@@ -66,12 +66,15 @@
 
 RTDECL(int)  RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass, const char *pszNameFmt, ...)
 {
+    PRTSEMEVENTINTERNAL pThis;
+
     AssertCompile(sizeof(RTSEMEVENTINTERNAL) > sizeof(void *));
     AssertReturn(!(fFlags & ~(RTSEMEVENT_FLAGS_NO_LOCK_VAL | RTSEMEVENT_FLAGS_BOOTSTRAP_HACK)), VERR_INVALID_PARAMETER);
     Assert(!(fFlags & RTSEMEVENT_FLAGS_BOOTSTRAP_HACK) || (fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL));
+    dprintf("phEventSem: %p\n", phEventSem);
     AssertPtrReturn(phEventSem, VERR_INVALID_POINTER);
 
-    PRTSEMEVENTINTERNAL pThis = (PRTSEMEVENTINTERNAL)RTMemAllocZ(sizeof(*pThis));
+    pThis = (PRTSEMEVENTINTERNAL)RTMemAllocZ(sizeof(*pThis));
     if (!pThis)
         return VERR_NO_MEMORY;
 
Index: src/VBox/Runtime/r0drv/haiku/alloc-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/alloc-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/alloc-r0drv-haiku.c	(working copy)
@@ -44,10 +44,12 @@
  */
 int rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
 {
+	PRTMEMHDR pHdr;
+
     if (RT_UNLIKELY(fFlags & RTMEMHDR_FLAG_ANY_CTX))
         return VERR_NOT_SUPPORTED;
 
-    PRTMEMHDR pHdr = (PRTMEMHDR)malloc(cb + sizeof(*pHdr));
+    pHdr = (PRTMEMHDR)malloc(cb + sizeof(*pHdr));
     if (RT_UNLIKELY(!pHdr))
     {
         LogRel(("rtR0MemAllocEx(%u, %#x) failed\n",(unsigned)cb + sizeof(*pHdr), fFlags));
@@ -75,6 +77,9 @@
 
 RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb) RT_NO_THROW
 {
+    void *pv;
+    area_id area;
+
     /*
      * Validate input.
      */
@@ -87,8 +92,7 @@
      * memory that's always below 4GB.
      */
     cb = RT_ALIGN_Z(cb, PAGE_SIZE);
-    void *pv;
-    area_id area = create_area("VirtualBox Contig Alloc", &pv, B_ANY_KERNEL_ADDRESS, cb, B_32_BIT_CONTIGUOUS,
+    area = create_area("VirtualBox Contig Alloc", &pv, B_ANY_KERNEL_ADDRESS, cb, B_32_BIT_CONTIGUOUS,
                                B_READ_AREA | B_WRITE_AREA);
     if (area >= 0)
     {
@@ -112,9 +116,10 @@
     RT_ASSERT_PREEMPTIBLE();
     if (pv)
     {
+        area_id area;
         Assert(cb > 0);
 
-        area_id area = area_for(pv);
+        area = area_for(pv);
         if (area >= B_OK)
         delete_area(area);
         else
Index: src/VBox/Runtime/r0drv/haiku/semeventmulti-r0drv-haiku.c
===================================================================
--- src/VBox/Runtime/r0drv/haiku/semeventmulti-r0drv-haiku.c	(revision 50860)
+++ src/VBox/Runtime/r0drv/haiku/semeventmulti-r0drv-haiku.c	(working copy)
@@ -76,7 +76,7 @@
     pThis->u32Magic  = RTSEMEVENTMULTI_MAGIC;
     pThis->cRefs     = 1;
     pThis->SemId     = create_sem(0, "IPRT Semaphore Event Multi");
-    if (pThis->SemId < B_OK)
+    if (pThis->SemId >= B_OK)
     {
         set_sem_owner(pThis->SemId, B_SYSTEM_TEAM);
         *phEventMultiSem = pThis;
Index: src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.c
===================================================================
--- src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.c	(revision 50860)
+++ src/VBox/Additions/common/VBoxGuest/VBoxGuest-haiku.c	(working copy)
@@ -69,6 +69,7 @@
 #include <iprt/heap.h>
 
 #define MODULE_NAME VBOXGUEST_MODULE_NAME
+#define DO_LOG 1
 
 /*
  * IRQ related functions.
@@ -302,9 +303,10 @@
  */
 static int32 VBoxGuestHaikuISR(void *pvState)
 {
+    bool fOurIRQ;
     LogFlow((MODULE_NAME ":VBoxGuestHaikuISR pvState=%p\n", pvState));
 
-    bool fOurIRQ = VBoxGuestCommonISR(&g_DevExt);
+    fOurIRQ = VBoxGuestCommonISR(&g_DevExt);
     if (fOurIRQ)
         return B_HANDLED_INTERRUPT;
     return B_UNHANDLED_INTERRUPT;
@@ -313,9 +315,10 @@
 
 void VBoxGuestNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
 {
+    status_t err = B_OK;
+
     LogFlow((MODULE_NAME "::NativeISRMousePollEvent:\n"));
 
-    status_t err = B_OK;
     //dprintf(MODULE_NAME ": isr mouse\n");
 
     /*
Index: src/VBox/Additions/common/VBoxGuest/VBoxDev-haiku.c
===================================================================
--- src/VBox/Additions/common/VBoxGuest/VBoxDev-haiku.c	(revision 50860)
+++ src/VBox/Additions/common/VBoxGuest/VBoxDev-haiku.c	(working copy)
@@ -191,11 +191,14 @@
  */
 static status_t VBoxGuestHaikuIOCtl(void *cookie, uint32 op, void *data, size_t len)
 {
+    int rc = B_OK;
+    void *pvBuf = NULL;
+    size_t cbDataReturned;
+
     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
+    dprintf(DRIVER_NAME ":VBoxGuestHaikuIOCtl cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len);
     Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl cookie=%p op=0x%08x data=%p len=%lu)\n", cookie, op, data, len));
 
-    int rc = B_OK;
-
     /*
      * Validate the input.
      */
@@ -223,7 +226,6 @@
     /*
      * Read the request.
      */
-    void *pvBuf = NULL;
     if (RT_LIKELY(len > 0))
     {
         pvBuf = RTMemTmpAlloc(len);
@@ -238,6 +240,7 @@
         if (RT_UNLIKELY(rc < 0))
         {
             RTMemTmpFree(pvBuf);
+            dprintf(DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p data=%p op=%d. rc=%d\n", pvBuf, data, op, rc);
             LogRel((DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p data=%p op=%d. rc=%d\n", pvBuf, data, op, rc));
             return EFAULT;
         }
@@ -253,7 +256,6 @@
     /*
      * Process the IOCtl.
      */
-    size_t cbDataReturned;
     rc = VBoxGuestCommonIOCtl(op, &g_DevExt, pSession, pvBuf, len, &cbDataReturned);
     if (RT_SUCCESS(rc))
     {
@@ -268,6 +270,7 @@
             rc = user_memcpy(data, pvBuf, cbDataReturned);
             if (RT_UNLIKELY(rc < 0))
             {
+                dprintf(DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, data, op, rc);
                 Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: user_memcpy failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, data, op, rc));
                 rc = EFAULT;
             }
@@ -275,6 +278,7 @@
     }
     else
     {
+        dprintf(DRIVER_NAME ":VBoxGuestHaikuIOCtl: VBoxGuestCommonIOCtl failed. rc=%d\n", rc);
         Log((DRIVER_NAME ":VBoxGuestHaikuIOCtl: VBoxGuestCommonIOCtl failed. rc=%d\n", rc));
         rc = EFAULT;
     }
@@ -297,6 +301,7 @@
 {
     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
     status_t err = B_OK;
+    uint32_t u32CurSeq;
 
     switch (event)
     {
@@ -308,7 +313,7 @@
 
     RTSpinlockAcquire(g_DevExt.SessionSpinlock);
 
-    uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
+    u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
     if (pSession->u32MousePosChangedSeq != u32CurSeq)
     {
         pSession->u32MousePosChangedSeq = u32CurSeq;
@@ -388,11 +393,12 @@
 static status_t VBoxGuestHaikuRead(void *cookie, off_t position, void *data, size_t *numBytes)
 {
     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)cookie;
+    uint32_t u32CurSeq;
 
     if (*numBytes == 0)
         return B_OK;
 
-    uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
+    u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
     if (pSession->u32MousePosChangedSeq != u32CurSeq)
     {
         pSession->u32MousePosChangedSeq = u32CurSeq;
Index: src/VBox/Additions/haiku/SharedFolders/lock.h
===================================================================
--- src/VBox/Additions/haiku/SharedFolders/lock.h	(revision 50860)
+++ src/VBox/Additions/haiku/SharedFolders/lock.h	(working copy)
@@ -64,7 +64,7 @@
         const char*                             name;
         struct rw_lock_waiter*  waiters;
         thread_id                               holder;
-        vint32                                  count;
+        int32                                  count;
         int32                                   owner_count;
         int16                                   active_readers;
                                                                 // Only > 0 while a writer is waiting: number
Index: src/VBox/Additions/haiku/SharedFolders/vboxsf.c
===================================================================
--- src/VBox/Additions/haiku/SharedFolders/vboxsf.c	(revision 50860)
+++ src/VBox/Additions/haiku/SharedFolders/vboxsf.c	(working copy)
@@ -55,6 +55,7 @@
 
 status_t init_module(void)
 {
+	int rc;
 #if 0
     /* @todo enable this soon */
     int rc = get_module(VBOXGUEST_MODULE_NAME, (module_info **)&g_VBoxGuest);
@@ -98,7 +99,10 @@
         return B_ERROR;
     }
 
-    if (RT_FAILURE(vboxInit()))
+    rc = vboxInit();
+    dprintf("rc=%d\n", rc);
+    if (RT_FAILURE(rc))
+    //if (RT_FAILURE(vboxInit()))
     {
         dprintf("vboxInit failed\n");
         return B_ERROR;
@@ -136,6 +140,7 @@
 
 PSHFLSTRING make_shflstring(const char* const s)
 {
+    PSHFLSTRING rv;
     int len = strlen(s);
     if (len > 0xFFFE)
     {
@@ -143,7 +148,7 @@
         return NULL;
     }
 
-    PSHFLSTRING rv = malloc(sizeof(SHFLSTRING) + len);
+    rv = malloc(sizeof(SHFLSTRING) + len);
     if (!rv)
         return NULL;
 
@@ -194,12 +199,14 @@
 
 PSHFLSTRING build_path(vboxsf_vnode* dir, const char* const name)
 {
+    size_t len;
+    PSHFLSTRING rv;
     dprintf("*** build_path(%p, %p)\n", dir, name);
     if (!dir || !name)
         return NULL;
 
-    size_t len = dir->path->u16Length + strlen(name) + 1;
-    PSHFLSTRING rv = malloc(sizeof(SHFLSTRING) + len);
+    len = dir->path->u16Length + strlen(name) + 1;
+    rv = malloc(sizeof(SHFLSTRING) + len);
     if (rv)
     {
         strcpy(rv->String.utf8, dir->path->String.utf8);
@@ -214,6 +221,10 @@
 
 status_t mount(fs_volume *volume, const char *device, uint32 flags, const char *args, ino_t *_rootVnodeID)
 {
+    PSHFLSTRING sharename;
+    vboxsf_volume* vbsfvolume;
+    int rv;
+
     if (device)
     {
         dprintf(FS_NAME ": trying to mount a real device as a vbox share is silly\n");
@@ -222,16 +233,17 @@
 
     dprintf(FS_NAME ": mount(%s)\n", args);
 
-    PSHFLSTRING sharename = make_shflstring(args);
+    sharename = make_shflstring(args);
 
-    vboxsf_volume* vbsfvolume = malloc(sizeof(vboxsf_volume));
+    vbsfvolume = malloc(sizeof(vboxsf_volume));
     volume->private_volume = vbsfvolume;
-    int rv = vboxCallMapFolder(&g_clientHandle, sharename, &(vbsfvolume->map));
+    rv = vboxCallMapFolder(&g_clientHandle, sharename, &(vbsfvolume->map));
     free(sharename);
 
     if (rv == 0)
     {
         vboxsf_vnode* root_vnode;
+        status_t rs;
 
         PSHFLSTRING name = make_shflstring("");
         if (!name)
@@ -240,7 +252,7 @@
             return B_NO_MEMORY;
         }
 
-        status_t rs = vboxsf_new_vnode(&vbsfvolume->map, name, name, &root_vnode);
+        rs = vboxsf_new_vnode(&vbsfvolume->map, name, name, &root_vnode);
         dprintf(FS_NAME ": allocated %p (path=%p name=%p)\n", root_vnode, root_vnode->path, root_vnode->name);
 
         if (rs != B_OK)
@@ -323,12 +335,13 @@
     vboxsf_volume* volume = _volume->private_volume;
     vboxsf_vnode* vnode = _vnode->private_node;
     SHFLCREATEPARMS params;
+    int rc;
 
     RT_ZERO(params);
     params.Handle = SHFL_HANDLE_NIL;
     params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_OPEN_IF_EXISTS | SHFL_CF_ACT_FAIL_IF_NEW | SHFL_CF_ACCESS_READ;
 
-    int rc = vboxCallCreate(&g_clientHandle, &volume->map, vnode->path, &params);
+    rc = vboxCallCreate(&g_clientHandle, &volume->map, vnode->path, &params);
     if (RT_SUCCESS(rc))
     {
         if (params.Result == SHFL_FILE_EXISTS && params.Handle != SHFL_HANDLE_NIL)
@@ -358,17 +371,23 @@
 status_t vboxsf_read_dir_1(vboxsf_volume* volume, vboxsf_vnode* vnode, vboxsf_dir_cookie* cookie,
     struct dirent* buffer, size_t bufferSize)
 {
+    PSHFLSTRING name1;
+    int rv;
+    vboxsf_vnode* new_vnode;
+    size_t size;
+
     dprintf("%p, %d, %p\n", cookie, cookie->has_more_files, cookie->buffer);
     if (!cookie->has_more_files)
         return B_ENTRY_NOT_FOUND;
 
     if (!cookie->buffer)
     {
+        int rc;
         cookie->buffer_length = 16384;
         cookie->buffer_start = cookie->buffer = malloc(cookie->buffer_length);
 
-        int rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path, 0, cookie->index,
-                                 &cookie->buffer_length, cookie->buffer, &cookie->num_files);
+        rc = vboxCallDirInfo(&g_clientHandle, &volume->map, cookie->handle, cookie->path, 0, cookie->index,
+                             &cookie->buffer_length, cookie->buffer, &cookie->num_files);
 
         if (rc != 0 && rc != VERR_NO_MORE_FILES)
         {
@@ -393,15 +412,14 @@
         return B_BUFFER_OVERFLOW;
     }
 
-    PSHFLSTRING name1 = clone_shflstring(&cookie->buffer->name);
+    name1 = clone_shflstring(&cookie->buffer->name);
     if (!name1)
     {
         dprintf(FS_NAME ": make_shflstring() failed\n");
         return B_NO_MEMORY;
     }
 
-    vboxsf_vnode* new_vnode;
-    int rv = vboxsf_new_vnode(&volume->map, build_path(vnode, name1->String.utf8), name1, &new_vnode);
+    rv = vboxsf_new_vnode(&volume->map, build_path(vnode, name1->String.utf8), name1, &new_vnode);
     if (rv != B_OK)
     {
         dprintf(FS_NAME ": vboxsf_new_vnode() failed\n");
@@ -415,7 +433,7 @@
     buffer->d_reclen = sizeof(struct dirent) + cookie->buffer->name.u16Length;
     strncpy(buffer->d_name, cookie->buffer->name.String.utf8, NAME_MAX);
 
-    size_t size = offsetof(SHFLDIRINFO, name.String) + cookie->buffer->name.u16Size;
+    size = offsetof(SHFLDIRINFO, name.String) + cookie->buffer->name.u16Size;
     cookie->buffer = ((void*)cookie->buffer + size);
     cookie->index++;
 
@@ -504,22 +522,24 @@
 
 status_t vboxsf_lookup(fs_volume* _volume, fs_vnode* dir, const char* name, ino_t* _id)
 {
-    dprintf(FS_NAME ": lookup %s\n", name);
     vboxsf_volume* volume = _volume->private_volume;
     SHFLCREATEPARMS params;
+    PSHFLSTRING path;
+    int rc;
+    dprintf(FS_NAME ": lookup %s\n", name);
 
     RT_ZERO(params);
     params.Handle = SHFL_HANDLE_NIL;
     params.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
 
-    PSHFLSTRING path = build_path(dir->private_node, name);
+    path = build_path(dir->private_node, name);
     if (!path)
     {
         dprintf(FS_NAME ": make_shflstring() failed\n");
         return B_NO_MEMORY;
     }
 
-    int rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
+    rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
     if (RT_SUCCESS(rc))
     {
         if (params.Result == SHFL_FILE_EXISTS)
@@ -600,11 +620,12 @@
 {
     vboxsf_volume* volume = _volume->private_volume;
     vboxsf_vnode* vnode = _vnode->private_node;
+    SHFLCREATEPARMS params;
+    int rc;
+    vboxsf_file_cookie* cookie;
 
     dprintf(FS_NAME ": open %s (mode=%x)\n", vnode->path->String.utf8, openMode);
 
-    SHFLCREATEPARMS params;
-
     RT_ZERO(params);
     params.Handle = SHFL_HANDLE_NIL;
 
@@ -637,14 +658,14 @@
             params.CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS;
     }
 
-    int rc = vboxCallCreate(&g_clientHandle, &volume->map, vnode->path, &params);
+    rc = vboxCallCreate(&g_clientHandle, &volume->map, vnode->path, &params);
     if (!RT_SUCCESS(rc))
     {
         dprintf("vboxCallCreate returned %d\n", rc);
         return vbox_err_to_haiku_err(rc);
     }
 
-    vboxsf_file_cookie* cookie = malloc(sizeof(vboxsf_file_cookie));
+    cookie = malloc(sizeof(vboxsf_file_cookie));
     if (!cookie)
     {
         dprintf("couldn't allocate file cookie\n");
@@ -665,6 +686,9 @@
     vboxsf_volume* volume = _volume->private_volume;
 
     SHFLCREATEPARMS params;
+    PSHFLSTRING path;
+    int rc;
+    vboxsf_file_cookie* cookie;
 
     RT_ZERO(params);
     params.Handle = SHFL_HANDLE_NIL;
@@ -698,8 +722,8 @@
             params.CreateFlags |= SHFL_CF_ACT_OPEN_IF_EXISTS;
     }
 
-    PSHFLSTRING path = build_path(_dir->private_node, name);
-    int rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
+    path = build_path(_dir->private_node, name);
+    rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
 
     if (!RT_SUCCESS(rc))
     {
@@ -708,7 +732,7 @@
         return vbox_err_to_haiku_err(rc);
     }
 
-    vboxsf_file_cookie* cookie = malloc(sizeof(vboxsf_file_cookie));
+    cookie = malloc(sizeof(vboxsf_file_cookie));
     if (!cookie)
     {
         dprintf("couldn't allocate file cookie\n");
@@ -761,13 +785,16 @@
     vboxsf_volume* volume = _volume->private_volume;
     vboxsf_vnode* vnode = _vnode->private_node;
     vboxsf_file_cookie* cookie = _cookie;
+    uint32_t l;
+    void* other_buffer;
+    int rc;
 
     if (*length > 0xFFFFFFFF)
         *length = 0xFFFFFFFF;
 
-    uint32_t l = *length;
-    void* other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
-    int rc = vboxCallRead(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
+    l = *length;
+    other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
+    rc = vboxCallRead(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
     memcpy(buffer, other_buffer, l);
     free(other_buffer);
 
@@ -782,14 +809,17 @@
     vboxsf_volume* volume = _volume->private_volume;
     vboxsf_vnode* vnode = _vnode->private_node;
     vboxsf_file_cookie* cookie = _cookie;
+    uint32_t l;
+    void* other_buffer;
+    int rc;
 
     if (*length > 0xFFFFFFFF)
         *length = 0xFFFFFFFF;
 
-    uint32_t l = *length;
-    void* other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
+    l = *length;
+    other_buffer = malloc(l);  /* @todo map the user memory into kernel space here for efficiency */
     memcpy(other_buffer, buffer, l);
-    int rc = vboxCallWrite(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
+    rc = vboxCallWrite(&g_clientHandle, &volume->map, cookie->handle, pos, &l, other_buffer, false);
     free(other_buffer);
 
     *length = l;
@@ -807,6 +837,8 @@
 status_t vboxsf_create_dir(fs_volume *_volume, fs_vnode *parent, const char *name, int perms)
 {
     vboxsf_volume* volume = _volume->private_volume;
+    PSHFLSTRING path;
+    int rc;
 
     SHFLCREATEPARMS params;
     params.Handle = 0;
@@ -814,8 +846,8 @@
     params.CreateFlags = SHFL_CF_DIRECTORY | SHFL_CF_ACT_CREATE_IF_NEW |
         SHFL_CF_ACT_FAIL_IF_EXISTS | SHFL_CF_ACCESS_READ;
 
-    PSHFLSTRING path = build_path(parent->private_node, name);
-    int rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
+    path = build_path(parent->private_node, name);
+    rc = vboxCallCreate(&g_clientHandle, &volume->map, path, &params);
     free(path);
     /** @todo r=ramshankar: we should perhaps also check rc here and change
      *        Handle initialization from 0 to SHFL_HANDLE_NIL. */
@@ -879,9 +911,10 @@
     PSHFLSTRING target = make_shflstring(path);
     PSHFLSTRING linkpath = build_path(dir->private_node, name);
     SHFLFSOBJINFO stuff;
+    int rc;
     RT_ZERO(stuff);
 
-    int rc = vboxCallSymlink(&g_clientHandle, &volume->map, linkpath, target, &stuff);
+    rc = vboxCallSymlink(&g_clientHandle, &volume->map, linkpath, target, &stuff);
 
     free(target);
     free(linkpath);
Index: src/VBox/Additions/haiku/VBoxMouse/Makefile.kmk
===================================================================
--- src/VBox/Additions/haiku/VBoxMouse/Makefile.kmk	(revision 50860)
+++ src/VBox/Additions/haiku/VBoxMouse/Makefile.kmk	(working copy)
@@ -52,7 +52,7 @@
 # R1 will need gcc2-built input_server add-ons.
 
 PROGRAMS += VBoxMouse
-VBoxMouse_TEMPLATE = VBOXGUESTR3EXE
+VBoxMouse_TEMPLATE = NewVBoxGuestR3Exe
 VBoxMouse_DEFS     = VBOX_WITH_HGCM LOG_TO_BACKDOOR
 VBoxMouse_DEFS    += LOG_ENABLED
 VBoxMouse_INCS     = ../include
@@ -67,7 +67,7 @@
 	/system/servers/input_server
 
 PROGRAMS += VBoxMouseFilter
-VBoxMouseFilter_TEMPLATE = VBOXGUESTR3EXE
+VBoxMouseFilter_TEMPLATE = NewVBoxGuestR3Exe
 VBoxMouseFilter_DEFS     = VBOX_WITH_HGCM LOG_TO_BACKDOOR
 VBoxMouseFilter_DEFS    += LOG_ENABLED
 VBoxMouseFilter_INCS     = ../include
Index: src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.h
===================================================================
--- src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.h	(revision 50860)
+++ src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.h	(working copy)
@@ -88,6 +88,7 @@
         status_t               _Init(BMessage *archive = NULL);
         BBitmap               *fIcon;
 
+        status_t               fInitStatus;
         VBoxClipboardService *fClipboardService;
         VBoxDisplayService *fDisplayService;
 };
Index: src/VBox/Additions/haiku/VBoxTray/VBoxGuestApplication.cpp
===================================================================
--- src/VBox/Additions/haiku/VBoxTray/VBoxGuestApplication.cpp	(revision 50860)
+++ src/VBox/Additions/haiku/VBoxTray/VBoxGuestApplication.cpp	(working copy)
@@ -75,6 +75,7 @@
     status_t err;
 
     err = VBoxGuestDeskbarView::AddToDeskbar();
+    printf("error 0x%08lx\n", err);
     LogFlow(("VBoxGuestDeskbarView::ReadyToRun: AddToDeskbar returned 0x%08lx\n", err));
     exit(0);
 }
Index: src/VBox/Additions/haiku/VBoxTray/Makefile.kmk
===================================================================
--- src/VBox/Additions/haiku/VBoxTray/Makefile.kmk	(revision 50860)
+++ src/VBox/Additions/haiku/VBoxTray/Makefile.kmk	(working copy)
@@ -51,7 +51,7 @@
 # single bin will cause problems loading gcc4 binary from a gcc2-built Deskbar!
 
 PROGRAMS += VBoxTray
-VBoxTray_TEMPLATE = VBOXGUESTR3EXE
+VBoxTray_TEMPLATE = NewVBoxGuestR3Exe
 VBoxTray_DEFS     = VBOX_WITH_HGCM LOG_TO_BACKDOOR
 VBoxTray_DEFS    += LOG_ENABLED
 VBoxTray_INCS     = ../include
Index: src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.cpp
===================================================================
--- src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.cpp	(revision 50860)
+++ src/VBox/Additions/haiku/VBoxTray/VBoxGuestDeskbarView.cpp	(working copy)
@@ -47,6 +47,7 @@
 *   Header Files                                                               *
 *******************************************************************************/
 #include <errno.h>
+#include <locale.h>
 #include <Alert.h>
 #include <Roster.h>
 #include <Debug.h>
@@ -83,7 +84,8 @@
 VBoxGuestDeskbarView::VBoxGuestDeskbarView()
      : BView(BRect(0, 0, 15, 15), VIEWNAME, B_FOLLOW_NONE,
              B_WILL_DRAW | B_NAVIGABLE),
-       fIcon(NULL), fClipboardService(NULL), fDisplayService(NULL)
+       fIcon(NULL), fInitStatus(B_NO_INIT),
+       fClipboardService(NULL), fDisplayService(NULL)
 {
     _Init();
 }
@@ -91,7 +93,8 @@
 
 VBoxGuestDeskbarView::VBoxGuestDeskbarView(BMessage *archive)
      : BView(archive),
-       fIcon(NULL)
+       fIcon(NULL), fInitStatus(B_NO_INIT),
+       fClipboardService(NULL), fDisplayService(NULL)
 {
     archive->PrintToStream();
     _Init(archive);
@@ -106,7 +109,13 @@
         fClipboardService->Disconnect();
         delete fClipboardService;
     }
-    VbglR3Term();
+    if (fDisplayService)
+    {
+        //fDisplayService->Disconnect();
+        delete fDisplayService;
+    }
+    if (fInitStatus == B_OK)
+        VbglR3Term();
 }
 
 
@@ -165,8 +174,10 @@
 void VBoxGuestDeskbarView::DetachedFromWindow()
 {
     BMessage message(B_QUIT_REQUESTED);
-    fClipboardService->MessageReceived(&message);
-    fDisplayService->MessageReceived(&message);
+    if (fClipboardService)
+        fClipboardService->MessageReceived(&message);
+    if (fDisplayService)
+        fDisplayService->MessageReceived(&message);
 }
 
 
@@ -197,7 +208,7 @@
     if (message->what == B_QUIT_REQUESTED)
         RemoveFromDeskbar();
     else
-        BHandler::MessageReceived(message);
+        BView::MessageReceived(message);
 }
 
 
@@ -217,7 +228,9 @@
         return err;
 
     BPath p(&info.ref);
-    return deskbar.AddItem(&info.ref);
+	printf("%s:%s\n", __FUNCTION__, p.Path());
+	int32 id;
+    return deskbar.AddItem(&info.ref, &id);
 }
 
 
@@ -260,14 +273,15 @@
         fIcon = BTranslationUtils::GetBitmap(&mem);
     }
 
-    int rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
+    int rc = RTR3InitDll(RTR3INIT_FLAGS_SUPLIB | RTR3INIT_FLAGS_UNOBTRUSIVE | RTR3INIT_FLAGS_UTF8_ARGV);
     if (RT_SUCCESS(rc))
     {
         rc = VbglR3Init();
         if (RT_SUCCESS(rc))
         {
             fClipboardService = new VBoxClipboardService();
-            fDisplayService = new VBoxDisplayService();
+            //fDisplayService = new VBoxDisplayService();
+            fInitStatus = B_OK;
         }
         else
             LogRel(("VBoxGuestDeskbarView::_init VbglR3Init failed. rc=%d\n", rc));
@@ -278,8 +292,10 @@
 }
 
 
+extern "C" {
 RTDECL(BView*) instantiate_deskbar_item()
 {
+	printf("%s()\n", __FUNCTION__);
     return new VBoxGuestDeskbarView();
 }
-
+} // C
Index: configure
===================================================================
--- configure	(revision 50860)
+++ configure	(working copy)
@@ -417,6 +417,9 @@
       elif [ $cc_maj -eq 4 -a $cc_min -eq 0 -a "$OS" = "darwin" ]; then
         log_success "found version $cc_ver"
       # gcc-4.0 is allowed for Darwin only
+      elif [ $cc_maj -eq 2 -a $cc_min -eq 95 -a "$OS" = "haiku" ]; then
+        log_success "found version $cc_ver (only for building guest additions)"
+      # gcc-2.95 is allowed for Haiku only; required to build guest additions
       elif [ $cc_maj -lt 3 \
              -o \( $cc_maj -eq 3 -a $cc_min -lt 2 \) \
              -o \( $cc_maj -eq 4 -a $cc_min -lt 1 -a "$OS" != "darwin" \) \
@@ -2597,6 +2600,12 @@
   else
     cnf_append "VBOX_WITH_LINUX_ADDITIONS" ""
   fi
+
+  if [ "$OS" = "haiku" ]; then
+    cnf_append "VBOX_WITH_HAIKU_ADDITIONS" "1"
+  else
+    cnf_append "VBOX_WITH_HAIKU_ADDITIONS" ""
+  fi
   echo >> $CNF
 fi
 
Index: include/iprt/cdefs.h
===================================================================
--- include/iprt/cdefs.h	(revision 50860)
+++ include/iprt/cdefs.h	(working copy)
@@ -1142,7 +1142,7 @@
  * @param   type    The return type of the function declaration.
  * @remarks Use sparsely and with care. Don't use this macro on C++ methods.
  */
-#ifdef __GNUC__
+#if defined(__GNUC__) && (__GNUC__ >= 3)
 # define DECL_FORCE_INLINE(type)    __attribute__((__always_inline__)) DECLINLINE(type)
 #elif defined(_MSC_VER)
 # define DECL_FORCE_INLINE(type)    __forceinline type
Index: include/iprt/types.h
===================================================================
--- include/iprt/types.h	(revision 50860)
+++ include/iprt/types.h	(working copy)
@@ -149,6 +149,13 @@
 #  undef false
 #  undef true
 #  undef bool
+/*
+# elif defined(RT_OS_HAIKU)
+#warning HAIKU_B
+#  include <stdbool.h>
+#  include <stddef.h>
+#  include <sys/types.h>
+*/
 # else
 #  include <stddef.h>
 #  include <sys/types.h>
@@ -206,8 +213,13 @@
 #   ifndef __bool_true_false_are_defined
 typedef _Bool bool;
 #   endif
+#  elif defined(RT_OS_HAIKU)
+#   ifndef __bool_true_false_are_defined
+#    include <stdbool.h>
+typedef _Bool bool;
+#   endif
 #  else
-#   if (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU)) && (defined(_STDBOOL_H) || defined(__STDBOOL_H))
+#   if (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU)) && (defined(_STDBOOL_H) || defined(__STDBOOL_H) || defined(__STDBOOL_H__))
 #    undef bool
 #   endif
 typedef _Bool bool;
Index: include/iprt/cpp/autores.h
===================================================================
--- include/iprt/cpp/autores.h	(revision 50860)
+++ include/iprt/cpp/autores.h	(working copy)
@@ -51,7 +51,7 @@
 }
 
 /** Specialisation of RTAutoResNil for RTFILE */
-template <>
+template <RTFILE>
 inline RTFILE RTAutoResNil(void)
 {
     return NIL_RTFILE;
Index: src/libs/kStuff/kStuff/include/k/kDefs.h
===================================================================
--- src/libs/kStuff/kStuff/include/k/kDefs.h	(revision 66)
+++ src/libs/kStuff/kStuff/include/k/kDefs.h	(working copy)
@@ -60,8 +60,10 @@
 #define K_OS_SOLARIS    9
 /** Windows. */
 #define K_OS_WINDOWS    10
+/** Haiku */
+#define K_OS_HAIKU      11
 /** The max K_OS_* value (exclusive). */
-#define K_OS_MAX        11
+#define K_OS_MAX        12
 /** @} */
 
 /** @def K_OS
@@ -82,6 +84,8 @@
 #  define K_OS      K_OS_DRAGONFLY
 # elif defined(__FreeBSD__) /*??*/
 #  define K_OS      K_OS_FREEBSD
+# elif defined(__HAIKU__)
+#  define K_OS      K_OS_HAIKU
 # elif defined(__gnu_linux__)
 #  define K_OS      K_OS_LINUX
 # elif defined(__NetBSD__) /*??*/
--- /dev/null	2014-03-25 22:16:38.824439000 +0100
+++ install-haiku-guest-additions.sh	2014-01-12 16:16:33.085196800 +0100
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+op="out/haiku.x86/${1-release}"
+ap=$op/bin/additions
+
+tad="$(finddir B_USER_NONPACKAGED_ADDONS_DIRECTORY)"
+tbd="$(finddir B_USER_NONPACKAGED_BIN_DIRECTORY)"
+
+mkdir -p "$tad/kernel/generic"
+cp $ap/vboxguest "$tad/kernel/generic/"
+cp $ap/vboxdev "$tad/kernel/drivers/bin/"
+mkdir -p "$tad/kernel/drivers/dev/misc"
+ln -fs ../../bin/vboxdev "$tad/kernel/drivers/dev/misc/"
+mkdir -p "$tad/kernel/file_systems"
+#cp $ap/vboxsf "$tad/kernel/file_systems/"
+
+sync
+
+cp $ap/VBoxControl "$tbd/"
+cp $ap/VBoxService "$tbd/"
+cp $ap/VBoxTray "$tbd/"
_______________________________________________
vbox-dev mailing list
[email protected]
https://www.virtualbox.org/mailman/listinfo/vbox-dev

Reply via email to