]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
2008.12.23-137267
authorMarcelo Vanzin <mvanzin@mvanzin-dev1.eng.vmware.com>
Tue, 23 Dec 2008 22:53:47 +0000 (14:53 -0800)
committerMarcelo Vanzin <mvanzin@mvanzin-dev1.eng.vmware.com>
Tue, 23 Dec 2008 22:53:47 +0000 (14:53 -0800)
180 files changed:
open-vm-tools/AUTHORS [changed mode: 0755->0644]
open-vm-tools/COPYING [changed mode: 0755->0644]
open-vm-tools/ChangeLog [changed mode: 0755->0644]
open-vm-tools/Makefile.am [changed mode: 0755->0644]
open-vm-tools/NEWS [changed mode: 0755->0644]
open-vm-tools/README [changed mode: 0755->0644]
open-vm-tools/configure.ac [changed mode: 0755->0644]
open-vm-tools/guestd/Makefile.am
open-vm-tools/hgfsclient/Makefile.am
open-vm-tools/hgfsmounter/Makefile.am
open-vm-tools/lib/SLPv2Parser/Makefile.am
open-vm-tools/lib/appUtil/Makefile.am
open-vm-tools/lib/auth/Makefile.am
open-vm-tools/lib/backdoor/Makefile.am
open-vm-tools/lib/backdoor/shared/Makefile.am [deleted file]
open-vm-tools/lib/conf/Makefile.am
open-vm-tools/lib/deployPkg/Makefile.am
open-vm-tools/lib/deployPkg/deployPkgLog.h [moved from open-vm-tools/lib/include/deployPkgLog.h with 100% similarity]
open-vm-tools/lib/deployPkg/toolsDeployPkg.h [moved from open-vm-tools/lib/include/toolsDeployPkg.h with 100% similarity]
open-vm-tools/lib/dict/Makefile.am
open-vm-tools/lib/dnd/Makefile.am
open-vm-tools/lib/dynxdr/Makefile.am
open-vm-tools/lib/err/Makefile.am
open-vm-tools/lib/eventManager/Makefile.am
open-vm-tools/lib/file/Makefile.am
open-vm-tools/lib/file/file.c
open-vm-tools/lib/file/fileIOPosix.c
open-vm-tools/lib/file/fileInt.h
open-vm-tools/lib/file/filePosix.c
open-vm-tools/lib/foundryMsg/Makefile.am
open-vm-tools/lib/foundryMsg/vixTranslateErrOpenSource.c
open-vm-tools/lib/ghIntegration/Makefile.am
open-vm-tools/lib/ghIntegration/ghIntegrationX11.c
open-vm-tools/lib/ghIntegrationStub/Makefile.am
open-vm-tools/lib/guestApp/Makefile.am
open-vm-tools/lib/guestInfo/Makefile.am
open-vm-tools/lib/guestRpc/Makefile.am
open-vm-tools/lib/hgfs/Makefile.am
open-vm-tools/lib/hgfs/cpNameUtil.c
open-vm-tools/lib/hgfsBd/Makefile.am
open-vm-tools/lib/hgfsServer/Makefile.am
open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/hgfsServer/hgfsServerInt.h
open-vm-tools/lib/hgfsServer/hgfsServerLinux.c
open-vm-tools/lib/hgfsServerManagerGuest/Makefile.am
open-vm-tools/lib/hgfsServerPolicyGuest/Makefile.am
open-vm-tools/lib/image/Makefile.am
open-vm-tools/lib/impersonate/Makefile.am
open-vm-tools/lib/include/backdoor_def.h
open-vm-tools/lib/include/buildNumber.h
open-vm-tools/lib/include/circList.h [deleted file]
open-vm-tools/lib/include/compat/compat_stdarg.h [changed mode: 0644->0755]
open-vm-tools/lib/include/cpNameUtil.h
open-vm-tools/lib/include/dnd.h
open-vm-tools/lib/include/embed_version.h
open-vm-tools/lib/include/file.h
open-vm-tools/lib/include/loglevel_user.h
open-vm-tools/lib/include/msg.h
open-vm-tools/lib/include/region.h
open-vm-tools/lib/include/socketMgr.h
open-vm-tools/lib/include/str.h
open-vm-tools/lib/include/unityCommon.h
open-vm-tools/lib/include/vix.h
open-vm-tools/lib/include/vm_atomic.h
open-vm-tools/lib/include/vm_basic_types.h
open-vm-tools/lib/include/vm_legal.h
open-vm-tools/lib/include/vm_tools_version.h
open-vm-tools/lib/include/vm_version.h
open-vm-tools/lib/include/vmtools.h [new file with mode: 0644]
open-vm-tools/lib/message/Makefile.am
open-vm-tools/lib/message/shared/Makefile.am [deleted file]
open-vm-tools/lib/misc/Makefile.am
open-vm-tools/lib/misc/base64.c
open-vm-tools/lib/misc/codeset.c
open-vm-tools/lib/misc/dynbuf.c
open-vm-tools/lib/misc/posixPosix.c
open-vm-tools/lib/misc/random.c
open-vm-tools/lib/misc/shared/Makefile.am [deleted file]
open-vm-tools/lib/netUtil/Makefile.am
open-vm-tools/lib/panic/Makefile.am
open-vm-tools/lib/panicDefault/Makefile.am
open-vm-tools/lib/printer/Makefile.am
open-vm-tools/lib/procMgr/Makefile.am
open-vm-tools/lib/raster/Makefile.am
open-vm-tools/lib/region/Makefile.am
open-vm-tools/lib/region/region.c
open-vm-tools/lib/resolution/Makefile.am
open-vm-tools/lib/rpcIn/Makefile.am
open-vm-tools/lib/rpcOut/Makefile.am
open-vm-tools/lib/rpcOut/shared/Makefile.am [deleted file]
open-vm-tools/lib/rpcVmx/Makefile.am
open-vm-tools/lib/socketMgr/Makefile.am
open-vm-tools/lib/string/Makefile.am
open-vm-tools/lib/string/shared/Makefile.am [deleted file]
open-vm-tools/lib/string/str.c
open-vm-tools/lib/stubs/Makefile.am
open-vm-tools/lib/stubs/shared/Makefile.am [deleted file]
open-vm-tools/lib/sync/Makefile.am
open-vm-tools/lib/sync/shared/Makefile.am [deleted file]
open-vm-tools/lib/syncDriver/Makefile.am
open-vm-tools/lib/system/Makefile.am
open-vm-tools/lib/toolsLogger/Makefile.am
open-vm-tools/lib/unicode/Makefile.am
open-vm-tools/lib/unity/Makefile.am
open-vm-tools/lib/unity/unity.c
open-vm-tools/lib/unity/unityPlatformX11.c
open-vm-tools/lib/unity/unityPlatformX11Settings.c
open-vm-tools/lib/unity/unityPlatformX11Window.c
open-vm-tools/lib/unity/unityX11.h
open-vm-tools/lib/unityStub/Makefile.am
open-vm-tools/lib/unityWindowTracker/Makefile.am
open-vm-tools/lib/user/Makefile.am
open-vm-tools/lib/vixTools/Makefile.am
open-vm-tools/lib/vmBackupLib/Makefile.am
open-vm-tools/lib/vmCheck/Makefile.am
open-vm-tools/lib/vmSignal/Makefile.am
open-vm-tools/lib/wiper/Makefile.am
open-vm-tools/libguestlib/Makefile.am
open-vm-tools/libvmtools/COPYING [new file with mode: 0644]
open-vm-tools/libvmtools/Makefile.am [new file with mode: 0644]
open-vm-tools/libvmtools/signalSource.c [new file with mode: 0644]
open-vm-tools/libvmtools/vmtools.c [new file with mode: 0644]
open-vm-tools/libvmtools/vmtoolsConfig.c [new file with mode: 0644]
open-vm-tools/libvmtools/vmtoolsLog.c [new file with mode: 0644]
open-vm-tools/libvmtools/vmtoolslib_version.h [new file with mode: 0644]
open-vm-tools/modules/Makefile.am
open-vm-tools/modules/freebsd/vmblock/vm_basic_types.h
open-vm-tools/modules/freebsd/vmhgfs/backdoor_def.h
open-vm-tools/modules/freebsd/vmhgfs/state.c
open-vm-tools/modules/freebsd/vmhgfs/vm_basic_types.h
open-vm-tools/modules/freebsd/vmmemctl/balloon_def.h
open-vm-tools/modules/freebsd/vmmemctl/vm_basic_types.h
open-vm-tools/modules/freebsd/vmxnet/vm_basic_types.h
open-vm-tools/modules/freebsd/vmxnet/vm_device_version.h
open-vm-tools/modules/linux/dkms.conf
open-vm-tools/modules/linux/pvscsi/scsi_defs.h
open-vm-tools/modules/linux/pvscsi/vm_basic_types.h
open-vm-tools/modules/linux/pvscsi/vm_device_version.h
open-vm-tools/modules/linux/vmblock/include/vm_basic_types.h
open-vm-tools/modules/linux/vmci/vm_atomic.h
open-vm-tools/modules/linux/vmci/vm_basic_types.h
open-vm-tools/modules/linux/vmci/vm_device_version.h
open-vm-tools/modules/linux/vmci/vmciCommonInt.h [new file with mode: 0644]
open-vm-tools/modules/linux/vmci/vmciDatagram.c
open-vm-tools/modules/linux/vmci/vmciDatagram.h
open-vm-tools/modules/linux/vmci/vmciProcess.c
open-vm-tools/modules/linux/vmci/vmciProcess.h
open-vm-tools/modules/linux/vmci/vmciUtil.c
open-vm-tools/modules/linux/vmci/vmci_drv.c
open-vm-tools/modules/linux/vmci/vmci_version.h
open-vm-tools/modules/linux/vmhgfs/backdoor_def.h
open-vm-tools/modules/linux/vmhgfs/page.c
open-vm-tools/modules/linux/vmhgfs/vm_basic_types.h
open-vm-tools/modules/linux/vmmemctl/backdoor_def.h
open-vm-tools/modules/linux/vmmemctl/balloon_def.h
open-vm-tools/modules/linux/vmmemctl/vm_basic_types.h
open-vm-tools/modules/linux/vmxnet/vm_basic_types.h
open-vm-tools/modules/linux/vmxnet/vm_device_version.h
open-vm-tools/modules/linux/vmxnet3/upt1_defs.h
open-vm-tools/modules/linux/vmxnet3/vm_basic_types.h
open-vm-tools/modules/linux/vmxnet3/vm_device_version.h
open-vm-tools/modules/linux/vsock/include/vm_atomic.h
open-vm-tools/modules/linux/vsock/include/vm_basic_asm.h [new file with mode: 0644]
open-vm-tools/modules/linux/vsock/include/vm_basic_asm_x86.h [new file with mode: 0644]
open-vm-tools/modules/linux/vsock/include/vm_basic_asm_x86_64.h [new file with mode: 0644]
open-vm-tools/modules/linux/vsock/include/vm_basic_math.h [new file with mode: 0644]
open-vm-tools/modules/linux/vsock/include/vm_basic_types.h
open-vm-tools/modules/linux/vsock/include/x86cpuid.h [new file with mode: 0644]
open-vm-tools/modules/linux/vsock/linux/af_vsock.c
open-vm-tools/toolbox/Makefile.am
open-vm-tools/toolbox/toolbox-gtk.c
open-vm-tools/toolbox/toolboxScripts.c
open-vm-tools/vmware-user-suid-wrapper/main.c
open-vm-tools/vmware-user/Makefile.am
open-vm-tools/vmware-user/dnd.c
open-vm-tools/vmware-user/modconfig.c
open-vm-tools/vmware-user/notify.c
open-vm-tools/vmware-user/vmware-user.c
open-vm-tools/vmware-user/vmwareuserInt.h
open-vm-tools/xferlogs/Makefile.am

old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4c21edf..b988b58
@@ -1,3 +1,74 @@
+2008-11-23  Marcelo Vanzin  <mvanzin@vmware.com>
+       * Resync with internal trunk (2008.12.19)
+
+       * configure.ac, */Makefile.am: standardize on using libtool archives for
+         the libraries. This also means several makefiles were removed, since
+         there's no need to build two archives of the same library anymore.
+
+       * configure.ac: add logic to detect glib 2.6; this is the minimum version
+         required by the "Core Services" project. Currently it's an optional
+         dependency.
+
+       * configure.ac: disable Unity when user specifies --disable-multimon.
+
+       * configure.ac: actually build the pvscsi modules if the detected kernel
+         version supports it.
+
+       * configure.ac, Makefile.am, lib/guestInfo/Makefile.am,
+         lib/stubs/Makefile.am, libvmtools/*, lib/include/vmtools.h: add the
+         "vmtools" shared library used in the "Core Services" project. The library
+         is a collection of a lot of other libraries used by most VMware Tools
+         programs, and adds some functionality on top of glib that is used in the
+         "Core Services" project. Currently no other components from that project
+         are available as part of open-vm-tools.
+
+       * lib/deployPkg/deployPkgLog.h, lib/deployPkg/toolsDeployPkg.h: moved private
+         headers out of the public header directory.
+
+       * lib/guestRpc/Makefile.am, modules/Makefile.am: fix the makefiles so that
+         it's possible to build open-vm-tools from a directory different from the
+         source dir.
+
+       * lib/hgfsServer/hgfsServer.c: changes to support aliases on Mac OS hosts.
+
+       * lib/hgfsServer/hgfsServerLinux.c: changes to map Windows attributes to
+         Mac OS FileInfo.
+
+       * lib/include/circList.h: removed unused file.
+
+       * lib/include/unityCommon.h, lib/unity/unity.c: changes to add documentation
+         to various application RPCs used in Tools.
+
+       * lib/misc/posixPosix.c, toolbox/toolboxScripts.c: fix include path for
+         syslimits.h on FreeBSD.
+
+       * lib/unity/unityPlatformX11.c: better detection of the guest's work area
+         boundaries; fixes a problem when dragging a Window in Unity mode with
+         the host's task bar on the left/right of screen would result in weird
+         behavior.
+
+       * lib/unity/unityPlatformX11Settings.c, lib/unity/unityPlatformX11Window.c,
+         lib/unity/unityX11.h: preserve the _NET_WM_DESKTOP setting when hiding
+         windows; this fixes a problem where hiding a panel and later restoring it
+         would result in the wrong _NET_WM_DESKTOP property being set for the panel,
+         causing it to only display on the first virtual desktop.
+
+       * modules/linux/vmci/*: minor changes related to internal development of the
+         Mac OS drivers.
+
+       * modules/linux/vmhgfs/page.c: fix HGFS driver for kernel 2.6.28.
+
+       * modules/linux/vsock/linux/af_vsock.c: added code to gather some performance
+         statistics for the driver.
+
+       * toolbox/toolbox-gtk.c: a few fixes to the help functionality.
+
+       * vmware-user/vmware-user.c, vmware-user-suid-wrapper/main.c: change the
+         "blockFd" argument to have an extra dash so it follows the convention of
+         common command line parsing libraries.
+
+       * Other bug fixes and changes in shared code that don't affect open-vm-tools.
+
 2008-11-18  Marcelo Vanzin  <mvanzin@vmware.com>
        * Resync with internal trunk (2008.11.14)
 
old mode 100755 (executable)
new mode 100644 (file)
index 65ba116..85dc196
@@ -39,6 +39,9 @@ if BUILD_HGFSMOUNTER
 endif
 SUBDIRS += checkvm
 SUBDIRS += libguestlib
+if ENABLE_CORE_SERVICES
+   SUBDIRS += libvmtools
+endif
 SUBDIRS += xferlogs
 SUBDIRS += scripts
 SUBDIRS += toolbox
old mode 100755 (executable)
new mode 100644 (file)
index b63ff97..e3b4242
@@ -1,6 +1,21 @@
+open-vm-tools 2009.12.23 changes:
+       * Lots of makefile cleanup with the switch to using libtool archives.
+
+       * Automatically disable Unity if multimon support is disabled.
+
+       * Actually build the pvscsi modules.
+
+       * First bits of the "Core Service" project are starting to show up; the
+       base "vmtools" library was added to the package. It currently is mostly
+       a collection of the existing libraries already shipped with open-vm-tools,
+       plus some extra functionality build on top of glib. Currently no other
+       code in open-vm-tools uses it, so it's optional.
+
+       * The HGFS driver was fixed for the Linux 2.6.28 kernel.
+
 open-vm-tools 2009.11.18 changes:
        * The pvscsi Linux kernel module has been added (for kernels >= 2.6.8).
-     It provides access to VMware's new paravirtualized SCSI device.
+       It provides access to VMware's new paravirtualized SCSI device.
 
        * The HGFS driver and user-level code has seen a lot of refactoring to
        enable more consistent name escaping. The FreeBSD driver now supports
@@ -9,8 +24,8 @@ open-vm-tools 2009.11.18 changes:
        * The Linux module makefiles now support exporting symbol version files,
        allowing modules with dependencies (such as vsock, which depends on vmci)
        to correctly build and load on Linux >= 2.6.26 with CONFIG_MODVERSIONS.
-   
-   * Rudimentary support for dkms.
+
+       * Rudimentary support for dkms.
 
        * Assortment of bug fixes.
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 05f27c6..820407c
@@ -22,6 +22,8 @@
 # In addition to the usual environment variables and command line
 # arguments that a configure script usually takes (CFLAGS, LDFLAGS,
 # etc.), this script also accepts:
+# $CUSTOM_GLIB2_CPPFLAGS - compile-time flags to find Glib headers.
+# $CUSTOM_GLIB2_LIBS - link-time flags to find Glib libraries.
 # $CUSTOM_GTK_CPPFLAGS - compile-time flags to find Gtk headers.
 # $CUSTOM_GTK_LIBS - link-time flags to find and link the Gtk libraries.
 # $CUSTOM_PROCPS_LIBS - link-time flags to find and link the procps library.
@@ -37,7 +39,7 @@
 
 AC_INIT(
    [open-vm-tools],
-   [2008.11.18-130226],
+   [8.0.0-137267],
    [open-vm-tools-devel@lists.sourceforge.net])
 
 # In order to make this configure script auto-detect situations where
@@ -237,6 +239,37 @@ fi
 
 AC_PATH_XTRA
 
+#
+# Check for glib 2.6.0 or greater.
+# XXX: glib < 2.6 should become an error once the code that needs it is the default.
+#
+if test "$HAVE_PKG_CONFIG" = "yes"; then
+   AC_MSG_CHECKING([for glib >= 2.6.0 (via pkg-config)])
+   if pkg-config --exists 'glib-2.0 >= 2.6.0'; then
+      GLIB2_CPPFLAGS="`pkg-config --cflags glib-2.0`"
+      GLIB2_LIBS="`pkg-config --libs glib-2.0`"
+      have_glib_26="yes"
+      AC_MSG_RESULT([yes])
+  else
+      have_glib_26="no"
+      AC_MSG_RESULT([no])
+  fi
+else
+   # g_key_file_new (and related) functions were added in glib 2.6. That's the
+   # minimum version supported by the Core Services code.
+   AC_CHECK_LIB(
+      [glib-2.0],
+      [g_key_file_new],
+      [have_glib_26="yes"],
+      [AC_MSG_WARN([glib 2 is older than 2.6.0, some features will be disabled.])],
+      [$CUSTOM_GLIB2_LIBS])
+   if test "$have_glib_26" = "yes"; then
+      GLIB2_CPPFLAGS="$CUSTOM_GLIB2_CPPFLAGS"
+      GLIB2_LIBS="$CUSTOM_GLIB2_LIBS"
+   fi
+fi
+
+
 # If the user explicitly disables X11, then don't try to detect the X-related libraries
 if test "$have_x" = "disabled"; then
    enable_multimon="no"
@@ -272,6 +305,11 @@ else
         [AC_MSG_ERROR(
            [libXinerama not found. Please configure without multimon (using --disable-multimon), configure without X11 (using --without-x), or install the libXinerama devel package(s).])],
         [$COMMON_XLIBS])
+   else
+      if test "$enable_unity" != "no"; then
+         AC_MSG_WARN([Disabling Unity due to --disable-multimon.])
+         enable_unity="no"
+      fi
    fi
 
    AC_CHECK_LIB(
@@ -858,8 +896,11 @@ done
 CPPFLAGS="$CPPFLAGS -DVMX86_TOOLS"
 CPPFLAGS="$CPPFLAGS -DNO_CORE_ICU"
 
+BUILDDIR="`pwd`"
+
 INCLUDE_DIR="`cd $srcdir; pwd`/lib/include"
-CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR"
+BLD_INCLUDE_DIR="$BUILDDIR/lib/include"
+CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR -I$BLD_INCLUDE_DIR"
 
 ### OS/arch-specific flags / actions
 
@@ -891,6 +932,9 @@ if test "$os" = "linux"; then
    if test "$osVersion" -ge 206006; then
       MODULES="$MODULES vmsync"
    fi
+   if test "$osVersion" -ge 206008; then
+      MODULES="$MODULES pvscsi"
+   fi
 fi
 
 if test "$os" = "freebsd"; then
@@ -940,6 +984,7 @@ AM_CONDITIONAL(WITH_KERNEL_MODULES, test "$with_kernel_modules" = "yes")
 AM_CONDITIONAL(PAMD, test -d /etc/pam.d)
 AM_CONDITIONAL(ENABLE_UNITY, test "$enable_unity" = "yes")
 AM_CONDITIONAL(WITH_ROOT_PRIVILEGES, test "$with_root_privileges" = "yes")
+AM_CONDITIONAL(ENABLE_CORE_SERVICES, test "$have_glib_26" = "yes")
 
 ### Feature-specific flags / actions
 # Combine where possible
@@ -978,6 +1023,11 @@ if test "$HAVE_WCHAR_H" = "yes"; then
    LIB_STRING_CPPFLAGS="$LIB_STRING_CPPFLAGS -DGLIBC_VERSION_22"
 fi
 
+### Core Services definitions.
+
+VMTOOLS_LIBS="$BUILDDIR/libvmtools/libvmtools.la"
+VMTOOLS_CPPFLAGS="-DVMTOOLS_USE_GLIB $GLIB2_CPPFLAGS"
+
 ### General substs
 
 AC_SUBST([TARGET_OS])
@@ -986,6 +1036,8 @@ AC_SUBST([MODULES_OS])
 AC_SUBST([MODULES_DIR])
 AC_SUBST([MODULES])
 AC_SUBST([COMMON_XLIBS])
+AC_SUBST([GLIB2_CPPFLAGS])
+AC_SUBST([GLIB2_LIBS])
 AC_SUBST([GTK_CPPFLAGS])
 AC_SUBST([GTK_LIBS])
 AC_SUBST([DNET_CPPFLAGS])
@@ -998,6 +1050,8 @@ AC_SUBST([URIPARSER_CPPFLAGS])
 AC_SUBST([URIPARSER_LIBS])
 AC_SUBST([LIBPNG_CPPFLAGS])
 AC_SUBST([LIBPNG_LIBS])
+AC_SUBST([VMTOOLS_CPPFLAGS])
+AC_SUBST([VMTOOLS_LIBS])
 AC_SUBST([ZLIB_CPPFLAGS])
 AC_SUBST([ZLIB_LIBS])
 
@@ -1012,6 +1066,9 @@ AC_SUBST([LIB_PROC_MGR_CPPFLAGS])
 AC_SUBST([LIB_STRING_CPPFLAGS])
 AC_SUBST([LIB_USER_CPPFLAGS])
 
+LIBVMTOOLS_LIBADD="$GUESTD_LDADD"
+AC_SUBST([LIBVMTOOLS_LIBADD])
+
 ### Program substs
 
 AC_SUBST([GUESTD_LDADD])
@@ -1028,7 +1085,6 @@ AC_CONFIG_FILES([                      \
    lib/appUtil/Makefile                \
    lib/auth/Makefile                   \
    lib/backdoor/Makefile               \
-   lib/backdoor/shared/Makefile        \
    lib/conf/Makefile                   \
    lib/dict/Makefile                   \
    lib/dnd/Makefile                    \
@@ -1051,9 +1107,7 @@ AC_CONFIG_FILES([                      \
    lib/image/Makefile                  \
    lib/impersonate/Makefile            \
    lib/message/Makefile                \
-   lib/message/shared/Makefile         \
    lib/misc/Makefile                   \
-   lib/misc/shared/Makefile            \
    lib/netUtil/Makefile                \
    lib/panic/Makefile                  \
    lib/panicDefault/Makefile           \
@@ -1064,16 +1118,12 @@ AC_CONFIG_FILES([                      \
    lib/resolution/Makefile             \
    lib/rpcIn/Makefile                  \
    lib/rpcOut/Makefile                 \
-   lib/rpcOut/shared/Makefile          \
    lib/rpcVmx/Makefile                 \
    lib/SLPv2Parser/Makefile            \
    lib/socketMgr/Makefile              \
    lib/string/Makefile                 \
-   lib/string/shared/Makefile          \
    lib/stubs/Makefile                  \
-   lib/stubs/shared/Makefile           \
    lib/sync/Makefile                   \
-   lib/sync/shared/Makefile            \
    lib/syncDriver/Makefile             \
    lib/system/Makefile                 \
    lib/toolsLogger/Makefile            \
@@ -1095,6 +1145,7 @@ AC_CONFIG_FILES([                      \
    hgfsmounter/Makefile                \
    checkvm/Makefile                    \
    libguestlib/Makefile                \
+   libvmtools/Makefile                 \
    xferlogs/Makefile                   \
    modules/Makefile                    \
    scripts/Makefile                   \
index aa52ff6f9c02cc3bd2970a3e497bdf21197ed416..5cd0780375e026b704e1d4732958c40f5062d2db 100644 (file)
@@ -21,54 +21,54 @@ pamdir = $(PAM_PREFIX)/pam.d
 AM_CFLAGS = -I$(top_builddir)/include
 
 vmware_guestd_LDADD =
-vmware_guestd_LDADD += ../lib/backdoor/libBackdoor.a
-vmware_guestd_LDADD += ../lib/conf/libConf.a
-vmware_guestd_LDADD += ../lib/dnd/libDnd.a
-vmware_guestd_LDADD += ../lib/err/libErr.a
-vmware_guestd_LDADD += ../lib/eventManager/libEventManager.a
-vmware_guestd_LDADD += ../lib/file/libFile.a
-vmware_guestd_LDADD += ../lib/guestApp/libGuestApp.a
-vmware_guestd_LDADD += ../lib/guestInfo/libGuestInfo.a
-vmware_guestd_LDADD += ../lib/guestRpc/libGuestRpc.a
-vmware_guestd_LDADD += ../lib/hgfsServer/libHgfsServer.a
-vmware_guestd_LDADD += ../lib/hgfsServerManagerGuest/libHgfsServerManagerGuest.a
-vmware_guestd_LDADD += ../lib/hgfsServerPolicyGuest/libHgfsServerPolicyGuest.a
-vmware_guestd_LDADD += ../lib/deployPkg/libDeployPkg.a
-vmware_guestd_LDADD += ../lib/impersonate/libImpersonate.a
-vmware_guestd_LDADD += ../lib/netUtil/libNetUtil.a
-vmware_guestd_LDADD += ../lib/printer/libPrinter.a
-vmware_guestd_LDADD += ../lib/procMgr/libProcMgr.a
-vmware_guestd_LDADD += ../lib/rpcIn/libRpcIn.a
-vmware_guestd_LDADD += ../lib/rpcOut/libRpcOut.a
-vmware_guestd_LDADD += ../lib/rpcVmx/libRpcVmx.a
-vmware_guestd_LDADD += ../lib/SLPv2Parser/libSLPv2Parser.a
-vmware_guestd_LDADD += ../lib/socketMgr/libSocketMgr.a
-vmware_guestd_LDADD += ../lib/string/libString.a
-vmware_guestd_LDADD += ../lib/sync/libSync.a
-vmware_guestd_LDADD += ../lib/syncDriver/libSyncDriver.a
-vmware_guestd_LDADD += ../lib/system/libSystem.a
-vmware_guestd_LDADD += ../lib/user/libUser.a
-vmware_guestd_LDADD += ../lib/vixTools/libVixTools.a
-vmware_guestd_LDADD += ../lib/vmBackupLib/libVmBackupLib.a
-vmware_guestd_LDADD += ../lib/vmCheck/libVmCheck.a
-vmware_guestd_LDADD += ../lib/vmSignal/libVmSignal.a
-vmware_guestd_LDADD += ../lib/wiper/libWiper.a
+vmware_guestd_LDADD += ../lib/backdoor/libBackdoor.la
+vmware_guestd_LDADD += ../lib/conf/libConf.la
+vmware_guestd_LDADD += ../lib/dnd/libDnd.la
+vmware_guestd_LDADD += ../lib/err/libErr.la
+vmware_guestd_LDADD += ../lib/eventManager/libEventManager.la
+vmware_guestd_LDADD += ../lib/file/libFile.la
+vmware_guestd_LDADD += ../lib/guestApp/libGuestApp.la
+vmware_guestd_LDADD += ../lib/guestInfo/libGuestInfo.la
+vmware_guestd_LDADD += ../lib/guestRpc/libGuestRpc.la
+vmware_guestd_LDADD += ../lib/hgfsServer/libHgfsServer.la
+vmware_guestd_LDADD += ../lib/hgfsServerManagerGuest/libHgfsServerManagerGuest.la
+vmware_guestd_LDADD += ../lib/hgfsServerPolicyGuest/libHgfsServerPolicyGuest.la
+vmware_guestd_LDADD += ../lib/deployPkg/libDeployPkg.la
+vmware_guestd_LDADD += ../lib/impersonate/libImpersonate.la
+vmware_guestd_LDADD += ../lib/netUtil/libNetUtil.la
+vmware_guestd_LDADD += ../lib/printer/libPrinter.la
+vmware_guestd_LDADD += ../lib/procMgr/libProcMgr.la
+vmware_guestd_LDADD += ../lib/rpcIn/libRpcIn.la
+vmware_guestd_LDADD += ../lib/rpcOut/libRpcOut.la
+vmware_guestd_LDADD += ../lib/rpcVmx/libRpcVmx.la
+vmware_guestd_LDADD += ../lib/SLPv2Parser/libSLPv2Parser.la
+vmware_guestd_LDADD += ../lib/socketMgr/libSocketMgr.la
+vmware_guestd_LDADD += ../lib/string/libString.la
+vmware_guestd_LDADD += ../lib/sync/libSync.la
+vmware_guestd_LDADD += ../lib/syncDriver/libSyncDriver.la
+vmware_guestd_LDADD += ../lib/system/libSystem.la
+vmware_guestd_LDADD += ../lib/user/libUser.la
+vmware_guestd_LDADD += ../lib/vixTools/libVixTools.la
+vmware_guestd_LDADD += ../lib/vmBackupLib/libVmBackupLib.la
+vmware_guestd_LDADD += ../lib/vmCheck/libVmCheck.la
+vmware_guestd_LDADD += ../lib/vmSignal/libVmSignal.la
+vmware_guestd_LDADD += ../lib/wiper/libWiper.la
 # In the absence of the linker options --start-group and --end-group (which
 # can't be put in LDADD), we need to bring the following libraries out of the
 # alphabetical order so their symbols are properly resolved.
-vmware_guestd_LDADD += ../lib/dict/libDict.a
-vmware_guestd_LDADD += ../lib/dynxdr/libDynxdr.a
-vmware_guestd_LDADD += ../lib/hgfs/libHgfs.a
-vmware_guestd_LDADD += ../lib/message/libMessage.a
-vmware_guestd_LDADD += ../lib/unicode/libUnicode.a
-vmware_guestd_LDADD += ../lib/misc/libMisc.a
-vmware_guestd_LDADD += ../lib/foundryMsg/libFoundryMsg.a
-vmware_guestd_LDADD += ../lib/auth/libAuth.a
-vmware_guestd_LDADD += ../lib/panicDefault/libPanicDefault.a
-vmware_guestd_LDADD += ../lib/panic/libPanic.a
-vmware_guestd_LDADD += ../lib/stubs/libStubs.a
+vmware_guestd_LDADD += ../lib/dict/libDict.la
+vmware_guestd_LDADD += ../lib/dynxdr/libDynxdr.la
+vmware_guestd_LDADD += ../lib/hgfs/libHgfs.la
+vmware_guestd_LDADD += ../lib/message/libMessage.la
+vmware_guestd_LDADD += ../lib/unicode/libUnicode.la
+vmware_guestd_LDADD += ../lib/misc/libMisc.la
+vmware_guestd_LDADD += ../lib/foundryMsg/libFoundryMsg.la
+vmware_guestd_LDADD += ../lib/auth/libAuth.la
+vmware_guestd_LDADD += ../lib/panicDefault/libPanicDefault.la
+vmware_guestd_LDADD += ../lib/panic/libPanic.la
+vmware_guestd_LDADD += ../lib/stubs/libStubs.la
 if SOLARIS
-   HGFS_BD = ../lib/hgfsBd/libHgfsBd.a
+   HGFS_BD = ../lib/hgfsBd/libHgfsBd.la
 else
    HGFS_BD =
 endif
index 2d353ea5cc8338cf3c7c227dc0d66851d1786114..f5b867ae44fb4e27c9fd55a5d4e90e0f2bd630f9 100644 (file)
 bin_PROGRAMS = vmware-hgfsclient
 
 vmware_hgfsclient_LDADD =
-vmware_hgfsclient_LDADD += ../lib/conf/libConf.a
-vmware_hgfsclient_LDADD += ../lib/guestApp/libGuestApp.a
-vmware_hgfsclient_LDADD += ../lib/hgfs/libHgfs.a
-vmware_hgfsclient_LDADD += ../lib/hgfsBd/libHgfsBd.a
-vmware_hgfsclient_LDADD += ../lib/rpcOut/libRpcOut.a
-vmware_hgfsclient_LDADD += ../lib/string/libString.a
-vmware_hgfsclient_LDADD += ../lib/toolsLogger/libToolsLogger.a
-vmware_hgfsclient_LDADD += ../lib/vmCheck/libVmCheck.a
-vmware_hgfsclient_LDADD += ../lib/vmSignal/libVmSignal.a
+vmware_hgfsclient_LDADD += ../lib/conf/libConf.la
+vmware_hgfsclient_LDADD += ../lib/guestApp/libGuestApp.la
+vmware_hgfsclient_LDADD += ../lib/hgfs/libHgfs.la
+vmware_hgfsclient_LDADD += ../lib/hgfsBd/libHgfsBd.la
+vmware_hgfsclient_LDADD += ../lib/rpcOut/libRpcOut.la
+vmware_hgfsclient_LDADD += ../lib/string/libString.la
+vmware_hgfsclient_LDADD += ../lib/toolsLogger/libToolsLogger.la
+vmware_hgfsclient_LDADD += ../lib/vmCheck/libVmCheck.la
+vmware_hgfsclient_LDADD += ../lib/vmSignal/libVmSignal.la
 # In the absence of the linker options --start-group and --end-group (which can't
 # be put in LDADD), we need to bring the following libraries out of the alphebetical
 # order so their symbols are properly resolved.
-vmware_hgfsclient_LDADD += ../lib/backdoor/libBackdoor.a
-vmware_hgfsclient_LDADD += ../lib/dict/libDict.a
-vmware_hgfsclient_LDADD += ../lib/err/libErr.a
-vmware_hgfsclient_LDADD += ../lib/file/libFile.a
-vmware_hgfsclient_LDADD += ../lib/message/libMessage.a
-vmware_hgfsclient_LDADD += ../lib/rpcVmx/libRpcVmx.a
-vmware_hgfsclient_LDADD += ../lib/unicode/libUnicode.a
-vmware_hgfsclient_LDADD += ../lib/sync/libSync.a
-vmware_hgfsclient_LDADD += ../lib/misc/libMisc.a
-vmware_hgfsclient_LDADD += ../lib/stubs/libStubs.a
+vmware_hgfsclient_LDADD += ../lib/backdoor/libBackdoor.la
+vmware_hgfsclient_LDADD += ../lib/dict/libDict.la
+vmware_hgfsclient_LDADD += ../lib/err/libErr.la
+vmware_hgfsclient_LDADD += ../lib/file/libFile.la
+vmware_hgfsclient_LDADD += ../lib/message/libMessage.la
+vmware_hgfsclient_LDADD += ../lib/rpcVmx/libRpcVmx.la
+vmware_hgfsclient_LDADD += ../lib/unicode/libUnicode.la
+vmware_hgfsclient_LDADD += ../lib/sync/libSync.la
+vmware_hgfsclient_LDADD += ../lib/misc/libMisc.la
+vmware_hgfsclient_LDADD += ../lib/stubs/libStubs.la
 
 vmware_hgfsclient_SOURCES =
 vmware_hgfsclient_SOURCES += hgfsclient.c
index 5416f94fa63c981212e11bfad60085880fd0ff58..91cad0cb5c68921dd47cd5bcc4aa51472aeb783c 100644 (file)
 sbin_PROGRAMS = mount.vmhgfs
 
 mount_vmhgfs_LDADD =
-mount_vmhgfs_LDADD += ../lib/misc/libMisc.a
-mount_vmhgfs_LDADD += ../lib/string/libString.a
-mount_vmhgfs_LDADD += ../lib/panicDefault/libPanicDefault.a
-mount_vmhgfs_LDADD += ../lib/panic/libPanic.a
-mount_vmhgfs_LDADD += ../lib/stubs/libStubs.a
+mount_vmhgfs_LDADD += ../lib/misc/libMisc.la
+mount_vmhgfs_LDADD += ../lib/string/libString.la
+mount_vmhgfs_LDADD += ../lib/panicDefault/libPanicDefault.la
+mount_vmhgfs_LDADD += ../lib/panic/libPanic.la
+mount_vmhgfs_LDADD += ../lib/stubs/libStubs.la
 
 mount_vmhgfs_SOURCES =
 mount_vmhgfs_SOURCES += hgfsmounter.c
index 96882a11545597f162fbf78fe96b049c67a6cb02..84f30ef7d6602e851027bbc7ec0321aec1dbdfc8 100644 (file)
@@ -15,9 +15,9 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libSLPv2Parser.a
+noinst_LTLIBRARIES = libSLPv2Parser.la
 
-libSLPv2Parser_a_SOURCES =
-libSLPv2Parser_a_SOURCES += SLPv2MsgParser.c
-libSLPv2Parser_a_SOURCES += SLPv2Match.c
-libSLPv2Parser_a_SOURCES += SLPv2MsgAssembler.c
+libSLPv2Parser_la_SOURCES =
+libSLPv2Parser_la_SOURCES += SLPv2MsgParser.c
+libSLPv2Parser_la_SOURCES += SLPv2Match.c
+libSLPv2Parser_la_SOURCES += SLPv2MsgAssembler.c
index 9c43f1d49ec69413ba3d72505d1bd25e80258923..8a8588171fb0356919f47d1e580427e37f452eeb 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libAppUtil.a
+noinst_LTLIBRARIES = libAppUtil.la
 
-libAppUtil_a_SOURCES =
-libAppUtil_a_SOURCES += appUtil.c
-libAppUtil_a_SOURCES += appUtilX11.c
+libAppUtil_la_SOURCES =
+libAppUtil_la_SOURCES += appUtil.c
+libAppUtil_la_SOURCES += appUtilX11.c
 
 AM_CFLAGS = @GTK_CPPFLAGS@
index fc87e7786c97f46dd87e1da8516d36561c0a8e26..d52e6bb281393590a7e316812aeca374b322a6fc 100644 (file)
@@ -15,9 +15,9 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libAuth.a
+noinst_LTLIBRARIES = libAuth.la
 
-libAuth_a_SOURCES =
-libAuth_a_SOURCES += authPosix.c
+libAuth_la_SOURCES =
+libAuth_la_SOURCES += authPosix.c
 
 AM_CFLAGS = @LIB_AUTH_CPPFLAGS@
index 2cd9a913fac72fb0abe7ab7d233f745c85079c67..2201074a8e302477b97ef2d5818990bcb24bf7f5 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libBackdoor.a
+noinst_LTLIBRARIES = libBackdoor.la
 
-libBackdoor_a_SOURCES =
-libBackdoor_a_SOURCES += backdoor.c
+libBackdoor_la_SOURCES =
+libBackdoor_la_SOURCES += backdoor.c
 if THIRTY_TWO_BIT_USERSPACE
-   libBackdoor_a_SOURCES += backdoorGcc32.c
+   libBackdoor_la_SOURCES += backdoorGcc32.c
 else
-   libBackdoor_a_SOURCES += backdoorGcc64.c
+   libBackdoor_la_SOURCES += backdoorGcc64.c
 endif
 
-SUBDIRS =
-SUBDIRS += shared
diff --git a/open-vm-tools/lib/backdoor/shared/Makefile.am b/open-vm-tools/lib/backdoor/shared/Makefile.am
deleted file mode 100644 (file)
index 48461da..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-################################################################################
-### Copyright 2007 VMware, Inc.  All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-################################################################################
-
-noinst_LTLIBRARIES = libBackdoor.la
-
-libBackdoor_la_SOURCES =
-libBackdoor_la_SOURCES += ../backdoor.c
-if THIRTY_TWO_BIT_USERSPACE
-   libBackdoor_la_SOURCES += ../backdoorGcc32.c
-else
-   libBackdoor_la_SOURCES += ../backdoorGcc64.c
-endif
index 7c79d363135b6d573a6558c8789f5559e6ad20f6..c673b50dd840e568263e749e13eddf6a3435d1e3 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libConf.a
+noinst_LTLIBRARIES = libConf.la
 
-libConf_a_SOURCES =
-libConf_a_SOURCES += conf.c
+libConf_la_SOURCES =
+libConf_la_SOURCES += conf.c
index 1bd52e18106b4e5a46e9e44da68a7b7a44ba2810..1f0822299832098ebd5d931ac357bd039956a908 100644 (file)
@@ -15,9 +15,9 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libDeployPkg.a
+noinst_LTLIBRARIES = libDeployPkg.la
 
-libDeployPkg_a_SOURCES =
-libDeployPkg_a_SOURCES += deployPkgLog.c
-libDeployPkg_a_SOURCES += deployPkg.c
-libDeployPkg_a_SOURCES += runDeployPkgPosix.c
+libDeployPkg_la_SOURCES =
+libDeployPkg_la_SOURCES += deployPkgLog.c
+libDeployPkg_la_SOURCES += deployPkg.c
+libDeployPkg_la_SOURCES += runDeployPkgPosix.c
index c7062a1d843148db33f7bb067ccb059b9c5bb521..3c41dabea41a6e403763f1a81938dfad182b6092 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libDict.a
+noinst_LTLIBRARIES = libDict.la
 
-libDict_a_SOURCES =
-libDict_a_SOURCES += dictll.c
+libDict_la_SOURCES =
+libDict_la_SOURCES += dictll.c
index be5313fdd6fd828c3c65d8c38afc402afe742edd..d8fab87dbf9b8d95d330c9512607ef6a7ccb00e2 100644 (file)
@@ -15,8 +15,8 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libDnd.a
+noinst_LTLIBRARIES = libDnd.la
 
-libDnd_a_SOURCES =
-libDnd_a_SOURCES += dndCommon.c
-libDnd_a_SOURCES += dndLinux.c
+libDnd_la_SOURCES =
+libDnd_la_SOURCES += dndCommon.c
+libDnd_la_SOURCES += dndLinux.c
index bf9c37de8aebf73f7cb94ad754d39f112b2c58a9..7e739ba374413b47d702b0d9aa9a87dc658fae47 100644 (file)
@@ -15,9 +15,9 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libDynxdr.a
+noinst_LTLIBRARIES = libDynxdr.la
 
-libDynxdr_a_SOURCES = 
-libDynxdr_a_SOURCES += dynxdr.c
-libDynxdr_a_SOURCES += xdrutil.c
+libDynxdr_la_SOURCES = 
+libDynxdr_la_SOURCES += dynxdr.c
+libDynxdr_la_SOURCES += xdrutil.c
 
index 64d690293964be4bee4eee1920930583158b6b89..7f845a473e761182da52320b5e7d1a476448c1ce 100644 (file)
@@ -15,8 +15,8 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libErr.a
+noinst_LTLIBRARIES = libErr.la
 
-libErr_a_SOURCES =
-libErr_a_SOURCES += err.c
-libErr_a_SOURCES += errPosix.c
+libErr_la_SOURCES =
+libErr_la_SOURCES += err.c
+libErr_la_SOURCES += errPosix.c
index 9901ad1b1116aebc6078596d2a289fb5d8cebd49..12352c923c6f94c7eab1837f69df324ef1fcf733 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libEventManager.a
+noinst_LTLIBRARIES = libEventManager.la
 
-libEventManager_a_SOURCES =
-libEventManager_a_SOURCES += eventManager.c
+libEventManager_la_SOURCES =
+libEventManager_la_SOURCES += eventManager.c
index 45743c761851c8b4ed03dd30f5ef204e24c1158a..baee5cfb4d01b65dc727b5609ba8eded7e024f2d 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libFile.a
+noinst_LTLIBRARIES = libFile.la
 
-libFile_a_SOURCES = 
-libFile_a_SOURCES += file.c
-libFile_a_SOURCES += filePosix.c
-libFile_a_SOURCES += fileIO.c
-libFile_a_SOURCES += fileIOPosix.c
-libFile_a_SOURCES += fileLockPrimitive.c
-libFile_a_SOURCES += fileLockPosix.c
+libFile_la_SOURCES = 
+libFile_la_SOURCES += file.c
+libFile_la_SOURCES += filePosix.c
+libFile_la_SOURCES += fileIO.c
+libFile_la_SOURCES += fileIOPosix.c
+libFile_la_SOURCES += fileLockPrimitive.c
+libFile_la_SOURCES += fileLockPosix.c
 
 AM_CFLAGS = @LIB_FILE_CPPFLAGS@
index 7d2bd85886a5a950c138f969945ee9f4da665131..f20cfae5e7484b3aa7effed177cc3b81ab72c6c8 100644 (file)
@@ -850,6 +850,45 @@ File_SplitName(ConstUnicode pathName,  // IN:
 }
 
 
+/*
+ *---------------------------------------------------------------------------
+ *
+ * File_PathJoin --
+ *
+ *      Join the dirName and baseName together to create a (full) path but
+ *      don't add a DIRSEPS unless necessary.
+ *
+ *      File_PathJoin("a", "b")  -> "a/b"
+ *      File_PathJoin("a/", "b") -> "a/b"
+ *
+ * Results: 
+ *      The constructed path which must be freed by the caller.
+ *
+ * Side effects: 
+ *      None
+ *
+ *---------------------------------------------------------------------------
+ */
+
+Unicode
+File_PathJoin(ConstUnicode dirName,   // IN:
+              ConstUnicode baseName)  // IN:
+{
+   Unicode result;
+
+   ASSERT(dirName);
+   ASSERT(baseName);
+
+   if (Unicode_EndsWith(dirName, DIRSEPS)) {
+      result = Unicode_Append(dirName, baseName);
+   } else {
+      result = Unicode_Join(dirName, DIRSEPS, baseName, NULL);
+   }
+
+   return result;
+}
+
+
 /*
  *---------------------------------------------------------------------------
  *
@@ -2093,16 +2132,18 @@ File_ExpandAndCheckDir(const char *dirName)
 
    if (dirName != NULL) {
       edirName = Util_ExpandString(dirName);
-      if (edirName != NULL) {
-        if (File_IsWritableDir(edirName) == TRUE) {
-            if (edirName[strlen(edirName) - 1] == DIRSEPC) {
-               edirName[strlen(edirName) - 1] = '\0';
-            }
-           return edirName;
-        }
-        free(edirName);
+
+      if ((edirName != NULL) && FileIsWritableDir(edirName)) {
+         size_t len = strlen(edirName) - 1;
+
+         if (edirName[len] == DIRSEPC) {
+            edirName[len] = '\0';
+         }
+
+        return edirName;
       }
    }
+
    return NULL;
 }
 
index 486cb299aa3da6922ca107b8c46346d9194089fb..abcea4a1b41e78ddaecf052ce906359adeba6ae7 100644 (file)
@@ -1138,6 +1138,9 @@ FileIO_Read(FileIODescriptor *fd,       // IN
             continue;
          }
          fret = FileIOErrno2Result(errno);
+         if (FILEIO_ERROR == fret) {
+            Log("read failed, errno=%d, %s\n", errno, strerror(errno));
+         }
          break;
       }
 
@@ -2152,6 +2155,8 @@ FileIO_ResetExcludedFromTimeMachine(char const *pathName) // IN
    char xattr;
    ssize_t gXattrResult = getxattr(pathName, XATTR_BACKUP_REENABLED,
                                    &xattr, sizeof(xattr), 0, 0);
+   int sXattrResult;
+
    if (gXattrResult != -1) {
       // We have already seen this file, don't touch it again.
       goto exit;
@@ -2167,8 +2172,8 @@ FileIO_ResetExcludedFromTimeMachine(char const *pathName) // IN
       goto exit;
    }
    xattr = '1';
-   int sXattrResult = setxattr(pathName, XATTR_BACKUP_REENABLED,
-                               &xattr, sizeof(xattr), 0, 0);
+   sXattrResult = setxattr(pathName, XATTR_BACKUP_REENABLED,
+                           &xattr, sizeof(xattr), 0, 0);
    if (sXattrResult == -1) {
       LOG_ONCE((LGPFX" %s Couldn't set xattr on path [%s]: %s.\n",
                 __func__, pathName, strerror(errno)));
index d74307be4c451ab1e4ea518c036a294f6e106149..9e5d2006758dcf9555ebe283ef72d2137350195c 100644 (file)
@@ -233,6 +233,8 @@ EXTERN Bool FileLockValidOwner(const char *executionID,
 
 EXTERN Bool FileLockValidName(ConstUnicode fileName);
 
+EXTERN Bool FileIsWritableDir(ConstUnicode dirName);
+
 #if defined(__APPLE__)
 EXTERN int PosixFileOpener(ConstUnicode pathName,
                            int flags,
index 2b5f15c3213dcd49eb3b767e47f55d4e2e70033f..09d348d625591535d37432e15fad40623be29e72 100644 (file)
@@ -111,13 +111,6 @@ struct WalkDirContextImpl
 #endif
 
 
-/*
- * Local functions
- */
-
-static Bool FileIsGroupsMember(gid_t gid);
-
-
 /*
  *-----------------------------------------------------------------------------
  *
@@ -2447,7 +2440,74 @@ File_WalkDirectoryEnd(WalkDirContext context) // IN
 /*
  *----------------------------------------------------------------------
  *
- * File_IsWritableDir --
+ * FileIsGroupsMember --
+ *
+ *     Determine if a gid is in the gid list of the current process
+ *
+ * Results:
+ *     FALSE if error (reported to the user)
+ *
+ * Side effects:
+ *     None
+ *
+ *----------------------------------------------------------------------
+ */
+
+static Bool
+FileIsGroupsMember(gid_t gid)
+{
+   int nr_members;
+   gid_t *members;
+   int res;
+   int ret;
+
+   members = NULL;
+   nr_members = 0;
+   for (;;) {
+      gid_t *new;
+
+      res = getgroups(nr_members, members);
+      if (res == -1) {
+         Warning(LGPFX" %s: Couldn't getgroups\n", __FUNCTION__);
+         ret = FALSE;
+         goto end;
+      }
+
+      if (res == nr_members) {
+         break;
+      }
+
+      /* Was bug 17760 --hpreg */
+      new = realloc(members, res * sizeof *members);
+      if (new == NULL) {
+         Warning(LGPFX" %s: Couldn't realloc\n", __FUNCTION__);
+         ret = FALSE;
+         goto end;
+      }
+
+      members = new;
+      nr_members = res;
+   }
+
+   for (res = 0; res < nr_members; res++) {
+      if (members[res] == gid) {
+         ret = TRUE;
+         goto end;
+      }
+   }
+   ret = FALSE;
+
+end:
+   free(members);
+
+   return ret;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileIsWritableDir --
  *
  *     Determine in a non-intrusive way if the user can create a file in a
  *     directory
@@ -2467,17 +2527,12 @@ File_WalkDirectoryEnd(WalkDirContext context) // IN
  */
 
 Bool
-File_IsWritableDir(ConstUnicode dirName)  // IN:
+FileIsWritableDir(ConstUnicode dirName)  // IN:
 {
    int err;
    uid_t euid;
    FileData fileData;
 
-   if (dirName == NULL) {
-      errno = EFAULT;
-      return FALSE;
-   }
-
    err = FileAttributes(dirName, &fileData);
 
    if ((err != 0) || (fileData.fileType != FILE_TYPE_DIRECTORY)) {
@@ -2531,7 +2586,7 @@ FileTryDir(const char *dirName) // IN: Is this a writable directory?
    }
 
    edirName = Util_ExpandString(dirName);
-   if (edirName != NULL && File_IsWritableDir(edirName)) {
+   if (edirName != NULL && FileIsWritableDir(edirName)) {
       return edirName;
    }
    free(edirName);
@@ -2620,72 +2675,6 @@ File_GetTmpDir(Bool useConf) // IN: Use the config file?
 #undef HOSTINFO_TRYDIR
 
 
-/*
- *----------------------------------------------------------------------
- *
- * FileIsGroupsMember --
- *
- *     Determine if a gid is in the gid list of the current process
- *
- * Results:
- *     FALSE if error (reported to the user)
- *
- * Side effects:
- *     None
- *
- *----------------------------------------------------------------------
- */
-
-static Bool
-FileIsGroupsMember(gid_t gid)
-{
-   int nr_members;
-   gid_t *members;
-   int res;
-   int ret;
-
-   members = NULL;
-   nr_members = 0;
-   for (;;) {
-      gid_t *new;
-
-      res = getgroups(nr_members, members);
-      if (res == -1) {
-         Warning(LGPFX" %s: Couldn't getgroups\n", __FUNCTION__);
-         ret = FALSE;
-         goto end;
-      }
-
-      if (res == nr_members) {
-         break;
-      }
-
-      /* Was bug 17760 --hpreg */
-      new = realloc(members, res * sizeof *members);
-      if (new == NULL) {
-         Warning(LGPFX" %s: Couldn't realloc\n", __FUNCTION__);
-         ret = FALSE;
-         goto end;
-      }
-
-      members = new;
-      nr_members = res;
-   }
-
-   for (res = 0; res < nr_members; res++) {
-      if (members[res] == gid) {
-         ret = TRUE;
-         goto end;
-      }
-   }
-   ret = FALSE;
-
-end:
-   free(members);
-
-   return ret;
-}
-
 /*
  *----------------------------------------------------------------------
  *
index 32282c3712056dde8fee4e1ca6684d6f1c40d49c..4d1e0633cfcd8419308e67edf8465db78a4b4be2 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libFoundryMsg.a
+noinst_LTLIBRARIES = libFoundryMsg.la
 
-libFoundryMsg_a_SOURCES =
-libFoundryMsg_a_SOURCES += foundryMsg.c
-libFoundryMsg_a_SOURCES += foundryThreads.c
-libFoundryMsg_a_SOURCES += foundryPropertyListCommon.c
-libFoundryMsg_a_SOURCES += vixTranslateErrOpenSource.c
+libFoundryMsg_la_SOURCES =
+libFoundryMsg_la_SOURCES += foundryMsg.c
+libFoundryMsg_la_SOURCES += foundryThreads.c
+libFoundryMsg_la_SOURCES += foundryPropertyListCommon.c
+libFoundryMsg_la_SOURCES += vixTranslateErrOpenSource.c
index 586343305e215f46d3327bff63f5ab28e8941d8e..f8c8ffa93885898888fa2a0ae345edb658ef0f52 100644 (file)
@@ -82,6 +82,8 @@ Vix_TranslateSystemError(int systemError) // IN
    case ERROR_SHARING_VIOLATION:
    case ERROR_SEEK:
    case ERROR_CANNOT_MAKE:
+      Log("%s: system error = %d\n", __FUNCTION__,
+          systemError);
       err = VIX_E_FILE_ERROR;
       break;
    case ERROR_HANDLE_DISK_FULL:
@@ -145,6 +147,8 @@ Vix_TranslateSystemError(int systemError) // IN
    case ENOTDIR:
    case ENOTEMPTY:
    case EROFS:
+      Log("%s: system error = %d\n", __FUNCTION__,
+                        systemError);
       err = VIX_E_FILE_ERROR;
       break;
    case ENODEV:
@@ -279,6 +283,8 @@ Vix_TranslateCryptoError(CryptoError cryptoError) // IN
    } else if (CRYPTO_ERROR_BAD_PASSWORD == cryptoError) {
       return VIX_E_CRYPTO_BAS_PASSWORD;
    } else if (CRYPTO_ERROR_IO_ERROR == cryptoError) {
+      Log("%s: crypto error = %d\n", __FUNCTION__,
+          (int)cryptoError);
       return VIX_E_FILE_ERROR;
    } else if (CRYPTO_ERROR_UNKNOWN_ERROR == cryptoError) {
       return VIX_E_FAIL;
index d55926c8dc6dad2238dede60b0b06b8e171d8a00..6d1463ebcbbab68f6548cdc27b07cf25d13ecffb 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libGhIntegration.a
+noinst_LTLIBRARIES = libGhIntegration.la
 
-libGhIntegration_a_SOURCES =
-libGhIntegration_a_SOURCES += ghIntegration.c
-libGhIntegration_a_SOURCES += ghIntegrationX11.c
+libGhIntegration_la_SOURCES =
+libGhIntegration_la_SOURCES += ghIntegration.c
+libGhIntegration_la_SOURCES += ghIntegrationX11.c
 
 AM_CFLAGS = @GTK_CPPFLAGS@
 AM_CFLAGS += @URIPARSER_CPPFLAGS@
 AM_CFLAGS += @LIB_FILE_CPPFLAGS@
-AM_CFLAGS += -I$(top_builddir)/include
index 4554a6f510f85f2af15fd70ce42d589f588f00c2..a80afab7889c8ddcb6a7936a55c1053ba1532d01 100644 (file)
@@ -1511,7 +1511,6 @@ GHIPlatformOpenStartMenuTree(GHIPlatform *ghip,        // IN: platform-specific
 {
 #ifdef GTK2
    char temp[64];
-   ASSERT(ghip);
    GHIMenuHandle *gmh;
    int itemCount = 0;
    Bool retval = FALSE;
@@ -2716,6 +2715,10 @@ GHIRestoreVMwareEnviron(GHIPlatform *ghip) // IN
    }
 
    for (p = environ; p && *p; p++) {
+      char *lhs;
+      char *rhs;
+      unsigned int index;
+
       if (!StrUtil_StartsWith(*p, "VMWARE_")) {
          continue;
       }
@@ -2732,10 +2735,6 @@ GHIRestoreVMwareEnviron(GHIPlatform *ghip) // IN
        * the variable name, and extract the rhs of the "=" to get the
        * value.
        */
-      char *lhs;
-      char *rhs;
-      unsigned int index;
-
       index = 0;
       lhs = StrUtil_GetNextToken(&index, *p, "=");
       if (lhs) {
index 9370885865b3395f528c302ba6c40299656a2cd7..23b4606f058e25a2f828091d4dd1bc3d0f67577e 100644 (file)
@@ -15,9 +15,9 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libGhIntegrationStub.a
+noinst_LTLIBRARIES = libGhIntegrationStub.la
 
-libGhIntegrationStub_a_SOURCES =
-libGhIntegrationStub_a_SOURCES += ghIntegrationStub.c
+libGhIntegrationStub_la_SOURCES =
+libGhIntegrationStub_la_SOURCES += ghIntegrationStub.c
 
 AM_CFLAGS = @LIB_FILE_CPPFLAGS@
index 67cf796e3a3992657dee84eb217d7b7ce5eb5fd3..68492239ccd74417f7f6b4ae9c77545f60f79143 100644 (file)
 # because the X11 code supports only GuestApp_OpenUrl, and we'd like to not
 # force an X11 dependency on applications that don't need one (e.g., guestd).
 
-noinst_LIBRARIES = libGuestApp.a
+noinst_LTLIBRARIES = libGuestApp.la
 
-libGuestApp_a_SOURCES =
-libGuestApp_a_SOURCES += guestApp.c
-libGuestApp_a_SOURCES += guestAppPosix.c
+libGuestApp_la_SOURCES =
+libGuestApp_la_SOURCES += guestApp.c
+libGuestApp_la_SOURCES += guestAppPosix.c
 
 if HAVE_X11
-noinst_LIBRARIES += libGuestAppX11.a
-libGuestAppX11_a_SOURCES = $(libGuestApp_a_SOURCES)
-libGuestAppX11_a_SOURCES += guestAppPosixX11.c
-libGuestAppX11_a_CPPFLAGS = -DGUESTAPP_HAS_X11
-libGuestAppX11_a_CPPFLAGS += @GTK_CPPFLAGS@
+noinst_LTLIBRARIES += libGuestAppX11.la
+libGuestAppX11_la_SOURCES = $(libGuestApp_la_SOURCES)
+libGuestAppX11_la_SOURCES += guestAppPosixX11.c
+libGuestAppX11_la_CPPFLAGS = -DGUESTAPP_HAS_X11
+libGuestAppX11_la_CPPFLAGS += @GTK_CPPFLAGS@
 endif
index e01f08f90987adb7ba03f159410eb18bba3e8191..033c1be4a47846b165a7e1284bef7d4c69215194 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libGuestInfo.a
+noinst_LTLIBRARIES = libGuestInfo.la
 
-libGuestInfo_a_SOURCES =
-libGuestInfo_a_SOURCES += guestInfo.c
-libGuestInfo_a_SOURCES += guestInfoServer.c
-libGuestInfo_a_SOURCES += guestInfoPosix.c
-libGuestInfo_a_SOURCES += guestInfoPerfMonLinux.c
+libGuestInfo_la_SOURCES =
+libGuestInfo_la_SOURCES += guestInfo.c
+libGuestInfo_la_SOURCES += guestInfoServer.c
+libGuestInfo_la_SOURCES += guestInfoPosix.c
+libGuestInfo_la_SOURCES += guestInfoPerfMonLinux.c
+
+if ENABLE_CORE_SERVICES
+noinst_LTLIBRARIES += libGuestInfoCS.la
+
+libGuestInfoCS_la_SOURCES =
+libGuestInfoCS_la_SOURCES += guestInfo.c
+libGuestInfoCS_la_SOURCES += guestInfoPosix.c
+endif
 
 AM_CFLAGS = $(DNET_CPPFLAGS)
-AM_CFLAGS += -I$(top_builddir)/include
 
index 4b0a5d54ef72d8c0e7509ce19aa6578395f890ec..2867be720038a2cafcadf2fcb0f8fad127ce822b 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libGuestRpc.a
+noinst_LTLIBRARIES = libGuestRpc.la
 
-libGuestRpc_a_SOURCES =
-libGuestRpc_a_SOURCES += ghiGetBinaryHandlers_xdr.c
-libGuestRpc_a_SOURCES += ghiProtocolHandler_xdr.c
-libGuestRpc_a_SOURCES += nicinfo_xdr.c
-libGuestRpc_a_SOURCES += unityActive_xdr.c
-
-nodist_libGuestRpc_a_SOURCES =
-nodist_libGuestRpc_a_SOURCES += ghiGetBinaryHandlers.h
-nodist_libGuestRpc_a_SOURCES += ghiGetBinaryHandlers_xdr.c
-nodist_libGuestRpc_a_SOURCES += ghiProtocolHandler.h
-nodist_libGuestRpc_a_SOURCES += ghiProtocolHandler_xdr.c
-nodist_libGuestRpc_a_SOURCES += nicinfo.h
-nodist_libGuestRpc_a_SOURCES += nicinfo_xdr.c
-nodist_libGuestRpc_a_SOURCES += unityActive.h
-nodist_libGuestRpc_a_SOURCES += unityActive_xdr.c
+libGuestRpc_la_SOURCES =
+libGuestRpc_la_SOURCES += ghiGetBinaryHandlers_xdr.c
+libGuestRpc_la_SOURCES += ghiProtocolHandler_xdr.c
+libGuestRpc_la_SOURCES += nicinfo_xdr.c
+libGuestRpc_la_SOURCES += unityActive_xdr.c
 
 # XXX: Autoreconf complains about this and recommends using AM_CFLAGS instead.
-# Neither that nor libGuestRpc_a_CFLAGS work, though. What gives?
+# Problem is, $(CFLAGS) is appended to the compiler command line after AM_CFLAGS
+# and after libGuestRpc_la_CFLAGS, so "-Wall -Werror" will override this flag.
 CFLAGS += -Wno-unused
 
 CLEANFILES =
@@ -55,9 +46,19 @@ EXTRA_DIST += unityActive.x
 
 ## `make clean` should also remove the copied headers.
 clean-local:
-       $(RM) -rf $(top_builddir)/lib/include/guestrpc
+       rm -rf $(top_builddir)/lib/include/guestrpc
+       if [ $(top_builddir) != $(top_srcdir) ]; then   \
+          rm -f *.x;                                                                                           \
+       fi
+
+# Rules to invoke rpcgen. rpcgen will generate funny paths in the generated
+# files if not invoked in the same directory as the source file, so we need
+# to copy the sources to the build dir before compiling them.
 
 ghiGetBinaryHandlers.h: ghiGetBinaryHandlers.x
+       if [ $(top_builddir) != $(top_srcdir) ]; then                        \
+          cp $(top_srcdir)/lib/guestRpc/ghiGetBinaryHandlers.x $(builddir); \
+       fi
        $(RPCGEN) -h -o $@ ghiGetBinaryHandlers.x
        $(SED) 's,rpc/rpc\.h,vmxrpc.h,' $@ > $@.tmp
        mv $@.tmp $@
@@ -68,6 +69,9 @@ ghiGetBinaryHandlers_xdr.c: ghiGetBinaryHandlers.x ghiGetBinaryHandlers.h
        $(RPCGEN) -c -o $@ ghiGetBinaryHandlers.x
 
 ghiProtocolHandler.h: ghiProtocolHandler.x
+       if [ $(top_builddir) != $(top_srcdir) ]; then                        \
+          cp $(top_srcdir)/lib/guestRpc/ghiProtocolHandler.x $(builddir);   \
+       fi
        $(RPCGEN) -h -o $@ ghiProtocolHandler.x
        $(SED) 's,rpc/rpc\.h,vmxrpc.h,' $@ > $@.tmp
        mv $@.tmp $@
@@ -78,6 +82,9 @@ ghiProtocolHandler_xdr.c: ghiProtocolHandler.x ghiProtocolHandler.h
        $(RPCGEN) -c -o $@ ghiProtocolHandler.x
 
 nicinfo.h: nicinfo.x
+       if [ $(top_builddir) != $(top_srcdir) ]; then            \
+          cp $(top_srcdir)/lib/guestRpc/nicinfo.x $(builddir);  \
+       fi
        $(RPCGEN) -h -o $@ nicinfo.x
        $(SED) 's,rpc/rpc\.h,vmxrpc.h,' $@ > $@.tmp
        mv $@.tmp $@
@@ -88,6 +95,9 @@ nicinfo_xdr.c: nicinfo.x nicinfo.h
        $(RPCGEN) -c -o $@ nicinfo.x
 
 unityActive.h: unityActive.x
+       if [ $(top_builddir) != $(top_srcdir) ]; then               \
+          cp $(top_srcdir)/lib/guestRpc/unityActive.x $(builddir); \
+       fi
        $(RPCGEN) -h -o $@ unityActive.x
        $(SED) 's,rpc/rpc\.h,vmxrpc.h,' $@ > $@.tmp
        mv $@.tmp $@
@@ -96,4 +106,4 @@ unityActive.h: unityActive.x
 
 unityActive_xdr.c: unityActive.x unityActive.h
        $(RPCGEN) -c -o $@ unityActive.x
-
+   GetBinaryHandlers.h: ghiGetBinaryHandlers.x
index 460c6d96b0a24569ef5bc2b5e6ef9099d4029863..8766f4c2664c1ee3e73e18aaf2b782205a54b907 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libHgfs.a
+noinst_LTLIBRARIES = libHgfs.la
 
-libHgfs_a_SOURCES =
-libHgfs_a_SOURCES += cpName.c
-libHgfs_a_SOURCES += cpNameLite.c
-libHgfs_a_SOURCES += cpNameLinux.c
-libHgfs_a_SOURCES += cpNameUtil.c
-libHgfs_a_SOURCES += cpNameUtilLinux.c
-libHgfs_a_SOURCES += hgfsUtil.c
-libHgfs_a_SOURCES += hgfsEscape.c
+libHgfs_la_SOURCES =
+libHgfs_la_SOURCES += cpName.c
+libHgfs_la_SOURCES += cpNameLite.c
+libHgfs_la_SOURCES += cpNameLinux.c
+libHgfs_la_SOURCES += cpNameUtil.c
+libHgfs_la_SOURCES += cpNameUtilLinux.c
+libHgfs_la_SOURCES += hgfsUtil.c
+libHgfs_la_SOURCES += hgfsEscape.c
index b40e906ec8570afae5d311acf0f20c0eaac4aa62..bd21385c2297ebf1be9068670c7be8e7da9d75a3 100644 (file)
@@ -286,4 +286,43 @@ CPNameUtil_Utf8FormCToUtf8FormHost(const char *cpUtf8FormCName,   // IN:
 }
 
 
+/*
+ *----------------------------------------------------------------------------
+ *
+ * CPNameUitl_CharReplace --
+ *
+ *    A simple function to replace all oldChar's with newChar's in a binary
+ *    buffer. This is used for either replacing NULL with local DIRSPEC to
+ *    convert from relative cross-platform name to local relative name, or
+ *    replacing local DIRSEPC with NULL to convert from local relative name
+ *    to relative cross-platform file name 
+ *
+ * Results:
+ *    None.
+ *
+ * Side effects:
+ *    None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void
+CPNameUtil_CharReplace(char *buf,      // IN/OUT
+                       size_t bufSize, // IN
+                       char oldChar,   // IN
+                       char newChar)   // IN
+
+{
+   size_t i;
+
+   ASSERT(buf);
+
+   for (i = 0; i < bufSize; i++) {
+      if (buf[i] == oldChar) {
+         buf[i] = newChar;
+      }
+   }
+}
+
+
 #endif /* __KERNEL__ */
index 6b471c3f3e000baf0ba8aab510a9d64280bcb805..fb16c3981d141d1700753653936a4054d336549e 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libHgfsBd.a
+noinst_LTLIBRARIES = libHgfsBd.la
 
-libHgfsBd_a_SOURCES =
-libHgfsBd_a_SOURCES += hgfsBd.c
+libHgfsBd_la_SOURCES =
+libHgfsBd_la_SOURCES += hgfsBd.c
index 0fcbb6a19290a8550f8e3accdad8cd56c2259099..32c9f437dded0195f0afe530ccb07c744220ccae 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libHgfsServer.a
+noinst_LTLIBRARIES = libHgfsServer.la
 
-libHgfsServer_a_SOURCES =
-libHgfsServer_a_SOURCES += hgfsServer.c
-libHgfsServer_a_SOURCES += hgfsServerLinux.c
+libHgfsServer_la_SOURCES =
+libHgfsServer_la_SOURCES += hgfsServer.c
+libHgfsServer_la_SOURCES += hgfsServerLinux.c
 
 AM_CFLAGS = @LIB_HGFS_SERVER_CPPFLAGS@
index 7b06bcfd6043a16d1205972198ce1114e67cf8c2..d76220d3d3fce1a1eb32bd213f4d1cef04200b32 100644 (file)
 
 #if defined(_WIN32)
 #include <io.h>
+#define HGFS_PARENT_DIR "..\\"
 #else
 #include <unistd.h>
 #define stricmp strcasecmp
+#define HGFS_PARENT_DIR "../"
 #endif // _WIN32
+#define HGFS_PARENT_DIR_LEN 3
 
 #define LOGLEVEL_MODULE hgfs
 #include "loglevel_user.h"
@@ -5379,6 +5382,95 @@ HgfsServer_ExitState(void)
    HgfsServerPlatformDestroy();
 }
 
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsBuildRelativePath --
+ *
+ *    Generates relative file path which need to be used a symbolic link target which
+ *    would generate target name defined in "target" if the path to symbolic link
+ *    file defined in the "source".
+ *    Both source and target parameters represent absolute paths.
+ *
+ * Results:
+ *    Allocated path that caller must free.
+ *    NULL if there is a low memory condition.
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+char*
+HgfsBuildRelativePath(const char* source,    // IN: source file name
+                      const char* target)    // IN: target file name
+{
+   const char *relativeSource = source;
+   const char *relativeTarget = target;
+   const char* sourceSep;
+   const char* targetSep;
+   int level = 0;
+   size_t targetSize;
+   char *result;
+   char *currentPosition;
+    /*  First remove the part of the path which is common between source and target */
+   while (*relativeSource != '\0' && *relativeTarget != '\0') {
+      sourceSep = strchr(relativeSource, DIRSEPC);
+      targetSep = strchr(relativeTarget, DIRSEPC);
+      if (sourceSep == NULL || targetSep == NULL) {
+         break;
+      }
+      if ((sourceSep - relativeSource) != (targetSep - relativeTarget)) {
+         break;
+      }
+      if (strncmp(relativeSource, relativeTarget, (targetSep - relativeTarget)) != 0) {
+         break;
+      }
+      relativeSource = sourceSep + 1;
+      relativeTarget = targetSep + 1;
+   };
+   /*
+    *  Find out how many directories deep the source file is from the common part of the
+    *  path.
+    */
+   while(*relativeSource != '\0') {
+      sourceSep = strchr(relativeSource, DIRSEPC);
+      if (sourceSep != NULL) {
+         /* Several consecutive separators mean only one level. */
+         while (*sourceSep == DIRSEPC) {
+            sourceSep++;
+         }
+         if (*sourceSep != '\0') {
+            level++;
+            relativeSource = sourceSep;
+         } else {
+            break;
+         }
+      } else {
+         break;
+      }
+   }
+
+   /*
+    * Consruct relative path by adding level number of "../"
+    * to the relative target path.
+    */
+   targetSize = level * HGFS_PARENT_DIR_LEN + strlen(relativeTarget) + sizeof '\0';
+   result = malloc(targetSize);
+   currentPosition = result;
+   if (result != NULL) {
+      while (level != 0) {
+         memcpy(currentPosition, HGFS_PARENT_DIR, HGFS_PARENT_DIR_LEN);
+         level--;
+         currentPosition += HGFS_PARENT_DIR_LEN;
+      }
+      memcpy(currentPosition, relativeTarget, strlen(relativeTarget) + sizeof '\0');
+   }
+   return result;
+}
+
 #ifdef HGFS_OPLOCKS
 /*
  *-----------------------------------------------------------------------------
index 1c896cea363ec4dcfd973183f438a3f4d88dcd8d..3a9036e7ba13872d619e2a01d80f6adf52bc483b 100644 (file)
@@ -657,6 +657,10 @@ HgfsServerConvertCase(const char *sharePath,             // IN: share path in qu
 Bool
 HgfsServerCaseConversionRequired(void);
 
+char*
+HgfsBuildRelativePath(const char* source,    // IN: source file name
+                      const char* target);   // IN: target file name
+
 /* All oplock-specific functionality is defined here. */
 #ifdef HGFS_OPLOCKS
 void
index cc6be87f1c6c90465090c2d26277a1ac862b20ba..0213463d9c18a536f3bfe6b19293bc3ccd46341e 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2008 VMware, Inc. All rights reserved.
  *
  * 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
@@ -77,6 +77,8 @@
 #if defined(__APPLE__)
 #include <CoreServices/CoreServices.h> // for the alias manager
 #include <CoreFoundation/CoreFoundation.h> // for CFString and CFURL
+#include <sys/attr.h>       // for getattrlist
+#include <sys/vnode.h>      // for VERG / VDIR
 #endif
 
 /*
@@ -232,6 +234,13 @@ futimes(int fd, const struct timeval times[2])
 #undef STRLEN_OF_MAXINT_AS_STRING
 #endif
 
+#if defined(__APPLE__)
+struct FInfoAttrBuf {
+   uint32 length;
+   fsobj_type_t objType;
+   char finderInfo[32];
+};
+#endif
 /*
  * Server open flags, indexed by HgfsOpenFlags. Stolen from
  * lib/fileIOPosix.c
@@ -268,6 +277,7 @@ static HgfsInternalStatus HgfsGetattrResolveAlias(char const *fileName,
 
 static HgfsInternalStatus HgfsGetattrFromName(char *fileName,
                                               HgfsShareOptions configOptions,
+                                              char *shareName,
                                               HgfsFileAttrInfo *attr,
                                               char **targetName);
 
@@ -321,6 +331,8 @@ static HgfsInternalStatus HgfsSetattrFromName(char *cpName,
                                              uint32 caseFlags);
 
 static Bool HgfsIsShareRoot(char const *cpName, size_t cpNameSize);
+static HgfsInternalStatus HgfsGetHiddenXAttr(char const *fileName, Bool *attribute);
+static HgfsInternalStatus HgfsSetHiddenXAttr(char const *fileName, Bool value);
 
 #ifdef HGFS_OPLOCKS
 /*
@@ -924,6 +936,7 @@ HgfsValidateOpen(HgfsFileOpenInfo *openInfo, // IN: Open info struct
    mode_t openPerms;
    HgfsServerLock serverLock;
    HgfsInternalStatus status = 0;
+   Bool needToSetAttribute = FALSE;
 
    ASSERT(openInfo);
    ASSERT(localId);
@@ -969,6 +982,23 @@ HgfsValidateOpen(HgfsFileOpenInfo *openInfo, // IN: Open info struct
       openFlags &= ~O_NOFOLLOW;
    }
 
+   /*
+    * Determine if hidden attribute needs to be updated.
+    * It needs to be updated if a new file is created or an existing file is truncated.
+    * Since Posix_Open does not tell us if a new file has been created when O_CREAT is
+    * specified we need to find out if the file exists before an open that may create
+    * it.
+    */
+   if (openInfo->mask & HGFS_OPEN_VALID_FILE_ATTR) {
+      if ((openFlags & O_TRUNC) ||
+          ((openFlags & O_CREAT) && (openFlags & O_EXCL))) {
+         needToSetAttribute = TRUE;
+      } else if (openFlags & O_CREAT) {
+         int err = access(openInfo->utf8Name, F_OK);
+         needToSetAttribute = (err != 0) && (errno == ENOENT);
+      }
+   }
+
    /*
     * Try to open the file with the requested mode, flags and permissions.
     */
@@ -983,6 +1013,11 @@ HgfsValidateOpen(HgfsFileOpenInfo *openInfo, // IN: Open info struct
       goto exit;
    }
 
+   /* Set the rest of the Windows specific attributes if necessary. */
+   if (needToSetAttribute) {
+      HgfsSetHiddenXAttr(openInfo->utf8Name, openInfo->attr & HGFS_ATTR_HIDDEN);
+   }
+
    /* Stat file to get its volume and file info */
    if (fstat(fd, &fileStat) < 0) {
       error = errno;
@@ -1253,6 +1288,7 @@ HgfsGetattrResolveAlias(char const *fileName,       // IN:  Input filename
 #endif
 }
 
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -1297,6 +1333,19 @@ HgfsGetHiddenAttr(char const *fileName,         // IN:  Input filename
        * This replicates SMB behavior see bug 292189.
        */
       attr->flags |= HGFS_ATTR_HIDDEN_FORCED;
+   } else {
+      Bool isHidden = FALSE;
+      /*
+       * Do not propagate any error returned from HgfsGetHiddenXAttr.
+       * Consider that the file is not hidden if can't get hidden attribute for
+       * whatever reason; most likely it fails because hidden attribute is not supported
+       * by the OS or file system.
+       */
+      HgfsGetHiddenXAttr(fileName, &isHidden);
+      if (isHidden) {
+         attr->mask |= HGFS_ATTR_VALID_FLAGS;
+         attr->flags |= HGFS_ATTR_HIDDEN;
+      }
    }
 }
 
@@ -1751,6 +1800,7 @@ HgfsServerCaseConversionRequired()
 static HgfsInternalStatus
 HgfsGetattrFromName(char *fileName,                    // IN/OUT:  Input filename
                     HgfsShareOptions configOptions,    // IN: Share config options
+                    char *shareName,                   // IN: Share name
                     HgfsFileAttrInfo *attr,            // OUT: Struct to copy into
                     char **targetName)                 // OUT: Symlink target filename
 {
@@ -1830,18 +1880,47 @@ HgfsGetattrFromName(char *fileName,                    // IN/OUT:  Input filenam
       if (HgfsGetattrResolveAlias(fileName, &myTargetName)) {
          LOG(4, ("HgfsGetattrFromName: could not resolve file aliases\n"));
       }
+      attr->type = HGFS_FILE_TYPE_REGULAR;
       if (myTargetName != NULL) {
          /*
-          * Let's mangle the permissions and size of the file so that it more
-          * closely resembles a symlink. The size should be the length of the
-          * target name (not including the nul-terminator), and the permissions
-          * should be 777.
+          * At this point the alias target has been successfully resolved. If the alias
+          * target is inside the same shared folder then convert it to relative path.
+          * Converting to a relative path produces a symlink that points to the target
+          * file in the guest OS.
+          * If the target lies outside the shared folder then treat it the same way as
+          * if alias has not been resolved.
           */
-         stats.st_size = strlen(myTargetName);
-         stats.st_mode |= ACCESSPERMS;
-         attr->type = HGFS_FILE_TYPE_SYMLINK;
-      } else {
-         attr->type = HGFS_FILE_TYPE_REGULAR;
+         HgfsNameStatus nameStatus;
+         size_t sharePathLen;
+         const char* sharePath;
+         nameStatus = HgfsServerPolicy_GetSharePath(shareName,
+                                                    strlen(shareName),
+                                                    HGFS_OPEN_MODE_READ_ONLY,
+                                                    &sharePathLen,
+                                                    &sharePath);
+         if (nameStatus == HGFS_NAME_STATUS_COMPLETE &&
+             sharePathLen < strlen(myTargetName) &&
+             Str_Strncmp(sharePath, myTargetName, sharePathLen) == 0) {
+            char *relativeName;
+            relativeName = HgfsBuildRelativePath(fileName, myTargetName);
+            free(myTargetName);
+            myTargetName = relativeName;
+            if (myTargetName != NULL) {
+               /*
+                * Let's mangle the permissions and size of the file so that it more
+                * closely resembles a symlink. The size should be the length of the
+                * target name (not including the nul-terminator), and the permissions
+                * should be 777.
+                */
+               stats.st_size = strlen(myTargetName);
+               stats.st_mode |= ACCESSPERMS;
+               attr->type = HGFS_FILE_TYPE_SYMLINK;
+            } else {
+               LOG(4, ("HgfsGetattrFromName: out of memory\n"));
+            }
+         } else {
+             LOG(4, ("HgfsGetattrFromName: alias target is outside shared folder\n"));
+         }
       }
    }
 
@@ -2479,6 +2558,15 @@ HgfsSetattrFromFd(HgfsHandle file,         // IN: file descriptor
       }
    }
 
+   if (attr->mask & HGFS_ATTR_VALID_FLAGS) {
+       char *localName;
+       size_t localNameSize;
+       if (HgfsHandle2FileName(file, &localName, &localNameSize)) {
+          status = HgfsSetHiddenXAttr(localName, attr->flags & HGFS_ATTR_HIDDEN);
+          free(localName);
+       }
+   }
+
    timesStatus = HgfsSetattrTimes(&statBuf, attr, hints,
                                   &times[0], &times[1], &timesChanged);
    if (timesStatus == 0 && timesChanged) {
@@ -2668,6 +2756,10 @@ HgfsSetattrFromName(char *cpName,             // IN: Name
       }
    }
 
+   if (attr->mask & HGFS_ATTR_VALID_FLAGS) {
+      status = HgfsSetHiddenXAttr(localName, attr->flags & HGFS_ATTR_HIDDEN);
+   }
+
    timesStatus = HgfsSetattrTimes(&statBuf, attr, hints,
                              &times[0], &times[1], &timesChanged);
    if (timesStatus == 0 && timesChanged) {
@@ -3583,7 +3675,8 @@ HgfsServerSearchRead(char const *packetIn, // IN: incoming packet
 
          LOG(4, ("HgfsServerSearchRead: about to stat \"%s\"\n", fullName));
 
-         status = HgfsGetattrFromName(fullName, configOptions, &attr, NULL);
+         status = HgfsGetattrFromName(fullName, configOptions, search.utf8ShareName,
+                                      &attr, NULL);
          free(fullName);
 
          if (status != 0) {
@@ -3651,7 +3744,8 @@ HgfsServerSearchRead(char const *packetIn, // IN: incoming packet
              * problems on the host, the server still enumerates it and
              * returns to the client.
              */
-            status = HgfsGetattrFromName(sharePath, configOptions, &attr, NULL);
+            status = HgfsGetattrFromName(sharePath, configOptions, dent->d_name,
+                                        &attr, NULL);
             if (status != 0) {
                /*
                 * The dent no longer exists. Log the event.
@@ -3817,7 +3911,8 @@ HgfsServerGetattr(char const *packetIn, // IN: incoming packet
             goto exit;
          }
 
-         status = HgfsGetattrFromName(localName, configOptions, &attr, &targetName);
+         status = HgfsGetattrFromName(localName, configOptions, cpName, &attr,
+                                      &targetName);
          free(localName);
          if (status != 0) {
             /*
@@ -4325,7 +4420,8 @@ HgfsServerRename(char const *packetIn, // IN: incoming packet
        * We were asked to avoid replacing an existing file,
        * so fail if the target exists.
        */
-      status = HgfsGetattrFromName(localNewName, configOptions, &attr, NULL);
+      status = HgfsGetattrFromName(localNewName, configOptions, cpNewName,
+                                   &attr, NULL);
       if (status == 0) {
          /* The target exists, and so must fail the rename. */
          LOG(4, ("HgfsServerRename: error: target %s exists\n", localNewName));
@@ -5040,3 +5136,214 @@ HgfsIsShareRoot(char const *cpName,         // IN: name to test
    return TRUE;
 }
 
+#if defined(__APPLE__)
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsGetHiddenXattr --
+ *
+ *    For Mac hosts returns true if file has invisible bit set in the FileFinder
+ *    extended attributes.
+ *
+ * Results:
+ *    0 if succeeded getting attribute, error code otherwise otherwise.
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static HgfsInternalStatus
+HgfsGetHiddenXAttr(char const *fileName,   // IN: File name
+                   Bool *attribute)        // OUT: Hidden atribute
+{
+   struct attrlist attrList;
+   struct FInfoAttrBuf attrBuf;
+   HgfsInternalStatus err;
+
+   ASSERT(fileName);
+   ASSERT(attribute);
+
+   memset(&attrList, 0, sizeof attrList);
+   attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
+   attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
+   err = getattrlist(fileName, &attrList, &attrBuf, sizeof attrBuf, 0);
+   if (err == 0) {
+      switch (attrBuf.objType) {
+      case VREG: {
+         FileInfo *info = (FileInfo*) attrBuf.finderInfo;
+         uint16 finderFlags = CFSwapInt16BigToHost(info->finderFlags);
+         *attribute = (finderFlags & kIsInvisible) != 0;
+         break;
+      }
+      case VDIR: {
+         FolderInfo *info = (FolderInfo*) attrBuf.finderInfo;
+         uint16 finderFlags = CFSwapInt16BigToHost(info->finderFlags);
+         *attribute = (finderFlags & kIsInvisible) != 0;
+         break;
+      }
+      default:
+         LOG(4, ("HgfsGetHiddenXattr: Unrecognized object type %d\n", attrBuf.objType));
+         err = EINVAL;
+      }
+   } else {
+      LOG(4, ("HgfsGetHiddenXattr: Error %d when getting attributes\n", err));
+   }
+   return err;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * ChangeInvisibleFlag --
+ *
+ *    Changes value of the invisible bit in a flags variable to a value defined by
+ *    setFlag parameter.
+ *
+ * Results:
+ *    TRUE flag has been changed, FALSE otherwise.
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static Bool
+ChangeInvisibleFlag(uint16 *flags,           // IN: variable that contains flags
+                    Bool setFlag)            // IN: new value for the invisible flag
+{
+   Bool changed = FALSE;
+   /* 
+    * Finder keeps, reports and expects to set flags in big endian format.
+    * Needs to convert to host endian before using constants
+    * and then convert back to big endian before saving
+    */
+   uint16 finderFlags = CFSwapInt16BigToHost(*flags);
+   Bool isInvisible = (finderFlags & kIsInvisible) != 0;
+   if (setFlag != isInvisible) {
+      if (setFlag) {
+         finderFlags |= kIsInvisible;
+      } else {
+         finderFlags &= ~kIsInvisible;
+      }
+      *flags = CFSwapInt16HostToBig(finderFlags);
+      changed = TRUE;
+   }
+   return changed;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsSetHiddenXAttr --
+ *
+ *    Sets new value for the invisible attribute of a file.
+ *
+ * Results:
+ *    0 if succeeded, error code otherwise.
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static HgfsInternalStatus
+HgfsSetHiddenXAttr(char const *fileName,       // IN: path to the file 
+                   Bool value)                 // IN: new value to the invisible attribute
+{
+   HgfsInternalStatus err;
+   Bool changed = FALSE;
+   struct attrlist attrList;
+   struct FInfoAttrBuf attrBuf;
+
+   ASSERT(fileName);
+
+   memset(&attrList, 0, sizeof attrList);
+   attrList.bitmapcount = ATTR_BIT_MAP_COUNT;
+   attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO;
+   err = getattrlist(fileName, &attrList, &attrBuf, sizeof attrBuf, 0);
+   if (err == 0) {
+      switch (attrBuf.objType) {
+      case VREG: {
+         FileInfo *info = (FileInfo*) attrBuf.finderInfo;
+         changed = ChangeInvisibleFlag(&info->finderFlags, value);
+         break;
+      }
+      case VDIR: {
+         FolderInfo *info = (FolderInfo*) attrBuf.finderInfo;
+         changed = ChangeInvisibleFlag(&info->finderFlags, value);
+         break;
+      }
+      default:
+         LOG(4, ("HgfsGetHiddenXattr: Unrecognized object type %d\n", attrBuf.objType));
+         err = EINVAL;
+      }
+   } else {
+      err = errno;
+   }
+   if (changed) {
+      attrList.commonattr = ATTR_CMN_FNDRINFO;
+      err = setattrlist(fileName, &attrList, attrBuf.finderInfo,
+                        sizeof attrBuf.finderInfo, 0);
+   }
+   return err;
+}
+
+#else // __APPLE__
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsGetHiddenXAttr --
+ *
+ *    Always returns EINVAL since there is no support for invisible files in Linux
+ *    HGFS server.
+ *
+ * Results:
+ *    Currently always returns EINVAL.  Will return 0 when support for invisible files
+ *    is implemented in Linux server.
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static HgfsInternalStatus
+HgfsGetHiddenXAttr(char const *fileName,    // IN: File name
+                   Bool *attribute)         // OUT: Value of the hidden attribute 
+{
+   return EINVAL;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsSetHiddenXAttr --
+ *
+ *    Sets new value for the invisible attribute of a file.
+ *    Currently Linux server does not support invisible or hiddden files thus
+ *    the function fails when a attempt to mark a file as hidden is made.
+ *
+ * Results:
+ *    0 if succeeded, error code otherwise.
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static HgfsInternalStatus
+HgfsSetHiddenXAttr(char const *fileName,   // IN: File name
+                   Bool value)             // IN: Value of the attribute to set
+{
+   return value ? EINVAL : 0;
+}
+#endif // __APPLE__
index fc595f3d238ac7a778c14c4a73b5913b03846b67..f1024e7e6fc7a8b45e3d8f479902cd44e1c787c3 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libHgfsServerManagerGuest.a
+noinst_LTLIBRARIES = libHgfsServerManagerGuest.la
 
-libHgfsServerManagerGuest_a_SOURCES =
-libHgfsServerManagerGuest_a_SOURCES += hgfsServerManagerGuest.c
+libHgfsServerManagerGuest_la_SOURCES =
+libHgfsServerManagerGuest_la_SOURCES += hgfsServerManagerGuest.c
index 31784e7cf861572cb369289fc96ce4e90ae7f0f5..1cbf050cc7913d989be64ad0a96d7a6f0ca432bb 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libHgfsServerPolicyGuest.a
+noinst_LTLIBRARIES = libHgfsServerPolicyGuest.la
 
-libHgfsServerPolicyGuest_a_SOURCES =
-libHgfsServerPolicyGuest_a_SOURCES += hgfsServerPolicyGuest.c
+libHgfsServerPolicyGuest_la_SOURCES =
+libHgfsServerPolicyGuest_la_SOURCES += hgfsServerPolicyGuest.c
index f58f1d1bd07efdd770be0d1bae07ca93ade091a3..8b52aff78c66bc8624aee9143d6be3eadddb9209 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libImage.a
+noinst_LTLIBRARIES = libImage.la
 
-libImage_a_SOURCES =
-libImage_a_SOURCES += imageUtilPng.c
+libImage_la_SOURCES =
+libImage_la_SOURCES += imageUtilPng.c
 
 AM_CFLAGS =
 AM_CFLAGS += @LIBPNG_CPPFLAGS@
index 09cbf8e812a5988e9736c711ec956888e16bc1fc..1c88f06451772bc00f55403f9bdea5c9cd945523 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libImpersonate.a
+noinst_LTLIBRARIES = libImpersonate.la
 
-libImpersonate_a_SOURCES =
-libImpersonate_a_SOURCES += impersonate.c
-libImpersonate_a_SOURCES += impersonatePosix.c
+libImpersonate_la_SOURCES =
+libImpersonate_la_SOURCES += impersonate.c
+libImpersonate_la_SOURCES += impersonatePosix.c
 
 AM_CFLAGS = @LIB_IMPERSONATE_CPPFLAGS@
index abd8847d61fcff8fa81bce2a14aaaa40f6863093..ac09bf5e9d20beda68148d49a158f8d426a392f1 100644 (file)
 #define BDOOR_CMD_DEBUGEVENT            53
 #define BDOOR_CMD_OSNOTMACOSXSERVER     54
 #define BDOOR_CMD_GETTIMEFULL_WITH_LAG  55
-#define BDOOR_CMD_ACPI_HOTPLUG          56
-#define BDOOR_CMD_MAX                   57
+#define BDOOR_CMD_ACPI_HOTPLUG_DEVICE   56
+#define BDOOR_CMD_ACPI_HOTPLUG_MEMORY   57
+#define BDOOR_CMD_ACPI_HOTPLUG_CBRET    58
+#define BDOOR_CMD_GET_HOST_VIDEO_MODES  59
+#define BDOOR_CMD_MAX                   60
 
 /* 
  * IMPORTANT NOTE: When modifying the behavior of an existing backdoor command,
index 1037c8fea7dc27d08ee73e6a3663ee0386207f6f..28d8524eba15a90ccb9af966a7dd01ed114445b6 100644 (file)
@@ -1,12 +1,12 @@
 #define BUILD_NUMBER \
-       "build-130226"
+       "build-137267"
 #define BUILD_NUMBER_NUMERIC \
-       130226
+       137267
 #define BUILD_NUMBER_NUMERIC_STRING \
-       "130226"
+       "137267"
 #define PRODUCT_BUILD_NUMBER \
-       "product-build-380"
+       "product-build-415"
 #define PRODUCT_BUILD_NUMBER_NUMERIC \
-       380
+       415
 #define PRODUCT_BUILD_NUMBER_NUMERIC_STRING \
-       "380"
+       "415"
diff --git a/open-vm-tools/lib/include/circList.h b/open-vm-tools/lib/include/circList.h
deleted file mode 100644 (file)
index 5f16c77..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-/*********************************************************
- * Copyright (C) 1998 VMware, Inc. All rights reserved.
- *
- * 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 the Free Software Foundation version 2.1 and no later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
- * License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
- *
- *********************************************************/
-
-/*
- *   circList.h --
- *
- * macros, prototypes and struct definitions for double-linked
- * circular lists.
- */
-
-#ifndef _CIRCLIST_H_
-#define _CIRCLIST_H_
-
-#define INCLUDE_ALLOW_USERLEVEL
-#define INCLUDE_ALLOW_VMMON
-#define INCLUDE_ALLOW_VMCORE
-#define INCLUDE_ALLOW_MODULE
-#define INCLUDE_ALLOW_VMKERNEL
-#include "includeCheck.h"
-#include "vmware.h"
-
-typedef struct ListItem {
-   struct ListItem *prev;
-   struct ListItem *next;
-} ListItem;
-
-/* A list with no elements is a null pointer. */
-#define   LIST_ITEM_DEF(name)   \
-   ListItem * name = NULL
-
-#define   LIST_EMPTY(l)      ((l) == NULL)
-
-/* initialize list item */
-#define   INIT_LIST_ITEM(p)   \
-   do {   \
-      (p)->prev = (p)->next = (p);   \
-   } while (0)
-
-/* check if initialized */
-#define   IS_LIST_ITEM_INITIALIZED(li)   \
-   (((li) == (li)->prev) && ((li) == (li)->next))
-
-/* return first element in the list */
-#define   LIST_FIRST(l)      (l)
-#define   LIST_FIRST_CHK(l)   (l)
-
-/* return last element in the list */
-#define   LIST_LAST(l)      ((l)->prev)
-#define   LIST_LAST_CHK(l)   (LIST_EMPTY(l) ? NULL : LIST_LAST(l))
-
-/*
- * LIST_CONTAINER - get the struct for this entry (like list_entry)
- * @ptr: the &struct ListItem pointer.
- * @type:   the type of the struct this is embedded in.
- * @member: the name of the list struct within the struct.
- */
-#define LIST_CONTAINER(ptr, type, member) \
-   ((type *)((char *)(ptr) - offsetof(type, member)))
-
-/*
- * delete item from the list
- */
-#define   LIST_DEL            DelListItem   
-
-/*
- * link two lists together
- */
-#define   LIST_SPLICE         SpliceLists
-
-/*
- * Split a list into two lists
- */
-#define   LIST_SPLIT          SplitLists
-
-/*
- * Add item to front of stack. List pointer points to new head.
- */
-#define   LIST_PUSH           PushListItem
-
-/*
- * Add item at back of queue. List pointer only changes if list was empty.
- */
-#define   LIST_QUEUE          QueueListItem
-
-/*
- * Get the list size.
- */
-#define   LIST_SIZE          GetListSize
-
-/*
- * LIST_SCAN_FROM scans the list from "from" up until "until".
- * The loop variable p should not be destroyed in the process.
- * "from" is an element in the list where to start scanning.
- * "until" is the element where search should stop.
- * member is the field to use for the search - either "next" or "prev".
- */
-#define   LIST_SCAN_FROM(p, from, until, member)   \
-   for (p = (from); (p) != NULL;   \
-      (p) = (((p)->member == (until)) ? NULL : (p)->member))
-
-/* scan the entire list (non-destructively) */ 
-#define   LIST_SCAN(p, l)   \
-   LIST_SCAN_FROM(p, LIST_FIRST(l), LIST_FIRST(l), next)
-
-
-/* scan a list backward from last element to first (non-destructively) */
-#define   LIST_SCAN_BACK(p, l)   \
-   LIST_SCAN_FROM(p, LIST_LAST_CHK(l), LIST_LAST(l), prev)
-
-/* scan the entire list where loop element may be destroyed */
-#define   LIST_SCAN_SAFE(p, pn, l)   \
-   if (!LIST_EMPTY(l))  \
-      for (p = (l), (pn) = NextListItem(p, l); (p) != NULL;   \
-           (p) = (pn), (pn) = NextListItem(p, l))
-
-/* scan the entire list backwards where loop element may be destroyed */
-#define   LIST_SCAN_BACK_SAFE(p, pn, l)   \
-   if (!LIST_EMPTY(l))  \
-      for (p = LIST_LAST(l), (pn) = PrevListItem(p, l); (p) != NULL;   \
-           (p) = (pn), (pn) = PrevListItem(p, l))
-
-
-/* function definitions */
-
-/*
- *----------------------------------------------------------------------
- *
- * NextListItem --
- *
- *      Returns the next member of a doubly linked list, or NULL if last.
- *      Assumes: p is member of the list headed by head.
- *
- * Result
- *      If head or p is NULL, return NULL. Otherwise,
- *      next list member (or null if last).
- *
- * Side effects:
- *      None.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE ListItem *
-NextListItem(ListItem *p,        // IN
-             ListItem *head)     // IN
-{
-   if (head == NULL || p == NULL) {
-      return NULL;
-   }
-   /* both p and head are non-null */
-   p = p->next;
-   return p == head ? NULL : p;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * PrevListItem --
- *
- *      Returns the prev member of a doubly linked list, or NULL if first.
- *      Assumes: p is member of the list headed by head.
- *
- * Result
- *      If head or prev is NULL, return NULL. Otherwise,
- *      prev list member (or null if first).
- *
- * Side effects:
- *      None.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE ListItem *
-PrevListItem(ListItem *p,        // IN
-             ListItem *head)     // IN
-{
-   if (head == NULL || p == NULL) {
-      return NULL;
-   }
-   /* both p and head are non-null */
-   return p == head ? NULL : p->prev;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * DelListItem --
- *
- *      Deletes a member of a doubly linked list, possibly modifies the
- *      list header itself.
- *      Assumes neither p nor headp is null and p is a member of *headp.
- *
- * Result
- *      None
- *
- * Side effects:
- *      Modifies *headp.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE void
-DelListItem(ListItem *p,         // IN
-            ListItem **headp)    // IN/OUT
-{
-   ListItem *next;
-
-   ASSERT(p);
-   ASSERT(headp);
-
-   next = p->next;
-   if (p == next) {
-      *headp = NULL;
-   } else {
-      next->prev = p->prev;
-      p->prev->next = next;
-      if (*headp == p) {
-         *headp = next;
-      }
-   }
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * QueueListItem --
- *
- *      Adds a new member to the back of a doubly linked list (queue)
- *      Assumes neither p nor headp is null and p is not a member of *headp.
- *
- * Result
- *      None
- *
- * Side effects:
- *      Modifies *headp.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE void
-QueueListItem(ListItem *p,              // IN
-              ListItem **headp)         // IN/OUT
-{
-   ListItem *head;
-
-   head = *headp;
-   if (LIST_EMPTY(head)) {
-      INIT_LIST_ITEM(p);
-      *headp = p;
-   } else {
-      p->prev = head->prev;
-      p->next = head;
-      p->prev->next = p;
-      head->prev = p;
-   }
-}
-                                                                                
-
-/*
- *----------------------------------------------------------------------
- *
- * PushListItem --
- *
- *      Adds a new member to the front of a doubly linked list (stack)
- *      Assumes neither p nor headp is null and p is not a member of *headp.
- *
- * Result
- *      None
- *
- * Side effects:
- *      Modifies *headp.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE void
-PushListItem(ListItem *p,               // IN
-             ListItem **headp)          // IN/OUT
-{
-   QueueListItem(p, headp);
-   *headp = p;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * SpliceLists --
- *
- *      Make a single list {l1 l2} from {l1} and {l2} and return it.
- *      It is okay for one or both lists to be NULL.
- *      No checking is done. It is assumed that l1 and l2 are two
- *      distinct lists.
- *
- * Result
- *      A list { l1 l2 }.
- *
- * Side effects:
- *      Modifies l1 and l2 list pointers.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE ListItem *
-SpliceLists(ListItem *l1,      // IN
-            ListItem *l2)      // IN
-{
-   ListItem *l1Last, *l2Last;
-
-   if (LIST_EMPTY(l1)) {
-      return l2;
-   }
-
-   if (LIST_EMPTY(l2)) {
-      return l1;
-   }
-
-   l1Last = l1->prev;   /* last elem of l1 */
-   l2Last = l2->prev;   /* last elem of l2 */
-
-   /*
-    *    l1 -> ... -> l1Last    l2 -> ... l2Last
-    */
-   l1Last->next = l2;
-   l2->prev = l1Last;
-
-   l1->prev = l2Last;
-   l2Last->next = l1;
-
-   return l1;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * SplitLists --
- *
- *      Make a list l = {l1 l2} into two separate lists {l1} and {l2}, where:
- *      l = { ... x -> p -> ... } split into:
- *      l1 = { ... -> x }
- *      l2 = { p -> ... } 
- *      Assumes neither p nor l is null and p is a member of l.
- *      If p is the first element of l, then l1 will be NULL.
- *
- * Result
- *      None.
- *
- * Side effects:
- *      Sets *l1p and *l2p to the resulting two lists.
- *      Modifies l's pointers.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE void
-SplitLists(ListItem *p,         // IN
-           ListItem *l,         // IN
-           ListItem **l1p,      // OUT
-           ListItem **l2p)      // OUT
-{
-   ListItem *last;
-
-   if (p == LIST_FIRST(l)) {   /* first element */
-      *l1p = NULL;
-      *l2p = l;
-      return;
-   }
-
-   last = l->prev;
-
-   *l1p = l;
-   p->prev->next = l;
-   l->prev = p->prev;
-
-   *l2p = p;
-   p->prev = last;
-   last->next = p;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * GetListSize --
- *
- *     Return the number of items in the list.
- *
- * Result:
- *     The number of items in the list.
- *
- * Side effects:
- *     None.
- *
- *----------------------------------------------------------------------
- */
-
-static INLINE int
-GetListSize(ListItem *head)    // IN
-{
-   ListItem *li;
-   int ret = 0;
-
-   LIST_SCAN(li, head) {
-      ret++;
-   }
-   return ret;
-}
-
-#endif /* _CIRCLIST_H_ */
index 9b3fc27e5aebb69936bc38696ad93a31ea5575b2..ac9b207646362adb5c2a815be817cd8a9045812f 100644 (file)
@@ -63,5 +63,9 @@ Bool CPNameUtil_Utf8FormCToUtf8FormHost(const char *cpUtf8FormCName,
                                         char **cpConvertedName,
                                         size_t *cpConvertedNameLen);
 
+void CPNameUtil_CharReplace(char *buf,
+                            size_t bufSize,
+                            char oldChar,
+                            char newChar);
 
 #endif /* __CP_NAME_UTIL_H__ */
index b5e17abd5ee1346e9cf92619d69ce2f386eabde2..94dec95b8a1205f88e24835cbea7b77e3adc6677 100644 (file)
@@ -91,6 +91,7 @@ typedef enum
    CPFORMAT_FILELIST,
    CPFORMAT_RTF,
    CPFORMAT_FILELIST_URI,
+   CPFORMAT_FILECONTENTS,
    CPFORMAT_MAX,
 } DND_CPFORMAT;
 
index e61983f2261d1e44445c1168e7ca8a6e15c0c8bd..c127a6667f3818c065e3828681b13422224e9925 100644 (file)
 #ifndef _EMBED_VERSION_H_
 #define _EMBED_VERSION_H_
 
-/* 
+/*
  * Using section attributes, embed the specified version in the "modinfo"
  * section of the ELF binary. We don't do this on Windows, where the PE format
- * already has version information stuffed inside it.
+ * already has version information stuffed inside it, nor on Mac OS X, which
+ * doesn't use ELF.
  *
  * We can't declare vm_version as static, otherwise it may get optimized out.
  * I've seen this when building with gcc 4.1, but not with 3.3.
+ *
+ * The argument to the macro should be the base name for the version number
+ * macros to embed in the final binary, as described in vm_version.h (see
+ * declaration of VM_VERSION_TO_STR).
  */
-#ifndef _WIN32
-#define VM_EMBED_VERSION(ver)                                                 \
-const char vm_version[]                                                       \
+#if !defined(_WIN32) && !defined(__APPLE__)
+
+#include "vm_version.h"
+
+#define VM_EMBED_VERSION(ver)                                    \
+const char vm_version[]                                          \
    __attribute__((section(".modinfo"), unused)) = "version=" ver
+
 #else
 #define VM_EMBED_VERSION(ver)
 #endif
index 8e0b01fe2e711193d2cb24633bd5e542d7e82dc0..0b7a5ece42c6fd4ca6f955dd77e067956d1fb23a 100644 (file)
@@ -45,8 +45,8 @@ extern "C"{
 # ifdef __FreeBSD__
 #  include <sys/param.h> // For __FreeBSD_version
 # endif
-# if defined(__FreeBSD__) && __FreeBSD_version >= 503000
-#  include <syslimits.h>  // PATH_MAX
+# if defined(__FreeBSD__)
+#  include <sys/syslimits.h>  // PATH_MAX
 # else 
 #  include <limits.h>  // PATH_MAX
 # endif 
@@ -110,6 +110,9 @@ EXTERN void File_GetPathName(ConstUnicode fullPath,
 
 EXTERN Unicode File_StripSlashes(ConstUnicode path);
 
+EXTERN Unicode File_PathJoin(ConstUnicode dirName,
+                             ConstUnicode baseName);
+
 EXTERN Bool File_CreateDirectory(ConstUnicode pathName);
 EXTERN Bool File_EnsureDirectory(ConstUnicode pathName);
 
@@ -131,8 +134,6 @@ EXTERN Bool File_WalkDirectoryNext(WalkDirContext context,
                                    Unicode *path);
 EXTERN void File_WalkDirectoryEnd(WalkDirContext context);
 
-EXTERN Bool File_IsWritableDir(ConstUnicode dirName);
-
 EXTERN Bool File_IsDirectory(ConstUnicode pathName);
 
 EXTERN Bool File_IsFile(ConstUnicode pathName);
index 6d3ac4de3b3a25b124dc68c8f81fe4ec604b46cb..63192d4edca97860e18421113513f7bebab0a052 100644 (file)
    LOGLEVEL_VAR(mksHostOps), \
    LOGLEVEL_VAR(mksGLManager), \
    LOGLEVEL_VAR(mksGLShader), \
+   LOGLEVEL_VAR(vdpPlugin), \
    \
    /* user/sound */ \
    LOGLEVEL_VAR(sound), \
    LOGLEVEL_VAR(worker), \
    LOGLEVEL_VAR(duiDevices), \
    LOGLEVEL_VAR(duiProxyApps), \
+   LOGLEVEL_VAR(docker), \
    LOGLEVEL_VAR(uwt), /* lib/unityWindowTracker */ \
    LOGLEVEL_VAR(cui), \
    LOGLEVEL_VAR(automation), \
    LOGLEVEL_VAR(oemDevice), \
    LOGLEVEL_VAR(cptOps), \
    LOGLEVEL_VAR(VProbeExec), \
-   LOGLEVEL_VAR(VProbeVP), \
+   LOGLEVEL_VAR(VP), \
    LOGLEVEL_VAR(device), \
    LOGLEVEL_VAR(devicePowerOn), \
    LOGLEVEL_VAR(vmxvmdbCallbacks), \
index 1b9d3b66c6f21f270d11e1222b54d5f565a56db4..d192dc660206103b69b2d38a67e6a2d01650b3fb 100644 (file)
@@ -89,8 +89,13 @@ typedef struct MsgCallback {
    HintResult (*hint)(HintOptions options,
                      const char *msgID, const char *message);
 
-   void *(*lazyProgressStart)(const char *msgID, const char *message);
-   void  (*lazyProgress)(void *handle, int percent);
+   void *(*lazyProgressStart)(const char *msgID,
+                              const char *message,
+                              Bool allowCancel);
+   Bool  (*lazyProgress)(void *handle,
+                         const char *msgID,
+                         const char *message,
+                         int percent);
    void  (*lazyProgressEnd)(void *handle);
 
    void (*postList)(MsgSeverity severity, Msg_List *messages);
@@ -147,9 +152,15 @@ EXTERN int Msg_Progress(int percentDone, Bool cancelButton, const char *idFmt,
 EXTERN int Msg_ProgressScaled(int percentDone, int opsDone, int opsTotal,
                               Bool cancelButton);
 
-EXTERN void *Msg_LazyProgressStart(const char *idFmt, ...)
-       PRINTF_DECL(1, 2);
-EXTERN void Msg_LazyProgress(void *handle, int percent);
+EXTERN void *Msg_LazyProgressStart(Bool allowCancel,
+                                   const char *idFmt,
+                                   ...)
+       PRINTF_DECL(2, 3);
+EXTERN Bool Msg_LazyProgress(void *handle,
+                             int percent,
+                             const char *idFmt,
+                             ...)
+       PRINTF_DECL(3, 4);
 EXTERN void Msg_LazyProgressEnd(void *handle);
 
 
index d149d67eca5484748d5cb6845a4d6105eeda1f8b..890ed0d0a90d8f2608fd75b2b8cb7a1c530254d2 100644 (file)
@@ -107,6 +107,8 @@ typedef enum {
    UpdateRect,
    ROPFillRect,
    Present3dRect,
+   LockRect,
+   FenceRect,
    MaxRect
 } RectInfoType;
 
@@ -121,6 +123,9 @@ typedef struct RectInfo {
          uint32 sid;
          uint32 srcx, srcy;
       } Present3d;
+      struct {
+         uint32 fenceId;
+      } Fence;
       /* add more here, then update miRectInfosEqual and miPrintRegion. */
    };
 } RectInfo, *RectInfoPtr;
index 343bd3717600e2d9381b9f52b3331f1eceb3197a..b7c71fa21697e64bea1abb077b293edb52c39097 100644 (file)
@@ -36,11 +36,11 @@ typedef SOCKET Socket;
 #else    // _WIN32
 typedef int SocketSelectable;
 typedef int Socket;
-#define INVALID_SOCKET     -1
+#define INVALID_SOCKET     (-1)
 #endif   // _WIN32
 
 
-#define SOCKET_INFINITE_TIMEOUT   -1
+#define SOCKET_INFINITE_TIMEOUT   (-1)
 
 
 typedef enum SocketMgrError {
index 030888697038a7fb2adb622038e9aed5cf189412..322753a6d623dc92e865d497856ccb1300b0e524 100644 (file)
@@ -79,6 +79,7 @@ EXTERN int Str_Snprintf(char *buf, size_t len,
                        const char *fmt, ...) PRINTF_DECL(3, 4);
 EXTERN int Str_Vsnprintf(char *buf, size_t len,
                         const char *fmt, va_list args);
+EXTERN size_t Str_Strlen(const char *src, size_t maxLen);
 EXTERN char *Str_Strnstr(const char *src, const char *sub, size_t n);
 EXTERN char *Str_Strcpy(char *dst, const char *src, size_t maxLen);
 EXTERN char *Str_Strcat(char *dst, const char *src, size_t maxLen);
index ed5315bcf107c69361903bdb304b661ffaca43d0..571d601d8b5f2b5c878b8ae6743f672a4ae13903 100644 (file)
 
 #define UNITY_MAX_SETTOP_WINDOW_COUNT 100
 
-/* 
- * RPC messages between host and guest that are part of Unity and GHI
- * protocols. 
- * If messages are added, make sure to update the corresponding JavaDoc
- * below.
+
+/*
+ * Unity, GHI GuestRPC interface.
+ */
+
+
+/**
+ * @name Unity RPCs: Host-to-Guest
+ * @{
+ * @attention Any changes to this list @e must be reflected in the detailed
+ * docblock(s) below.
+ */
+#define UNITY_RPC_ENTER                   "unity.enter"
+#define UNITY_RPC_GET_UPDATE              "unity.get.update"
+#define UNITY_RPC_GET_WINDOW_PATH         "unity.get.window.path"
+#define UNITY_RPC_GET_BINARY_INFO         "unity.get.binary.info"
+#define UNITY_RPC_GET_BINARY_HANDLERS     "unity.get.binary.handlers"
+#define UNITY_RPC_OPEN_LAUNCHMENU         "unity.launchmenu.open"
+#define UNITY_RPC_GET_LAUNCHMENU_ITEM     "unity.launchmenu.get.item"
+#define UNITY_RPC_CLOSE_LAUNCHMENU        "unity.launchmenu.close"
+#define UNITY_RPC_WINDOW_SETTOP           "unity.window.settop"
+#define UNITY_RPC_WINDOW_CLOSE            "unity.window.close"
+#define UNITY_RPC_GET_WINDOW_CONTENTS     "unity.get.window.contents"
+#define UNITY_RPC_GET_ICON_DATA           "unity.get.icon.data"
+#define UNITY_RPC_EXIT                    "unity.exit"
+#define UNITY_RPC_GET_UPDATE_FULL         "unity.get.update.full"
+#define UNITY_RPC_GET_UPDATE_INCREMENTAL  "unity.get.update.incremental"
+#define UNITY_RPC_SHELL_OPEN              "unity.shell.open"
+#define UNITY_RPC_SHOW_TASKBAR            "unity.show.taskbar"
+#define UNITY_RPC_WINDOW_MOVE_RESIZE      "unity.window.move_resize"
+#define UNITY_RPC_DESKTOP_WORK_AREA_SET   "unity.desktop.work_area.set"
+#define UNITY_RPC_WINDOW_MINIMIZE         "unity.window.minimize"
+#define UNITY_RPC_WINDOW_UNMINIMIZE       "unity.window.restore"
+#define UNITY_RPC_WINDOW_MAXIMIZE         "unity.window.maximize"
+#define UNITY_RPC_WINDOW_UNMAXIMIZE       "unity.window.unmaximize"
+#define UNITY_RPC_DESKTOP_CONFIG_SET      "unity.desktop.config.set"
+#define UNITY_RPC_DESKTOP_ACTIVE_SET      "unity.desktop.active.set"
+#define UNITY_RPC_WINDOW_DESKTOP_SET      "unity.window.desktop.set"
+
+#define GHI_RPC_GUEST_SHELL_ACTION                    "ghi.guest.shell.action"
+#define GHI_RPC_SET_GUEST_HANDLER                     "ghi.guest.handler.set"
+#define GHI_RPC_RESTORE_DEFAULT_GUEST_HANDLER         "ghi.guest.handler.restoreDefault"
+/* @} */
+
+
+/**
+ * @name Unity RPCs: Guest-to-Host
+ * @{
+ * @attention Any changes to this list @e must be reflected in the detailed
+ * docblock(s) below.
+ */
+#define UNITY_RPC_PUSH_UPDATE_CMD         "tools.unity.push.update"
+#define UNITY_RPC_VMX_SHOW_TASKBAR        "vmx.unity.show.taskbar"
+#define UNITY_RPC_UNITY_CAP               "tools.capability.unity"
+#define UNITY_RPC_SHOW_TASKBAR_CAP        "tools.capability.unity.taskbar"
+#define GHI_RPC_LAUNCHMENU_CHANGE         "tools.ghi.launchmenu.change"
+#define GHI_RPC_PROTOCOL_HANDLER_INFO     "tools.ghi.protocolhandler.info"
+#define UNITY_RPC_UNITY_ACTIVE            "unity.active"
+
+#define GHI_RPC_HOST_SHELL_ACTION         "ghi.host.shell.action"
+/* @} */
+
+
+/**
+ * @name Unity start menus
+ * @{
+ * @todo Someone with GHI clue needs to correctly document these.
+ *
+ * Currently we have four possible unity start menu roots.
+ *
+ * @li @ref UNITY_START_MENU_LAUNCH_FOLDER is for all guest start menu
+ * 'Programs' items plus favorite items from guest start menu folder.
+ *
+ * @li @ref UNITY_START_MENU_FIXED_FOLDER is for special items like 'My
+ * Computer', 'My Documents', 'Control Panel', etc.
+ *
+ * @li @ref UNITY_START_MENU_ALL_HANDLERS_FOLDER is for all the applications
+ * that are known by the guest to open files.
+ *
+ * @li @ref UNITY_START_MENU_RESOLVED_LAUNCH_FOLDER is the same contents as
+ * @ref UNITY_START_MENU_LAUNCH_FOLDER however each item that is a shortcut
+ * (link) is resolved into its destination path.
+ */
+#define UNITY_START_MENU_LAUNCH_FOLDER          "VMGuestLaunchItems"
+#define UNITY_START_MENU_FIXED_FOLDER           "VMGuestFixedItems"
+#define UNITY_START_MENU_ALL_HANDLERS_FOLDER    "VMGuestAllHandlers"
+#define UNITY_START_MENU_RESOLVED_LAUNCH_FOLDER "VMGuestResolvedItems"
+/* @} */
+
+
+/*
+ * Type definitions
  */
 
+
 /**
-   @defgroup UnityRpcHG Unity: Host-to-Guest RPCs
+ * @brief Opaque Unity window identifier.
+ *
+ * UnityWindowIds are chosen by (and only have meaning to) the guest.
+ */
+typedef uint32 UnityWindowId;
+
+/**
+ * @brief Unity desktop identifier.
+ *
+ * Starting from @c 0, references a particular Unity desktop.
+ * @note A window with a @c UnityDesktopId of -1 once meant that the window was
+ * sticky.  This convention is deprecated in favor of
+ * @ref UNITY_WINDOW_ATTR_STICKY.
+ */
+typedef int32 UnityDesktopId;
+
+
+/**
+ * @name Unity window states
+ * @{
+ * @deprecated These are deprecated in favor of window attributes and window
+ * types, and are retained for compatibility purposes only.
+ */
+#define UNITY_WINDOW_STATE_MINIMIZED   (1 << 0)
+#define UNITY_WINDOW_STATE_IN_FOCUS    (1 << 1)
+#define UNITY_WINDOW_STATE_TOPMOST     (1 << 2)
+/* @} */
+
+
+/**
+ * @brief Unity window attributes
+ *
+ * Unity window attributes are boolean flags that can be set in combination on a window.
+ * If they are not set by the guest, it is up to the host to decide on a reasonable
+ * default.
+ *
+ * @attention
+ * If you add attributes here, please also update unityAttributeNames in
+ * unityWindowTracker.c.
+ */
+typedef enum {
+   UNITY_WINDOW_ATTR_BORDERLESS = 0,
+   UNITY_WINDOW_ATTR_MINIMIZABLE = 1,
+   UNITY_WINDOW_ATTR_MAXIMIZABLE = 2,
+   UNITY_WINDOW_ATTR_MAXIMIZED = 3,
+   UNITY_WINDOW_ATTR_CLOSABLE = 5,
+   UNITY_WINDOW_ATTR_HAS_TITLEBAR = 6,
+   UNITY_WINDOW_ATTR_VISIBLE = 7,
+   UNITY_WINDOW_ATTR_CHILD_WINDOW = 8,
+   UNITY_WINDOW_ATTR_HAS_TOOLBAR_BTN = 9,
+   UNITY_WINDOW_ATTR_BELONGS_TO_APP = 10,
+   UNITY_WINDOW_ATTR_DROPSHADOWED = 11,
+   UNITY_WINDOW_ATTR_ALWAYS_ABOVE = 12,
+   UNITY_WINDOW_ATTR_ALWAYS_BELOW = 13,
+   UNITY_WINDOW_ATTR_DISABLED = 14,
+   UNITY_WINDOW_ATTR_NOACTIVATE = 15,
+   UNITY_WINDOW_ATTR_SYSMENU = 16,
+   UNITY_WINDOW_ATTR_TOOLWINDOW = 17,
+   UNITY_WINDOW_ATTR_APPWINDOW = 18,
+   UNITY_WINDOW_ATTR_FULLSCREENABLE = 19,
+   UNITY_WINDOW_ATTR_FULLSCREENED = 20,
+   UNITY_WINDOW_ATTR_ATTN_WANTED = 21,
+   UNITY_WINDOW_ATTR_SHADEABLE = 22,
+   UNITY_WINDOW_ATTR_SHADED = 23,
+   UNITY_WINDOW_ATTR_STICKABLE = 24,
+   UNITY_WINDOW_ATTR_STICKY = 25,
+   UNITY_WINDOW_ATTR_MODAL = 26,
+
+   UNITY_MAX_ATTRIBUTES // Not a valid attribute
+} UnityWindowAttribute;
+
+typedef enum {
+   UNITY_WINDOW_TYPE_NONE   = -1,
+   UNITY_WINDOW_TYPE_NORMAL = 0,
+   UNITY_WINDOW_TYPE_PANEL,
+   UNITY_WINDOW_TYPE_DIALOG,
+   UNITY_WINDOW_TYPE_MENU,
+   UNITY_WINDOW_TYPE_TOOLTIP,
+   UNITY_WINDOW_TYPE_SPLASH,
+   UNITY_WINDOW_TYPE_TOOLBAR,
+   UNITY_WINDOW_TYPE_DOCK,
+   UNITY_WINDOW_TYPE_DESKTOP,
+   UNITY_WINDOW_TYPE_COMBOBOX,
+   UNITY_WINDOW_TYPE_WIDGET,
+
+   UNITY_MAX_WINDOW_TYPES  // Not a valid window type
+} UnityWindowType;
+
+typedef enum {
+   UNITY_ICON_TYPE_MAIN = 0,
+
+   UNITY_MAX_ICONS // Not a valid icon type
+} UnityIconType;
+
+typedef uint32 UnityIconSize; // Number of pixels on the larger side of the icon (which is usually square anyways).
+#define UNITY_MAX_ICON_DATA_CHUNK ((1 << 16) - 100) // 64k, minus space for a few other return values
+
+#define UNITY_DEFAULT_COLOR "#c0c0c0"
+
+
+/*
+ * Multipage Doxygen documentation.
+ */
+
+
+/**
+   @defgroup UnityRpcHG Unity RPCs: Host-to-Guest
    @{
 
    @def         UNITY_RPC_ENTER
    @note                A full update reports all current state of all windows,
                         while incremental sends updates received since the last
                         UNITY_RPC_GET_UPDATE was received.
+   @return See @ref UnityGetUpdateReturn.
 
 
    @def         UNITY_RPC_GET_WINDOW_PATH
-   @brief       Return the pathname of the application corresponding to the
-                specified window. 
+   @brief       Return keys which uniquely identify a window and its owning
+                application.
    @code
    UNITY_RPC_GET_WINDOW_PATH UnityWindowId
    @endcode
    @param UnityWindowId window to get path information from
-   @note       The data is returned as UTF-8. 
+   @return
+@verbatim
+retval ::= windowPath '\0' execPath '\0' '\0'
+windowPath ::= ? UTF-8 string tying UnityWindowId to an executable ?
+execPath ::= ? UTF-8 string uniquely identifying JUST the executable ?
+@endverbatim
+   @note        Clients are to treat the returned paths @e only as unique
+                binary keys.
+   @sa UNITY_RPC_SHELL_OPEN
 
 
    @def         UNITY_RPC_GET_BINARY_INFO
    @todo        Move this into a GHI-specific header.
    @todo        Give this RPC command an intuitive name.
    @code 
-   UNITY_RPC_GET_BINARY_INFO UnityWindowId
+   UNITY_RPC_GET_BINARY_INFO windowPath
    @endcode
-   @param[in] UnityWindowId     window id to get icons for 
+   @param[in] windowPath UTF-8 encoded "window path" returned by
+                         @ref UNITY_RPC_GET_WINDOW_PATH.
    @return
    @verbatim
 <retval> := <name><nul><icon_data>{<icon_data>}
    @code 
    UNITY_RPC_GET_UPDATE_FULL 
    @endcode
+   @return See @ref UnityGetUpdateReturn.
 
 
    @def         UNITY_RPC_GET_UPDATE_INCREMENTAL 
    @code 
    UNITY_RPC_GET_UPDATE_INCREMENTAL 
    @endcode
+   @return See @ref UnityGetUpdateReturn.
 
 
    @def         UNITY_RPC_SHELL_OPEN            
    @note        Window origin refers to the upper left (north west) corner.
    @note        It is possible that the result will not be as requested due
                 to the layout policy of the guest desktop or window manager.
+   @return      The new window location, dimensions.
+@verbatim
+retval ::= newX newY newWidth newHeight ;
+newX ::= ? post-op north west corner X coordinate ? ;
+newY ::= ? post-op north west corner Y coordinate ? ;
+newWidth ::= ? post-op window width ? ;
+newHeight ::= ? post-op window height ? ;
+@endverbatim
 
 
    @def         UNITY_RPC_DESKTOP_WORK_AREA_SET 
@@ -482,44 +696,12 @@ desktop where the upper right <tt>{1,2}</tt> is the currently active desktop.
    @param[in] UnityWindowId UnityWindowId of window to move 
    @param[in] offset Offset into desktop configuration, as defined by
                      @ref UNITY_RPC_DESKTOP_CONFIG_SET, 0 or greater. 
-
    @}
 */
 
-/* Host -> Guest */
-#define UNITY_RPC_ENTER                   "unity.enter"
-#define UNITY_RPC_GET_UPDATE              "unity.get.update"
-#define UNITY_RPC_GET_WINDOW_PATH         "unity.get.window.path"
-#define UNITY_RPC_GET_BINARY_INFO         "unity.get.binary.info"
-#define UNITY_RPC_GET_BINARY_HANDLERS     "unity.get.binary.handlers"
-#define UNITY_RPC_OPEN_LAUNCHMENU         "unity.launchmenu.open"
-#define UNITY_RPC_GET_LAUNCHMENU_ITEM     "unity.launchmenu.get.item"
-#define UNITY_RPC_CLOSE_LAUNCHMENU        "unity.launchmenu.close"
-#define UNITY_RPC_WINDOW_SETTOP           "unity.window.settop"
-#define UNITY_RPC_WINDOW_CLOSE            "unity.window.close"
-#define UNITY_RPC_GET_WINDOW_CONTENTS     "unity.get.window.contents"
-#define UNITY_RPC_GET_ICON_DATA           "unity.get.icon.data"
-#define UNITY_RPC_EXIT                    "unity.exit"
-#define UNITY_RPC_GET_UPDATE_FULL         "unity.get.update.full"
-#define UNITY_RPC_GET_UPDATE_INCREMENTAL  "unity.get.update.incremental"
-#define UNITY_RPC_SHELL_OPEN              "unity.shell.open"
-#define UNITY_RPC_SHOW_TASKBAR            "unity.show.taskbar"
-#define UNITY_RPC_WINDOW_MOVE_RESIZE      "unity.window.move_resize"
-#define UNITY_RPC_DESKTOP_WORK_AREA_SET   "unity.desktop.work_area.set"
-#define UNITY_RPC_WINDOW_MINIMIZE         "unity.window.minimize"
-#define UNITY_RPC_WINDOW_UNMINIMIZE       "unity.window.restore"
-#define UNITY_RPC_WINDOW_MAXIMIZE         "unity.window.maximize"
-#define UNITY_RPC_WINDOW_UNMAXIMIZE       "unity.window.unmaximize"
-#define UNITY_RPC_DESKTOP_CONFIG_SET      "unity.desktop.config.set"
-#define UNITY_RPC_DESKTOP_ACTIVE_SET      "unity.desktop.active.set"
-#define UNITY_RPC_WINDOW_DESKTOP_SET      "unity.window.desktop.set"
-
-#define GHI_RPC_GUEST_SHELL_ACTION                    "ghi.guest.shell.action"
-#define GHI_RPC_SET_GUEST_HANDLER                     "ghi.guest.handler.set"
-#define GHI_RPC_RESTORE_DEFAULT_GUEST_HANDLER         "ghi.guest.handler.restoreDefault"
 
 /**
-   @defgroup UnityRpcGH Unity: Guest-to-Host RPCs
+   @defgroup UnityRpcGH Unity RPCs: Guest-to-Host
    @{
 
    @def         UNITY_RPC_PUSH_UPDATE_CMD
@@ -585,121 +767,80 @@ desktop where the upper right <tt>{1,2}</tt> is the currently active desktop.
    @}
 */
 
-/* Guest -> Host */
-#define UNITY_RPC_PUSH_UPDATE_CMD         "tools.unity.push.update"
-#define UNITY_RPC_VMX_SHOW_TASKBAR        "vmx.unity.show.taskbar"
-#define UNITY_RPC_UNITY_CAP               "tools.capability.unity"
-#define UNITY_RPC_SHOW_TASKBAR_CAP        "tools.capability.unity.taskbar"
-#define GHI_RPC_LAUNCHMENU_CHANGE         "tools.ghi.launchmenu.change"
-#define GHI_RPC_PROTOCOL_HANDLER_INFO     "tools.ghi.protocolhandler.info"
-#define UNITY_RPC_UNITY_ACTIVE            "unity.active"
 
-#define GHI_RPC_HOST_SHELL_ACTION         "ghi.host.shell.action"
-
-/*
- * Currently we have four possible unity start menu roots.
+/**
+ * @page UnityGetUpdateReturn UNITY_RPC_GET_UPDATE RPC Return Value
  *
- * UNITY_START_MENU_LAUNCH_FOLDER is for all guest start menu 'Programs' items
- * plus favorite items from guest start menu folder.
+ * The return value of this RPC is a mapping of @ref UnityWindowTracker updates
+ * to GuestRpc-safe text strings.  (Think of this simply as a poor-man's
+ * marshalling scheme between the UnityWindowTrackers running in the Unity
+ * Agent and Server (presently the VMware Tools and VMX/MKS, respectively).
  *
- * UNITY_START_MENU_FIXED_FOLDER is for special items like 'My Computer',
- * 'My Documents', 'Control Panel', etc.
+ * @sa
+ * @li UNITY_RPC_GET_UPDATE
+ * @li UNITY_RPC_GET_UPDATE_FULL
+ * @li UNITY_RPC_GET_UPDATE_INCREMENTAL
  *
- * UNITY_START_MENU_ALL_HANDLERS_FOLDER is for all the applications that are known
- * by the guest to open files.
+ * @section URGUReturnFormat Return value format
  *
- * UNITY_START_MENU_RESOLVED_LAUNCH_FOLDER is the same contents as
- * UNITY_START_MENU_LAUNCH_FOLDER however each item that is a shortcut (link) is resolved
- * into its destination path.
- */
-
-#define UNITY_START_MENU_LAUNCH_FOLDER          "VMGuestLaunchItems"
-#define UNITY_START_MENU_FIXED_FOLDER           "VMGuestFixedItems"
-#define UNITY_START_MENU_ALL_HANDLERS_FOLDER    "VMGuestAllHandlers"
-#define UNITY_START_MENU_RESOLVED_LAUNCH_FOLDER "VMGuestResolvedItems"
-
-typedef uint32 UnityWindowId;
-
-typedef int32 UnityDesktopId;
-
-/*
- * Unity window state tracks the current state of the window (right now we only have
- * minimized, might have more in the future).
+ * The reply to the RPC is a double-null-terminated list of null-terminated
+ * strings.
  *
- * These are deprecated in favor of window attributes and window types, and are retained
- * for compatibility purposes only.
- */
-
-#define UNITY_WINDOW_STATE_MINIMIZED   (1 << 0)
-#define UNITY_WINDOW_STATE_IN_FOCUS    (1 << 1)
-#define UNITY_WINDOW_STATE_TOPMOST     (1 << 2)
-
-/*
- * Unity window attributes are boolean flags that can be set in combination on a window.
- * If they are not set by the guest, it is up to the host to decide on a reasonable
- * default.
+ * Each string in the list has one of the following formats:
  *
- * If you add attributes here, please also update unityAttributeNames in
- * unityWindowTracker.c.
+ * @li <tt>"add" UnityWindowId</tt> @par
+ *    A window identified by @a UnityWindowId has just been created.
+ *
+ * @li <tt>"remove" UnityWindowId</tt> @par
+ *    The window identified by @a UnityWindowId has been removed.  Get rid
+ *    of it.
+ *
+ * @li <tt>"move" UnityWindowId x1 y1 x2 y2</tt> @par
+ *    The window identified by @a UnityWindowId has moved or resized such
+ *    that its top left corner rests at <tt>(x1, y1)</tt> and its bottom
+ *    right at <tt>(x2, y2)</tt>.
+ *
+ * @li <tt>"region" UnityWindowId numrects</tt> @par
+ *    The window identified by @a UnityWindowId has a not-rectangular window
+ *    region (e.g. the curved corner windows in Windows XP).  Immediately,
+ *    after this message are @c numrects messages with the following (@ref
+ *    rect) format.
+ * @par
+ *    The actual window region is the union of all the rectangles in the list.
+ *    A value of 0 for @c numrects indicates that the window region should
+ *    be ignored (i.e. the window region is identical to the bounds of
+ *    the window).
+ *
+ * @li <tt>"rect" x1 y1 x2 y2</tt> @par
+ *    @anchor rect Defines a rectangle in the coordinate system of the window
+ *    for this region (not the coordinate system of the desktop!!)
+ *
+ * @li <tt>"title" UnityWindowId title</tt> @par
+ *    A window identified by @a UnityWindowId has just changed its to @a title.
+ *
+ * @li <tt>"zorder" numWindows UnityWindowId {UnityWindowId}</tt> @par
+ *    Resets the Z order of @a numWindows Unity windows in top-to-bottom order.
+ *
+ * @li <tt>"attr" UnityWindowId UnityWindowAttribute enabled</tt> @par
+ *    <tt>enabled ::= "0" | "1"</tt>\n The window identified by @a
+ *    UnityWindowId has an attribute enabled/disabled.
+ *
+ * @li <tt>"type" UnityWindowId UnityWindowType</tt> @par
+ *    The window identified by @a UnityWindowId is of a certain type
+ *
+ * @li <tt>"icon" UnityWindowId UnityIconType</tt> @par
+ *    The window identified by @a UnityWindowId has changed its icon type
+ *    to @a UnityIconType.
+ *
+ * @li <tt>"desktop" UnityWindowId UnityDesktopId</tt> @par
+ *    The window identified by @a UnityWindowId has been moved to the desktop
+ *    identified by @a UnityDesktopId.
+ *
+ * @li <tt>"activedesktop" UnityDesktopId</tt> @par
+ *    The desktop identified by @a UnityDesktopId has become active.
+ *
+ * @subsection ""
+ * @sa UnityWindowId, UnityDesktopId, UnityWindowType, UnityIconType
  */
 
-typedef enum {
-   UNITY_WINDOW_ATTR_BORDERLESS = 0,
-   UNITY_WINDOW_ATTR_MINIMIZABLE = 1,
-   UNITY_WINDOW_ATTR_MAXIMIZABLE = 2,
-   UNITY_WINDOW_ATTR_MAXIMIZED = 3,
-   UNITY_WINDOW_ATTR_CLOSABLE = 5,
-   UNITY_WINDOW_ATTR_HAS_TITLEBAR = 6,
-   UNITY_WINDOW_ATTR_VISIBLE = 7,
-   UNITY_WINDOW_ATTR_CHILD_WINDOW = 8,
-   UNITY_WINDOW_ATTR_HAS_TOOLBAR_BTN = 9,
-   UNITY_WINDOW_ATTR_BELONGS_TO_APP = 10,
-   UNITY_WINDOW_ATTR_DROPSHADOWED = 11,
-   UNITY_WINDOW_ATTR_ALWAYS_ABOVE = 12,
-   UNITY_WINDOW_ATTR_ALWAYS_BELOW = 13,
-   UNITY_WINDOW_ATTR_DISABLED = 14,
-   UNITY_WINDOW_ATTR_NOACTIVATE = 15,
-   UNITY_WINDOW_ATTR_SYSMENU = 16,
-   UNITY_WINDOW_ATTR_TOOLWINDOW = 17,
-   UNITY_WINDOW_ATTR_APPWINDOW = 18,
-   UNITY_WINDOW_ATTR_FULLSCREENABLE = 19,
-   UNITY_WINDOW_ATTR_FULLSCREENED = 20,
-   UNITY_WINDOW_ATTR_ATTN_WANTED = 21,
-   UNITY_WINDOW_ATTR_SHADEABLE = 22,
-   UNITY_WINDOW_ATTR_SHADED = 23,
-   UNITY_WINDOW_ATTR_STICKABLE = 24,
-   UNITY_WINDOW_ATTR_STICKY = 25,
-   UNITY_WINDOW_ATTR_MODAL = 26,
-
-   UNITY_MAX_ATTRIBUTES // Not a valid attribute
-} UnityWindowAttribute;
-
-typedef enum {
-   UNITY_WINDOW_TYPE_NONE   = -1,
-   UNITY_WINDOW_TYPE_NORMAL = 0,
-   UNITY_WINDOW_TYPE_PANEL,
-   UNITY_WINDOW_TYPE_DIALOG,
-   UNITY_WINDOW_TYPE_MENU,
-   UNITY_WINDOW_TYPE_TOOLTIP,
-   UNITY_WINDOW_TYPE_SPLASH,
-   UNITY_WINDOW_TYPE_TOOLBAR,
-   UNITY_WINDOW_TYPE_DOCK,
-   UNITY_WINDOW_TYPE_DESKTOP,
-   UNITY_WINDOW_TYPE_COMBOBOX,
-   UNITY_WINDOW_TYPE_WIDGET,
-
-   UNITY_MAX_WINDOW_TYPES  // Not a valid window type
-} UnityWindowType;
-
-typedef enum {
-   UNITY_ICON_TYPE_MAIN = 0,
-
-   UNITY_MAX_ICONS // Not a valid icon type
-} UnityIconType;
-
-typedef uint32 UnityIconSize; // Number of pixels on the larger side of the icon (which is usually square anyways).
-#define UNITY_MAX_ICON_DATA_CHUNK ((1 << 16) - 100) // 64k, minus space for a few other return values
-
-#define UNITY_DEFAULT_COLOR "#c0c0c0"
-
 #endif
index f67f0fd09eb74bac57419774d112ee0c4dd22006..2cb40240b25b28329a01b8176735f4c67493bc9b 100644 (file)
@@ -60,8 +60,15 @@ enum {
    VIX_HANDLETYPE_METADATA_CONTAINER   = 11
 };
 
+/*
+ * The "//{{ Begin VIX_ERROR  }}" and "//{{ End VIX_ERROR }}" lines are
+ * to bracket the error code definitions that will be copied over
+ * to vixDiskLib.h during build time. If you modify these two lines, please
+ * make sure you also change bora/lib/distribute/vixDiskLib.h and
+ * bora/support/scripts/replaceVixErrors.py
+ */
 
-
+// {{ Begin VIX_ERROR }}
 /*
  * An error is a 64-bit value. If there is no error, then the value is
  * set to VIX_OK. If there is an error, then the least significant bits
@@ -293,6 +300,7 @@ enum {
    VIX_E_TOOLS_INSTALL_GUEST_NOT_READY          = 21007,
    VIX_E_TOOLS_INSTALL_SIG_CHECK_FAILED         = 21008,
    VIX_E_TOOLS_INSTALL_ERROR                    = 21009,
+   VIX_E_TOOLS_INSTALL_ALREADY_UP_TO_DATE       = 21010,
 
    /* Wrapper Errors */
    VIX_E_WRAPPER_WORKSTATION_NOT_INSTALLED      = 22001,
@@ -300,6 +308,8 @@ enum {
    VIX_E_WRAPPER_SERVICEPROVIDER_NOT_FOUND      = 22003,
 };
 
+// {{ End VIX_ERROR }}
+
 const char *Vix_GetErrorText(VixError err, const char *locale);
 
 
index 5fecac0451e774b8b450395e21537e8c69666e21..763604b86d99b17bb656c773478ee95daee7306f 100644 (file)
@@ -1417,6 +1417,39 @@ Atomic_ReadDec64(Atomic_uint64 *var) // IN
 #endif
 
 
+#ifdef VMKERNEL
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CMPXCHG1B --
+ *
+ *      Compare and exchange a single byte.
+ *
+ * Results:
+ *      The value read from ptr.
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+static INLINE uint8
+CMPXCHG1B(volatile uint8 *ptr, // IN
+          uint8 oldVal,        // IN
+          uint8 newVal)        // IN
+{
+   uint8 val;
+   __asm__ __volatile__("lock; cmpxchgb %b2, %1"
+                        : "=a" (val),
+                          "+m" (*ptr)
+                        : "r" (newVal),
+                          "0" (oldVal)
+                        : "cc");
+   return val;
+}
+#endif
+
+
 /*
  * Usage of this helper struct is strictly reserved to the following
  * function. --hpreg
index 46a8f752641cebdccd13b12a1f908b27e262f1b9..c4b9bbda006a159801ab771d1796fa63c30a1cc2 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 883a7b90938577481ca033a3a8d28c8745cfdd09..e499e9848b71d65c82a1e1c18e71fc02a4ffeee4 100644 (file)
 #include "vm_version.h"
 
 
-/* XXX: Sadly, the legalese is replicated in:
- * apps/acesc-config/html/about.html
- * apps/acesc-config/js/ascc_pagestr_en.js
- * apps/acesc-config/js/ascc_pagestr_ja.js
- * apps/lib/foundry/doc/copyright.html
- * apps/lib/foundry/doc/Server_C_API_Preview_Programming_Manual.html
- * apps/vcb/README
- * apps/scripts/perlAPI-samplecode/VmPerl_samples/README.txt
- * apps/vixDiskLib/doc/copyright.html
- * and in a whole bunch of Mac OS files for different locales that I'm not
- * going to enumerate here.
- *
- * Note about the newlines: Keep at most 6 patents per line, but be careful
- * with the last line which will have "; patents pending" appended.
- */
-#define COPYRIGHT_YEARS    "1998-2008"
+#define COPYRIGHT_YEARS    "1998-2009"
 #define COPYRIGHT_STRING   "Copyright \251 " COPYRIGHT_YEARS " " COMPANY_NAME
 #define UTF8_COPYRIGHT_STRING   "Copyright \302\251 " COPYRIGHT_YEARS " " COMPANY_NAME
 #define GENERIC_COPYRIGHT_STRING   "Copyright (C) " COPYRIGHT_YEARS " " COMPANY_NAME
 #define RIGHT_RESERVED     "All rights reserved."
-#define PATENTS_LIST       "6,397,242, 6,496,847, 6,704,925, 6,711,672, 6,725,289, 6,735,601,\n6,785,886, 6,789,156, 6,795,966, 6,880,022, 6,944,699, 6,961,806,\n6,961,941, 7,069,413, 7,082,598, 7,089,377, 7,111,086, 7,111,145,\n7,117,481, 7,149,843, 7,155,558, 7,222,221, 7,260,815, 7,260,820,\n7,269,683, 7,275,136, 7,277,998, 7,277,999, 7,278,030, 7,281,102,\n7,290,253, 7,356,679, 7,409,487, 7,412,492, 7,412,702, 7,424,710\n"
-#define PATENTS_LAST       "7,428,636"
-#define PATENTS_STRING     "Protected by one or more U.S. Patent Nos.\n" PATENTS_LIST "and " PATENTS_LAST "; patents pending."
+
+/*
+ * Note about the newlines: Keep at most 6 patents per line, but be careful
+ * with the last line which will have "; patents pending" appended.
+ *
+ * Deprecated.  Don't use these anymore.
+ */
+#define PATENTS_LIST "6,075,938, 6,397,242, 6,496,847, 6,704,925, 6,711,672, 6,725,289,\n6,735,601, 6,785,886, 6,789,156, 6,795,966, 6,880,022, 6,944,699,\n6,961,806, 6,961,941, 7,069,413, 7,082,598, 7,089,377, 7,111,086,\n7,111,145, 7,117,481, 7,149,843, 7,155,558, 7,222,221, 7,260,815,\n7,260,820, 7,269,683, 7,275,136, 7,277,998, 7,277,999, 7,278,030,\n7,281,102, 7,290,253, 7,356,679, 7,409,487, 7,412,492, 7,412,702,\n7,424,710, 7,428,636, 7,433,951, 7,434,002, 7,447,854"
+#define PATENTS_STRING_OLD "Protected by one or more U.S. Patent Nos.\n" PATENTS_LIST " and patents pending."
+
+/*
+ * Use PATENTS_STRING for showing the patents string in plaintext form.
+ * PATENTS_FMT_STRING can be used with PATENTS_URL for creating hyperlinks.
+ */
+#define PATENTS_STRING_BASE "This product is protected by U.S. and international copyright and\nintellectual property laws. This product is covered by one or more\npatents listed at "
+#define PATENTS_STRING PATENTS_STRING_BASE "<" PATENTS_URL ">."
+#define PATENTS_FMT_STRING PATENTS_STRING_BASE "%s."
+#define PATENTS_URL "http://www.vmware.com/go/patents"
+
 #define TRADEMARK_STRING   "VMware, the VMware \"boxes\" logo and design, Virtual SMP and VMotion are\nregistered trademarks or trademarks of VMware, Inc. in the United States\nand/or other jurisdictions."
 #define GENERIC_TRADEMARK_STRING "All other marks and names mentioned herein may be trademarks of their\nrespective companies."
 
index db3ea74212fcb238177e2266af428505e50ab5de..112304e37e53f839d05fd1ad133dc16bc4e208c4 100644 (file)
@@ -709,6 +709,13 @@ typedef uint32 ToolsVersion;
 #define   TOOLS_VERSION_ESX310_UPDATE1_V_MNR     4
 #define   TOOLS_VERSION_ESX310_UPDATE1_V_BASE    4
 
+#ifndef RC_INVOKED
+#define   TOOLS_VERSION_ESX310_UPDATE2     TOOLS_VERSION_TO_UINT(TOOLS_VERSION_ESX310_UPDATE2_V)
+#endif /* RC_INVOKED */
+#define   TOOLS_VERSION_ESX310_UPDATE2_V_MJR     7
+#define   TOOLS_VERSION_ESX310_UPDATE2_V_MNR     4
+#define   TOOLS_VERSION_ESX310_UPDATE2_V_BASE    6
+
 #ifndef RC_INVOKED
 #define   TOOLS_VERSION_SERVER20_FF     TOOLS_VERSION_TO_UINT(TOOLS_VERSION_SERVER20_FF_V)
 #endif /* RC_INVOKED */
index 3f332bd2ff48f997e74c050f7de995d969bf46eb..03f16f88d7c7eb283dbe5c3aeab10b7407c345d2 100644 (file)
 #if defined(VMX86_DESKTOP)
    #define PRODUCT_VERSION    6,5,0,PRODUCT_BUILD_NUMBER_NUMERIC
 #elif defined(VMX86_TOOLS)
-   #define PRODUCT_VERSION    TOOLS_VERSION_CURRENT_CSV,PRODUCT_BUILD_NUMBER_NUMERIC
+   #define PRODUCT_VERSION    TOOLS_VERSION_EXT_CURRENT_CSV
 #elif defined(VMX86_VCB)
    #define PRODUCT_VERSION    1,0,0,PRODUCT_BUILD_NUMBER_NUMERIC
 #else
 #define PLAYER_VERSION "e.x.p"
 #define V2V_VERSION "e.x.p"
 #define V2V_FILE_VERSION 1,0,0,0
+#define FUSION_VERSION "2.0"
 
 // These must match VIE_FILEVERSION above
 #define SYSIMAGE_VERSION "4.0.0"
         VMRC_PLUGIN_VERSION_MAJOR,VMRC_PLUGIN_VERSION_MINOR,0,PRODUCT_BUILD_NUMBER_NUMERIC
 
 /*
- * When setting the Tools product version, please use the string corresponding
- * to TOOLS_VERSION_CURRENT_STR from vm_tools_version.h.
- *
- * XXX: The extract-macro script should be updated to handle this special case.
+ * The current Tools version, derived from vm_tools_version.h. Do not modify this.
  */
-#define TOOLS_VERSION "2008.11.18"
+#define TOOLS_VERSION "2008.12.23"
 
 #ifdef VMX86_VPX
 #define VIM_API_TYPE "VirtualCenter"
diff --git a/open-vm-tools/lib/include/vmtools.h b/open-vm-tools/lib/include/vmtools.h
new file mode 100644 (file)
index 0000000..b33e637
--- /dev/null
@@ -0,0 +1,140 @@
+/*********************************************************
+ * Copyright (C) 2008 VMware, Inc. All rights reserved.
+ *
+ * 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 the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+#ifndef _VMTOOLS_H_
+#define _VMTOOLS_H_
+
+/**
+ * @file vmtools.h
+ *
+ *    Public functions from the VMTools shared library.
+ *
+ * @addtogroup vmtools_utils
+ * @{
+ */
+
+#if !defined(G_LOG_DOMAIN)
+#  define G_LOG_DOMAIN VMTools_GetDefaultLogDomain()
+#endif
+
+#define  VMTOOLS_GUEST_SERVICE   "vmsvc"
+#define  VMTOOLS_USER_SERVICE    "vmusr"
+
+/* Needs to come before glib.h. */
+const char *
+VMTools_GetDefaultLogDomain(void);
+
+#include <glib.h>
+#if defined(G_PLATFORM_WIN32)
+#  include <windows.h>
+#else
+#  include <signal.h>
+#  include <sys/time.h>
+#endif
+
+/**
+ * Converts an UTF-8 path to the local (i.e., glib) file name encoding.
+ * This is a no-op on Windows, since the local encoding is always UTF-8
+ * in glib. The returned value should not be freed directly; instead,
+ * use VMTOOLS_FREE_FILENAME.
+ *
+ * @param[in]  path  Path in UTF-8 (should not be NULL).
+ * @param[out] err   Where to store errors (type: GError **; may be NULL).
+ *
+ * @return The path in glib's filename encoding, or NULL on error.
+ */
+
+#if defined(G_PLATFORM_WIN32)
+#  define VMTOOLS_GET_FILENAME_LOCAL(path, err) (gchar *) (path)
+#else
+#  define VMTOOLS_GET_FILENAME_LOCAL(path, err) g_filename_from_utf8((path),  \
+                                                                     -1,      \
+                                                                     NULL,    \
+                                                                     NULL,    \
+                                                                     (err))
+#endif
+
+/**
+ * Frees a path allocated with VMTOOLS_GET_FILENAME_LOCAL. No-op on Windows.
+ *
+ * @param[in]  path  Path in UTF-8.
+ */
+
+#if defined(G_PLATFORM_WIN32)
+#  define VMTOOLS_RELEASE_FILENAME_LOCAL(path)   (void) (path)
+#else
+#  define VMTOOLS_RELEASE_FILENAME_LOCAL(path)   g_free(path)
+#endif
+
+
+void
+vm_free(void *ptr);
+
+void
+VMTools_SetDefaultLogDomain(const gchar *domain);
+
+void
+VMTools_ConfigLogging(GKeyFile *cfg);
+
+void
+VMTools_EnableLogging(gboolean enable);
+
+gchar *
+VMTools_GetToolsConfFile(void);
+
+GKeyFile *
+VMTools_LoadConfig(const gchar *path,
+                   GKeyFileFlags flags,
+                   gboolean autoUpgrade);
+
+
+gboolean
+VMTools_ReloadConfig(const gchar *path,
+                     GKeyFileFlags flags,
+                     GKeyFile **config,
+                     time_t *mtime);
+
+gboolean
+VMTools_WriteConfig(const gchar *path,
+                    GKeyFile *config,
+                    GError **err);
+
+#if defined(G_PLATFORM_WIN32)
+
+GSource *
+VMTools_NewHandleSource(HANDLE h);
+
+#else
+
+/** Type of callback used by the signal event source. */
+typedef gboolean (*SignalSourceCb)(const siginfo_t *, gpointer);
+
+GSource *
+VMTools_NewSignalSource(int signum);
+
+#endif
+
+GArray *
+VMTools_WrapArray(gconstpointer data,
+                  guint elemSize,
+                  guint count);
+
+/** @} */
+
+#endif /* _VMTOOLS_H_ */
+
index 924dec43539afe87efa4d212e0916903d0ddbe94..1c2aa4f548883ed162e452d09a738377de27f8b1 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libMessage.a
+noinst_LTLIBRARIES = libMessage.la
 
-libMessage_a_SOURCES =
-libMessage_a_SOURCES += message.c
-libMessage_a_SOURCES += messageBackdoor.c
-libMessage_a_SOURCES += messageStub.c
+libMessage_la_SOURCES =
+libMessage_la_SOURCES += message.c
+libMessage_la_SOURCES += messageBackdoor.c
+libMessage_la_SOURCES += messageStub.c
 
-SUBDIRS =
-SUBDIRS += shared
diff --git a/open-vm-tools/lib/message/shared/Makefile.am b/open-vm-tools/lib/message/shared/Makefile.am
deleted file mode 100644 (file)
index b07d6cd..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-### Copyright 2007 VMware, Inc.  All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-################################################################################
-
-noinst_LTLIBRARIES = libMessage.la
-
-libMessage_la_SOURCES =
-libMessage_la_SOURCES += ../message.c
-libMessage_la_SOURCES += ../messageBackdoor.c
-libMessage_la_SOURCES += ../messageStub.c
index 9669a910064017027228543b6a8d9d7603f22cbb..b04abaf9bd02a83d88778ec4ed12072691d6f212 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libMisc.a
+noinst_LTLIBRARIES = libMisc.la
 
-libMisc_a_SOURCES =
-libMisc_a_SOURCES += atomic.c
-libMisc_a_SOURCES += base64.c
-libMisc_a_SOURCES += codesetOld.c
-libMisc_a_SOURCES += dbllnklst.c
-libMisc_a_SOURCES += dynarray.c
-libMisc_a_SOURCES += dynbuf.c
-libMisc_a_SOURCES += escape.c
-libMisc_a_SOURCES += hashTable.c
-libMisc_a_SOURCES += hostinfo_misc.c
-libMisc_a_SOURCES += hostname.c
-libMisc_a_SOURCES += idLinux.c
-libMisc_a_SOURCES += iovector.c
-libMisc_a_SOURCES += machineID.c
-libMisc_a_SOURCES += miscSolaris.c
-libMisc_a_SOURCES += posixDlopen.c
-libMisc_a_SOURCES += posixPosix.c
-libMisc_a_SOURCES += random.c
-libMisc_a_SOURCES += timeutil.c
-libMisc_a_SOURCES += util_misc.c
-libMisc_a_SOURCES += vmstdio.c
-libMisc_a_SOURCES += strutil.c
+libMisc_la_SOURCES =
+libMisc_la_SOURCES += atomic.c
+libMisc_la_SOURCES += base64.c
+libMisc_la_SOURCES += codesetOld.c
+libMisc_la_SOURCES += dbllnklst.c
+libMisc_la_SOURCES += dynarray.c
+libMisc_la_SOURCES += dynbuf.c
+libMisc_la_SOURCES += escape.c
+libMisc_la_SOURCES += hashTable.c
+libMisc_la_SOURCES += hostinfo_misc.c
+libMisc_la_SOURCES += hostname.c
+libMisc_la_SOURCES += idLinux.c
+libMisc_la_SOURCES += iovector.c
+libMisc_la_SOURCES += machineID.c
+libMisc_la_SOURCES += miscSolaris.c
+libMisc_la_SOURCES += posixDlopen.c
+libMisc_la_SOURCES += posixPosix.c
+libMisc_la_SOURCES += random.c
+libMisc_la_SOURCES += timeutil.c
+libMisc_la_SOURCES += util_misc.c
+libMisc_la_SOURCES += vmstdio.c
+libMisc_la_SOURCES += strutil.c
 
 if HAVE_ICU
-libMisc_a_SOURCES += codeset.c
+libMisc_la_SOURCES += codeset.c
 endif
 
 AM_CFLAGS = @LIB_MISC_CPPFLAGS@
 
-SUBDIRS =
-SUBDIRS += shared
index 9751a67d7822f1b251de2e61c1ba4db7f6b3a4eb..8946da2c78eef53487e04b724e7152ca8233c39a 100644 (file)
@@ -450,11 +450,15 @@ Base64_DecodedLength(char const *src, size_t srcLength) {
    ASSERT(src);
 
    length = srcLength / 4 * 3;
-   if (src[srcLength-1] == '=') {
-      length--;
-   }
-   if (src[srcLength-2] == '=') {
-      length--;
+   // PR 303173 - do the following check to avoid a negative value returned
+   // from this function. Note: length can only be in a multiple of 3
+   if (length > 2) {
+      if (src[srcLength-1] == '=') {
+         length--;
+      }
+      if (src[srcLength-2] == '=') {
+         length--;
+      }
    }
    return length;
 }
index d439cc6594d65d3a206915ab8195336898d441e1..e03250af68b02876a725b48f5aeaeee1ca5445b4 100644 (file)
@@ -1415,11 +1415,13 @@ CodeSet_Utf8FormDToUtf8FormC(const char *bufIn,     // IN
    }
 
 #if defined(__APPLE__)
-   DynBuf db;
-   Bool ok;
-   DynBuf_Init(&db);
-   ok = CodeSet_Utf8Normalize(bufIn, sizeIn, TRUE, &db);
-   return CodeSetDynBufFinalize(ok, &db, bufOut, sizeOut);
+   {
+      DynBuf db;
+      Bool ok;
+      DynBuf_Init(&db);
+      ok = CodeSet_Utf8Normalize(bufIn, sizeIn, TRUE, &db);
+      return CodeSetDynBufFinalize(ok, &db, bufOut, sizeOut);
+   }
 #else
    NOT_IMPLEMENTED();
 #endif
@@ -1462,11 +1464,13 @@ CodeSet_Utf8FormCToUtf8FormD(const char *bufIn,     // IN
    }
 
 #if defined(__APPLE__)
-   DynBuf db;
-   Bool ok;
-   DynBuf_Init(&db);
-   ok = CodeSet_Utf8Normalize(bufIn, sizeIn, FALSE, &db);
-   return CodeSetDynBufFinalize(ok, &db, bufOut, sizeOut);
+   {
+      DynBuf db;
+      Bool ok;
+      DynBuf_Init(&db);
+      ok = CodeSet_Utf8Normalize(bufIn, sizeIn, FALSE, &db);
+      return CodeSetDynBufFinalize(ok, &db, bufOut, sizeOut);
+   }
 #else
    NOT_IMPLEMENTED();
 #endif
index 6e5c7748509ed123debeccddfec1bb6e7e401726..730d22389af0e2f62df7dc465e06f2ea4bb6f386 100644 (file)
@@ -81,6 +81,7 @@ DynBuf_Destroy(DynBuf *b) // IN
 
    free(b->data);
    b->data = NULL;
+   b->allocated = 0;
 }
 
 
@@ -164,6 +165,7 @@ DynBuf_Attach(DynBuf *b,    // IN
               void *data)   // IN
 {
    ASSERT(b);
+   ASSERT((size == 0) == (data == NULL));
 
    free(b->data);
    b->data = data;
@@ -197,6 +199,7 @@ DynBuf_Detach(DynBuf *b) // IN
 
    data = b->data;
    b->data = NULL;
+   b->allocated = 0;
 
    return data;
 }
@@ -227,10 +230,24 @@ DynBufRealloc(DynBuf *b,            // IN
 
    ASSERT(b);
 
-   new_data = realloc(b->data, new_allocated);
-   if (new_data == NULL) {
-      /* Not enough memory */
-      return FALSE;
+   if (b->data != NULL && new_allocated != 0) {
+      new_data = realloc(b->data, new_allocated);
+      if (new_data == NULL) {
+         /* Not enough memory */
+         return FALSE;
+      }
+   } else {
+      free(b->data);
+      if (new_allocated != 0) {
+         new_data = malloc(new_allocated);
+         if (new_data == NULL) {
+            /* Not enough memory */
+            return FALSE;
+         }
+      } else {
+         /* We now have no buffer. */
+         new_data = NULL;
+      }
    }
 
    b->data = new_data;
index 334bb276d275b35ee7744ac3f30198f3ac4de996..83383da5603e0cdf4ea833c8415b326bf43d2557 100644 (file)
@@ -70,8 +70,8 @@
 #define VM_SYSTEM_HAS_GETGRNAM_R 1
 #endif
 
-# if defined(__FreeBSD__) && __FreeBSD_version >= 503000
-#  include <syslimits.h>  // PATH_MAX
+# if defined(__FreeBSD__)
+#  include <sys/syslimits.h>  // PATH_MAX
 # else
 #  include <limits.h>  // PATH_MAX
 # endif
index 492b4e15dcdfc4c9ccb15f56aa24de8926e0bece..5554d18a23c34d90ef09c76d96705cd270767b5f 100644 (file)
@@ -92,8 +92,16 @@ Random_Crypto(unsigned int size, // IN
    /*
     * We use /dev/urandom and not /dev/random because it is good enough and
     * because it cannot block. --hpreg
+    *
+    * Bug 352496: On ESX, /dev/urandom is proxied into COS, and hence is
+    * expensive. The VMkernel RNG is available through VMFS and is not proxied.
+    * So we use that instead.
     */
+#ifdef VMX86_SERVER
+   fd = open("/vmfs/devices/char/vmkdriver/urandom", O_RDONLY);
+#else
    fd = open("/dev/urandom", O_RDONLY);
+#endif
    if (fd < 0) {
       error = errno;
       Log("Random_Crypto: Failed to open: %d\n", error);
diff --git a/open-vm-tools/lib/misc/shared/Makefile.am b/open-vm-tools/lib/misc/shared/Makefile.am
deleted file mode 100644 (file)
index cac3582..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-################################################################################
-### Copyright 2007 VMware, Inc.  All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-################################################################################
-
-noinst_LTLIBRARIES = libMisc.la
-
-libMisc_la_SOURCES =
-libMisc_la_SOURCES += ../atomic.c
-libMisc_la_SOURCES += ../base64.c
-libMisc_la_SOURCES += ../codesetOld.c
-libMisc_la_SOURCES += ../dbllnklst.c
-libMisc_la_SOURCES += ../dynarray.c
-libMisc_la_SOURCES += ../dynbuf.c
-libMisc_la_SOURCES += ../escape.c
-libMisc_la_SOURCES += ../hashTable.c
-libMisc_la_SOURCES += ../hostinfo_misc.c
-libMisc_la_SOURCES += ../hostname.c
-libMisc_la_SOURCES += ../idLinux.c
-libMisc_la_SOURCES += ../iovector.c
-libMisc_la_SOURCES += ../machineID.c
-libMisc_la_SOURCES += ../miscSolaris.c
-libMisc_la_SOURCES += ../posixDlopen.c
-libMisc_la_SOURCES += ../posixPosix.c
-libMisc_la_SOURCES += ../random.c
-libMisc_la_SOURCES += ../timeutil.c
-libMisc_la_SOURCES += ../util_misc.c
-libMisc_la_SOURCES += ../vmstdio.c
-
-if HAVE_ICU
-libMisc_la_SOURCES += ../codeset.c
-endif
-
-AM_CFLAGS = @LIB_MISC_CPPFLAGS@
index a1f1d7526d8271e4b8b2bf03e4a45f0faa970d1c..6a0434fdff2651730e994a8b9914a050d04cd92f 100644 (file)
@@ -15,9 +15,8 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libNetUtil.a
+noinst_LTLIBRARIES = libNetUtil.la
 
-libNetUtil_a_SOURCES =
-libNetUtil_a_SOURCES += netUtilLinux.c
-AM_CFLAGS = -I$(top_builddir)/include
+libNetUtil_la_SOURCES =
+libNetUtil_la_SOURCES += netUtilLinux.c
 
index c9df33150962a0dfce746b102b9b0cb2add513e2..4e6ec382735da7c6b5e90c4347904aa14ea99c9c 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libPanic.a
+noinst_LTLIBRARIES = libPanic.la
 
-libPanic_a_SOURCES =
-libPanic_a_SOURCES += panic.c
+libPanic_la_SOURCES =
+libPanic_la_SOURCES += panic.c
index 244474093d465227e8294f9d8c793e3985d69dfa..11cbf3a7129fe99f3112b91d0e39d4d4d716d815 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libPanicDefault.a
+noinst_LTLIBRARIES = libPanicDefault.la
 
-libPanicDefault_a_SOURCES =
-libPanicDefault_a_SOURCES += panic.c
+libPanicDefault_la_SOURCES =
+libPanicDefault_la_SOURCES += panic.c
index 8a9494d62906050478acda8a60c134f3d8df634c..1ff9b92131378b5f9a5e87c6f02f2d2a1d0fe332 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libPrinter.a
+noinst_LTLIBRARIES = libPrinter.la
 
-libPrinter_a_SOURCES =
-libPrinter_a_SOURCES += printer.c
+libPrinter_la_SOURCES =
+libPrinter_la_SOURCES += printer.c
index 5547f14aec19ecbe25ca300a7640de80f7f1876b..4b4c3d9a433691ae2aec47c9c32ce3b741b5a039 100644 (file)
@@ -15,9 +15,9 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libProcMgr.a
+noinst_LTLIBRARIES = libProcMgr.la
 
-libProcMgr_a_SOURCES =
-libProcMgr_a_SOURCES += procMgrPosix.c
+libProcMgr_la_SOURCES =
+libProcMgr_la_SOURCES += procMgrPosix.c
 
 AM_CFLAGS = @LIB_PROC_MGR_CPPFLAGS@
index 4321a83750802a1de04839fd79ec217dcbb8512c..e1109ac549a985f55acd1e3ea2742269d0052830 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libRaster.a
+noinst_LTLIBRARIES = libRaster.la
 
-libRaster_a_SOURCES =
-libRaster_a_SOURCES += rasterConv.c
+libRaster_la_SOURCES =
+libRaster_la_SOURCES += rasterConv.c
index b2b39703a85102414d05ed5f87875a8e5b0df542..366ee863083ff1d1b75d55ae5124cd1aabd0d6bd 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libRegion.a
+noinst_LTLIBRARIES = libRegion.la
 
-libRegion_a_SOURCES =
-libRegion_a_SOURCES += region.c
+libRegion_la_SOURCES =
+libRegion_la_SOURCES += region.c
index 05a9f2ea7b109b2df80d8151c76c5d434280d303..a146cdcf6484fa8a815c08f0e287b22f83ce94eb 100644 (file)
@@ -139,14 +139,14 @@ int miFindMaxBand(RegionPtr prgn);
  * the y1 to y2 area spanned by the band), then the rectangle may be broken
  * down into two or more smaller rectangles stacked one atop the other. 
  *
- *  -----------                                    -----------
- *  |         |                                    |         |             band 0
- *  |         |  --------                  -----------  --------
- *  |         |  |      |  in y-x banded    |         |  |      |   band 1
- *  |         |  |      |  form is         |         |  |      |
- *  -----------  |      |                  -----------  --------
- *               |      |                               |      |   band 2
- *               --------                               --------
+ *  -----------                              -----------
+ *  |         |                              |         |             band 0
+ *  |         |  --------                    -----------  --------
+ *  |         |  |      |  in y-x banded     |         |  |      |   band 1
+ *  |         |  |      |  form is           |         |  |      |
+ *  -----------  |      |                    -----------  --------
+ *               |      |                                 |      |   band 2
+ *               --------                                 --------
  *
  * An added constraint on the rectangles is that they must cover as much
  * horizontal area as possible: no two rectangles within a band are allowed
@@ -336,6 +336,10 @@ miPrintRegion(RegionPtr rgn)
                  rects[i].info.Present3d.sid,
                  rects[i].info.Present3d.srcx, rects[i].info.Present3d.srcy);
          break;
+      case LockRect:
+         Warning(" LockRect ");
+      case FenceRect:
+         Warning(" FenceRect fence: 0x%x", rects[i].info.Fence.fenceId);
       default:
          Warning(" UNKNOWN!");
          break;
@@ -375,6 +379,7 @@ miRectInfosEqual(RectInfo *info1,
 
    switch (info1->type) {
    case UpdateRect:
+   case LockRect:
       return TRUE;
    case ROPFillRect:
       return (info1->ROPFill.rop == info2->ROPFill.rop &&
@@ -383,6 +388,8 @@ miRectInfosEqual(RectInfo *info1,
       return (info1->Present3d.sid == info2->Present3d.sid &&
               info1->Present3d.srcx == info2->Present3d.srcx &&
               info1->Present3d.srcy == info2->Present3d.srcy);
+   case FenceRect:
+      return (info1->Fence.fenceId == info2->Fence.fenceId);
    default:
       NOT_IMPLEMENTED();
    }
index 1d65a59ce7046855e0b82f75f2d84e1e43cf57d1..35c65f5077e99d4a8198fcae3b7bc75200398bd6 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libResolution.a
+noinst_LTLIBRARIES = libResolution.la
 
 AM_CPPFLAGS =
 AM_CPPFLAGS += -DRESOLUTION_X11
 AM_CPPFLAGS += @GTK_CPPFLAGS@
 
-libResolution_a_SOURCES =
-libResolution_a_SOURCES += resolution.c
-libResolution_a_SOURCES += resolutionX11.c
-libResolution_a_SOURCES += libvmwarectrl.c
+libResolution_la_SOURCES =
+libResolution_la_SOURCES += resolution.c
+libResolution_la_SOURCES += resolutionX11.c
+libResolution_la_SOURCES += libvmwarectrl.c
index 24ab7ea9576325b614630f75dacf658d4556a0ff..6f8077d01fb7f8cc6574cc493c4ba716232e2c9e 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libRpcIn.a
+noinst_LTLIBRARIES = libRpcIn.la
 
-libRpcIn_a_SOURCES =
-libRpcIn_a_SOURCES += rpcin.c
+libRpcIn_la_SOURCES =
+libRpcIn_la_SOURCES += rpcin.c
index df50a0840c7ab0c6cf3e1899eab291e3f1e88706..c67137a9a8124f73ce8839e73eb28052fcf56e0a 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libRpcOut.a
+noinst_LTLIBRARIES = libRpcOut.la
 
-libRpcOut_a_SOURCES =
-libRpcOut_a_SOURCES += rpcout.c
+libRpcOut_la_SOURCES =
+libRpcOut_la_SOURCES += rpcout.c
 
-SUBDIRS =
-SUBDIRS += shared
diff --git a/open-vm-tools/lib/rpcOut/shared/Makefile.am b/open-vm-tools/lib/rpcOut/shared/Makefile.am
deleted file mode 100644 (file)
index 42818b1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-################################################################################
-### Copyright 2007 VMware, Inc.  All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-################################################################################
-
-noinst_LTLIBRARIES = libRpcOut.la
-
-libRpcOut_la_SOURCES =
-libRpcOut_la_SOURCES += ../rpcout.c
index aafe9dfc77de4d32d88ad13f3629319ec6692334..9d60367f09b60b4345bde63e9af79f586e882b0d 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libRpcVmx.a
+noinst_LTLIBRARIES = libRpcVmx.la
 
-libRpcVmx_a_SOURCES =
-libRpcVmx_a_SOURCES += rpcvmx.c
+libRpcVmx_la_SOURCES =
+libRpcVmx_la_SOURCES += rpcvmx.c
index 8f4a076d59a0372d5450f0e3a605051ae460617e..cb36a6ebcf995c0be2b439557f0c98990f764fac 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libSocketMgr.a
+noinst_LTLIBRARIES = libSocketMgr.la
 
-libSocketMgr_a_SOURCES =
-libSocketMgr_a_SOURCES += socketMgr.c
+libSocketMgr_la_SOURCES =
+libSocketMgr_la_SOURCES += socketMgr.c
index ccb03b08c26c1dba0e74bffaa2574b765f5b9e27..1edab81da2cbfcaf1ad7ae3f20ec037629c842ed 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libString.a
+noinst_LTLIBRARIES = libString.la
 
-libString_a_SOURCES =
-libString_a_SOURCES += bsd_output_shared.c
-libString_a_SOURCES += bsd_vsnprintf.c
-libString_a_SOURCES += bsd_vsnwprintf.c
-libString_a_SOURCES += convertutf.c
-libString_a_SOURCES += str.c
+libString_la_SOURCES =
+libString_la_SOURCES += bsd_output_shared.c
+libString_la_SOURCES += bsd_vsnprintf.c
+libString_la_SOURCES += bsd_vsnwprintf.c
+libString_la_SOURCES += convertutf.c
+libString_la_SOURCES += str.c
 
 AM_CFLAGS = @LIB_STRING_CPPFLAGS@
 
-SUBDIRS =
-SUBDIRS += shared
diff --git a/open-vm-tools/lib/string/shared/Makefile.am b/open-vm-tools/lib/string/shared/Makefile.am
deleted file mode 100644 (file)
index 0be013b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-################################################################################
-### Copyright 2007 VMware, Inc.  All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-################################################################################
-
-noinst_LTLIBRARIES = libString.la
-
-libString_la_SOURCES =
-libString_la_SOURCES += ../bsd_output_shared.c
-libString_la_SOURCES += ../bsd_vsnprintf.c
-libString_la_SOURCES += ../bsd_vsnwprintf.c
-libString_la_SOURCES += ../convertutf.c
-libString_la_SOURCES += ../str.c
-
-AM_CFLAGS = @LIB_STRING_CPPFLAGS@
index 6096c2260ef7ae09f2796ff58647e424895fb831..b83b56881dfadb3ef389ca8871500a53f34cad3d 100644 (file)
@@ -248,6 +248,41 @@ Str_Strcpy(char *buf,       // OUT
    return memcpy(buf, src, len + 1);
 }
 
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Str_Strlen --
+ *
+ *      Calculate length of the string.
+ *
+ * Results:
+ *      Length of s not including the terminating '\0' character. 
+ *      If there is no '\0' for first maxLen bytes, then it
+ *      returns maxLen.
+ *
+ * Side Effects:
+ *      None
+ *
+ *----------------------------------------------------------------------
+ */
+
+size_t
+Str_Strlen(const char *s,      // IN 
+          size_t maxLen)       // IN
+
+{
+   const char *end;
+
+   ASSERT(s != NULL);
+
+   if ((end = memchr(s, '\0', maxLen)) == NULL) {
+      return maxLen;
+   } 
+   return end - s;
+}
+
+
 /*
  *----------------------------------------------------------------------
  *
index a8f29e9faed88254c4a054fd081f883b856bbd50..2965aa9a11a878311e13fbeef5426231d4792b7e 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libStubs.a
+noinst_LTLIBRARIES = libStubs.la
 
-libStubs_a_SOURCES =
-libStubs_a_SOURCES += stub-config.c
-libStubs_a_SOURCES += stub-log.c
-libStubs_a_SOURCES += stub-warning.c
-libStubs_a_SOURCES += stub-user-msg.c
-libStubs_a_SOURCES += stub-user-panic.c
+libStubs_la_SOURCES =
+libStubs_la_SOURCES += stub-config.c
+libStubs_la_SOURCES += stub-log.c
+libStubs_la_SOURCES += stub-warning.c
+libStubs_la_SOURCES += stub-user-msg.c
+libStubs_la_SOURCES += stub-user-panic.c
 
-SUBDIRS =
-SUBDIRS += shared
+if ENABLE_CORE_SERVICES
+noinst_LTLIBRARIES += libStubsCS.la
+
+libStubsCS_la_SOURCES =
+libStubsCS_la_SOURCES += stub-config.c
+libStubsCS_la_SOURCES += stub-user-msg.c
+libStubsCS_la_SOURCES += stub-user-panic.c
+endif
 
diff --git a/open-vm-tools/lib/stubs/shared/Makefile.am b/open-vm-tools/lib/stubs/shared/Makefile.am
deleted file mode 100644 (file)
index 1caf14f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-################################################################################
-### Copyright 2008 VMware, Inc.  All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-################################################################################
-
-noinst_LTLIBRARIES = libStubs.la
-
-libStubs_la_SOURCES =
-libStubs_la_SOURCES += ../stub-config.c
-libStubs_la_SOURCES += ../stub-log.c
-libStubs_la_SOURCES += ../stub-warning.c
-libStubs_la_SOURCES += ../stub-user-msg.c
-libStubs_la_SOURCES += ../stub-user-panic.c
-
index 3034297c626375ba391571bfb01a2817431838a6..ccb7495ea1ac86546b2dbcbba5ca0f3d4bda7a70 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libSync.a
+noinst_LTLIBRARIES = libSync.la
 
-libSync_a_SOURCES =
-libSync_a_SOURCES += syncMutex.c
-libSync_a_SOURCES += syncWaitQPosix.c
+libSync_la_SOURCES =
+libSync_la_SOURCES += syncMutex.c
+libSync_la_SOURCES += syncWaitQPosix.c
 
-SUBDIRS =
-SUBDIRS += shared
diff --git a/open-vm-tools/lib/sync/shared/Makefile.am b/open-vm-tools/lib/sync/shared/Makefile.am
deleted file mode 100644 (file)
index d9440ac..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-################################################################################
-### Copyright 2007 VMware, Inc.  All rights reserved.
-###
-### This program is free software; you can redistribute it and/or modify
-### it under the terms of version 2 of the GNU General Public License as
-### published by the Free Software Foundation.
-###
-### This program is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-### GNU General Public License for more details.
-###
-### You should have received a copy of the GNU General Public License
-### along with this program; if not, write to the Free Software
-### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-################################################################################
-
-noinst_LTLIBRARIES = libSync.la
-
-libSync_la_SOURCES =
-libSync_la_SOURCES += ../syncMutex.c
-libSync_la_SOURCES += ../syncWaitQPosix.c
index b46cf2382061674f58001ecd5ddb2467e85b000e..9c8d22a0a5eb9ba07fb3c6617c9dd221637c9620 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libSyncDriver.a
+noinst_LTLIBRARIES = libSyncDriver.la
 
-libSyncDriver_a_SOURCES =
-libSyncDriver_a_SOURCES += syncDriverPosix.c
+libSyncDriver_la_SOURCES =
+libSyncDriver_la_SOURCES += syncDriverPosix.c
index aef90b409305146bf03871d790d02de548d8fe6b..d3977131223fa5caed7da3793bde0dd9fb45caa3 100644 (file)
@@ -15,6 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libSystem.a
+noinst_LTLIBRARIES = libSystem.la
 
-libSystem_a_SOURCES = systemLinux.c
+libSystem_la_SOURCES =
+libSystem_la_SOURCES += systemLinux.c
index dd31847042303b173d48451c166456b38f8d836b..41f9615d35771368334765dfa99d683d4a7fb882 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libToolsLogger.a
+noinst_LTLIBRARIES = libToolsLogger.la
 
-libToolsLogger_a_SOURCES =
-libToolsLogger_a_SOURCES += logger.c
+libToolsLogger_la_SOURCES =
+libToolsLogger_la_SOURCES += logger.c
index f6938816816a97e714e28d8916a4e46a663fce50..a8c23af313f993d5741c3f4661ad709b974ccc31 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libUnicode.a
+noinst_LTLIBRARIES = libUnicode.la
 
-libUnicode_a_SOURCES =
-libUnicode_a_SOURCES += unicodeCommon.c
-libUnicode_a_SOURCES += unicodeSimpleBase.c
-libUnicode_a_SOURCES += unicodeSimpleCaseFolding.c
-libUnicode_a_SOURCES += unicodeSimpleTypes.c
-libUnicode_a_SOURCES += unicodeSimpleOperations.c
-libUnicode_a_SOURCES += unicodeSimpleTransforms.c
-libUnicode_a_SOURCES += unicodeStatic.c
+libUnicode_la_SOURCES =
+libUnicode_la_SOURCES += unicodeCommon.c
+libUnicode_la_SOURCES += unicodeSimpleBase.c
+libUnicode_la_SOURCES += unicodeSimpleCaseFolding.c
+libUnicode_la_SOURCES += unicodeSimpleTypes.c
+libUnicode_la_SOURCES += unicodeSimpleOperations.c
+libUnicode_la_SOURCES += unicodeSimpleTransforms.c
+libUnicode_la_SOURCES += unicodeStatic.c
 
 if HAVE_ICU
-libUnicode_a_SOURCES += unicodeICU.c
+libUnicode_la_SOURCES += unicodeICU.c
 endif
index 5b236616553d99ef05f803e6cee90403fe92699b..87f77bbaa48a5d0de2df156b22b918c4c5b65f1f 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libUnity.a
+noinst_LTLIBRARIES = libUnity.la
 
-libUnity_a_SOURCES =
-libUnity_a_SOURCES += unity.c
-libUnity_a_SOURCES += unityPlatformX11.c
-libUnity_a_SOURCES += unityPlatformX11Settings.c
-libUnity_a_SOURCES += unityPlatformX11Window.c
+libUnity_la_SOURCES =
+libUnity_la_SOURCES += unity.c
+libUnity_la_SOURCES += unityPlatformX11.c
+libUnity_la_SOURCES += unityPlatformX11Settings.c
+libUnity_la_SOURCES += unityPlatformX11Window.c
 
 AM_CFLAGS = @GTK_CPPFLAGS@
 AM_CFLAGS += @LIB_FILE_CPPFLAGS@
index f0d129ecc597658e1f8925a96273baaa18174288..b72922b99d31da892a54a05abe37bfe20662663d 100644 (file)
  *
  *********************************************************/
 
-/*
- * Unity.c --
- *
- *    Unity window manager intergration tools service.
- *
- *    RPC Usage:
- *       unity.get.update [incremental]
- *
- *    The tools service response to requests for windows events via the
- *    "unity.get.update" RPC from the host.  Upon receiving the RPC, the
- *    service will crawl the window manager, taking note of the positions,
- *    window regions, etc for every window in the system.  The service
- *    will reply describing the current state.
- *
- *    If the intial request included the "incremental" argument, a list
- *    of all the changes to the windowing system  since the last
- *    unity.get.update request will be sent (e.g. if a window moves
- *    or has been destroyed).
- *
- *    If the "incremental" argument is not present, the entire state
- *    of the windowing system is returned.
- *
- *    The reply to the RPC is a double null terminated list of null
- *    terminated strings.  Each string in the list has one of the following
- *    formats:
- *
- *     add <windowid>
- *        A window with the specified integer windowid has just been
- *        created.
- *
- *     remove <windowid>
- *        The window with integer windowid has been removed.  Get rid of it.
+/**
+ * @file unity.c
  *
- *     move <windowid> <x1> <y1> <x2> <y2>
- *        The window with specified integer windowid has moved or resized
- *        such that its top left corner rests at x1,y1 and its bottom right
- *        at x2,y2.
+ *    Unity: Guest window manager integration service.
  *
- *     region <windowid> <numrects>
- *        The window with specified windowid has a not-rectangular window
- *        region (e.g. the curved corner windows in Windows XP).  Immediately,
- *        after this messages are numrects messages with the following format:
+ * This file implements the guest-side Unity agent as part of the VMware Tools.
+ * It contains entry points for embedding within the VMware Tools User Agent and
+ * handles the GuestRpc (TCLO) interface.
  *
- *        rect <x1> <y1> <x2> <y2>
- *            Defines a rectangle in the coordinate system of the window
- *            for this region (not the coordinate system of the desktop!!)
+ * UnityWindowTracker updates are sent to the MKS in two ways:
+ *    @li @ref UNITY_RPC_GET_UPDATE GuestRpc (host-to-guest).
+ *    @li @ref UNITY_RPC_PUSH_UPDATE_CMD GuestRpc (guest-to-host).
  *
- *        The actual window region is the union of all the rectangles in the
- *        list.  A value of 0 for numrects indicates that the window region
- *        should be ignored (i.e. the window region is identical to the
- *        bounds of the window).
- *
- *     title <windowid> <title>
- *        A window with the specified integer windowid has just changed its
- *        title.
- *
- *     zorder <num windows> <window id 1> <window id 2> ... <window id n>
- *        Z order of windows from top to bottom(or front to rear)
- *
- *     attr <windowid> <attr> <enabled>
- *        The window with specified windowid has an attribute enabled/disabled.
- *
- *     type <windowid> <type>
- *        The window with specified windowid is of a certain type
- *
- *     icon <windowid> <icontype>
- *        The window with specified windowid has changed an icon of the specified
- *        type.
- *
- *     desktop <windowid> <desktopid>
- *        The window with specified windowid has been moved to a different desktop.
- *
- *     activedesktop <desktopid>
- *        The desktop with specified desktopid has become active.
- *
- *     The guest is also capable of pushing incremental updates to the VMX.
- *     When we enter Unity (upon getting "unity.enter" command from the VMX),
- *     start a separate Unity window update thread. This thread will gather
- *     window updates from the guest, and send them to the VMX (if there are
- *     any updates to be sent).
- *     The incremental updates will be sent using 'tools.unity.push.update' command.
+ * @note Looking for the old "unity.get.update" return syntax?  See @ref
+ * UNITY_RPC_GET_UPDATE and @ref UnityGetUpdateReturn instead.
  *
+ * @sa
+ *    @li UnityRpcHG
+ *    @li UnityRpcGH
  */
 
 #include "vmware.h"
@@ -730,10 +667,15 @@ UnityTcloExit(char const **result,     // OUT
 /*
  *----------------------------------------------------------------------------
  *
- * UnityTcloGetWindowInfo --
+ * UnityTcloGetWindowPath --
+ *
+ *      RPC handler for UNITY_RPC_GET_WINDOW_PATH.
  *
- *     RPC handler for 'unity.get.window.info'. Get required window info
- *     and send it back to the VMX.
+ *      Get the information needed to re-launch a window and retrieve further
+ *      information on it.  Returns double-NUL-terminated buffer consisting of
+ *      NUL-terminated strings "windowPath" and "execPath" strings, the first
+ *      uniquely identifying the window and the second uniquely identifying the
+ *      window's owning executable.
  *
  * Results:
  *     TRUE if everything is successful.
index a2d6db1878bc0a3b678515c7e21cf85a7e7e95bb..509f419a83734ef02a9bc4cbbd8b5a240f5c679c 100644 (file)
@@ -2343,30 +2343,16 @@ UnityPlatformSetDesktopWorkAreas(UnityPlatform *up,     // IN
                                  UnityRect workAreas[], // IN
                                  uint32 numWorkAreas)   // IN
 {
+   int iScreens;
    int i;
    XineramaScreenInfo *screenInfo = NULL;
    int numScreens;
-   RegionPtr bigDaddyRegion;
+   RegionPtr strutsRegion;
    RegionPtr screenRegion;
    RegionPtr workAreasRegion;
-   xRectangle *screenRects;
-   xRectangle *workAreaRects;
-   uint32 rootX;
-   uint32 rootY;
-   uint32 rootWidth;
-   uint32 rootHeight;
-   uint32 dummy;
-   Window winDummy;
-   BoxRec screenSize;
    XID (*strutInfos)[12];
    int numStrutInfos;
 
-   /*
-    * XXX TODO: rework this so that we create a Region with workAreas, and then figure
-    * out what struts we need to set to get that effect... That will also deal with the
-    * other bugs this code has.
-    */
-
    if (!up->rootWindows) {
       /*
        * We're not in Unity mode yet. Save the info until we are.
@@ -2386,26 +2372,35 @@ UnityPlatformSetDesktopWorkAreas(UnityPlatform *up,     // IN
    ASSERT(up);
    ASSERT(up->rootWindows);
 
-   if (!XGetGeometry(up->display, up->rootWindows->windows[0], &winDummy,
-                     &rootX, &rootY, &rootWidth, &rootHeight,
-                     &dummy, &dummy)) {
-      return FALSE;
-   }
-   screenSize.x1 = rootX;
-   screenSize.y1 = rootY;
-   screenSize.x2 = rootX + rootWidth;
-   screenSize.y2 = rootY + rootHeight;
-
+   /*
+    * Get the geometry of all attached screens.  If we're running multi-mon,
+    * we'll query the Xinerama extension.  Otherwise we just fall back to
+    * examining our root window's geometry.
+    */
    if (XineramaQueryExtension(up->display, &i, &i)) {
       screenInfo = XineramaQueryScreens(up->display, &numScreens);
    }
+
    if (!screenInfo) {
+      uint32 rootX;
+      uint32 rootY;
+      uint32 rootWidth;
+      uint32 rootHeight;
+      uint32 dummy;
+      Window winDummy;
+
       if (numWorkAreas > 1) {
          Debug("Xinerama extension not present, or XineramaQueryScreens failed,"
                " but multiple work areas were requested.\n");
          return FALSE;
       }
 
+      if (!XGetGeometry(up->display, up->rootWindows->windows[0], &winDummy,
+                        &rootX, &rootY, &rootWidth, &rootHeight,
+                        &dummy, &dummy)) {
+         return FALSE;
+      }
+
       screenInfo = Util_SafeCalloc(1, sizeof *screenInfo);
       numScreens = 1;
 
@@ -2415,92 +2410,170 @@ UnityPlatformSetDesktopWorkAreas(UnityPlatform *up,     // IN
       screenInfo->height = rootHeight;
    }
 
-   screenRects = alloca(numScreens * sizeof *screenRects);
-   for (i = 0; i < numScreens; i++) {
-      screenRects[i].x = screenInfo[i].x_org;
-      screenRects[i].y = screenInfo[i].y_org;
-      screenRects[i].width = screenInfo[i].width;
-      screenRects[i].height = screenInfo[i].height;
-      screenRects[i].info.type = UpdateRect;
-   }
-   screenRegion = miRectsToRegion(numScreens, screenRects, 0);
-
-   workAreaRects = alloca(numWorkAreas * sizeof *workAreaRects);
-   for (i = 0; i < numWorkAreas; i++) {
-      workAreaRects[i].x = workAreas[i].x;
-      workAreaRects[i].y = workAreas[i].y;
-      workAreaRects[i].width = workAreas[i].width;
-      workAreaRects[i].height = workAreas[i].height;
-      workAreaRects[i].info.type = UpdateRect;
-   }
-   workAreasRegion = miRectsToRegion(numWorkAreas, workAreaRects, 0);
-
-   bigDaddyRegion = miRegionCreate(NULL, 0);
-   miSubtract(bigDaddyRegion, screenRegion, workAreasRegion);
-   miRegionDestroy(workAreasRegion);
-   miRegionDestroy(screenRegion);
+   /*
+    * New and improved wild'n'crazy scheme to map the host's work area
+    * coordinates to a collection of struts.
+    *
+    * This implementation depends upon the y-x banded rectangles
+    * implementation of lib/region.
+    *
+    * In short, here's how things go:
+    *
+    *    1.  For each Xinerama screen (or the root window in case we have no
+    *        Xinerama) and host work area, a region is created.  A strut
+    *        region is then created by subtracting the work area region from
+    *        the screen region.
+    *
+    *    2.  This remaining region will contain between 0 and 4 rectangles,
+    *        each of which will be transformed into a strut window.
+    *
+    *        For each of these rectangles, we infer based on their dimensions
+    *        which screen boundary the resulting strut should be bound to.
+    *
+    *        a.  Boxes touching both the left and right sides of the screen
+    *            are either top or bottom struts, depending on whether they
+    *            also touch the top or bottom edge.
+    *
+    *        b.  Any remaining box will touch either the left OR the right
+    *            side, but not both.  (Such an irregular layout cannot be
+    *            described by the work areas RPC.)  That box's strut will
+    *            then be attached to the same side of the screen.
+    *
+    * While also not perfect, this algorithm should do a better job of creating
+    * struts along their correct sides of a screen than its predecessor.  It
+    * will let us assume the common case that what we define as a strut attached
+    * to the left or right side really should be attached to the left or right,
+    * rather than attached to the top or bottom and spanning the height of the
+    * display.
+    *
+    * Pathological case:
+    *    1.  Screen geometry: 1280x960.
+    *        Left strut: 100px wide, 600px tall.  Touches top of screen.
+    *        Right strut: 1180px wide, 100px tall.  Touches top of screen.
+    *
+    *    2.  Note that these struts touch each other.  We'd interpret the resulting
+    *        work area as follows:
+    *
+    *        Top strut: 1280px wide, 100px tall.
+    *        Left strut: 100px wide, 500px tall, starting from y = 100.
+    *
+    * I believe this sort of layout to be uncommon enough that we can accept
+    * failure here.  If we -really- want to get these things right, then
+    * we should send strut information explicitly, rather than having the
+    * guest try to deduce it from work area geometry.
+    */
 
    /*
-    * In order to deal with all the odd possibilities for workarea setups, we make a
-    * Region that includes all the space taken up by the struts, and then turn each of
-    * that region's rectangles into a separate strut. It's less efficient than packing
-    * the information into as few _NET_WM_STRUT_PARTIAL properties as possible, but it's
-    * simpler.
+    * One strut per screen edge = at most 4 strutInfos.
     */
-   strutInfos = alloca(REGION_NUM_RECTS(bigDaddyRegion) * sizeof *strutInfos);
-   memset(strutInfos, 0, REGION_NUM_RECTS(bigDaddyRegion) * sizeof *strutInfos);
+   strutInfos = alloca(4 * sizeof *strutInfos * numScreens);
+   memset(strutInfos, 0, 4 * sizeof *strutInfos * numScreens);
    numStrutInfos = 0;
-   for (i = 0; i < REGION_NUM_RECTS(bigDaddyRegion); i++) {
-      BoxPtr p = REGION_RECTS(bigDaddyRegion) + i;
-      int leftDiff;
-      int rightDiff;
-      int topDiff;
-      int bottomDiff;
+
+   for (iScreens = 0; iScreens < numScreens; iScreens++) {
+      int iRects;
+
+      xRectangle screenRect;
+      xRectangle workAreaRect;
 
       /*
-       * Because EWMH struts are currently assumed to be locked to an edge of the screen,
-       * this code hopes that finding the closest edge will work well enough.
-       *
-       * XXX This may produce results that are not 100% correct from a technical
-       * perspective, and fall apart in pathological cases, but it'll work well enough in
-       * typical usage, and is better than just ignoring multimon use cases.
+       * Steps 1a. Create screen, work area regions.
        */
-      leftDiff = p->x1 - screenSize.x1;
-      topDiff = p->y1 - screenSize.y1;
-      rightDiff = screenSize.x2 - p->x2;
-      bottomDiff = screenSize.y2 - p->y2;
+      screenRect.x = screenInfo[iScreens].x_org;
+      screenRect.y = screenInfo[iScreens].y_org;
+      screenRect.width = screenInfo[iScreens].width;
+      screenRect.height = screenInfo[iScreens].height;
+      screenRect.info.type = UpdateRect;
+
+      workAreaRect.x = workAreas[iScreens].x;
+      workAreaRect.y = workAreas[iScreens].y;
+      workAreaRect.width = workAreas[iScreens].width;
+      workAreaRect.height = workAreas[iScreens].height;
+      workAreaRect.info.type = UpdateRect;
+
+      screenRegion = miRectsToRegion(1, &screenRect, 0);
+      workAreasRegion = miRectsToRegion(1, &workAreaRect, 0);
+
+      /*
+       * Step 1b.  Create struts region by subtracting work area from screen.
+       */
+      strutsRegion = miRegionCreate(NULL, 0);
+      miSubtract(strutsRegion, screenRegion, workAreasRegion);
+      miRegionDestroy(workAreasRegion);
+      miRegionDestroy(screenRegion);
+
+      /*
+       * Step 2.  Transform struts region rectangles into individual struts.
+       */
+      for (iRects = 0; iRects < REGION_NUM_RECTS(strutsRegion);
+           iRects++, numStrutInfos++) {
+         BoxPtr p = REGION_RECTS(strutsRegion) + iRects;
+         int bounds = 0;
+#define TOUCHES_LEFT          0x1
+#define TOUCHES_RIGHT         0x2
+#define TOUCHES_TOP           0x4
+#define TOUCHES_BOTTOM        0x8
+
+         if (p->x1 == screenRect.x) { bounds |= TOUCHES_LEFT; }
+         if (p->x2 == screenRect.x + screenRect.width) { bounds |= TOUCHES_RIGHT; }
+         if (p->y1 == screenRect.y) { bounds |= TOUCHES_TOP; }
+         if (p->y2 == screenRect.y + screenRect.height) { bounds |= TOUCHES_BOTTOM; }
 
-      if (topDiff <= leftDiff && topDiff <= rightDiff && topDiff <= bottomDiff) {
-         /*
-          * It's closest to the top side of the screen.
-          */
-         strutInfos[numStrutInfos][2] = p->y2 - screenSize.y1;
-         strutInfos[numStrutInfos][8] = p->x1;
-         strutInfos[numStrutInfos][9] = p->x2;
-      } else if (bottomDiff <= leftDiff && bottomDiff <= rightDiff && bottomDiff <= topDiff) {
-         /*
-          * It's closest to the bottom side.
-          */
-         strutInfos[numStrutInfos][3] = screenSize.y2 - p->y1;
-         strutInfos[numStrutInfos][10] = p->x1;
-         strutInfos[numStrutInfos][11] = p->x2;
-      } else if (leftDiff <= rightDiff && leftDiff <= topDiff && leftDiff <= bottomDiff) {
-         /*
-          * It's closest to the left side.
-          */
-         strutInfos[numStrutInfos][0] = p->x2 - screenSize.x1;
-         strutInfos[numStrutInfos][4] = p->y1;
-         strutInfos[numStrutInfos][5] = p->y2;
-      } else {
          /*
-          * Assume it's along the right hand side.
+          * strutInfos is passed directly to
+          * XSetProperty(..._NET_WM_STRUTS_PARTIAL).  I.e., look up that
+          * property's entry in NetWM/wm-spec for more info on the indices.
+          *
+          * I went the switch/case route only because it does a better job (for me)
+          * of organizing & showing -all- possible cases.  YMMV.
           */
-         strutInfos[numStrutInfos][1] = screenSize.x2 - p->x1;
-         strutInfos[numStrutInfos][6] = p->y1;
-         strutInfos[numStrutInfos][7] = p->y2;
+         switch (bounds) {
+         case TOUCHES_LEFT | TOUCHES_RIGHT | TOUCHES_TOP:
+            /* Top strut. */
+            strutInfos[numStrutInfos][2] = p->y2 - p->y1;
+            strutInfos[numStrutInfos][8] = p->x1;
+            strutInfos[numStrutInfos][9] = p->x2;
+            break;
+         case TOUCHES_LEFT | TOUCHES_RIGHT | TOUCHES_BOTTOM:
+            /* Bottom strut. */
+            strutInfos[numStrutInfos][3] = p->y2 - p->y1;
+            strutInfos[numStrutInfos][10] = p->x1;
+            strutInfos[numStrutInfos][11] = p->x2;
+            break;
+         case TOUCHES_LEFT:
+         case TOUCHES_LEFT | TOUCHES_TOP:
+         case TOUCHES_LEFT | TOUCHES_BOTTOM:
+         case TOUCHES_LEFT | TOUCHES_TOP | TOUCHES_BOTTOM:
+            /* Left strut. */
+            strutInfos[numStrutInfos][0] = p->x2 - p->x1;
+            strutInfos[numStrutInfos][4] = p->y1;
+            strutInfos[numStrutInfos][5] = p->y2;
+            break;
+         case TOUCHES_RIGHT:
+         case TOUCHES_RIGHT | TOUCHES_TOP:
+         case TOUCHES_RIGHT | TOUCHES_BOTTOM:
+         case TOUCHES_RIGHT | TOUCHES_TOP | TOUCHES_BOTTOM:
+            /* Right strut. */
+            strutInfos[numStrutInfos][1] = p->x2 - p->x1;
+            strutInfos[numStrutInfos][6] = p->y1;
+            strutInfos[numStrutInfos][7] = p->y2;
+            break;
+         case TOUCHES_LEFT | TOUCHES_RIGHT | TOUCHES_TOP | TOUCHES_BOTTOM:
+            Warning("%s: Struts occupy entire display.", __func__);
+            /* FALLTHROUGH */
+         default:
+            Warning("%s: Irregular strut configuration: bounds %4x\n", __func__, bounds);
+            miRegionDestroy(strutsRegion);
+            goto out;
+            break;
+         }
       }
+#undef TOUCHES_LEFT
+#undef TOUCHES_RIGHT
+#undef TOUCHES_TOP
+#undef TOUCHES_BOTTOM
 
-      numStrutInfos++;
+      miRegionDestroy(strutsRegion);
    }
 
    /*
@@ -2564,6 +2637,7 @@ UnityPlatformSetDesktopWorkAreas(UnityPlatform *up,     // IN
                       32, PropModeReplace, (unsigned char *)strutInfos[i], ARRAYSIZE(strutInfos[i]));
    }
 
+out:
    free(screenInfo);
 
    return TRUE;
index a5aa44d1575f9d17dac0848eef403678721d3ab8..96b2834f744678f56127b78aab8a6229ce6ddb87 100644 (file)
@@ -598,19 +598,25 @@ UnityPlatformSetTaskbarVisible(UnityPlatform *up,   // IN
    for (i = 0; i < numWindows; i++) {
       if (UNITY_WINDOW_TYPE_DOCK == allWindows[i]->windowType) {
          Window dockWindow;
+         UnityPlatformWindow *upw = allWindows[i];
 
-         dockWindow = allWindows[i]->clientWindow;
+         dockWindow = upw->clientWindow;
          if (!dockWindow) {
-            dockWindow = allWindows[i]->toplevelWindow;
+            dockWindow = upw->toplevelWindow;
          }
 
          if (currentSetting) {
             XMapWindow(up->display, dockWindow);
          } else {
+            /* Preserve _NET_WM_DESKTOP across unmap. */
+            if (!upw->wantSetDesktopNumberOnUnmap) {
+               upw->wantSetDesktopNumberOnUnmap = TRUE;
+               upw->onUnmapDesktopNumber = upw->desktopNumber;
+            }
             XWithdrawWindow(up->display, dockWindow, 0);
          }
 
-         UPWindow_CheckRelevance(up, allWindows[i], NULL);
+         UPWindow_CheckRelevance(up, upw, NULL);
       }
    }
 
index c064f52a572c45f5c08b581a74167d53746b9b25..46f8e733321b312545f1a65b7a2d0812efe6e768 100644 (file)
@@ -77,6 +77,9 @@ static void UPWindowSetWindows(UnityPlatform *up,
                                UnityPlatformWindow *upw,
                                Window toplevelWindow,
                                Window clientWindow);
+static void UPWindowSetEWMHDesktop(UnityPlatform *up,
+                                   UnityPlatformWindow *upw,
+                                   uint32 ewmhDesktopId);
 
 
 #ifdef VMX86_DEVEL
@@ -1036,6 +1039,12 @@ UPWindow_CheckRelevance(UnityPlatform *up,        // IN
                   return;
                }
             } else if (event->atom == up->atoms._NET_WM_DESKTOP) {
+               if (upw->wantSetDesktopNumberOnUnmap &&
+                   event->state == PropertyDelete) {
+                  UPWindowSetEWMHDesktop(up, upw, upw->onUnmapDesktopNumber);
+                  upw->wantSetDesktopNumberOnUnmap = FALSE;
+                  return;
+               }
                regetDesktop = TRUE;
             } else if (event->atom != up->atoms._NET_WM_WINDOW_TYPE) {
                return;
@@ -1064,6 +1073,10 @@ UPWindow_CheckRelevance(UnityPlatform *up,        // IN
          break;
 
       case MapNotify:
+         if (upw->wantSetDesktopNumberOnUnmap) {
+            Debug("%s: Expected PropertyDelete before MapNotify.\n", __func__);
+            upw->wantSetDesktopNumberOnUnmap = FALSE;
+         }
          regetDesktop = TRUE;
          break;
 
@@ -1120,6 +1133,10 @@ UPWindow_CheckRelevance(UnityPlatform *up,        // IN
       if (regetDesktop) {
          if (!UPWindowGetDesktop(up, upw, &upw->desktopNumber)) {
             upw->desktopNumber = -1;
+         } else {
+            if (upw->wantSetDesktopNumberOnUnmap) {
+               upw->onUnmapDesktopNumber = upw->desktopNumber;
+            }
          }
       }
       if (upw->desktopNumber < up->desktopInfo.numDesktops
@@ -3703,7 +3720,6 @@ UnityPlatformSetWindowDesktop(UnityPlatform *up,         // IN
                               UnityDesktopId desktopId)  // IN
 {
    UnityPlatformWindow *upw;
-   Atom data[5] = {0, 0, 0, 0, 0};
    uint32 guestDesktopId;
 
    ASSERT(up);
@@ -3727,8 +3743,44 @@ UnityPlatformSetWindowDesktop(UnityPlatform *up,         // IN
    ASSERT(desktopId < up->desktopInfo.numDesktops);
    guestDesktopId = up->desktopInfo.unityDesktopToGuest[desktopId];
 
+   UPWindowSetEWMHDesktop(up, upw, guestDesktopId);
+
+   return TRUE;
+}
+
+
+/*
+ *------------------------------------------------------------------------------
+ *
+ * UPWindowSetEWMHDesktop --
+ *
+ *     Move the window to the specified desktop.  ewmhDesktopId corresponds
+ *     to a desktop index to be used with _NET_WM_DESKTOP.
+ *
+ * Results:
+ *     This will directly change _NET_WM_DESKTOP of an unmapped window,
+ *     and will instead request the window manager to update that property
+ *     for a mapped window.
+ *
+ * Side effects:
+ *     None.
+ *
+ *------------------------------------------------------------------------------
+ */
+
+
+static void
+UPWindowSetEWMHDesktop(UnityPlatform *up,               // IN
+                       UnityPlatformWindow *upw,        // IN
+                       uint32 ewmhDesktopId)            // IN
+{
+   Atom data[5] = {0, 0, 0, 0, 0};
+
+   ASSERT(up);
+   ASSERT(upw);
+
    if (!upw->isViewable) {
-     Atom currentDesktop = guestDesktopId; // Cast for 64-bit correctness.
+     Atom currentDesktop = ewmhDesktopId; // Cast for 64-bit correctness.
 
      /*
       * Sending the _NET_WM_DESKTOP client message only works if the
@@ -3742,13 +3794,11 @@ UnityPlatformSetWindowDesktop(UnityPlatform *up,         // IN
                     XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&currentDesktop, 1);
    }
 
-   data[0] = guestDesktopId;
+   data[0] = ewmhDesktopId;
    data[1] = 2; // Indicates that this was requested by the pager/taskbar/etc.
    UnityPlatformSendClientMessage(up,
                                  upw->rootWindow,
                                  upw->clientWindow,
                                  up->atoms._NET_WM_DESKTOP,
                                  32, 5, data);
-
-   return TRUE;
 }
index 743a96ead2ed0ab4d6e989c055bb98b990ce7a34..4808e10ea911ec631bca35f1258d74a3bd6080fd 100644 (file)
@@ -298,6 +298,7 @@ struct UnityPlatformWindow {
    Window rootWindow;
    int screenNumber;
    int desktopNumber;
+   int onUnmapDesktopNumber;    ///< @sa wantSetDesktopNumberOnUnmap
    UnityPlatformWindow *higherWindow;
    UnityPlatformWindow *lowerWindow;
 
@@ -317,6 +318,20 @@ struct UnityPlatformWindow {
    Bool isViewable;
    Bool wasViewable;
    Bool wantInputFocus;
+   /**
+    * Indicates we wish to force a value of _NET_CURRENT_DESKTOP across XUnmapWindow.
+    *
+    * When we unmap a window, its _NET_CURRENT_DESKTOP property is cleared.  There are
+    * some circumstances in which this behavior is undesirable.  (E.g., once we hide
+    * the KDE taskbar, it will only appear on desktop #0 after exiting Unity, as KDE
+    * doesn't automatically remap panel/dock windows as sticky windows.)
+    *
+    * Setting this flag (in combination with setting onUnmapDesktopNumber) causes
+    * us to reset the _NET_CURRENT_DESKTOP property in response to receiving its
+    * PropertyDelete.  If a PropertyNewValue arrives before the -Delete, we'll query
+    * and record the new value into onUnmapDesktopNumber (if the property exists).
+    */
+   Bool wantSetDesktopNumberOnUnmap;
 
    /*
     * Mini state-machine:
index a2899d7b04b6b767de554225029f13453de07211..820cc56cc44a7844a577459102f29447031a9b1d 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libUnityStub.a
+noinst_LTLIBRARIES = libUnityStub.la
 
-libUnityStub_a_SOURCES =
-libUnityStub_a_SOURCES += unityStub.c
+libUnityStub_la_SOURCES =
+libUnityStub_la_SOURCES += unityStub.c
 
 AM_CFLAGS = @GTK_CPPFLAGS@
 AM_CFLAGS += @LIB_FILE_CPPFLAGS@
index 51cf099840e73f744db8bde5689a1a2e6faf4882..f7f872bcbd82148083d4fdeb1bae675718970008 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libUnityWindowTracker.a
+noinst_LTLIBRARIES = libUnityWindowTracker.la
 
-libUnityWindowTracker_a_SOURCES =
-libUnityWindowTracker_a_SOURCES += unityWindowTracker.c
+libUnityWindowTracker_la_SOURCES =
+libUnityWindowTracker_la_SOURCES += unityWindowTracker.c
index 4fa78fa4fc0cfb34fe7c95af88149e224c012fb8..ccb84b08ca10fd20827a98345994691a5b621013 100644 (file)
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libUser.a
+noinst_LTLIBRARIES = libUser.la
 
-libUser_a_SOURCES =
-libUser_a_SOURCES += hostinfo.c
-libUser_a_SOURCES += hostinfoPosix.c
-libUser_a_SOURCES += util.c
-libUser_a_SOURCES += utilPosix.c
+libUser_la_SOURCES =
+libUser_la_SOURCES += hostinfo.c
+libUser_la_SOURCES += hostinfoPosix.c
+libUser_la_SOURCES += util.c
+libUser_la_SOURCES += utilPosix.c
 
 AM_CFLAGS = @LIB_USER_CPPFLAGS@
index 122434cb0fdd1b4a0359c43a4e6c6f5b38fed74a..a7324898ac29c412a4038069c567df4aa3983940 100644 (file)
@@ -15,9 +15,8 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libVixTools.a
+noinst_LTLIBRARIES = libVixTools.la
 
-libVixTools_a_SOURCES =
-libVixTools_a_SOURCES += vixTools.c
-AM_CFLAGS = -I$(top_builddir)/include
+libVixTools_la_SOURCES =
+libVixTools_la_SOURCES += vixTools.c
 
index 11125d8b6bc1fd3738aa7d656cdf0aeeab66333d..2761bb826b6a8bf115caadf2e0c2c1eae7404568 100644 (file)
@@ -15,9 +15,9 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libVmBackupLib.a
+noinst_LTLIBRARIES = libVmBackupLib.la
 
-libVmBackupLib_a_SOURCES =
-libVmBackupLib_a_SOURCES += scriptOps.c
-libVmBackupLib_a_SOURCES += stateMachine.c
-libVmBackupLib_a_SOURCES += syncDriverOps.c
+libVmBackupLib_la_SOURCES =
+libVmBackupLib_la_SOURCES += scriptOps.c
+libVmBackupLib_la_SOURCES += stateMachine.c
+libVmBackupLib_la_SOURCES += syncDriverOps.c
index 245a01023875167a29cb33f75b40a2692b28c3c6..13582a28e9ac5f8bf8c61054cdc8716925868933 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libVmCheck.a
+noinst_LTLIBRARIES = libVmCheck.la
 
-libVmCheck_a_SOURCES =
-libVmCheck_a_SOURCES += vmcheck.c
+libVmCheck_la_SOURCES =
+libVmCheck_la_SOURCES += vmcheck.c
index b9c984edcd39d4257deb0fecbe4e37827b87c783..a43028dccb9d006eaf759b8ae6c3a83c4e3371f5 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libVmSignal.a
+noinst_LTLIBRARIES = libVmSignal.la
 
-libVmSignal_a_SOURCES =
-libVmSignal_a_SOURCES += vmsignal.c
+libVmSignal_la_SOURCES =
+libVmSignal_la_SOURCES += vmsignal.c
index 1e8cf69666df5a5d2a685deea1e84572d983c8d0..a17f35f077248b258031066c7381b4a1f456f1c1 100644 (file)
@@ -15,7 +15,7 @@
 ### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ################################################################################
 
-noinst_LIBRARIES = libWiper.a
+noinst_LTLIBRARIES = libWiper.la
 
-libWiper_a_SOURCES =
-libWiper_a_SOURCES += wiperPosix.c
+libWiper_la_SOURCES =
+libWiper_la_SOURCES += wiperPosix.c
index 654d089c8d6a89092d2216bec428a4303ca4a0ca..1858665ecc15179f1f747c0dd1f91729f0e2d94e 100644 (file)
 lib_LTLIBRARIES = libguestlib.la
 
 libguestlib_la_LIBADD =
-libguestlib_la_LIBADD += ../lib/rpcOut/shared/libRpcOut.la
-libguestlib_la_LIBADD += ../lib/string/shared/libString.la
-libguestlib_la_LIBADD += ../lib/stubs/shared/libStubs.la
+libguestlib_la_LIBADD += ../lib/rpcOut/libRpcOut.la
+libguestlib_la_LIBADD += ../lib/string/libString.la
+libguestlib_la_LIBADD += ../lib/stubs/libStubs.la
 # In the absence of the linker options --start-group and --end-group (which can't
 # be put in LDADD), we need to bring the following libraries out of the alphebetical
 # order so their symbols are properly resolved.
-libguestlib_la_LIBADD += ../lib/message/shared/libMessage.la
-libguestlib_la_LIBADD += ../lib/backdoor/shared/libBackdoor.la
+libguestlib_la_LIBADD += ../lib/message/libMessage.la
+libguestlib_la_LIBADD += ../lib/backdoor/libBackdoor.la
 
 libguestlib_la_SOURCES =
 libguestlib_la_SOURCES += vmGuestLib.c
diff --git a/open-vm-tools/libvmtools/COPYING b/open-vm-tools/libvmtools/COPYING
new file mode 100644 (file)
index 0000000..09f465a
--- /dev/null
@@ -0,0 +1,502 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/open-vm-tools/libvmtools/Makefile.am b/open-vm-tools/libvmtools/Makefile.am
new file mode 100644 (file)
index 0000000..b665b1f
--- /dev/null
@@ -0,0 +1,69 @@
+################################################################################
+### Copyright 2008 VMware, Inc.  All rights reserved.
+###
+### This program is free software; you can redistribute it and/or modify
+### it under the terms of version 2 of the GNU General Public License as
+### published by the Free Software Foundation.
+###
+### This program is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with this program; if not, write to the Free Software
+### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+################################################################################
+
+lib_LTLIBRARIES = libvmtools.la
+
+libvmtools_la_LIBADD =
+libvmtools_la_LIBADD += ../lib/backdoor/libBackdoor.la
+libvmtools_la_LIBADD += ../lib/conf/libConf.la
+libvmtools_la_LIBADD += ../lib/dict/libDict.la
+libvmtools_la_LIBADD += ../lib/dynxdr/libDynxdr.la
+libvmtools_la_LIBADD += ../lib/err/libErr.la
+libvmtools_la_LIBADD += ../lib/file/libFile.la
+libvmtools_la_LIBADD += ../lib/guestApp/libGuestApp.la
+libvmtools_la_LIBADD += ../lib/guestInfo/libGuestInfoCS.la
+libvmtools_la_LIBADD += ../lib/hgfs/libHgfs.la
+libvmtools_la_LIBADD += ../lib/message/libMessage.la
+libvmtools_la_LIBADD += ../lib/misc/libMisc.la
+libvmtools_la_LIBADD += ../lib/panic/libPanic.la
+libvmtools_la_LIBADD += ../lib/rpcOut/libRpcOut.la
+libvmtools_la_LIBADD += ../lib/string/libString.la
+libvmtools_la_LIBADD += ../lib/sync/libSync.la
+libvmtools_la_LIBADD += ../lib/system/libSystem.la
+libvmtools_la_LIBADD += ../lib/stubs/libStubsCS.la
+libvmtools_la_LIBADD += ../lib/unicode/libUnicode.la
+libvmtools_la_LIBADD += ../lib/user/libUser.la
+libvmtools_la_LIBADD += ../lib/vmCheck/libVmCheck.la
+libvmtools_la_LIBADD += ../lib/vmSignal/libVmSignal.la
+libvmtools_la_LIBADD += ../lib/wiper/libWiper.la
+libvmtools_la_LIBADD += @LIBVMTOOLS_LIBADD@
+libvmtools_la_LIBADD += @GLIB2_LIBS@
+libvmtools_la_LIBADD += @ICU_LIBS@
+
+libvmtools_la_SOURCES =
+libvmtools_la_SOURCES += signalSource.c
+libvmtools_la_SOURCES += vmtools.c
+libvmtools_la_SOURCES += vmtoolsConfig.c
+libvmtools_la_SOURCES += vmtoolsLog.c
+
+# Recompile the rpcIn library with GLIB support.
+libvmtools_la_SOURCES += $(top_srcdir)/lib/rpcIn/rpcin.c
+
+# Recompile the stub for Log_* functions, but not Log() itself (see -DNO_LOG_STUB).
+libvmtools_la_SOURCES += $(top_srcdir)/lib/stubs/stub-log.c
+
+libvmtools_la_CPPFLAGS =
+libvmtools_la_CPPFLAGS += -DVMTOOLS_USE_GLIB
+libvmtools_la_CPPFLAGS += -DNO_LOG_STUB
+libvmtools_la_CPPFLAGS += @GLIB2_CPPFLAGS@
+
+libvmtools_la_LDFLAGS =
+# We require GCC, so we're fine passing compiler-specific flags.
+libvmtools_la_LDFLAGS += -Wl,-z,defs
+# Needed for OS's that don't link shared libraries against libc by default, e.g. FreeBSD
+libvmtools_la_LDFLAGS += -Wl,-lc
+
diff --git a/open-vm-tools/libvmtools/signalSource.c b/open-vm-tools/libvmtools/signalSource.c
new file mode 100644 (file)
index 0000000..b5f20b1
--- /dev/null
@@ -0,0 +1,306 @@
+/*********************************************************
+ * Copyright (C) 2008 VMware, Inc. All rights reserved.
+ *
+ * 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 the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @file signalSource.c
+ *
+ *    A GSource implementation that is activated by OS signals.
+ *
+ *    Caveat: if the process is receiving a lot of signals in a short period
+ *    of time, it's possible that the sources will not be notified for all
+ *    the instances of a particular signal. So this mechanism shouldn't be
+ *    used for reliable event delivery.
+ */
+
+#include "vmtools.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+
+typedef enum {
+   SIG_SRC_UNHANDLED = 0,
+   SIG_SRC_IDLE,
+   SIG_SRC_SIGNALED
+} SignalState;
+
+/* Use NSIG if it's defined, otherwise use a hardcoded limit. */
+#if defined(NSIG)
+#  define MAX_SIGNALS   (NSIG - 1)
+#else
+#  define MAX_SIGNALS   64
+#endif
+
+typedef struct SignalHandler {
+   gboolean                initialized;
+   int                     wakeupPipe[2];
+   struct sigaction        handler;
+   GPollFD                 wakeupFd;
+   SignalState             signals[MAX_SIGNALS];
+   siginfo_t               currSignal;
+} SignalHandler;
+
+static SignalHandler gHandler = { FALSE, };
+G_LOCK_DEFINE_STATIC(gLock);
+
+typedef struct SignalSource {
+   GSource     src;
+   int         signum;
+} SignalSource;
+
+
+/**
+ * Reads one siginfo_t struct from the pipe if data is available, and
+ * place it in the global state variable. This allows us to, eventually,
+ * service all the processed signals, although in a not very efficient
+ * way...
+ */
+
+static inline void
+SignalSourceReadSigInfo(void)
+{
+   if (gHandler.wakeupFd.revents & G_IO_IN) {
+      siginfo_t info;
+      ssize_t nbytes = read(gHandler.wakeupFd.fd, &info, sizeof info);
+      if (nbytes == -1) {
+         g_warning("Signal source: reading from wake up fd failed.");
+         return;
+      } else {
+         /* XXX: Maybe we should handle this in some other way? */
+         g_assert(nbytes == sizeof info);
+      }
+      memcpy(&gHandler.currSignal, &info, sizeof info);
+      gHandler.signals[info.si_signo] = SIG_SRC_SIGNALED;
+      gHandler.wakeupFd.revents = 0;
+   }
+}
+
+
+/**
+ * Handles a signal. Writes the signal information to the wakeup pipe.
+ *
+ * According to signal(7), "write()" is safe to call from a signal handling
+ * context. If the write fails, though, signal delivery might be delayed.
+ *
+ * @param[in]  signum      Signal received.
+ * @param[in]  info        Information about the signal.
+ * @param[in]  context     Unused.
+ */
+
+static void
+SignalSourceSigHandler(int signum,
+                       siginfo_t *info,
+                       void *context)
+{
+   ssize_t bytes;
+   siginfo_t dummy;
+   if (signum >= MAX_SIGNALS) {
+      return;
+   }
+
+   if (info == NULL) {
+      /*
+       * Solaris seems to call the handler with a NULL info struct in certain
+       * situations. I noticed it when hitting CTRL-C (sending SIGINT) in a
+       * terminal; calling "kill [pid]" (sending SIGTERM) seemed to work fine.
+       * Still, it's better to handle this case.
+       */
+      memset(&dummy, 0, sizeof dummy);
+      dummy.si_signo = signum;
+      info = &dummy;
+   }
+   bytes = write(gHandler.wakeupPipe[1], info, sizeof *info);
+
+   if (bytes == -1) {
+      if (errno == EAGAIN) {
+         /*
+          * Pipe is full. If this ever becomes a problem, more pipes will
+          * have to be created...
+          */
+         g_warning("Too many signals queued, this shouldn't happen.\n");
+         g_assert(FALSE);
+      } else {
+         g_warning("Could not queue signal %d (error %d: %s)\n",
+                   signum, errno, strerror(errno));
+      }
+   }
+}
+
+
+/**
+ * Does nothing.
+ *
+ * @param[in]  _src        Unused.
+ * @param[out] timeout     Set to -1.
+ *
+ * @return FALSE
+ */
+
+static gboolean
+SignalSourcePrepare(GSource *_src,
+                    gint *timeout)
+{
+   *timeout = -1;
+   return FALSE;
+}
+
+
+/**
+ * Checks whether the process received the signal the source is watching.
+ *
+ * @param[in]  _src     The event source.
+ *
+ * @return Whether the source's signal was received.
+ */
+
+static gboolean
+SignalSourceCheck(GSource *_src)
+{
+   SignalSource *src = (SignalSource *) _src;
+   SignalSourceReadSigInfo();
+   return (gHandler.signals[src->signum] == SIG_SRC_SIGNALED);
+}
+
+
+/**
+ * Calls the callback associated with the handle, if any. Resets the source's
+ * signal state to "not signaled".
+ *
+ * @param[in]  _src        The event source.
+ * @param[in]  _callback   The callback to be called.
+ * @param[in]  data        User-supplied data.
+ *
+ * @return The return value of the callback, or FALSE if the callback is NULL.
+ */
+
+static gboolean
+SignalSourceDispatch(GSource *_src,
+                     GSourceFunc _callback,
+                     gpointer data)
+{
+   SignalSourceCb callback = (SignalSourceCb) _callback;
+   SignalSource *src = (SignalSource *) _src;
+   gHandler.signals[src->signum] = SIG_SRC_IDLE;
+   return (callback != NULL) ? callback(&gHandler.currSignal, data)
+                             : FALSE;
+}
+
+
+/**
+ * Destroys the event source. Nothing needs to be done.
+ *
+ * @param[in]  src      The event source.
+ */
+
+static void
+SignalSourceFinalize(GSource *src)
+{
+}
+
+/**
+ * @addtogroup vmtools_utils
+ * @{
+ */
+
+/**
+ * Creates a new source for the given signal.
+ *
+ * Rather than processing the events in the signal handling context, the main
+ * loop is woken up and callbacks are processed in the main loop's thread.
+ *
+ * The same "wakeup" file descriptors are used for all sources, so if sources
+ * are added to different main loop instances, all of them will be woken up
+ * if any signal for which handlers are registered occurs.
+ *
+ * This code assumes that the rest of the app is not setting signal
+ * handlers directly, at least for signals for which glib sources have
+ * been set up.
+ *
+ * Also note that on older Linux systems (pre-NPTL), some real-time signals
+ * are used by the pthread library and shouldn't be used by applications.
+ *
+ * Example of setting a handler for a signal:
+ *
+ * @code
+ *
+ *    GSource *src = VMTools_NewSignalSource(signum);
+ *    g_source_set_callback(src, MyCallback, myData, NULL);
+ *    g_source_attach(src, myContext);
+ *
+ * @endcode
+ *
+ * @note This API is not available on Win32.
+ *
+ * @param[in]  signum   Signal to watch.
+ *
+ * @return Pointer to the new source, NULL if failed to set signal handler.
+ */
+
+GSource *
+VMTools_NewSignalSource(int signum)
+{
+   static GSourceFuncs srcFuncs = {
+      SignalSourcePrepare,
+      SignalSourceCheck,
+      SignalSourceDispatch,
+      SignalSourceFinalize,
+      NULL,
+      NULL
+   };
+   SignalSource *ret;
+
+   g_assert(signum < MAX_SIGNALS);
+   g_assert(signum != SIGKILL && signum != SIGSTOP);
+
+   G_LOCK(gLock);
+   if (!gHandler.initialized) {
+      memset(&gHandler, 0, sizeof gHandler);
+      if (pipe(gHandler.wakeupPipe) == -1 ||
+          fcntl(gHandler.wakeupPipe[0], F_SETFL, O_RDONLY | O_NONBLOCK) < 0 ||
+          fcntl(gHandler.wakeupPipe[1], F_SETFL, O_WRONLY | O_NONBLOCK) < 0) {
+         g_assert(FALSE);
+      }
+      gHandler.wakeupFd.fd = gHandler.wakeupPipe[0];
+      gHandler.wakeupFd.events = G_IO_IN | G_IO_ERR;
+      gHandler.handler.sa_sigaction = SignalSourceSigHandler;
+      gHandler.handler.sa_flags = SA_SIGINFO;
+   }
+   G_UNLOCK(gLock);
+
+   /*
+    * Sets the signal handler if it hasn't been set yet. The code is
+    * racy, but it's OK if 2 threads are trying to install the same
+    * signal handler (one will win and all will be fine).
+    */
+   if (gHandler.signals[signum] == SIG_SRC_UNHANDLED) {
+      if (sigaction(signum, &gHandler.handler, NULL) == -1) {
+         g_warning("Cannot set signal handler: %s\n", strerror(errno));
+         return NULL;
+      }
+      gHandler.signals[signum] = SIG_SRC_IDLE;
+   }
+
+   ret = (SignalSource *) g_source_new(&srcFuncs, sizeof *ret);
+   ret->signum = signum;
+
+   g_source_add_poll(&ret->src, &gHandler.wakeupFd);
+   return &ret->src;
+}
+
+/** @}  */
+
diff --git a/open-vm-tools/libvmtools/vmtools.c b/open-vm-tools/libvmtools/vmtools.c
new file mode 100644 (file)
index 0000000..eced935
--- /dev/null
@@ -0,0 +1,162 @@
+/*********************************************************
+ * Copyright (C) 2008 VMware, Inc. All rights reserved.
+ *
+ * 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 the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @file vmtools.c
+ *
+ * Library entry point, utility and memory de-allocation functions for the VMTools
+ * shared library.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#if defined(_WIN32)
+#  include <windows.h>
+#  include "coreDump.h"
+#  include "netutil.h"
+#endif
+
+#include "vmtools.h"
+#include "wiper.h"
+
+#if !defined(__APPLE__)
+#include "embed_version.h"
+#include "vmtoolslib_version.h"
+VM_EMBED_VERSION(VMTOOLSLIB_VERSION_STRING);
+#endif
+
+extern void VMTools_InitLogging(void);
+
+
+/**
+ * A convenience function for wrapping an array with a GArray instance.
+ *
+ * @param[in]  data        The array data. The original data is copied into the
+ *                         new array.
+ * @param[in]  elemSize    The size of each element in the array.
+ * @param[in]  count       The number of elements in the array.
+ *
+ * @return A new GArray.
+ */
+
+GArray *
+VMTools_WrapArray(gconstpointer data,
+                  guint elemSize,
+                  guint count)
+{
+   GArray *array;
+
+   array = g_array_sized_new(FALSE, TRUE, elemSize, count);
+   memcpy(array->data, data, elemSize * count);
+   array->len = count;
+
+   return array;
+}
+
+
+/**
+ * Library constructor. Calls any needed initialization functions.
+ *
+ * @param[in]  lib      The library handle (Win32 only).
+ */
+
+#if defined(__GNUC__)
+__attribute__((constructor))
+#endif
+static void
+VMToolsDllInit(void *lib)
+{
+   Bool success;
+#if defined(_WIN32)
+   WiperInitData wiperData;
+   CoreDump_SetUnhandledExceptionFilter();
+   VMTools_InitLogging();
+   wiperData.resourceModule = lib;
+   success = (NetUtil_LoadIpHlpApiDll() == ERROR_SUCCESS);
+   g_assert(success);
+   success = Wiper_Init(&wiperData.resourceModule);
+   g_assert(success);
+#else
+   VMTools_InitLogging();
+   success = Wiper_Init(NULL);
+   g_assert(success);
+#endif
+}
+
+
+/**
+ * Library destructor. Uninitializes any libraries that need to be cleaned up.
+ */
+
+#if defined(__GNUC__)
+__attribute__((destructor))
+#endif
+static void
+VMToolsDllFini(void)
+{
+#if defined(_WIN32)
+   NetUtil_FreeIpHlpApiDll();
+#endif
+}
+
+
+/**
+ * Frees a pointer allocated by the vmtools library.
+ *
+ * @param[in] ptr Pointer to memory to be freed.
+ */
+
+void
+vm_free(void *ptr)
+{
+   free(ptr);
+}
+
+
+#if defined(_WIN32)
+/**
+ * Windows initialization callback. Calls the library's constructor or
+ * destructor, depending on what is being done.
+ *
+ * @param[in]  hinstDLL    The library handle.
+ * @param[in]  fdwReason   Why the callback is being called.
+ * @param[in]  lpvReserved Unused.
+ *
+ * @return TRUE.
+ */
+
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL,
+        DWORD fdwReason,
+        LPVOID lpvReserved)
+{
+   switch (fdwReason) {
+   case DLL_PROCESS_ATTACH:
+      VMToolsDllInit(hinstDLL);
+      break;
+
+   case DLL_PROCESS_DETACH:
+      VMToolsDllFini();
+      break;
+   }
+   return TRUE;
+}
+#endif
+
diff --git a/open-vm-tools/libvmtools/vmtoolsConfig.c b/open-vm-tools/libvmtools/vmtoolsConfig.c
new file mode 100644 (file)
index 0000000..1711a2f
--- /dev/null
@@ -0,0 +1,447 @@
+/*********************************************************
+ * Copyright (C) 2008 VMware, Inc. All rights reserved.
+ *
+ * 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 the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @file vmtoolsConfig.c
+ *
+ *    Convenience functions for loading tools configuration files, and
+ *    automatically migrating from old-style tools configuration files.
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib/gstdio.h>
+#include "vmtools.h"
+#include "conf.h"
+#include "file.h"
+#include "guestApp.h"
+#include "str.h"
+#include "util.h"
+
+/** Data types supported for translation. */
+typedef enum {
+   CFG_BOOLEAN,
+   CFG_INTEGER,
+   CFG_STRING,
+   CFG_CALLBACK
+} ConfigType;
+
+/** Holds information about how to upgrade an old config entry. */
+typedef struct ConfigEntry {
+   const gchar         *key;
+   const gchar         *destGroup;
+   const gchar         *destKey;
+   const ConfigType     type;
+   const gpointer       data;
+} ConfigEntry;
+
+typedef void (*CfgCallback)(GKeyFile *cfg, const ConfigEntry *, const char *);
+
+/**
+ * Upgrade the logging configuration.
+ *
+ * @param[in] cfg       Config dictionary.
+ * @param[in] entry     The ConfigEntry instance.
+ * @param[in] value     Config value.
+ */
+
+static void
+VMToolsConfigUpgradeLog(GKeyFile *cfg,
+                        const ConfigEntry *entry,
+                        const char *value)
+{
+   /*
+    * The old configuration used the same file path for both guestd
+    * and vmware-user. Instead of baking in the library whether we're
+    * running one or the other, separate the two configurations, so that
+    * the user can choose a different location for one or another.
+    */
+   gchar *userlog;
+
+   g_key_file_set_string(cfg, entry->destGroup,
+                         VMTOOLS_GUEST_SERVICE ".handler", "file");
+   g_key_file_set_string(cfg, entry->destGroup,
+                         VMTOOLS_GUEST_SERVICE ".level", "debug");
+   g_key_file_set_string(cfg, entry->destGroup,
+                         VMTOOLS_GUEST_SERVICE ".data", value);
+
+   userlog = g_strdup_printf("%s.user", value);
+   g_key_file_set_string(cfg, entry->destGroup,
+                         VMTOOLS_USER_SERVICE ".handler", "file");
+   g_key_file_set_string(cfg, entry->destGroup,
+                         VMTOOLS_USER_SERVICE ".level", "debug");
+   g_key_file_set_string(cfg, entry->destGroup,
+                         VMTOOLS_USER_SERVICE ".data", userlog);
+
+   g_free(userlog);
+}
+
+
+/**
+ * Translates a VMware dictionary containing tools configuration data
+ * to a GKeyFile dictionary. Only known tools options are translated.
+ *
+ * @param[in] old    The old configuration data.
+ * @param[in] dst    The destination.
+ */
+
+static void
+VMToolsConfigUpgrade(GuestApp_Dict *old,
+                     GKeyFile *dst)
+{
+   const ConfigEntry entries[] = {
+      /* Logging options. */
+      { CONFNAME_LOGFILE, "logging", NULL, CFG_CALLBACK, VMToolsConfigUpgradeLog },
+      { CONFNAME_LOG, "logging", "log", CFG_BOOLEAN, NULL },
+      /* Power op scripts. */
+      { CONFNAME_POWEROFFSCRIPT, "powerops", CONFNAME_POWEROFFSCRIPT, CFG_STRING, NULL },
+      { CONFNAME_POWERONSCRIPT, "powerops", CONFNAME_POWERONSCRIPT, CFG_STRING, NULL },
+      { CONFNAME_RESUMESCRIPT, "powerops", CONFNAME_RESUMESCRIPT, CFG_STRING, NULL },
+      { CONFNAME_SUSPENDSCRIPT, "powerops", CONFNAME_SUSPENDSCRIPT, CFG_STRING, NULL },
+      /* guestd options. */
+      { CONFNAME_MAX_WIPERSIZE, "vmsvc", CONFNAME_MAX_WIPERSIZE, CFG_INTEGER, NULL },
+      { CONFNAME_DISABLEQUERYDISKINFO, "guestinfo", CONFNAME_DISABLEQUERYDISKINFO, CFG_BOOLEAN, NULL },
+      { CONFNAME_DISABLETOOLSVERSION, "vmsvc", CONFNAME_DISABLETOOLSVERSION, CFG_BOOLEAN, NULL },
+#if !defined(_WIN32)
+      { CONFNAME_HALT, "vmsvc", CONFNAME_HALT, CFG_STRING, NULL },
+      { CONFNAME_REBOOT, "vmsvc", CONFNAME_REBOOT, CFG_STRING, NULL },
+      /* HGFS options. */
+      { CONFNAME_MOUNT_POINT, "hgfs", CONFNAME_MOUNT_POINT, CFG_STRING, NULL },
+      /* Tray options. */
+      { CONFNAME_SHOW_WIRELESS_ICON, "vmtray", CONFNAME_SHOW_WIRELESS_ICON, CFG_BOOLEAN, NULL },
+#endif
+      /* Null terminator. */
+      { NULL, }
+   };
+   const ConfigEntry *entry;
+
+   for (entry = entries; entry->key != NULL; entry++) {
+      const char *value = GuestApp_GetDictEntry(old, entry->key);
+      const char *dfltValue = GuestApp_GetDictEntryDefault(old, entry->key);
+      
+      if (value == NULL || (dfltValue != NULL && strcmp(value, dfltValue) == 0)) {
+         continue;
+      }
+      switch (entry->type) {
+      case CFG_BOOLEAN:
+         {
+            gboolean val = GuestApp_GetDictEntryBool(old, entry->key);
+            g_key_file_set_boolean(dst, entry->destGroup, entry->destKey, val);
+            break;
+         }
+
+      case CFG_INTEGER:
+         {
+            gint val;
+            if (GuestApp_GetDictEntryInt(old, entry->key, &val)) {
+               g_key_file_set_integer(dst, entry->destGroup, entry->destKey, val);
+            }
+            break;
+         }
+
+      case CFG_STRING:
+         {
+            const char *val = GuestApp_GetDictEntry(old, entry->key);
+            if (val != NULL) {
+               g_key_file_set_string(dst, entry->destGroup, entry->destKey, val);
+            }
+            break;
+         }
+
+      case CFG_CALLBACK:
+         {
+            const char *val = GuestApp_GetDictEntry(old, entry->key);
+            if (val != NULL) {
+               g_assert(entry->data);
+               ((CfgCallback)entry->data)(dst, entry, val);
+            }
+            break;
+         }
+
+      default:
+         g_assert_not_reached();
+      }
+   }
+}
+
+
+/**
+ * Returns the path to the default tools config file.
+ *
+ * @return String with the default config path (should be freed by caller).
+ */
+
+gchar *
+VMTools_GetToolsConfFile(void)
+{
+   char *confPath = GuestApp_GetConfPath();
+   gchar *confFilePath;
+
+   /*
+    * XXX: GuestApp_GetConfPath() is racy. If two different people are calling
+    * the function and the conf directory doesn't exist, there's the risk that
+    * one of them will fail to create the directory and return NULL. So if we
+    * get NULL back, retry the call (at which point the directory will
+    * hopefully exist), and assert if it's NULL (which now should only happen
+    * if we fail to allocate memory).
+    */
+   if (confPath == NULL) {
+      confPath = GuestApp_GetConfPath();
+      g_assert(confPath != NULL);
+   }
+   confFilePath = g_strdup_printf("%s%c%s", confPath, DIRSEPC, CONF_FILE);
+   free(confPath);
+
+   return confFilePath;
+}
+
+
+/**
+ * Loads the configuration file at the given path. If an old configuration
+ * file is detected, the caller can request for it to be automatically upgraded
+ * to the new configuration format (the old configuration file is saved with a
+ * ".old" extension).
+ *
+ * @param[in] path         Path to the configuration file.
+ * @param[in] flags        Flags for opening the file.
+ * @param[in] autoUpgrade  Whether to try to upgrade old tools configuration.
+ *
+ * @return A configuration dictionary, or NULL on error.
+ */
+
+GKeyFile *
+VMTools_LoadConfig(const gchar *path,
+                   GKeyFileFlags flags,
+                   gboolean autoUpgrade)
+{
+   gchar *backup = NULL;
+   gchar *localPath;
+   GuestApp_Dict *old = NULL;
+   GError *err = NULL;
+   GKeyFile *cfg;
+
+   cfg = g_key_file_new();
+
+   localPath = VMTOOLS_GET_FILENAME_LOCAL(path, &err);
+   if (err != NULL) {
+      g_warning("Error converting to local encoding: %s\n", err->message);
+      goto exit;
+   }
+
+   if (!File_IsFile(path)) {
+      goto exit;
+   }
+
+   g_key_file_load_from_file(cfg, localPath, flags, &err);
+   if (err == NULL) {
+      goto exit;
+   }
+
+   if (err->code != G_KEY_FILE_ERROR_GROUP_NOT_FOUND) {
+      g_warning("Cannot load config file: %s", err->message);
+      goto error;
+   }
+
+   /* Failed to load the config file; try to upgrade if requested. */
+   if (!autoUpgrade) {
+      goto error;
+   }
+
+   old = Conf_Load();
+   if (old == NULL) {
+      g_warning("Error loading old tools config data, bailing out.\n");
+      goto error;
+   }
+
+   VMToolsConfigUpgrade(old, cfg);
+   backup = g_strdup_printf("%s.old", path);
+
+   if (!File_IsFile(backup)) {
+      if (!File_Rename(path, backup)) {
+         g_warning("Error creating backup of old config file.\n");
+         goto error;
+      }
+   } else {
+      g_warning("Backup config exists, skipping backup.\n");
+   }
+
+   g_clear_error(&err);
+
+   if (!VMTools_WriteConfig(path, cfg, NULL)) {
+      goto error;
+   }
+
+   goto exit;
+
+error:
+   g_key_file_free(cfg);
+   cfg = NULL;
+
+exit:
+   g_clear_error(&err);
+   if (old != NULL) {
+      GuestApp_FreeDict(old);
+   }
+   g_free(backup);
+   VMTOOLS_RELEASE_FILENAME_LOCAL(localPath);
+   return cfg;
+}
+
+
+/**
+ * Reloads the configuration file at the given path if it has changed since the
+ * given timestamp. No translation (such as in VMTools_LoadConfig()) will be
+ * performed.
+ *
+ * @param[in]     path     Path to the config file.
+ * @param[in]     flags    Flags to use when opening the file.
+ * @param[in,out] config   GKeyFile object; when reloading the file, the old
+ *                         config object will be destroyed.
+ * @param[in,out] mtime    Last known modification time of the config file.
+ *                         When the function succeeds, will contain the new
+ *                         modification time read from the file.
+ *
+ * @return Whether the file was reloaded.
+ */
+
+gboolean
+VMTools_ReloadConfig(const gchar *path,
+                     GKeyFileFlags flags,
+                     GKeyFile **config,
+                     time_t *mtime)
+{
+   struct stat confStat;
+   gboolean ret = FALSE;
+   GKeyFile *newConfig = NULL;
+
+   g_assert(config != NULL);
+   g_assert(mtime != NULL);
+
+   if (g_stat(path, &confStat) == -1) {
+      g_warning("Failed to stat conf file: %s\n", strerror(errno));
+      goto exit;
+   }
+
+   if (*mtime == 0 || confStat.st_mtime > *mtime) {
+      GError *err = NULL;
+      gchar *localPath;
+
+      localPath = VMTOOLS_GET_FILENAME_LOCAL(path, &err);
+      if (err != NULL) {
+         g_warning("Error converting to local encoding: %s\n", err->message);
+         goto exit;
+      }
+
+      newConfig = g_key_file_new();
+      g_key_file_load_from_file(newConfig, localPath, flags, &err);
+
+      if (err != NULL) {
+         g_warning("Error loading conf file: %s\n", err->message);
+         g_clear_error(&err);
+         g_key_file_free(newConfig);
+         newConfig = NULL;
+      } else {
+         ret = TRUE;
+      }
+
+      VMTOOLS_RELEASE_FILENAME_LOCAL(localPath);
+   }
+
+   if (newConfig != NULL) {
+      if (*config != NULL) {
+         g_key_file_free(*config);
+      }
+      *config = newConfig;
+      *mtime = confStat.st_mtime;
+   }
+
+exit:
+   return ret;
+}
+
+
+/**
+ * Saves the given config data to the given path.
+ *
+ * @param[in]  path     Where to save the data.
+ * @param[in]  config   Config data.
+ * @param[out] err      Where to store error information (may be NULL).
+ *
+ * @return Whether saving was successful.
+ */
+
+gboolean
+VMTools_WriteConfig(const gchar *path,
+                    GKeyFile *config,
+                    GError **err)
+{
+   gboolean ret = FALSE;
+   gchar *data = NULL;
+   gchar *localPath = NULL;
+   FILE *out = NULL;
+   GError *lerr = NULL;
+
+   g_assert(path != NULL);
+   g_assert(config != NULL);
+
+   localPath = VMTOOLS_GET_FILENAME_LOCAL(path, &lerr);
+   if (lerr != NULL) {
+      g_warning("Error converting to local encoding: %s\n", lerr->message);
+      goto exit;
+   }
+
+   data = g_key_file_to_data(config, NULL, &lerr);
+   if (lerr != NULL) {
+      g_warning("Error serializing conf data: %s\n", lerr->message);
+      goto exit;
+   }
+
+   out = g_fopen(localPath, "w");
+
+   if (out == NULL) {
+      const char *errstr = strerror(errno);
+      g_warning("Error opening conf file for writing: %s\n", errstr);
+      g_set_error(&lerr, G_FILE_ERROR, G_FILE_ERROR_FAILED, "%s", errstr);
+      goto exit;
+   }
+
+   if (g_fprintf(out, "%s", data) < 0) {
+      const char *errstr = strerror(errno);
+      g_warning("Error writing conf file: %s\n", errstr);
+      g_set_error(&lerr, G_FILE_ERROR, G_FILE_ERROR_FAILED, "%s", errstr);
+      goto exit;
+   }
+
+   ret = TRUE;
+
+exit:
+   if (out != NULL) {
+      fclose(out);
+   }
+   if (err != NULL && lerr != NULL) {
+      *err = lerr;
+   } else {
+      g_clear_error(&lerr);
+   }
+   g_free(data);
+   VMTOOLS_RELEASE_FILENAME_LOCAL(localPath);
+   return ret;
+}
+
diff --git a/open-vm-tools/libvmtools/vmtoolsLog.c b/open-vm-tools/libvmtools/vmtoolsLog.c
new file mode 100644 (file)
index 0000000..83b4b33
--- /dev/null
@@ -0,0 +1,597 @@
+/*********************************************************
+ * Copyright (C) 2008 VMware, Inc. All rights reserved.
+ *
+ * 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 the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/**
+ * @file vmtoolsLog.c
+ *
+ *    Defines a logging infrastructure for the vmtools library based
+ *    on glib's logging facilities. Wrap the commonly used logging functions
+ *    (Log/Warning/Debug), and provides configurability for where logs should
+ *    go to.
+ *
+ *    To choose the logging domain for your source file, define G_LOG_DOMAIN
+ *    before including glib.h.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib/gstdio.h>
+
+#include "vmtools.h"
+#include "codeset.h"
+#if defined(G_PLATFORM_WIN32)
+#  include "coreDump.h"
+#endif
+#include "file.h"
+#include "str.h"
+#include "system.h"
+
+#if defined(G_PLATFORM_WIN32)
+#  define  DEFAULT_HANDLER    VMToolsLogOutputDebugString
+#else
+#  define  DEFAULT_HANDLER    VMToolsLogFile
+#endif
+
+#define MAX_DOMAIN_LEN        64
+
+/*
+ * glib will send log messages to the default handler if there's no
+ * handler specified for a given log level. We want to avoid that,
+ * and force configuration at each different log domain, so we always
+ * register the handlers for all log levels, and filter at the handler
+ * function.
+ */
+#define ALL_LOG_LEVELS        G_LOG_LEVEL_ERROR    |  \
+                              G_LOG_LEVEL_CRITICAL |  \
+                              G_LOG_LEVEL_WARNING  |  \
+                              G_LOG_LEVEL_MESSAGE  |  \
+                              G_LOG_LEVEL_INFO     |  \
+                              G_LOG_LEVEL_DEBUG
+
+/** Tells whether the given log level is a fatal error. */
+#define IS_FATAL(level) ((level) & G_LOG_FLAG_FATAL)
+
+/**
+ * Tells whether a message should be logged. All fatal messages are logged,
+ * regardless of what the configuration says. Otherwise, the log domain's
+ * configuration is respected.
+ */
+#define SHOULD_LOG(level, data) (IS_FATAL(level) || \
+                                 (gLogEnabled && ((data)->mask & (level))))
+
+
+typedef struct LogHandlerData {
+   GLogLevelFlags    mask;
+   FILE             *file;
+} LogHandlerData;
+
+static gchar *gLogDomain = NULL;
+static gboolean gEnableCoreDump = TRUE;
+static gboolean gLogEnabled = FALSE;
+static guint gPanicCount = 0;
+static LogHandlerData *gDefaultData = NULL;
+
+/* Internal functions. */
+
+/**
+ * Opens a log file for writing, backing up the existing log file if one is
+ * present. Only one old log file is preserved.
+ *
+ * @param[in] path   Path to log file.
+ *
+ * @return File pointer for writing to the file (NULL on error).
+ */
+
+static FILE *
+VMToolsLogOpenFile(const gchar *path)
+{
+   FILE *logfile = NULL;
+
+   g_assert(path != NULL);
+   if (File_Exists(path)) {
+      /* Back up existing log file. */
+      char *bakFile = Str_Asprintf(NULL, "%s.old", path);
+      if (bakFile &&
+          !File_IsDirectory(bakFile) &&
+          0 == File_UnlinkIfExists(bakFile)) {  // remove old back up file.
+         File_Rename(path, bakFile);
+      }
+      free(bakFile);
+   }
+   logfile = g_fopen(path, "w");
+   return logfile;
+}
+
+
+/**
+ * Creates a formatted message to be logged. The format of the message will be:
+ *
+ *    [timestamp] [domain] [level] Log message
+ *
+ * @param[in] message      User log message.
+ * @param[in] domain       Log domain.
+ * @param[in] level        Log level.
+ * @param[in] timestamp    Whether to print the timestamp.
+ *
+ * @return Formatted log message in the current encoding. Should be free()'d.
+ */
+
+static char *
+VMToolsLogFormat(const gchar *message,
+                 const gchar *domain,
+                 GLogLevelFlags level,
+                 gboolean timestamp)
+{
+   char *msg = NULL;
+   char *msgCurr = NULL;
+   char *slevel;
+
+   if (domain == NULL) {
+      domain = gLogDomain;
+   }
+
+   switch (level & G_LOG_LEVEL_MASK) {
+   case G_LOG_LEVEL_ERROR:
+      slevel = "error";
+      break;
+
+   case G_LOG_LEVEL_CRITICAL:
+      slevel = "critical";
+      break;
+
+   case G_LOG_LEVEL_WARNING:
+      slevel = "warning";
+      break;
+
+   case G_LOG_LEVEL_MESSAGE:
+      slevel = "message";
+      break;
+
+   case G_LOG_LEVEL_INFO:
+      slevel = "info";
+      break;
+
+   case G_LOG_LEVEL_DEBUG:
+      slevel = "debug";
+      break;
+
+   default:
+      slevel = "unknown";
+   }
+
+   if (timestamp) {
+      char *tstamp;
+
+      tstamp = System_GetTimeAsString();
+      msg = Str_Asprintf(NULL, "[%s] [%8s] [%s] %s\n",
+                         (tstamp != NULL) ? tstamp : "no time",
+                         slevel, domain, message);
+      free(tstamp);
+   } else {
+      msg = Str_Asprintf(NULL, "[%8s] [%s] %s", slevel, domain, message);
+   }
+
+   if (msg != NULL) {
+      size_t len;
+      CodeSet_Utf8ToCurrent(msg, strlen(msg), &msgCurr, &len);
+
+      /*
+       * The log messages from glib itself (and probably other libraries based
+       * on glib) do not include a trailing new line. Most of our code does. So
+       * we detect whether the original message already had a new line, and
+       * remove it, to avoid having two newlines when printing our log messages.
+       */
+      if (msgCurr[len - 2] == '\n') {
+         msgCurr[len - 1] = '\0';
+      }
+   }
+
+   free(msg);
+   return msgCurr;
+}
+
+
+/**
+ * Aborts the program, optionally creating a core dump.
+ */
+
+static INLINE NORETURN void
+VMToolsLogPanic(void)
+{
+   if (gEnableCoreDump) {
+#if defined(G_PLATFORM_WIN32)
+      CoreDump_CoreDump();
+#else
+      abort();
+#endif
+   }
+   /* Same behavior as Panic_Panic(). */
+   exit(-1);
+}
+
+
+#if defined(G_PLATFORM_WIN32)
+/**
+ * Logs a message to OutputDebugString.
+ *
+ * @param[in] domain    Log domain.
+ * @param[in] level     Log level.
+ * @param[in] message   Message to log.
+ * @param[in] _data     LogHandlerData pointer.
+ */
+
+static void
+VMToolsLogOutputDebugString(const gchar *domain,
+                            GLogLevelFlags level,
+                            const gchar *message,
+                            gpointer _data)
+{
+   LogHandlerData *data = _data;
+   if (SHOULD_LOG(level, data)) {
+      char *msg = VMToolsLogFormat(message, domain, level, FALSE);
+      if (msg != NULL) {
+         OutputDebugStringA(msg);
+         free(msg);
+      }
+   }
+   if (IS_FATAL(level)) {
+      VMToolsLogPanic();
+   }
+}
+#endif
+
+
+/**
+ * Logs a message to a file streams. When writing to the standard streams,
+ * any level >= MESSAGE will cause the message to go to stdout; otherwise,
+ * it will go to stderr.
+ *
+ * @param[in] domain    Log domain.
+ * @param[in] level     Log level.
+ * @param[in] message   Message to log.
+ * @param[in] _data     LogHandlerData pointer.
+ */
+
+static void
+VMToolsLogFile(const gchar *domain,
+               GLogLevelFlags level,
+               const gchar *message,
+               gpointer _data)
+{
+   LogHandlerData *data = _data;
+   if (SHOULD_LOG(level, data)) {
+      char *msg = VMToolsLogFormat(message, domain, level, TRUE);
+      if (msg != NULL) {
+         FILE *dest =  (data->file != NULL) ? data->file
+                          : ((level < G_LOG_LEVEL_MESSAGE) ? stderr : stdout);
+         fputs(msg, dest);
+         fflush(dest);
+         free(msg);
+      }
+   }
+   if (IS_FATAL(level)) {
+      VMToolsLogPanic();
+   }
+}
+
+
+/**
+ * Initializes the default log handler.
+ */
+
+void
+VMTools_InitLogging(void)
+{
+   gDefaultData = g_malloc0(sizeof *gDefaultData);
+   gDefaultData->mask = G_LOG_LEVEL_ERROR |
+                        G_LOG_LEVEL_CRITICAL |
+                        G_LOG_LEVEL_WARNING;
+#if defined(VMX86_DEBUG)
+   gDefaultData->mask |= G_LOG_LEVEL_MESSAGE;
+#endif
+   gLogDomain = g_strdup("vmtools");
+   g_log_set_default_handler(DEFAULT_HANDLER, gDefaultData);
+}
+
+
+
+/* Public API. */
+
+/**
+ * Returns the default log domain for the application.
+ *
+ * @return  A string with the name of the log domain.
+ */
+
+const char *
+VMTools_GetDefaultLogDomain(void)
+{
+   return gLogDomain;
+}
+
+
+/**
+ * Sets the default log domain. This only changes the output of the default
+ * log handler.
+ *
+ * @param[in]  domain   The log domain.
+ */
+
+void
+VMTools_SetDefaultLogDomain(const gchar *domain)
+{
+   g_assert(domain != NULL);
+   if (gLogDomain != NULL) {
+      g_free(gLogDomain);
+   }
+   gLogDomain = g_strdup(domain);
+}
+
+
+/**
+ * Configures the logging system according to the configuration provided from
+ * the given dictionary.
+ *
+ * @param[in] cfg    The configuration data.
+ */
+
+void
+VMTools_ConfigLogging(GKeyFile *cfg)
+{
+   const gchar *group = "logging";
+   gchar **list;
+   gchar **curr;
+
+   if (!g_key_file_has_group(cfg, group)) {
+      return;
+   }
+
+   list = g_key_file_get_keys(cfg, group, NULL, NULL);
+
+   for (curr = list; curr != NULL && *curr != NULL; curr++) {
+      gchar *domain = *curr;
+      gchar *handler;
+      gchar *level = NULL;
+      gchar *logpath = NULL;
+      gchar key[128];
+      guint handlerId;
+
+      GLogFunc handlerFn = NULL;
+      GLogLevelFlags levelsMask;
+      LogHandlerData *data;
+      FILE *logfile = NULL;
+
+      /* Check whether it's a domain "declaration". */
+      if (!g_str_has_suffix(domain, ".level")) {
+         continue;
+      }
+
+      level = g_key_file_get_string(cfg, group, domain, NULL);
+
+      /* Trims ".level" from the key to get the domain name. */
+      domain[strlen(domain) - 6] = '\0';
+
+      /* Arbitrary limit. */
+      if (strlen(domain) > MAX_DOMAIN_LEN) {
+         g_warning("Domain name too long: %s\n", domain);
+         continue;
+      } else if (strlen(domain) == 0) {
+         g_warning("Invalid domain declaration, missing name.\n");
+         continue;
+      }
+
+      /* Parse the handler information. */
+      Str_Sprintf(key, sizeof key, "%s.handler", domain);
+      handler = g_key_file_get_string(cfg, group, key, NULL);
+
+      if (handler == NULL) {
+         handlerFn = DEFAULT_HANDLER;
+      } else if (strcmp(handler, "std") == 0) {
+         handlerFn = VMToolsLogFile;
+      } else if (strcmp(handler, "file") == 0) {
+         /* Don't set up the file sink if logging is disabled. */
+         if (strcmp(level, "none") != 0) {
+            handlerFn = VMToolsLogFile;
+            Str_Sprintf(key, sizeof key, "%s.data", domain);
+            logpath = g_key_file_get_string(cfg, group, key, NULL);
+            if (logpath == NULL) {
+               g_warning("Missing log path for file handler (%s).\n", domain);
+               goto next;
+            }
+         }
+#if defined(G_PLATFORM_WIN32)
+      } else if (strcmp(handler, "outputdebugstring") == 0) {
+         handlerFn = VMToolsLogOutputDebugString;
+#endif
+      } else {
+         g_warning("Unknown log handler: %s\n", handler);
+         goto next;
+      }
+
+      /* Parse the log level configuration, and build the mask. */
+      if (strcmp(level, "error") == 0) {
+         levelsMask = G_LOG_LEVEL_ERROR;
+      } else if (strcmp(level, "critical") == 0) {
+         levelsMask = G_LOG_LEVEL_ERROR |
+                      G_LOG_LEVEL_CRITICAL;
+      } else if (strcmp(level, "warning") == 0) {
+         levelsMask = G_LOG_LEVEL_ERROR |
+                      G_LOG_LEVEL_CRITICAL |
+                      G_LOG_LEVEL_WARNING;
+      } else if (strcmp(level, "message") == 0) {
+         levelsMask = G_LOG_LEVEL_ERROR |
+                      G_LOG_LEVEL_CRITICAL |
+                      G_LOG_LEVEL_WARNING |
+                      G_LOG_LEVEL_MESSAGE;
+      } else if (strcmp(level, "info") == 0) {
+         levelsMask = G_LOG_LEVEL_ERROR |
+                      G_LOG_LEVEL_CRITICAL |
+                      G_LOG_LEVEL_WARNING |
+                      G_LOG_LEVEL_MESSAGE |
+                      G_LOG_LEVEL_INFO;
+      } else if (strcmp(level, "debug") == 0) {
+         levelsMask = ALL_LOG_LEVELS;
+      } else if (strcmp(level, "none") == 0) {
+         levelsMask = 0;
+      } else {
+         g_warning("Unknown log level (%s): %s\n", domain, level);
+         goto next;
+      }
+
+      /* Initialize the log file, if using the "file" handler. */
+      if (logpath != NULL) {
+         logfile = VMToolsLogOpenFile(logpath);
+         if (logfile == NULL) {
+            g_warning("Couldn't open log file (%s): %s\n", domain, logpath);
+            goto next;
+         }
+      }
+
+      data = g_malloc0(sizeof *data);
+      data->mask = levelsMask;
+      data->file = logfile;
+
+      if (strcmp(domain, VMTools_GetDefaultLogDomain()) == 0) {
+         g_free(gDefaultData);
+         gDefaultData = NULL;
+         g_log_set_default_handler(handlerFn, data);
+      }
+      handlerId = g_log_set_handler(domain, ALL_LOG_LEVELS, handlerFn, data);
+
+   next:
+      g_free(handler);
+      g_free(logpath);
+      g_free(level);
+   }
+
+   g_strfreev(list);
+
+   gLogEnabled = g_key_file_get_boolean(cfg, group, "log", NULL);
+   if (g_key_file_has_key(cfg, group, "enableCoreDump", NULL)) {
+      gEnableCoreDump = g_key_file_get_boolean(cfg, group, "enableCoreDump", NULL);
+   }
+}
+
+
+/**
+ * Enables of disables all the log domains configured by the vmtools library.
+ * This doesn't affect other log domains that may have configured by other
+ * code.
+ *
+ * @param[in] enable    Whether logging should be enabled.
+ */
+
+void
+VMTools_EnableLogging(gboolean enable)
+{
+   gLogEnabled = enable;
+}
+
+
+/* Wrappers for VMware's logging functions. */
+
+/**
+ * Logs a message using the G_LOG_LEVEL_DEBUG level.
+ *
+ * @param[in] fmt Log message format.
+ */
+
+void
+Debug(const char *fmt, ...)
+{
+   va_list args;
+   va_start(args, fmt);
+   g_logv(gLogDomain, G_LOG_LEVEL_DEBUG, fmt, args);
+   va_end(args);
+}
+
+
+/**
+ * Logs a message using the G_LOG_LEVEL_MESSAGE level.
+ *
+ * @param[in] fmt Log message format.
+ */
+
+void
+Log(const char *fmt, ...)
+{
+   /* CoreDump_CoreDump() calls Log(), avoid that message. */
+   if (gPanicCount == 0) {
+      va_list args;
+      va_start(args, fmt);
+      g_logv(gLogDomain, G_LOG_LEVEL_MESSAGE, fmt, args);
+      va_end(args);
+   }
+}
+
+
+/**
+ * Logs a message using the G_LOG_LEVEL_ERROR level. In the default
+ * configuration, this will cause the application to terminate and,
+ * if enabled, to dump core.
+ *
+ * @param[in] fmt Log message format.
+ */
+
+void
+Panic(const char *fmt, ...)
+{
+   va_list args;
+
+   gPanicCount++;
+   va_start(args, fmt);
+   if (gPanicCount == 1) {
+      g_logv(gLogDomain, G_LOG_LEVEL_ERROR, fmt, args);
+   } else {
+      char *msg;
+      g_vasprintf(&msg, fmt, args);
+      if (gPanicCount == 2) {
+         fprintf(stderr, "Recursive panic: %s\n", msg);
+      } else {
+         fprintf(stderr, "Recursive panic, giving up: %s\n", msg);
+         exit(-1);
+      }
+      g_free(msg);
+   }
+   va_end(args);
+   /*
+    * In case an user-installed custom handler doesn't panic on error, force a
+    * core dump. Also force a dump in the recursive case.
+    */
+   VMToolsLogPanic();
+}
+
+
+/**
+ * Logs a message using the G_LOG_LEVEL_WARNING level.
+ *
+ * @param[in] fmt Log message format.
+ */
+
+void
+Warning(const char *fmt, ...)
+{
+   /* CoreDump_CoreDump() may call Warning(), avoid that message. */
+   if (gPanicCount == 0) {
+      va_list args;
+      va_start(args, fmt);
+      g_logv(gLogDomain, G_LOG_LEVEL_WARNING, fmt, args);
+      va_end(args);
+   }
+}
+
diff --git a/open-vm-tools/libvmtools/vmtoolslib_version.h b/open-vm-tools/libvmtools/vmtoolslib_version.h
new file mode 100644 (file)
index 0000000..9b772fd
--- /dev/null
@@ -0,0 +1,27 @@
+/*********************************************************
+ * Copyright (C) 2008 VMware, Inc. All rights reserved.
+ *
+ * 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 the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+#ifndef _VMTOOLSLIB_VERSION_H_
+#define _VMTOOLSLIB_VERSION_H_
+
+#include "vm_tools_version.h"
+#define VMTOOLSLIB_VERSION_COMMAS   TOOLS_VERSION_EXT_CURRENT_CSV
+#define VMTOOLSLIB_VERSION_STRING   TOOLS_VERSION_EXT_CURRENT_STR
+
+#endif /* _VMTOOLS_VERSION_H_ */
+
index fbf37b52aa4ba91a5ef7573148bb246c8fd571e1..b8b72a4b6769fe4bbb2c665eff61901156c279c9 100755 (executable)
@@ -3,10 +3,13 @@ all: modules
 .PHONY: modules $(MODULES)
 modules: $(MODULES)
 
+modulesrc = $(top_srcdir)/modules
+
 $(MODULES):
-       $(MAKE) VM_UNAME=$(KERNEL_RELEASE) -C "$(MODULES_OS)/$@"
+       $(MAKE) VM_UNAME=$(KERNEL_RELEASE) -C "$(modulesrc)/$(MODULES_OS)/$@"
 
 if LINUX
+export pvscsidir := $(MODULES_DIR)/drivers/scsi
 export vmblockdir := $(MODULES_DIR)/fs/vmblock
 export vmcidir := $(MODULES_DIR)/drivers/misc
 export vmhgfsdir := $(MODULES_DIR)/fs/vmhgfs
@@ -30,19 +33,22 @@ endif FREEBSD
 
 ## Automake will supplement its own "clean" targets with this.
 clean-local:
-       for MOD in $(MODULES); do \
-          $(MAKE) -C "$(MODULES_OS)/$$MOD" clean || exit 1; \
+       for MOD in $(MODULES); do                                                                                                                       \
+          if [ -d "$(modulesrc)/$(MODULES_OS)/$$MOD" ]; then                                           \
+             $(MAKE) -C "$(modulesrc)/$(MODULES_OS)/$$MOD" clean || exit 1; \
+          fi                                                                                                                                                                           \
        done
-       $(RM) -f $(MODULES_OS)/*.o $(MODULES_OS)/*.ko
+       $(RM) -f $(modulesrc)/$(MODULES_OS)/*.o $(modulesrc)/$(MODULES_OS)/*.ko
 
 install-exec-hook:
-       for MOD in $(MODULES); do \
-               $(INSTALL) -d $(DESTDIR)`eval echo '$$'$${MOD}dir`; \
-               $(INSTALL) -m644 $(MODULES_OS)/$$MOD/$$MOD.ko $(DESTDIR)`eval echo '$$'$${MOD}dir`; \
+       for MOD in $(MODULES); do                                                                                                       \
+          $(INSTALL) -d $(DESTDIR)`eval echo '$$'$${MOD}dir`;                  \
+          $(INSTALL) -m644 $(modulesrc)/$(MODULES_OS)/$$MOD/$$MOD.ko   \
+             $(DESTDIR)`eval echo '$$'$${MOD}dir`;                                                     \
        done
        eval "$$DEPMOD"
 uninstall-hook:
        for MOD in $(MODULES); do \
-               $(RM) -f $(DESTDIR)`eval echo '$$'$${MOD}dir`/$$MOD.ko &> /dev/null; \
+          $(RM) -f $(DESTDIR)`eval echo '$$'$${MOD}dir`/$$MOD.ko &> /dev/null; \
        done
        eval "$$DEPMOD"
index 8322ee5464ab8658671eaebe39ec7c612198c73f..4c8255f7082ed229f264b278271a325fd27d6078 100644 (file)
@@ -95,8 +95,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -107,6 +105,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -123,7 +160,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -133,6 +170,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -155,9 +194,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -243,6 +279,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -264,10 +306,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -283,7 +325,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index c06c5212d780fc680214970cb0c0f029611bedcc..b902e6eb2285b5ea5c0fd3b6964be07db373ad70 100644 (file)
 #define BDOOR_CMD_DEBUGEVENT            53
 #define BDOOR_CMD_OSNOTMACOSXSERVER     54
 #define BDOOR_CMD_GETTIMEFULL_WITH_LAG  55
-#define BDOOR_CMD_ACPI_HOTPLUG          56
-#define BDOOR_CMD_MAX                   57
+#define BDOOR_CMD_ACPI_HOTPLUG_DEVICE   56
+#define BDOOR_CMD_ACPI_HOTPLUG_MEMORY   57
+#define BDOOR_CMD_ACPI_HOTPLUG_CBRET    58
+#define BDOOR_CMD_GET_HOST_VIDEO_MODES  59
+#define BDOOR_CMD_MAX                   60
 
 /* 
  * IMPORTANT NOTE: When modifying the behavior of an existing backdoor command,
index a3acf9121bd4b9b65b538f617a70281b016c9aad..e803269cf7aaee5e3c321ece50ee2216118aa90d 100644 (file)
@@ -1133,16 +1133,17 @@ HgfsVnodeGetInt(struct vnode **vpp,        // OUT
                HgfsFileHashTable *htp,    // IN
                Bool rootVnode)            // IN
 {
+   struct vnode *vp;
+   struct vnode_fsparam params;
+   int ret = 0;
+   HgfsOpenFile *ofp;
+
    ASSERT(vpp);
    ASSERT(sip);
    ASSERT(vfsp);
    ASSERT(fileName);
    ASSERT(htp);
 
-   struct vnode *vp;
-   struct vnode_fsparam params;
-   int ret = 0;
-
    params.vnfs_mp         = vfsp;
    params.vnfs_str        = NULL;
    params.vnfs_dvp        = NULL;
@@ -1192,7 +1193,7 @@ HgfsVnodeGetInt(struct vnode **vpp,        // OUT
     * necessary) the per-file state.
     */
 
-   HgfsOpenFile *ofp = HgfsAllocOpenFile(fileName, fileType, htp);
+   ofp = HgfsAllocOpenFile(fileName, fileType, htp);
 
    params.vnfs_fsnode = (void *)ofp;
    if (params.vnfs_fsnode == NULL) {
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index a001ec463a32cd37a277b79aa64796a45f1a858a..01452142d0a163e04b6598f26935d84ed3bb7b93 100644 (file)
 /*
  * balloon_def.h -- 
  *
- *     Definitions for server "balloon" mechanism for reclaiming
- *     physical memory from a VM.
+ *      Definitions for server "balloon" mechanism for reclaiming
+ *      physical memory from a VM.
  */
 
-#ifndef        _BALLOON_DEF_H
-#define        _BALLOON_DEF_H
+#ifndef _BALLOON_DEF_H
+#define _BALLOON_DEF_H
 
 #define INCLUDE_ALLOW_VMCORE
 #define INCLUDE_ALLOW_VMKERNEL
-#define        INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_MODULE
 #include "includeCheck.h"
 
 #include "vm_basic_types.h"
  */
 
 /* backdoor port */
-#define        BALLOON_BDOOR_PORT              (0x5670)
-#define        BALLOON_BDOOR_MAGIC             (0x456c6d6f)
+#define BALLOON_BDOOR_PORT              (0x5670)
+#define BALLOON_BDOOR_MAGIC             (0x456c6d6f)
 
 /* backdoor command numbers */
-#define        BALLOON_BDOOR_CMD_START         (0)
-#define        BALLOON_BDOOR_CMD_TARGET        (1)
-#define        BALLOON_BDOOR_CMD_LOCK          (2)
-#define        BALLOON_BDOOR_CMD_UNLOCK        (3)
-#define        BALLOON_BDOOR_CMD_GUEST_ID      (4)
+#define BALLOON_BDOOR_CMD_START         (0)
+#define BALLOON_BDOOR_CMD_TARGET        (1)
+#define BALLOON_BDOOR_CMD_LOCK          (2)
+#define BALLOON_BDOOR_CMD_UNLOCK        (3)
+#define BALLOON_BDOOR_CMD_GUEST_ID      (4)
 
 /* use config value for max balloon size */
-#define BALLOON_MAX_SIZE_USE_CONFIG    (0)
+#define BALLOON_MAX_SIZE_USE_CONFIG     (0)
 
 /* guest identities */
-#define BALLOON_GUEST_UNKNOWN          (0)
-#define BALLOON_GUEST_LINUX            (1)
-#define BALLOON_GUEST_BSD              (2)
-#define BALLOON_GUEST_WINDOWS_NT4      (3)
-#define BALLOON_GUEST_WINDOWS_NT5      (4)
-#define BALLOON_GUEST_SOLARIS          (5)
+#define BALLOON_GUEST_UNKNOWN           (0)
+#define BALLOON_GUEST_LINUX             (1)
+#define BALLOON_GUEST_BSD               (2)
+#define BALLOON_GUEST_WINDOWS_NT4       (3)
+#define BALLOON_GUEST_WINDOWS_NT5       (4)
+#define BALLOON_GUEST_SOLARIS           (5)
 
 /* error codes */
-#define        BALLOON_SUCCESS                 (0)
-#define        BALLOON_FAILURE                 (-1)
-#define        BALLOON_ERROR_CMD_INVALID       (1)
-#define        BALLOON_ERROR_PPN_INVALID       (2)
-#define        BALLOON_ERROR_PPN_LOCKED        (3)
-#define        BALLOON_ERROR_PPN_UNLOCKED      (4)
-#define        BALLOON_ERROR_PPN_PINNED        (5)
-#define        BALLOON_ERROR_PPN_TRANSPARENT   (6)
-#define        BALLOON_ERROR_RESET             (7)
-#define        BALLOON_ERROR_BUSY              (8)
+#define BALLOON_SUCCESS                 (0)
+#define BALLOON_FAILURE                (-1)
+#define BALLOON_ERROR_CMD_INVALID       (1)
+#define BALLOON_ERROR_PPN_INVALID       (2)
+#define BALLOON_ERROR_PPN_LOCKED        (3)
+#define BALLOON_ERROR_PPN_UNLOCKED      (4)
+#define BALLOON_ERROR_PPN_PINNED        (5)
+#define BALLOON_ERROR_PPN_NOTNEEDED     (6)
+#define BALLOON_ERROR_RESET             (7)
+#define BALLOON_ERROR_BUSY              (8)
 
-#endif /* _BALLOON_DEF_H */
+#endif  /* _BALLOON_DEF_H */
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 083fbcd1d3bdb529545035d3129be18e42b5fc1b..5c6e8f06489118271c5e2837e02f5a41bbe7aa09 100644 (file)
 #include "guiddef.h"
 #endif
 
+/* LSILogic 53C1030 Parallel SCSI controller
+ * LSILogic SAS1068 SAS controller
+ */
+#define PCI_VENDOR_ID_LSILOGIC          0x1000
+#define PCI_DEVICE_ID_LSI53C1030        0x0030
+#define PCI_DEVICE_ID_LSISAS1068        0x0054
+
 /* Our own PCI IDs
  *    VMware SVGA II (Unified VGA)
  *    VMware SVGA (PCI Accelerator)
index ffed427f46b8f4bb62eccc0fceb454ad9fe9c88b..961bfd278b28b850911d449e07a3a8f2443eb1de 100644 (file)
@@ -1,5 +1,5 @@
 PACKAGE_NAME=open-vm-tools
-PACKAGE_VERSION=2008.11.18
+PACKAGE_VERSION=8.0.0
 MAKE[0]="make -C pvscsi VM_UNAME=\$kernelver;   \
          make -C vmblock VM_UNAME=\$kernelver;  \
          make -C vmhgfs VM_UNAME=\$kernelver;   \
index 9454ba8d8bcc4b2b09f9b7b0f2183c183e0fe6ef..66bb714d75a4ce0b8a4271b017c41a37eaf29cdc 100644 (file)
@@ -382,7 +382,9 @@ typedef struct {
         tio         :1,   // device supports TERMINATE I/O PROCESS message
         aen         :1;   // asynchronous event notification capability
    uint8 optlen;          // length of additional data that follows
-   uint8            :8;
+   uint8       :4,
+         tpgs  :2,         // Target Portal Group Support
+               :2;
 #define SCSI_TPGS_NONE                       0x0
 #define SCSI_TPGS_IMPLICIT_ONLY              0x1
 #define SCSI_TPGS_IMPLICIT                  SCSI_TPGS_IMPLICIT_ONLY 
@@ -431,7 +433,9 @@ typedef struct {
         tio         :1,   // device supports TERMINATE I/O PROCESS message
         aen         :1;   // asynchronous event notification capability
    uint8 optlen;          // length of additional data that follows
-   uint8            :8;
+   uint8       :4,
+         tpgs  :2,         // Target Portal Group Support
+               :2;
    uint8 adr16      :1,   // device supports 16-bit wide SCSI addresses
         adr32       :1,   // device supports 32-bit wide SCSI addresses
         arq         :1,
@@ -553,6 +557,34 @@ struct SCSIInqPage83ResponseDescriptor {
 #include "vmware_pack_end.h"
 SCSIInqPage83ResponseDescriptor;
 
+/* Page83 structs differ for SCSI2. */
+typedef
+#include "vmware_pack_begin.h"
+struct SCSI2InqPage83ResponseHeader {
+   uint8  devClass      :5,
+          pQual         :3;
+   uint8  pageCode;
+   uint8  reserved;
+   uint8  pageLength;
+}
+#include "vmware_pack_end.h"
+SCSI2InqPage83ResponseHeader;
+
+typedef
+#include "vmware_pack_begin.h"
+struct SCSI2InqPage83ResponseDescriptor {
+   /* Identification Descriptor follows */
+   uint8  codeSet     :4, 
+          reserved    :4; 
+   uint8  idType      :4, 
+          association :2,
+          reserved1   :2; 
+   uint8  reserved2;
+   uint8  idLength;
+}
+#include "vmware_pack_end.h"
+SCSI2InqPage83ResponseDescriptor;
+
 typedef
 #include "vmware_pack_begin.h"
 struct SCSIInquiryVPDResponseHeader {
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 083fbcd1d3bdb529545035d3129be18e42b5fc1b..5c6e8f06489118271c5e2837e02f5a41bbe7aa09 100644 (file)
 #include "guiddef.h"
 #endif
 
+/* LSILogic 53C1030 Parallel SCSI controller
+ * LSILogic SAS1068 SAS controller
+ */
+#define PCI_VENDOR_ID_LSILOGIC          0x1000
+#define PCI_DEVICE_ID_LSI53C1030        0x0030
+#define PCI_DEVICE_ID_LSISAS1068        0x0054
+
 /* Our own PCI IDs
  *    VMware SVGA II (Unified VGA)
  *    VMware SVGA (PCI Accelerator)
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index e77d518a162ae6327b36c6d75ddd040c4b527912..abfa5fccf429a6d290328f28a83d7c070e293839 100644 (file)
@@ -1417,6 +1417,39 @@ Atomic_ReadDec64(Atomic_uint64 *var) // IN
 #endif
 
 
+#ifdef VMKERNEL
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CMPXCHG1B --
+ *
+ *      Compare and exchange a single byte.
+ *
+ * Results:
+ *      The value read from ptr.
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+static INLINE uint8
+CMPXCHG1B(volatile uint8 *ptr, // IN
+          uint8 oldVal,        // IN
+          uint8 newVal)        // IN
+{
+   uint8 val;
+   __asm__ __volatile__("lock; cmpxchgb %b2, %1"
+                        : "=a" (val),
+                          "+m" (*ptr)
+                        : "r" (newVal),
+                          "0" (oldVal)
+                        : "cc");
+   return val;
+}
+#endif
+
+
 /*
  * Usage of this helper struct is strictly reserved to the following
  * function. --hpreg
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 083fbcd1d3bdb529545035d3129be18e42b5fc1b..5c6e8f06489118271c5e2837e02f5a41bbe7aa09 100644 (file)
 #include "guiddef.h"
 #endif
 
+/* LSILogic 53C1030 Parallel SCSI controller
+ * LSILogic SAS1068 SAS controller
+ */
+#define PCI_VENDOR_ID_LSILOGIC          0x1000
+#define PCI_DEVICE_ID_LSI53C1030        0x0030
+#define PCI_DEVICE_ID_LSISAS1068        0x0054
+
 /* Our own PCI IDs
  *    VMware SVGA II (Unified VGA)
  *    VMware SVGA (PCI Accelerator)
diff --git a/open-vm-tools/modules/linux/vmci/vmciCommonInt.h b/open-vm-tools/modules/linux/vmci/vmciCommonInt.h
new file mode 100644 (file)
index 0000000..bccd228
--- /dev/null
@@ -0,0 +1,58 @@
+/*********************************************************
+ * Copyright (C) 2006 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ *********************************************************/
+
+/*
+ * vmciCommonInt.h --
+ *
+ * Struct definitions for VMCI internal common code.
+ */
+
+#ifndef _VMCI_COMMONINT_H_
+#define _VMCI_COMMONINT_H_
+
+#define INCLUDE_ALLOW_MODULE
+#include "includeCheck.h"
+
+#include "vm_atomic.h"
+#include "vmci_defs.h"
+#include "vmci_call_defs.h"
+#include "vmci_infrastructure.h"
+#include "vmci_handle_array.h"
+#include "vmci_kernel_if.h"
+#include "circList.h"
+
+struct DatagramQueueEntry {
+   ListItem listItem; /* For queuing. */
+   VMCIDatagram *dg;  /* Pending datagram. */
+};
+
+struct VMCIProcess {
+   ListItem         listItem;           /* For global process list. */
+   VMCIId           pid;                /* Process id. */
+};
+
+struct VMCIDatagramProcess {
+   VMCILock   datagramQueueLock;
+   VMCIHandle handle;
+   VMCIHost   host;
+   uint32     pendingDatagrams;
+   size_t     datagramQueueSize;
+   ListItem   *datagramQueue;
+};
+
+#endif /* _VMCI_COMMONINT_H_ */
index 759659e57a984ce900c70af0a5ed37949345b253..db7ad91de4ea2ae04ad7bae3e545e6c2db84d2e7 100644 (file)
 #elif defined(SOLARIS)
 #  include <sys/ddi.h>
 #  include <sys/sunddi.h>
+#elif defined(__APPLE__)
 #else
 #  error "Platform not support by VMCI datagram API."
 #endif // linux
 
+#include "vmci_kernel_if.h"
 #include "vm_basic_types.h"
 #include "vm_assert.h"
 #include "vmci_defs.h"
-#include "vmci_kernel_if.h"
 #include "vmci_infrastructure.h"
 #include "vmciInt.h"
 #include "vmciUtil.h"
 #include "vmciDatagram.h"
+#include "vmciCommonInt.h"
 
 typedef struct DatagramHashEntry {
    struct DatagramHashEntry  *next;
index 997da9dedfc40b7dd772b5dabcad504e09e910d8..5dd4797e21fd0bd5233ed56e2aaa3b8f8394de2f 100644 (file)
 #include "vmci_defs.h"
 #include "vmci_kernel_if.h"
 #include "vmci_infrastructure.h"
-#include "circList.h"
 #include "vmciGuestKernelAPI.h"
 #include "vmci_iocontrols.h"
 
-typedef struct DatagramQueueEntry {
-   ListItem listItem; /* For queuing. */
-   VMCIDatagram *dg;  /* Pending datagram. */
-} DatagramQueueEntry;
-
-typedef struct VMCIDatagramProcess {
-   VMCILock   datagramQueueLock;
-   VMCIHandle handle;
-   VMCIHost   host;
-   uint32     pendingDatagrams;
-   size_t     datagramQueueSize;
-   ListItem   *datagramQueue;
-} VMCIDatagramProcess;
+typedef struct DatagramQueueEntry DatagramQueueEntry;
+typedef struct VMCIDatagramProcess VMCIDatagramProcess;
 
 void VMCIDatagram_Init(void);
 Bool VMCIDatagram_CheckHostCapabilities(void);
index 5cf577eed2cbe0b8c25fa9ff02a48bb7387c8330..1068087b5a00e974e84ce887cf140e3145f74a0d 100644 (file)
@@ -41,6 +41,7 @@
 #include "circList.h"
 #include "vmciUtil.h"
 #include "vmciGuestKernelAPI.h"
+#include "vmciCommonInt.h"
 
 static ListItem *processList = NULL;
 static VMCILock processLock;
index 4135d4823e081a1736b3708aca358e897ce56b61..c73549f0c3c842cf85dc019c883348d4183975a6 100644 (file)
 
 #include "vmci_defs.h"
 #include "vmci_handle_array.h"
-#include "circList.h"
 
-typedef struct VMCIProcess {
-   ListItem        listItem;          /* For global process list. */
-   VMCIId          pid;               /* Process id. */
-} VMCIProcess;
+typedef struct VMCIProcess VMCIProcess;
 
 void VMCIProcess_Init(void);
 void VMCIProcess_Exit(void);
index 7421f9ef7added7cc8afc64edc7c417a26d4b7b2..9d81e2f06dfe1143b64b30b6e3128d118d5e6fd8 100644 (file)
@@ -435,7 +435,7 @@ VMCI_ReadDatagramsFromPort(VMCIIoHandle ioHandle,  // IN
    dg = (VMCIDatagram *)dgInBuffer; 
    remainingBytes = currentDgInBufferSize;
    
-   while (dg->dst.resource != VMCI_ERROR_INVALID_RESOURCE || remainingBytes > PAGE_SIZE) {
+   while (dg->dst.resource != VMCI_INVALID_ID || remainingBytes > PAGE_SIZE) {
       unsigned dgInSize;
       
       /*
@@ -443,7 +443,7 @@ VMCI_ReadDatagramsFromPort(VMCIIoHandle ioHandle,  // IN
        * start on any page boundary in the buffer. 
        */
 
-      if (dg->dst.resource == VMCI_ERROR_INVALID_RESOURCE) {
+      if (dg->dst.resource == VMCI_INVALID_ID) {
          ASSERT(remainingBytes > PAGE_SIZE);
          dg = (VMCIDatagram *)ROUNDUP((uintptr_t)dg + 1, PAGE_SIZE);
          ASSERT((uint8 *)dg < dgInBuffer + currentDgInBufferSize);
index f448e28ac754ec647c72b3fa8fa8743c40a217e3..fae5e0554ff8c97e0082c9969eba942cc3d102c0 100644 (file)
@@ -52,6 +52,7 @@
 #include "vmciEvent.h"
 #include "vmciQueuePairInt.h"
 #include "vmci_version.h"
+#include "vmciCommonInt.h"
 
 #define LGPFX "VMCI: "
 #define VMCI_DEVICE_MINOR_NUM 0
index 680c860104bc1921f48849e1d4cd4cdd06b49b50..a46a6b81e1eec926ba1cc382b576f1e8eb43a63f 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef _VMCI_VERSION_H_
 #define _VMCI_VERSION_H_
 
-#define VMCI_DRIVER_VERSION          1.0.15.0
-#define VMCI_DRIVER_VERSION_COMMAS   1,0,15,0
-#define VMCI_DRIVER_VERSION_STRING   "1.0.15.0"
+#define VMCI_DRIVER_VERSION          1.0.16.0
+#define VMCI_DRIVER_VERSION_COMMAS   1,0,16,0
+#define VMCI_DRIVER_VERSION_STRING   "1.0.16.0"
 
 #endif /* _VMCI_VERSION_H_ */
index c06c5212d780fc680214970cb0c0f029611bedcc..b902e6eb2285b5ea5c0fd3b6964be07db373ad70 100644 (file)
 #define BDOOR_CMD_DEBUGEVENT            53
 #define BDOOR_CMD_OSNOTMACOSXSERVER     54
 #define BDOOR_CMD_GETTIMEFULL_WITH_LAG  55
-#define BDOOR_CMD_ACPI_HOTPLUG          56
-#define BDOOR_CMD_MAX                   57
+#define BDOOR_CMD_ACPI_HOTPLUG_DEVICE   56
+#define BDOOR_CMD_ACPI_HOTPLUG_MEMORY   57
+#define BDOOR_CMD_ACPI_HOTPLUG_CBRET    58
+#define BDOOR_CMD_GET_HOST_VIDEO_MODES  59
+#define BDOOR_CMD_MAX                   60
 
 /* 
  * IMPORTANT NOTE: When modifying the behavior of an existing backdoor command,
index 8d2016062289aa26e7bd8bfda0a1b7326bd6ad5f..4fc9b5352f59c2cb42b62854486ef26c5bea3fd4 100644 (file)
@@ -62,6 +62,15 @@ static int HgfsDoWritepage(HgfsHandle handle,
                            struct page *page,
                            unsigned pageFrom,
                            unsigned pageTo);
+static void HgfsDoWriteBegin(struct page *page,
+                             unsigned pageFrom,
+                             unsigned pageTo);
+static int HgfsDoWriteEnd(struct file *file,
+                          struct page *page,
+                          unsigned pageFrom,
+                          unsigned pageTo,
+                          loff_t writeTo,
+                          unsigned copied);
 
 /* HGFS address space operations. */
 static int HgfsReadpage(struct file *file,
@@ -72,6 +81,31 @@ static int HgfsWritepage(struct page *page,
 #else
 static int HgfsWritepage(struct page *page);
 #endif
+
+/*
+ * Write aop interface has changed in 2.6.28. Specifically,
+ * the page locking semantics and requirement to handle
+ * short writes. We already handle short writes, so no major
+ * changes needed. write_begin is expected to return a locked
+ * page and write_end is expected to unlock the page and drop
+ * the reference before returning.
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
+static int HgfsWriteBegin(struct file *file,
+                          struct address_space *mapping,
+                          loff_t pos,
+                          unsigned len,
+                          unsigned flags,
+                          struct page **page,
+                          void **clientData);
+static int HgfsWriteEnd(struct file *file,
+                        struct address_space *mapping,
+                        loff_t pos,
+                        unsigned len,
+                        unsigned copied,
+                        struct page *page,
+                        void *clientData);
+#else
 static int HgfsPrepareWrite(struct file *file,
                             struct page *page,
                             unsigned pageFrom,
@@ -80,13 +114,19 @@ static int HgfsCommitWrite(struct file *file,
                            struct page *page,
                            unsigned pageFrom,
                            unsigned pageTo);
+#endif
 
 /* HGFS address space operations structure. */
 struct address_space_operations HgfsAddressSpaceOperations = {
    .readpage      = HgfsReadpage,
    .writepage     = HgfsWritepage,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
+   .write_begin   = HgfsWriteBegin,
+   .write_end     = HgfsWriteEnd,
+#else
    .prepare_write = HgfsPrepareWrite,
    .commit_write  = HgfsCommitWrite,
+#endif
 #ifdef HGFS_ENABLE_WRITEBACK
    .set_page_dirty = __set_page_dirty_nobuffers,
 #endif
@@ -698,14 +738,14 @@ HgfsWritepage(struct page *page)             // IN: Page to write from
 /*
  *-----------------------------------------------------------------------------
  *
- * HgfsPrepareWrite --
+ * HgfsDoWriteBegin --
  *
- *      Called by the generic write path to set up a write request for a page.
- *      We're expected to do any pre-allocation and housekeeping prior to
- *      receiving the write.
+ *      Helper function for HgfsWriteBegin / HgfsPrepareWrite.
+ *
+ *      Initialize the page if the file is to be appended.
  *
  * Results:
- *      Always zero.
+ *      None.
  *
  * Side effects:
  *      None.
@@ -713,12 +753,12 @@ HgfsWritepage(struct page *page)             // IN: Page to write from
  *-----------------------------------------------------------------------------
  */
 
-static int
-HgfsPrepareWrite(struct file *file,  // IN: Ignored
-                 struct page *page,  // IN: Page to prepare
-                 unsigned pageFrom,  // IN: Beginning page offset
-                 unsigned pageTo)    // IN: Ending page offset
+static void
+HgfsDoWriteBegin(struct page *page,         // IN: Page to be written
+                 unsigned pageFrom,         // IN: Starting page offset
+                 unsigned pageTo)           // IN: Ending page offset
 {
+   ASSERT(page);
 #ifdef HGFS_ENABLE_WRITEBACK
    loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
    loff_t currentFileSize = compat_i_size_read(page->mapping->host);
@@ -742,6 +782,35 @@ HgfsPrepareWrite(struct file *file,  // IN: Ignored
       flush_dcache_page(page);
    }
 #endif
+}
+
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsPrepareWrite --
+ *
+ *      Called by the generic write path to set up a write request for a page.
+ *      We're expected to do any pre-allocation and housekeeping prior to
+ *      receiving the write.
+ *
+ * Results:
+ *      Always zero.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+HgfsPrepareWrite(struct file *file,  // IN: Ignored
+                 struct page *page,  // IN: Page to prepare
+                 unsigned pageFrom,  // IN: Beginning page offset
+                 unsigned pageTo)    // IN: Ending page offset
+{
+   HgfsDoWriteBegin(page, pageFrom, pageTo);
 
    /*
     * Prior to 2.4.10, our caller expected to call page_address(page) between
@@ -758,48 +827,94 @@ HgfsPrepareWrite(struct file *file,  // IN: Ignored
    return 0;
 }
 
+#else
+
 
 /*
  *-----------------------------------------------------------------------------
  *
- * HgfsCommitWrite --
+ * HgfsWriteBegin --
  *
- *    This function is the more common write path for HGFS, called from
- *    generic_file_buffered_write. It is much simpler for us than
- *    HgfsWritepage above: the caller has obtained a reference to the page
- *    and will unlock it when we're done. And we don't need to worry about
- *    properly marking the writeback bit, either. See mm/filemap.c in the
- *    kernel for details about how we are called.
+ *      Called by the generic write path to set up a write request for a page.
+ *      We're expected to do any pre-allocation and housekeeping prior to
+ *      receiving the write.
+ *
+ *      This function is expected to return a locked page.
  *
  * Results:
- *    Zero on succes, non-zero on error.
+ *      Zero on success, non-zero error otherwise.
  *
  * Side effects:
- *    None.
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+HgfsWriteBegin(struct file *file,             // IN: File to be written
+               struct address_space *mapping, // IN: Mapping
+               loff_t pos,                    // IN: File position
+               unsigned len,                  // IN: Bytes to be written
+               unsigned flags,                // IN: Write flags
+               struct page **pagePtr,         // OUT: Locked page
+               void **clientData)             // OUT: Opaque to pass to write_end, unused
+{
+   pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+   unsigned pageFrom = pos & (PAGE_CACHE_SHIFT - 1);
+   unsigned pageTo = pos + len;
+   struct page *page;
+
+   page = __grab_cache_page(mapping, index);
+   if (page == NULL) {
+      return -ENOMEM;
+   }
+   *pagePtr = page;
+
+   HgfsDoWriteBegin(page, pageFrom, pageTo);
+   return 0;
+}
+#endif
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsDoWriteEnd --
+ *
+ *      Helper function for HgfsWriteEnd.
+ *
+ *      This function updates the inode->i_size, conditionally marks the page
+ *      updated and carries out the actual write in case of partial page writes.
+ *
+ * Results:
+ *      Zero on succes, non-zero on error.
+ *
+ * Side effects:
+ *      None.
  *
  *-----------------------------------------------------------------------------
  */
 
 static int
-HgfsCommitWrite(struct file *file, // IN: File we're writing to
-                struct page *page, // IN: Page we're writing from
-                unsigned pageFrom, // IN: Beginning page offset
-                unsigned pageTo)   // IN: Ending page offset
+HgfsDoWriteEnd(struct file *file, // IN: File we're writing to
+               struct page *page, // IN: Page we're writing from
+               unsigned pageFrom, // IN: Starting page offset
+               unsigned pageTo,   // IN: Ending page offset
+               loff_t writeTo,    // IN: File position to write to
+               unsigned copied)   // IN: Number of bytes copied to the page
 {
    HgfsHandle handle;
    struct inode *inode;
    loff_t currentFileSize;
    loff_t offset;
-   loff_t writeTo;
 
    ASSERT(file);
    ASSERT(page);
    inode = page->mapping->host;
    currentFileSize = compat_i_size_read(inode);
    offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
-   writeTo = offset + pageTo;
 
-   /* See coment in HgfsPrepareWrite. */
+   /* See comment in HgfsPrepareWrite. */
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 10)
    kunmap(page);
 #endif
@@ -809,14 +924,14 @@ HgfsCommitWrite(struct file *file, // IN: File we're writing to
    }
 
    /* We wrote a complete page, so it is up to date. */
-   if ((pageTo - pageFrom) == PAGE_CACHE_SIZE) {
+   if (copied == PAGE_CACHE_SIZE) {
       SetPageUptodate(page);
    }
 
 #ifdef HGFS_ENABLE_WRITEBACK
    /*
     * Check if this is a partial write to a new page, which was
-    * initialized in HgfsPrepareWrite.
+    * initialized in HgfsDoWriteBegin.
     */
    if ((offset >= currentFileSize) ||
        ((pageFrom == 0) && (writeTo >= currentFileSize))) {
@@ -835,13 +950,109 @@ HgfsCommitWrite(struct file *file, // IN: File we're writing to
    /*
     * We've recieved a partial write to page that is not uptodate, so
     * do the write now while the page is still locked.  Another
-    * alternative would be to read the page in HgfsPrepareWrite, which
+    * alternative would be to read the page in HgfsDoWriteBegin, which
     * would make it uptodate (ie a complete cached page).
     */
    handle = FILE_GET_FI_P(file)->handle;
-   LOG(6, (KERN_DEBUG "VMware hgfs: HgfsCommitWrite: writing to handle %u\n",
+   LOG(6, (KERN_DEBUG "VMware hgfs: %s: writing to handle %u\n", __FUNCTION__,
            handle));
    return HgfsDoWritepage(handle, page, pageFrom, pageTo);
 }
 
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsCommitWrite --
+ *
+ *      This function is the more common write path for HGFS, called from
+ *      generic_file_buffered_write. It is much simpler for us than
+ *      HgfsWritepage above: the caller has obtained a reference to the page
+ *      and will unlock it when we're done. And we don't need to worry about
+ *      properly marking the writeback bit, either. See mm/filemap.c in the
+ *      kernel for details about how we are called.
+ *
+ * Results:
+ *      Zero on succes, non-zero on error.
+ *
+ * Side effects:
+ *      None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+HgfsCommitWrite(struct file *file,    // IN: File to write
+                struct page *page,    // IN: Page to write from
+                unsigned pageFrom,    // IN: Starting page offset
+                unsigned pageTo)      // IN: Ending page offset
+{
+   loff_t offset;
+   loff_t writeTo;
+   unsigned copied;
+
+   ASSERT(page);
+   ASSERT(file);
+
+   offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
+   writeTo = offset + pageTo;
+   copied = pageTo - pageFrom;
+
+   return HgfsDoWriteEnd(file, page, pageFrom, pageTo, writeTo, copied);
+}
+
+#else
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * HgfsWriteEnd --
+ *
+ *      This function is the more common write path for HGFS, called from
+ *      generic_file_buffered_write. It is much simpler for us than
+ *      HgfsWritepage above: write_begin has obtained a reference to the page
+ *      and we will unlock it when we're done. And we don't need to worry about
+ *      properly marking the writeback bit, either. See mm/filemap.c in the
+ *      kernel for details about how we are called.
+ *
+ *      This function should unlock the page and reduce the refcount.
+ *
+ * Results:
+ *      Number of bytes written or negative error
+ *
+ * Side effects:
+ *      Unlocks the page and drops the reference.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static int
+HgfsWriteEnd(struct file *file,              // IN: File to write
+             struct address_space *mapping,  // IN: Mapping
+             loff_t pos,                     // IN: File position
+             unsigned len,                   // IN: len passed from write_begin
+             unsigned copied,                // IN: Number of actually copied bytes
+             struct page *page,              // IN: Page to write from
+             void *clientData)               // IN: From write_begin, unused.
+{
+   unsigned pageFrom = pos & (PAGE_CACHE_SIZE - 1);
+   unsigned pageTo = pageFrom + copied;
+   loff_t writeTo = pos + copied;
+   int ret;
+
+   ASSERT(file);
+   ASSERT(mapping);
+   ASSERT(page);
+
+   ret = HgfsDoWriteEnd(file, page, pageFrom, pageTo, writeTo, copied);
+   if (ret == 0) {
+      ret = copied;
+   }
+
+   compat_unlock_page(page);
+   page_cache_release(page);
+   return ret;
+}
+#endif
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index c06c5212d780fc680214970cb0c0f029611bedcc..b902e6eb2285b5ea5c0fd3b6964be07db373ad70 100644 (file)
 #define BDOOR_CMD_DEBUGEVENT            53
 #define BDOOR_CMD_OSNOTMACOSXSERVER     54
 #define BDOOR_CMD_GETTIMEFULL_WITH_LAG  55
-#define BDOOR_CMD_ACPI_HOTPLUG          56
-#define BDOOR_CMD_MAX                   57
+#define BDOOR_CMD_ACPI_HOTPLUG_DEVICE   56
+#define BDOOR_CMD_ACPI_HOTPLUG_MEMORY   57
+#define BDOOR_CMD_ACPI_HOTPLUG_CBRET    58
+#define BDOOR_CMD_GET_HOST_VIDEO_MODES  59
+#define BDOOR_CMD_MAX                   60
 
 /* 
  * IMPORTANT NOTE: When modifying the behavior of an existing backdoor command,
index a001ec463a32cd37a277b79aa64796a45f1a858a..01452142d0a163e04b6598f26935d84ed3bb7b93 100644 (file)
 /*
  * balloon_def.h -- 
  *
- *     Definitions for server "balloon" mechanism for reclaiming
- *     physical memory from a VM.
+ *      Definitions for server "balloon" mechanism for reclaiming
+ *      physical memory from a VM.
  */
 
-#ifndef        _BALLOON_DEF_H
-#define        _BALLOON_DEF_H
+#ifndef _BALLOON_DEF_H
+#define _BALLOON_DEF_H
 
 #define INCLUDE_ALLOW_VMCORE
 #define INCLUDE_ALLOW_VMKERNEL
-#define        INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_MODULE
 #include "includeCheck.h"
 
 #include "vm_basic_types.h"
  */
 
 /* backdoor port */
-#define        BALLOON_BDOOR_PORT              (0x5670)
-#define        BALLOON_BDOOR_MAGIC             (0x456c6d6f)
+#define BALLOON_BDOOR_PORT              (0x5670)
+#define BALLOON_BDOOR_MAGIC             (0x456c6d6f)
 
 /* backdoor command numbers */
-#define        BALLOON_BDOOR_CMD_START         (0)
-#define        BALLOON_BDOOR_CMD_TARGET        (1)
-#define        BALLOON_BDOOR_CMD_LOCK          (2)
-#define        BALLOON_BDOOR_CMD_UNLOCK        (3)
-#define        BALLOON_BDOOR_CMD_GUEST_ID      (4)
+#define BALLOON_BDOOR_CMD_START         (0)
+#define BALLOON_BDOOR_CMD_TARGET        (1)
+#define BALLOON_BDOOR_CMD_LOCK          (2)
+#define BALLOON_BDOOR_CMD_UNLOCK        (3)
+#define BALLOON_BDOOR_CMD_GUEST_ID      (4)
 
 /* use config value for max balloon size */
-#define BALLOON_MAX_SIZE_USE_CONFIG    (0)
+#define BALLOON_MAX_SIZE_USE_CONFIG     (0)
 
 /* guest identities */
-#define BALLOON_GUEST_UNKNOWN          (0)
-#define BALLOON_GUEST_LINUX            (1)
-#define BALLOON_GUEST_BSD              (2)
-#define BALLOON_GUEST_WINDOWS_NT4      (3)
-#define BALLOON_GUEST_WINDOWS_NT5      (4)
-#define BALLOON_GUEST_SOLARIS          (5)
+#define BALLOON_GUEST_UNKNOWN           (0)
+#define BALLOON_GUEST_LINUX             (1)
+#define BALLOON_GUEST_BSD               (2)
+#define BALLOON_GUEST_WINDOWS_NT4       (3)
+#define BALLOON_GUEST_WINDOWS_NT5       (4)
+#define BALLOON_GUEST_SOLARIS           (5)
 
 /* error codes */
-#define        BALLOON_SUCCESS                 (0)
-#define        BALLOON_FAILURE                 (-1)
-#define        BALLOON_ERROR_CMD_INVALID       (1)
-#define        BALLOON_ERROR_PPN_INVALID       (2)
-#define        BALLOON_ERROR_PPN_LOCKED        (3)
-#define        BALLOON_ERROR_PPN_UNLOCKED      (4)
-#define        BALLOON_ERROR_PPN_PINNED        (5)
-#define        BALLOON_ERROR_PPN_TRANSPARENT   (6)
-#define        BALLOON_ERROR_RESET             (7)
-#define        BALLOON_ERROR_BUSY              (8)
+#define BALLOON_SUCCESS                 (0)
+#define BALLOON_FAILURE                (-1)
+#define BALLOON_ERROR_CMD_INVALID       (1)
+#define BALLOON_ERROR_PPN_INVALID       (2)
+#define BALLOON_ERROR_PPN_LOCKED        (3)
+#define BALLOON_ERROR_PPN_UNLOCKED      (4)
+#define BALLOON_ERROR_PPN_PINNED        (5)
+#define BALLOON_ERROR_PPN_NOTNEEDED     (6)
+#define BALLOON_ERROR_RESET             (7)
+#define BALLOON_ERROR_BUSY              (8)
 
-#endif /* _BALLOON_DEF_H */
+#endif  /* _BALLOON_DEF_H */
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 083fbcd1d3bdb529545035d3129be18e42b5fc1b..5c6e8f06489118271c5e2837e02f5a41bbe7aa09 100644 (file)
 #include "guiddef.h"
 #endif
 
+/* LSILogic 53C1030 Parallel SCSI controller
+ * LSILogic SAS1068 SAS controller
+ */
+#define PCI_VENDOR_ID_LSILOGIC          0x1000
+#define PCI_DEVICE_ID_LSI53C1030        0x0030
+#define PCI_DEVICE_ID_LSISAS1068        0x0054
+
 /* Our own PCI IDs
  *    VMware SVGA II (Unified VGA)
  *    VMware SVGA (PCI Accelerator)
index a30807356882917dbe63f2e347d5321870658dde..ec777a34cb18c72f298d688b2258eba81c53897a 100644 (file)
 /* upt1_defs.h
  *
  *      Definitions for UPTv1
+ *
+ *      Some of the defs are duplicated in vmkapi_net_upt.h, because
+ *      vmkapi_net_upt.h cannot distribute with OSS yet and vmkapi headers can
+ *      only include vmkapi headers. Make sure they are kept in sync!
  */
 
 #ifndef _UPT1_DEFS_H
 
 #define UPT1_MAX_INTRS  (UPT1_MAX_TX_QUEUES + UPT1_MAX_RX_QUEUES)
 
-typedef
-#include "vmware_pack_begin.h"
-struct UPT1_RingDesc {
-   uint64 basePA;    /* physical addr of the ring */
-   uint16 size;      /* # of descriptors */
-   uint16 prodIdx;   /* index of the descriptor the producer of the ring 
-                      * will write to next */
-   uint16 consIdx;   /* index of the descriptor the consumer of the ring 
-                      * will read next */
-   uint16 pad;
-}
-#include "vmware_pack_end.h"
-UPT1_RingDesc;
-
 typedef
 #include "vmware_pack_begin.h"
 struct UPT1_TxStats {
@@ -60,22 +50,6 @@ struct UPT1_TxStats {
 #include "vmware_pack_end.h"
 UPT1_TxStats;
 
-typedef
-#include "vmware_pack_begin.h"
-struct UPT1_TxQueueState {
-   UPT1_RingDesc txRing;
-   UPT1_RingDesc dataRing;
-   UPT1_RingDesc compRing;
-   uint8         tcGen;    /* value of the TCGEN register */
-   uint8         intrIdx;  /* which MSI/MSI-X vector to use for the tx queue */
-   Bool          stopped;  /* is the queue stopped? */
-   uint8         pad;
-   uint32        error;    /* error code if the queue is stopped due to error */
-   UPT1_TxStats  stats;    /* stats for the tx queue */
-}
-#include "vmware_pack_end.h"
-UPT1_TxQueueState;
-
 typedef
 #include "vmware_pack_begin.h"
 struct UPT1_RxStats {
@@ -94,40 +68,11 @@ struct UPT1_RxStats {
 #include "vmware_pack_end.h"
 UPT1_RxStats;
 
-typedef
-#include "vmware_pack_begin.h"
-struct UPT1_RxQueueState {
-   UPT1_RingDesc rxRing[2];
-   UPT1_RingDesc compRing;
-   uint8         rcGen;     /* value of the RCGEN register */
-   uint8         intrIdx;   /* which MSI/MSI-X vector to use for the rx queue */
-   Bool          stopped;   /* is the queue stopped? */
-   uint8         pad;
-   uint32        error;     /* error code if the queue is stopped due to error */
-   UPT1_RxStats  stats;     /* stats for the rx queue */
-}
-#include "vmware_pack_end.h"
-UPT1_RxQueueState;
-
-/* physical dev intr type */
-typedef enum {
-   UPT1_IT_MSI = 1,
-   UPT1_IT_MSIX
-} UPT1_IntrType;
-
 /* interrupt moderation level */
 #define UPT1_IML_NONE     0 /* no interrupt moderation */
 #define UPT1_IML_HIGHEST  7 /* least intr generated */
 #define UPT1_IML_ADAPTIVE 8 /* adpative intr moderation */
 
-typedef struct UPT1_IntrState {
-   UPT1_IntrType type;
-   Bool  autoMask;
-   uint8 numIntrs;      /* # of MSI/MSI-X vectors allocated */
-   uint8 *modLevels;    /* interrupt moderation level */
-   uint8 *imr;          /* IMR register values */
-} UPT1_IntrState;
-
 /* values for UPT1_RSSConf.hashFunc */
 #define UPT1_RSS_HASH_TYPE_NONE      0x0
 #define UPT1_RSS_HASH_TYPE_IPV4      0x01
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
index 083fbcd1d3bdb529545035d3129be18e42b5fc1b..5c6e8f06489118271c5e2837e02f5a41bbe7aa09 100644 (file)
 #include "guiddef.h"
 #endif
 
+/* LSILogic 53C1030 Parallel SCSI controller
+ * LSILogic SAS1068 SAS controller
+ */
+#define PCI_VENDOR_ID_LSILOGIC          0x1000
+#define PCI_DEVICE_ID_LSI53C1030        0x0030
+#define PCI_DEVICE_ID_LSISAS1068        0x0054
+
 /* Our own PCI IDs
  *    VMware SVGA II (Unified VGA)
  *    VMware SVGA (PCI Accelerator)
index e77d518a162ae6327b36c6d75ddd040c4b527912..abfa5fccf429a6d290328f28a83d7c070e293839 100644 (file)
@@ -1417,6 +1417,39 @@ Atomic_ReadDec64(Atomic_uint64 *var) // IN
 #endif
 
 
+#ifdef VMKERNEL
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * CMPXCHG1B --
+ *
+ *      Compare and exchange a single byte.
+ *
+ * Results:
+ *      The value read from ptr.
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+static INLINE uint8
+CMPXCHG1B(volatile uint8 *ptr, // IN
+          uint8 oldVal,        // IN
+          uint8 newVal)        // IN
+{
+   uint8 val;
+   __asm__ __volatile__("lock; cmpxchgb %b2, %1"
+                        : "=a" (val),
+                          "+m" (*ptr)
+                        : "r" (newVal),
+                          "0" (oldVal)
+                        : "cc");
+   return val;
+}
+#endif
+
+
 /*
  * Usage of this helper struct is strictly reserved to the following
  * function. --hpreg
diff --git a/open-vm-tools/modules/linux/vsock/include/vm_basic_asm.h b/open-vm-tools/modules/linux/vsock/include/vm_basic_asm.h
new file mode 100644 (file)
index 0000000..5bc4d6b
--- /dev/null
@@ -0,0 +1,856 @@
+/*********************************************************
+ * Copyright (C) 2003 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ *********************************************************/
+
+/*
+ * vm_basic_asm.h
+ *
+ *     Basic asm macros
+ */
+
+#ifndef _VM_BASIC_ASM_H_
+#define _VM_BASIC_ASM_H_
+
+#define INCLUDE_ALLOW_USERLEVEL
+#define INCLUDE_ALLOW_VMMEXT
+#define INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_VMMON
+#define INCLUDE_ALLOW_VMNIXMOD
+#define INCLUDE_ALLOW_VMK_MODULE
+#define INCLUDE_ALLOW_VMKERNEL
+#define INCLUDE_ALLOW_DISTRIBUTE
+#define INCLUDE_ALLOW_VMCORE
+#define INCLUDE_ALLOW_VMIROM
+#include "includeCheck.h"
+
+#include "vm_basic_types.h"
+#include "x86cpuid.h"
+
+#ifdef VM_X86_64
+#include "vm_basic_asm_x86_64.h"
+#else
+#include "vm_basic_asm_x86.h"
+#endif
+
+
+/*
+ * x86-64 windows doesn't support inline asm so we have to use these
+ * intrinsic functions defined in the compiler.  Not all of these are well
+ * documented.  There is an array in the compiler dll (c1.dll) which has
+ * an array of the names of all the intrinsics minus the leading
+ * underscore.  Searching around in the ntddk.h file can also be helpful.
+ *
+ * The declarations for the intrinsic functions were taken from the DDK. 
+ * Our declarations must match the ddk's otherwise the 64-bit c++ compiler
+ * will complain about second linkage of the intrinsic functions.
+ * We define the intrinsic using the basic types corresponding to the 
+ * Windows typedefs. This avoids having to include windows header files
+ * to get to the windows types.
+ */
+#ifdef _MSC_VER
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * It seems x86 & x86-64 windows still implements these intrinsic
+ * functions.  The documentation for the x86-64 suggest the
+ * __inbyte/__outbyte intrinsics eventhough the _in/_out work fine and
+ * __inbyte/__outbyte aren't supported on x86.
+ */
+int            _inp(unsigned short);
+unsigned short _inpw(unsigned short);
+unsigned long  _inpd(unsigned short);
+
+int            _outp(unsigned short, int);
+unsigned short _outpw(unsigned short, unsigned short);
+unsigned long  _outpd(uint16, unsigned long);
+#pragma intrinsic(_inp, _inpw, _inpd, _outp, _outpw, _outpw, _outpd)
+void _ReadWriteBarrier(void);
+#pragma intrinsic(_ReadWriteBarrier)
+
+#ifdef VM_X86_64
+/*
+ * intrinsic functions only supported by x86-64 windows as of 2k3sp1
+ */
+void             __cpuid(unsigned int*, unsigned int);
+unsigned __int64 __rdtsc(void);
+void             __stosw(unsigned short*, unsigned short, size_t);
+void             __stosd(unsigned long*, unsigned long, size_t);
+#pragma intrinsic(__cpuid, __rdtsc, __stosw, __stosd)
+
+/*
+ * intrinsic functions supported by x86-64 windows and newer x86
+ * compilers (13.01.2035 for _BitScanForward).
+ */
+unsigned char  _BitScanForward(unsigned long*, unsigned long);
+void           _mm_pause(void);
+#pragma intrinsic(_BitScanForward, _mm_pause)
+#endif /* VM_X86_64 */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _MSC_VER */
+
+
+#ifdef __GNUC__ // {
+
+/*
+ * Checked against the Intel manual and GCC --hpreg
+ *
+ * volatile because reading from port can modify the state of the underlying
+ * hardware.
+ *
+ * Note: The undocumented %z construct doesn't work (internal compiler error)
+ *       with gcc-2.95.1
+ */
+
+#define __GCC_IN(s, type, name) \
+static INLINE type              \
+name(uint16 port)               \
+{                               \
+   type val;                    \
+                                \
+   __asm__ __volatile__(        \
+      "in" #s " %w1, %0"        \
+      : "=a" (val)              \
+      : "Nd" (port)             \
+   );                           \
+                                \
+   return val;                  \
+}
+
+__GCC_IN(b, uint8, INB)
+__GCC_IN(w, uint16, INW)
+__GCC_IN(l, uint32, IN32)
+
+
+/*
+ * Checked against the Intel manual and GCC --hpreg
+ *
+ * Note: The undocumented %z construct doesn't work (internal compiler error)
+ *       with gcc-2.95.1
+ */
+
+#define __GCC_OUT(s, s2, port, val) do { \
+   __asm__(                              \
+      "out" #s " %" #s2 "1, %w0"         \
+      :                                  \
+      : "Nd" (port), "a" (val)           \
+   );                                    \
+} while (0)
+
+#define OUTB(port, val) __GCC_OUT(b, b, port, val)
+#define OUTW(port, val) __GCC_OUT(w, w, port, val)
+#define OUT32(port, val) __GCC_OUT(l, , port, val)
+
+
+#define GET_CURRENT_EIP(_eip) \
+      __asm__ __volatile("call 0\n\tpopl %0" : "=r" (_eip): );
+
+
+/*
+ * Checked against the Intel manual and GCC --hpreg
+ * 
+ * Need __volatile__ and "memory" since CPUID has a synchronizing effect.
+ * The CPUID may also change at runtime (APIC flag, etc).
+ *
+ */
+
+static INLINE void
+__GET_CPUID(int eax,         // IN
+            CPUIDRegs *regs) // OUT
+{
+   __asm__ __volatile__(
+#if defined __PIC__ && !vm_x86_64 // %ebx is reserved by the compiler.
+      "movl %%ebx, %1"  "\n\t"
+      "cpuid"           "\n\t"
+      "xchgl %%ebx, %1"
+      : "=a" (regs->eax), "=&rm" (regs->ebx), "=c" (regs->ecx), "=d" (regs->edx)
+#else
+      "cpuid"
+      : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx), "=d" (regs->edx)
+#endif
+      : "a" (eax)
+      : "memory"
+   );
+}
+
+static INLINE void
+__GET_CPUID2(int eax,         // IN
+             int ecx,         // IN
+             CPUIDRegs *regs) // OUT
+{
+   __asm__ __volatile__(
+#if defined __PIC__ && !vm_x86_64 // %ebx is reserved by the compiler.
+      "movl %%ebx, %1"  "\n\t"
+      "cpuid"           "\n\t"
+      "xchgl %%ebx, %1"
+      : "=a" (regs->eax), "=&rm" (regs->ebx), "=c" (regs->ecx), "=d" (regs->edx)
+#else
+      "cpuid"
+      : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx), "=d" (regs->edx)
+#endif
+      : "a" (eax), "c" (ecx)
+      : "memory"
+   );
+}
+
+static INLINE uint32
+__GET_EAX_FROM_CPUID(int eax) // IN
+{
+#if defined __PIC__ && !vm_x86_64 // %ebx is reserved by the compiler.
+   uint32 ebx;
+
+   __asm__ __volatile__(
+      "movl %%ebx, %1"  "\n\t"
+      "cpuid"           "\n\t"
+      "xchgl %%ebx, %1"
+      : "=a" (eax), "=&rm" (ebx)
+      : "a" (eax)
+      : "memory", "%ecx", "%edx"
+   );
+#else
+   __asm__ __volatile__(
+      "cpuid"
+      : "=a" (eax)
+      : "a" (eax)
+      : "memory", "%ebx", "%ecx", "%edx"
+   );
+#endif
+
+   return eax;
+}
+
+static INLINE uint32
+__GET_EBX_FROM_CPUID(int eax) // IN
+{
+   uint32 ebx;
+
+   __asm__ __volatile__(
+#if defined __PIC__ && !vm_x86_64 // %ebx is reserved by the compiler.
+      "movl %%ebx, %1"  "\n\t"
+      "cpuid"           "\n\t"
+      "xchgl %%ebx, %1"
+      : "=a" (eax), "=&rm" (ebx)
+#else
+      "cpuid"
+      : "=a" (eax), "=b" (ebx)
+#endif
+      : "a" (eax)
+      : "memory", "%ecx", "%edx"
+   );
+
+   return ebx;
+}
+
+static INLINE uint32
+__GET_ECX_FROM_CPUID(int eax) // IN
+{
+   uint32 ecx;
+#if defined __PIC__ && !vm_x86_64 // %ebx is reserved by the compiler.
+   uint32 ebx;
+
+   __asm__ __volatile__(
+      "movl %%ebx, %1"  "\n\t"
+      "cpuid"           "\n\t"
+      "xchgl %%ebx, %1"
+      : "=a" (eax), "=&rm" (ebx), "=c" (ecx)
+      : "a" (eax)
+      : "memory", "%edx"
+   );
+#else
+
+   __asm__ __volatile__(
+      "cpuid"
+      : "=a" (eax), "=c" (ecx)
+      : "a" (eax)
+      : "memory", "%ebx", "%edx"
+   );
+#endif
+
+   return ecx;
+}
+
+static INLINE uint32
+__GET_EDX_FROM_CPUID(int eax) // IN
+{
+   uint32 edx;
+#if defined __PIC__ && !vm_x86_64 // %ebx is reserved by the compiler.
+   uint32 ebx;
+
+   __asm__ __volatile__(
+      "movl %%ebx, %1"  "\n\t"
+      "cpuid"           "\n\t"
+      "xchgl %%ebx, %1"
+      : "=a" (eax), "=&rm" (ebx), "=d" (edx)
+      : "a" (eax)
+      : "memory", "%ecx"
+   );
+#else
+
+   __asm__ __volatile__(
+      "cpuid"
+      : "=a" (eax), "=d" (edx)
+      : "a" (eax)
+      : "memory", "%ebx", "%ecx"
+   );
+#endif
+
+   return edx;
+}
+
+
+static INLINE uint32
+__GET_EAX_FROM_CPUID4(int ecx) // IN
+{
+   uint32 eax;
+#if defined __PIC__ && !vm_x86_64 // %ebx is reserved by the compiler.
+   uint32 ebx;
+
+   __asm__ __volatile__(
+      "movl %%ebx, %1"  "\n\t"
+      "cpuid"           "\n\t"
+      "xchgl %%ebx, %1"
+      : "=a" (eax), "=&rm" (ebx), "=c" (ecx)
+      : "a" (4), "c" (ecx)
+      : "memory", "%edx"
+   );
+#else
+
+   __asm__ __volatile__(
+      "cpuid"
+      : "=a" (eax), "=c" (ecx)
+      : "a" (4), "c" (ecx)
+      : "memory", "%ebx", "%edx"
+   );
+#endif
+
+   return eax;
+}
+
+#elif defined(_MSC_VER) // } {
+static INLINE  uint8
+INB(uint16 port) 
+{
+   return (uint8)_inp(port);
+}
+static INLINE void
+OUTB(uint16 port, uint8 value)
+{
+   _outp(port, value);
+}
+static INLINE uint16
+INW(uint16 port)
+{
+   return _inpw(port);
+}
+static INLINE void
+OUTW(uint16 port, uint16 value)
+{
+   _outpw(port, value);
+}
+static INLINE  uint32
+IN32(uint16 port) 
+{
+   return _inpd(port);
+}
+static INLINE void 
+OUT32(uint16 port, uint32 value)
+{
+   _outpd(port, value);
+}
+
+#ifndef VM_X86_64
+#ifdef NEAR
+#undef NEAR
+#endif
+
+#define GET_CURRENT_EIP(_eip) do { \
+   __asm call NEAR PTR $+5 \
+   __asm pop eax \
+   __asm mov _eip, eax \
+} while (0)
+#endif
+
+static INLINE void
+__GET_CPUID(int input, CPUIDRegs *regs)
+{
+#ifdef VM_X86_64
+   __cpuid((unsigned int *)regs, input);
+#else
+   __asm push esi
+   __asm push ebx
+   __asm push ecx
+   __asm push edx
+
+   __asm mov  eax, input
+   __asm mov  esi, regs
+   __asm _emit 0x0f __asm _emit 0xa2
+   __asm mov 0x0[esi], eax
+   __asm mov 0x4[esi], ebx
+   __asm mov 0x8[esi], ecx
+   __asm mov 0xC[esi], edx
+
+   __asm pop edx
+   __asm pop ecx
+   __asm pop ebx
+   __asm pop esi
+#endif
+}
+
+#ifdef VM_X86_64
+
+/*
+ * No inline assembly in Win64. Implemented in bora/lib/user in
+ * cpuidMasm64.asm.
+ */
+
+extern void
+__GET_CPUID2(int inputEax, int inputEcx, CPUIDRegs *regs);
+
+#else // VM_X86_64
+
+static INLINE void
+__GET_CPUID2(int inputEax, int inputEcx, CPUIDRegs *regs)
+{
+   __asm push esi
+   __asm push ebx
+   __asm push ecx
+   __asm push edx
+
+   __asm mov  eax, inputEax
+   __asm mov  ecx, inputEcx
+   __asm mov  esi, regs
+   __asm _emit 0x0f __asm _emit 0xa2
+   __asm mov 0x0[esi], eax
+   __asm mov 0x4[esi], ebx
+   __asm mov 0x8[esi], ecx
+   __asm mov 0xC[esi], edx
+
+   __asm pop edx
+   __asm pop ecx
+   __asm pop ebx
+   __asm pop esi
+}
+#endif
+
+static INLINE uint32
+__GET_EAX_FROM_CPUID(int input)
+{
+#ifdef VM_X86_64
+   CPUIDRegs regs;
+   __cpuid((unsigned int *)&regs, input);
+   return regs.eax;
+#else
+   uint32 output;
+
+   //NOT_TESTED();
+   __asm push ebx
+   __asm push ecx
+   __asm push edx
+
+   __asm mov  eax, input
+   __asm _emit 0x0f __asm _emit 0xa2
+   __asm mov  output, eax
+
+   __asm pop edx
+   __asm pop ecx
+   __asm pop ebx
+
+   return output;
+#endif
+}
+
+static INLINE uint32
+__GET_EBX_FROM_CPUID(int input)
+{
+#ifdef VM_X86_64
+   CPUIDRegs regs;
+   __cpuid((unsigned int *)&regs, input);
+   return regs.ebx;
+#else
+   uint32 output;
+
+   //NOT_TESTED();
+   __asm push ebx
+   __asm push ecx
+   __asm push edx
+
+   __asm mov  eax, input
+   __asm _emit 0x0f __asm _emit 0xa2
+   __asm mov  output, ebx
+
+   __asm pop edx
+   __asm pop ecx
+   __asm pop ebx
+
+   return output;
+#endif
+}
+
+static INLINE uint32
+__GET_ECX_FROM_CPUID(int input)
+{
+#ifdef VM_X86_64
+   CPUIDRegs regs;
+   __cpuid((unsigned int *)&regs, input);
+   return regs.ecx;
+#else
+   uint32 output;
+
+   //NOT_TESTED();
+   __asm push ebx
+   __asm push ecx
+   __asm push edx
+
+   __asm mov  eax, input
+   __asm _emit 0x0f __asm _emit 0xa2
+   __asm mov  output, ecx
+
+   __asm pop edx
+   __asm pop ecx
+   __asm pop ebx
+
+   return output;
+#endif
+}
+
+static INLINE uint32
+__GET_EDX_FROM_CPUID(int input)
+{
+#ifdef VM_X86_64
+   CPUIDRegs regs;
+   __cpuid((unsigned int *)&regs, input);
+   return regs.edx;
+#else
+   uint32 output;
+
+   //NOT_TESTED();
+   __asm push ebx
+   __asm push ecx
+   __asm push edx
+
+   __asm mov  eax, input
+   __asm _emit 0x0f __asm _emit 0xa2
+   __asm mov  output, edx
+
+   __asm pop edx
+   __asm pop ecx
+   __asm pop ebx
+
+   return output;
+#endif
+}
+
+#ifdef VM_X86_64
+
+/*
+ * No inline assembly in Win64. Implemented in bora/lib/user in
+ * cpuidMasm64.asm.
+ */
+
+extern uint32
+__GET_EAX_FROM_CPUID4(int inputEcx);
+
+#else // VM_X86_64
+
+static INLINE uint32
+__GET_EAX_FROM_CPUID4(int inputEcx)
+{
+   uint32 output;
+
+   //NOT_TESTED();
+   __asm push ebx
+   __asm push ecx
+   __asm push edx
+
+   __asm mov  eax, 4
+   __asm mov  ecx, inputEcx
+   __asm _emit 0x0f __asm _emit 0xa2
+   __asm mov  output, eax
+
+   __asm pop edx
+   __asm pop ecx
+   __asm pop ebx
+
+   return output;
+}
+
+#endif // VM_X86_64
+
+#else // }
+#error 
+#endif
+
+#define CPUID_FOR_SIDE_EFFECTS() ((void)__GET_EAX_FROM_CPUID(0))
+
+static INLINE void
+__GET_CPUID4(int inputEcx, CPUIDRegs *regs)
+{
+   __GET_CPUID2(4, inputEcx, regs);
+}
+
+/* The first parameter is used as an rvalue and then as an lvalue. */
+#define GET_CPUID(_ax, _bx, _cx, _dx) { \
+   CPUIDRegs regs;                      \
+   __GET_CPUID(_ax, &regs);             \
+   _ax = regs.eax;                      \
+   _bx = regs.ebx;                      \
+   _cx = regs.ecx;                      \
+   _dx = regs.edx;                      \
+}
+
+
+/* Sequence recommended by Intel for the Pentium 4. */
+#define INTEL_MICROCODE_VERSION() (             \
+   __SET_MSR(MSR_BIOS_SIGN_ID, 0),              \
+   __GET_EAX_FROM_CPUID(1),                     \
+   __GET_MSR(MSR_BIOS_SIGN_ID))
+
+
+#ifdef _MSC_VER   
+static INLINE int
+ffs(uint32 bitVector)
+{
+   int idx;
+   if (!bitVector) {
+      return 0;
+   }
+#ifdef VM_X86_64
+   _BitScanForward((unsigned long*)&idx, (unsigned long)bitVector);
+#else
+   __asm bsf eax, bitVector
+   __asm mov idx, eax
+#endif
+   return idx+1;
+}
+#endif
+
+#ifdef __GNUC__
+static INLINE void *
+uint16set(void *dst, uint16 val, size_t count)
+{
+   int dummy0;
+   int dummy1;
+
+   __asm__ __volatile__("\t"
+                        "cld"            "\n\t"
+                        "rep ; stosw"    "\n"
+                        : "=c" (dummy0), "=D" (dummy1)
+                        : "0" (count), "1" (dst), "a" (val)
+                        : "memory", "cc"
+      );
+
+   return dst;
+}
+
+static INLINE void *
+uint32set(void *dst, uint32 val, size_t count)
+{
+   int dummy0;
+   int dummy1;
+
+   __asm__ __volatile__("\t"
+                        "cld"            "\n\t"
+                        "rep ; stosl"    "\n"
+                        : "=c" (dummy0), "=D" (dummy1)
+                        : "0" (count), "1" (dst), "a" (val)
+                        : "memory", "cc"
+      );
+
+   return dst;
+}
+
+#elif defined(_MSC_VER)
+
+static INLINE void *
+uint16set(void *dst, uint16 val, size_t count)
+{
+#ifdef VM_X86_64
+   __stosw((uint16*)dst, val, count);
+#else
+   __asm { pushf;
+           mov ax, val;
+           mov ecx, count;
+           mov edi, dst;
+           cld;
+           rep stosw;
+           popf;
+   }
+#endif
+   return dst;
+}
+
+static INLINE void *
+uint32set(void *dst, uint32 val, size_t count)
+{
+#ifdef VM_X86_64
+   __stosd((unsigned long*)dst, (unsigned long)val, count);
+#else
+   __asm { pushf;
+           mov eax, val;
+           mov ecx, count;
+           mov edi, dst;
+           cld;
+           rep stosd;
+           popf;
+   }
+#endif
+   return dst;
+}
+
+#else
+#error "No compiler defined for uint*set"
+#endif
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Bswap32 --
+ *
+ *      Swap the 4 bytes of "v" as follows: 3210 -> 0123.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static INLINE uint32
+Bswap32(uint32 v) // IN
+{
+#ifdef __GNUC__ // {
+   /* Checked against the Intel manual and GCC. --hpreg */
+   __asm__(
+      "bswap %0"
+      : "=r" (v)
+      : "0" (v)
+   );
+   return v;
+#else // } {
+   return    (v >> 24)
+          | ((v >>  8) & 0xFF00)
+          | ((v & 0xFF00) <<  8)
+          |  (v << 24)          ;
+#endif // }
+}
+#define Bswap Bswap32
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Bswap64 --
+ *
+ *      Swap the 8 bytes of "v" as follows: 76543210 -> 01234567.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static INLINE uint64
+Bswap64(uint64 v) // IN
+{
+   return ((uint64)Bswap((uint32)v) << 32) | Bswap((uint32)(v >> 32));
+}
+
+
+#ifdef __GNUC__ // {
+/*
+ * COMPILER_MEM_BARRIER prevents the compiler from re-ordering memory
+ * references accross the barrier.  NOTE: It does not generate any
+ * instruction, so the CPU is free to do whatever it wants to...
+ */
+#define COMPILER_MEM_BARRIER() __asm__ __volatile__ ("": : :"memory")
+#elif defined(_MSC_VER) // } {
+#define COMPILER_MEM_BARRIER() _ReadWriteBarrier()
+#endif // }
+
+
+/*
+ * PAUSE is a P4 instruction that improves spinlock power+performance;
+ * on non-P4 IA32 systems, the encoding is interpreted as a REPZ-NOP.
+ * Use volatile to avoid NOP removal.
+ */
+static INLINE void
+PAUSE(void)
+#ifdef __GNUC__
+{
+   __asm__ __volatile__( "pause" :);
+}
+#elif defined(_MSC_VER)
+#ifdef VM_X86_64
+{
+   _mm_pause();
+}
+#else /* VM_X86_64 */
+#pragma warning( disable : 4035)
+{
+   __asm _emit 0xf3 __asm _emit 0x90
+}
+#pragma warning (default: 4035)
+#endif /* VM_X86_64 */
+#else  /* __GNUC__  */
+#error No compiler defined for PAUSE
+#endif
+
+
+/*
+ * Checked against the Intel manual and GCC --hpreg
+ *
+ * volatile because the tsc always changes without the compiler knowing it.
+ */
+static INLINE uint64
+RDTSC(void)
+#ifdef __GNUC__
+{
+#ifdef VM_X86_64
+   uint64 tscLow;
+   uint64 tscHigh;
+
+   __asm__ __volatile__(
+      "rdtsc"
+      : "=a" (tscLow), "=d" (tscHigh)
+   );
+
+   return tscHigh << 32 | tscLow;
+#else
+   uint64 tim;
+
+   __asm__ __volatile__(
+      "rdtsc"
+      : "=A" (tim)
+   );
+
+   return tim;
+#endif
+}
+#elif defined(_MSC_VER)
+#ifdef VM_X86_64
+{
+   return __rdtsc();
+}
+#else
+#pragma warning( disable : 4035)
+{
+   __asm _emit 0x0f __asm _emit 0x31
+}
+#pragma warning (default: 4035)
+#endif /* VM_X86_64 */
+#else  /* __GNUC__  */
+#error No compiler defined for RDTSC
+#endif /* __GNUC__  */
+
+#endif
diff --git a/open-vm-tools/modules/linux/vsock/include/vm_basic_asm_x86.h b/open-vm-tools/modules/linux/vsock/include/vm_basic_asm_x86.h
new file mode 100644 (file)
index 0000000..c6c9b9e
--- /dev/null
@@ -0,0 +1,500 @@
+/*********************************************************
+ * Copyright (C) 1998-2003 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ *********************************************************/
+
+/*
+ * vm_basic_asm_x86.h
+ *
+ *     Basic IA32 asm macros
+ */
+
+#ifndef _VM_BASIC_ASM_X86_H_
+#define _VM_BASIC_ASM_X86_H_
+
+#define INCLUDE_ALLOW_USERLEVEL
+#define INCLUDE_ALLOW_VMMEXT
+#define INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_VMMON
+#define INCLUDE_ALLOW_VMNIXMOD
+#define INCLUDE_ALLOW_VMK_MODULE
+#define INCLUDE_ALLOW_VMKERNEL
+#define INCLUDE_ALLOW_DISTRIBUTE
+#define INCLUDE_ALLOW_VMCORE
+#define INCLUDE_ALLOW_VMIROM
+#include "includeCheck.h"
+
+#ifdef VM_X86_64
+/*
+ * The gcc inline asm uses the "A" constraint which differs in 32 & 64
+ * bit mode.  32 bit means eax and edx, 64 means rax or rdx.
+ */
+#error "x86-64 not supported"
+#endif
+
+
+
+
+/*
+ * from linux: usr/include/asm/io.h
+ */
+#ifdef __GNUC__
+#ifndef __SLOW_DOWN_IO
+#ifdef SLOW_IO_BY_JUMPING
+#define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:")
+#else
+#define __SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80")
+#endif
+#endif
+#elif _MSC_VER
+#ifdef SLOW_IO_BY_JUMPING
+#define __SLOW_DOWN_IO __asm jmp SHORT $+2 __asm  jmp SHORT $+2
+#else
+#define __SLOW_DOWN_IO __asm out 80h,al
+#endif
+#else
+#error
+#endif
+
+#ifdef REALLY_SLOW_IO
+#define SLOW_DOWN_IO { __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; __SLOW_DOWN_IO; }
+#else
+#define SLOW_DOWN_IO __SLOW_DOWN_IO
+#endif
+
+/*
+ * FXSAVE/FXRSTOR
+ *     save/restore SIMD/MMX fpu state
+ *
+ * The pointer passed in must be 16-byte aligned.
+ *
+ * Intel and AMD processors behave differently w.r.t. fxsave/fxrstor. Intel
+ * processors unconditionally save the exception pointer state (instruction
+ * ptr., data ptr., and error instruction opcode). FXSAVE_ES1 and FXRSTOR_ES1
+ * work correctly for Intel processors.
+ *
+ * AMD processors only save the exception pointer state if ES=1. This leads to a
+ * security hole whereby one process/VM can inspect the state of another process
+ * VM. The AMD recommended workaround involves clobbering the exception pointer
+ * state unconditionally, and this is implemented in FXRSTOR_AMD_ES0. Note that
+ * FXSAVE_ES1 will only save the exception pointer state for AMD processors if
+ * ES=1.
+ *
+ * The workaround (FXRSTOR_AMD_ES0) only costs 1 cycle more than just doing an
+ * fxrstor, on both AMD Opteron and Intel Core CPUs.
+ */
+#if defined(__GNUC__)
+static INLINE void 
+FXSAVE_ES1(uint8 *save)
+{
+   __asm__ __volatile__ ("fxsave %0\n" : "=m" (*save) : : "memory");
+}
+
+static INLINE void 
+FXRSTOR_ES1(const uint8 *load)
+{
+   __asm__ __volatile__ ("fxrstor %0\n" : : "m" (*load) : "memory");
+}
+
+static INLINE void 
+FXRSTOR_AMD_ES0(const uint8 *load)
+{
+   uint64 dummy = 0;
+      
+   __asm__ __volatile__ 
+       ("fnstsw  %%ax    \n"     // Grab x87 ES bit
+        "bt      $7,%%ax \n"     // Test ES bit
+        "jnc     1f      \n"     // Jump if ES=0
+        "fnclex          \n"     // ES=1. Clear it so fild doesn't trap
+        "1:              \n"
+        "ffree   %%st(7) \n"     // Clear tag bit - avoid poss. stack overflow
+        "fildl   %0      \n"     // Dummy Load from "safe address" changes all
+                                 // x87 exception pointers.
+        "fxrstor %1      \n"
+        :  
+        : "m" (dummy), "m" (*load)
+        : "ax", "memory");
+}
+#endif /* __GNUC__ */
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Div643232 --
+ *
+ *    Unsigned integer division:
+ *       The dividend is 64-bit wide
+ *       The divisor  is 32-bit wide
+ *       The quotient is 32-bit wide
+ *
+ *    Use this function if you are certain that:
+ *    o Either the quotient will fit in 32 bits,
+ *    o Or your code is ready to handle a #DE exception indicating overflow.
+ *    If that is not the case, then use Div643264(). --hpreg
+ *
+ * Results:
+ *    Quotient and remainder
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__)
+
+static INLINE void
+Div643232(uint64 dividend,   // IN
+          uint32 divisor,    // IN
+          uint32 *quotient,  // OUT
+          uint32 *remainder) // OUT
+{
+   /* Checked against the Intel manual and GCC --hpreg */
+   __asm__(
+      "divl %4"
+      : "=a" (*quotient),
+        "=d" (*remainder)
+      : "0" ((uint32)dividend),
+        "1" ((uint32)(dividend >> 32)),
+        "rm" (divisor)
+      : "cc"
+   );
+}
+
+#elif _MSC_VER
+
+static INLINE void
+Div643232(uint64 dividend,   // IN
+          uint32 divisor,    // IN
+          uint32 *quotient,  // OUT
+          uint32 *remainder) // OUT
+{
+   /* Written and tested by mann, checked by dbudko and hpreg */
+   __asm {
+      mov  eax, DWORD PTR [dividend]
+      mov  edx, DWORD PTR [dividend+4]
+      div  DWORD PTR [divisor]
+      mov  edi, DWORD PTR [quotient]
+      mov  [edi], eax
+      mov  edi, DWORD PTR [remainder]
+      mov  [edi], edx
+   }
+}
+
+#else
+#error No compiler defined for Div643232
+#endif
+
+
+#if defined(__GNUC__)
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Div643264 --
+ *
+ *    Unsigned integer division:
+ *       The dividend is 64-bit wide
+ *       The divisor  is 32-bit wide
+ *       The quotient is 64-bit wide --hpreg
+ *
+ * Results:
+ *    Quotient and remainder
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static INLINE void
+Div643264(uint64 dividend,   // IN
+          uint32 divisor,    // IN
+          uint64 *quotient,  // OUT
+          uint32 *remainder) // OUT
+{
+   uint32 hQuotient;
+   uint32 lQuotient;
+
+   /* Checked against the Intel manual and GCC --hpreg */
+   __asm__(
+      "divl %5"        "\n\t"
+      "movl %%eax, %0" "\n\t"
+      "movl %4, %%eax" "\n\t"
+      "divl %5"
+      : "=&rm" (hQuotient),
+        "=a" (lQuotient),
+        "=d" (*remainder)
+      : "1" ((uint32)(dividend >> 32)),
+        "g" ((uint32)dividend),
+        "rm" (divisor),
+        "2" (0)
+      : "cc"
+   );
+   *quotient = (uint64)hQuotient << 32 | lQuotient;
+}
+#endif
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Mul64x3264 --
+ *
+ *    Unsigned integer by fixed point multiplication:
+ *       Unsigned 64-bit integer multiplicand.
+ *       Unsigned 32-bit fixed point multiplier, represented as
+ *         multiplier >> shift, where shift < 64.
+ *       Unsigned 64-bit integer product.
+ *
+ * Implementation:
+ *    Multiply 64x32 bits to yield a full 96-bit product.
+ *    Shift right by shift.
+ *    Return the low-order 64 bits of the result.
+ *
+ * Result:
+ *    Product
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__)
+
+static INLINE uint64
+Mul64x3264(uint64 multiplicand, uint32 multiplier, uint32 shift)
+{
+   uint64 result;
+   uint32 tmp1, tmp2;
+   // ASSERT(shift >= 0 && shift < 64);
+  
+   /*
+    * Written and tested by mann, improved with suggestions by hpreg.
+    *
+    * The main improvement over the previous version is that the test
+    * of shift against 32 is moved out of the asm and into C code.
+    * This lets the compiler delete the test and one of the
+    * alternative code sequences in the case where shift is a
+    * constant.  It also lets us use the best code sequence in each
+    * alternative, rather than a compromise.  The downside is that in
+    * the non-constant case, this version takes slightly more code
+    * space.
+    *
+    * Note on the constraints: We don't really want multiplicand to
+    * start in %edx:%eax as the =A constraint dictates; in fact, we'd
+    * prefer any *other* two registers.  But gcc doesn't have
+    * constraint syntax for any other register pair, and trying to
+    * constrain ((uint32) multiplicand) to one place and (multiplicand
+    * >> 32) to another generates *really* bad code -- gcc is just not
+    * smart enough, at least in the version we are currently using.
+    */
+   if (shift < 32) {
+      __asm__("mov   %%eax, %2     \n\t" // Save lo(multiplicand) in tmp2
+              "mov   %%edx, %%eax  \n\t" // Get hi(multiplicand)
+              "mull  %4            \n\t" // p2 = hi(multiplicand) * multiplier
+              "xchg  %%eax, %2     \n\t" // Save lo(p2) in tmp2, get lo(multiplicand)
+              "mov   %%edx, %1     \n\t" // Save hi(p2) in tmp1
+              "mull  %4            \n\t" // p1 = lo(multiplicand) * multiplier
+              "addl  %2, %%edx     \n\t" // hi(p1) += lo(p2)
+              "adcl  $0, %1        \n\t" // hi(p2) += carry from previous step
+              "shrdl %%edx, %%eax  \n\t" // result = hi(p2):hi(p1):lo(p1) >> shift
+              "shrdl %1, %%edx"
+              : "=A"  (result),
+                "=&r" (tmp1),            // use in shrdl requires it to be a register
+                "=&r" (tmp2)             // could be "=&rm" but "m" is slower
+              : "0"   (multiplicand),
+                "rm"  (multiplier),
+                "c"   (shift)
+              : "cc"
+         );
+   } else {
+      __asm__("mov   %%edx, %2     \n\t" // Save hi(multiplicand) in tmp2
+              "mull  %4            \n\t" // p1 = lo(multiplicand) * multiplier
+              "mov   %%edx, %1     \n\t" // Save hi(p1) in tmp1
+              "mov   %2, %%eax     \n\t" // Discard lo(p1), get hi(multiplicand)
+              "mull  %4            \n\t" // p2 = hi(multiplicand) * multiplier
+              "addl  %1, %%eax     \n\t" // lo(p2) += hi(p1)
+              "adcl  $0, %%edx     \n\t" // hi(p2) += carry from previous step
+              "shrdl %%edx, %%eax  \n\t" // result = p2 >> (shift & 31)
+              "shrl  %%cl, %%edx"
+              : "=A"  (result),
+                "=&r" (tmp1),            // could be "=&rm" but "m" is slower
+                "=&r" (tmp2)             // could be "=&rm" but "m" is slower
+              : "0"   (multiplicand),
+                "rm"  (multiplier),
+                "c"   (shift)
+              : "cc"
+         );
+   }
+   return result;
+}
+
+#elif _MSC_VER
+#pragma warning(disable: 4035)
+
+static INLINE uint64
+Mul64x3264(uint64 multiplicand, uint32 multiplier, uint32 shift)
+{
+   // ASSERT(shift >= 0 && shift < 64);
+
+   /* Written and tested by mann, checked by dbudko and hpreg */
+   __asm {
+      mov  eax, DWORD PTR [multiplicand+4]  // Get hi(multiplicand)
+      mul  DWORD PTR [multiplier]           // p2 = hi(multiplicand) * multiplier
+      mov  ecx, eax                         // Save lo(p2)
+      mov  ebx, edx                         // Save hi(p2)
+      mov  eax, DWORD PTR [multiplicand]    // Get lo(multiplicand)
+      mul  DWORD PTR [multiplier+0]         // p1 = lo(multiplicand) * multiplier
+      add  edx, ecx                         // hi(p1) += lo(p2)
+      adc  ebx, 0                           // hi(p2) += carry from previous step
+      mov  ecx, DWORD PTR [shift]           // Get shift
+      cmp  ecx, 32                          // shift < 32?
+      jl   SHORT l2                         // Go if so
+      mov  eax, edx                         // result = hi(p2):hi(p1) >> (shift & 31)
+      mov  edx, ebx
+      shrd eax, edx, cl
+      shr  edx, cl
+      jmp  SHORT l3
+   l2:
+      shrd eax, edx, cl                     // result = hi(p2):hi(p1):lo(p1) >> shift
+      shrd edx, ebx, cl
+   l3:
+   }
+   // return with result in edx:eax
+}
+
+#pragma warning(default: 4035)
+#else
+#error No compiler defined for Mul64x3264
+#endif
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Muls64x32s64 --
+ *
+ *    Signed integer by fixed point multiplication:
+ *       Signed 64-bit integer multiplicand.
+ *       Unsigned 32-bit fixed point multiplier, represented as
+ *         multiplier >> shift, where shift < 64.
+ *       Signed 64-bit integer product.
+ *
+ * Implementation:
+ *    Multiply 64x32 bits to yield a full 96-bit product.
+ *    Shift right by the location of the binary point.
+ *    Return the low-order 64 bits of the result.
+ *
+ * Result:
+ *    Product
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__)
+
+static INLINE int64
+Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift)
+{
+   int64 result;
+   uint32 tmp1, tmp2;
+   // ASSERT(shift >= 0 && shift < 64);
+
+   /* Written and tested by mann, checked by dbudko and hpreg */
+   /* XXX hpreg suggested some improvements that we haven't converged on yet */
+   __asm__("mov   %%eax, %2\n\t"      // Save lo(multiplicand)
+           "mov   %%edx, %%eax\n\t"   // Get hi(multiplicand)
+           "test  %%eax, %%eax\n\t"   // Check sign of multiplicand
+           "jl    0f\n\t"             // Go if negative
+           "mull  %4\n\t"             // p2 = hi(multiplicand) * multiplier
+           "jmp   1f\n"
+        "0:\n\t"
+           "mull  %4\n\t"             // p2 = hi(multiplicand) * multiplier
+           "sub   %4, %%edx\n"        // hi(p2) += -1 * multiplier
+        "1:\n\t"
+           "xchg  %%eax, %2\n\t"      // Save lo(p2), get lo(multiplicand)
+           "mov   %%edx, %1\n\t"      // Save hi(p2)
+           "mull  %4\n\t"             // p1 = lo(multiplicand) * multiplier
+           "addl  %2, %%edx\n\t"      // hi(p1) += lo(p2)
+           "adcl  $0, %1\n\t"         // hi(p2) += carry from previous step
+           "cmpl  $32, %%ecx\n\t"     // shift < 32?
+           "jl    2f\n\t"             // Go if so
+           "mov   %%edx, %%eax\n\t"   // result = hi(p2):hi(p1) >> (shift & 31)
+           "mov   %1, %%edx\n\t"
+           "shrdl %%edx, %%eax\n\t"
+           "sarl  %%cl, %%edx\n\t"
+           "jmp   3f\n"
+        "2:\n\t"
+           "shrdl %%edx, %%eax\n\t"   // result = hi(p2):hi(p1):lo(p1) >> shift
+           "shrdl %1, %%edx\n"
+        "3:\n\t"
+           : "=A" (result), "=&r" (tmp1), "=&r" (tmp2)
+           : "0" (multiplicand), "rm" (multiplier), "c" (shift)
+           : "cc");
+   return result;
+}
+
+#elif _MSC_VER
+#pragma warning(disable: 4035)
+
+static INLINE int64
+Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift)
+{
+   //ASSERT(shift >= 0 && shift < 64);
+  
+   /* Written and tested by mann, checked by dbudko and hpreg */
+   __asm {
+      mov  eax, DWORD PTR [multiplicand+4]  // Get hi(multiplicand)
+      test eax, eax                         // Check sign of multiplicand
+      jl   SHORT l0                         // Go if negative
+      mul  DWORD PTR [multiplier]           // p2 = hi(multiplicand) * multiplier
+      jmp  SHORT l1
+   l0:
+      mul  DWORD PTR [multiplier]           // p2 = hi(multiplicand) * multiplier
+      sub  edx, DWORD PTR [multiplier]      // hi(p2) += -1 * multiplier
+   l1:
+      mov  ecx, eax                         // Save lo(p2)
+      mov  ebx, edx                         // Save hi(p2)
+      mov  eax, DWORD PTR [multiplicand]    // Get lo(multiplicand)
+      mul  DWORD PTR [multiplier]           // p1 = lo(multiplicand) * multiplier
+      add  edx, ecx                         // hi(p1) += lo(p2)
+      adc  ebx, 0                           // hi(p2) += carry from previous step
+      mov  ecx, DWORD PTR [shift]           // Get shift
+      cmp  ecx, 32                          // shift < 32?
+      jl   SHORT l2                         // Go if so
+      mov  eax, edx                         // result = hi(p2):hi(p1) >> (shift & 31)
+      mov  edx, ebx
+      shrd eax, edx, cl
+      sar  edx, cl
+      jmp  SHORT l3
+   l2:
+      shrd eax, edx, cl                     // result = hi(p2):hi(p1):lo(p1) << shift
+      shrd edx, ebx, cl
+   l3:
+   }
+   // return with result in edx:eax
+}
+
+#pragma warning(default: 4035)
+#else
+#error No compiler defined for Muls64x32s64
+#endif
+
+
+#endif
diff --git a/open-vm-tools/modules/linux/vsock/include/vm_basic_asm_x86_64.h b/open-vm-tools/modules/linux/vsock/include/vm_basic_asm_x86_64.h
new file mode 100644 (file)
index 0000000..054660e
--- /dev/null
@@ -0,0 +1,336 @@
+/*********************************************************
+ * Copyright (C) 1998-2004 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ *********************************************************/
+
+/*
+ * vm_basic_asm_x86_64.h
+ *
+ *     Basic x86_64 asm macros.
+ */
+
+#ifndef _VM_BASIC_ASM_X86_64_H_
+#define _VM_BASIC_ASM_X86_64_H_
+
+#define INCLUDE_ALLOW_USERLEVEL
+#define INCLUDE_ALLOW_VMMEXT
+#define INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_VMMON
+#define INCLUDE_ALLOW_VMK_MODULE
+#define INCLUDE_ALLOW_VMKERNEL
+#define INCLUDE_ALLOW_DISTRIBUTE
+#define INCLUDE_ALLOW_VMCORE
+#define INCLUDE_ALLOW_VMNIXMOD
+#include "includeCheck.h"
+
+#ifndef VM_X86_64
+#error "This file is x86-64 only!"
+#endif
+
+#ifdef _MSC_VER
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+uint64 _umul128(uint64 multiplier, uint64 multiplicand, 
+                uint64 *highProduct);
+int64 _mul128(int64 multiplier, int64 multiplicand, 
+              int64 *highProduct);
+uint64 __shiftright128(uint64 lowPart, uint64 highPart, uint8 shift);
+#ifdef __cplusplus
+}
+#endif
+
+#pragma intrinsic(_umul128, _mul128, __shiftright128)
+
+#endif // _MSC_VER
+
+/*
+ * FXSAVE/FXRSTOR
+ *     save/restore SIMD/MMX fpu state
+ *
+ * The pointer passed in must be 16-byte aligned.
+ *
+ * Intel and AMD processors behave differently w.r.t. fxsave/fxrstor. Intel
+ * processors unconditionally save the exception pointer state (instruction
+ * ptr., data ptr., and error instruction opcode). FXSAVE_ES1 and FXRSTOR_ES1
+ * work correctly for Intel processors.
+ *
+ * AMD processors only save the exception pointer state if ES=1. This leads to a
+ * security hole whereby one process/VM can inspect the state of another process
+ * VM. The AMD recommended workaround involves clobbering the exception pointer
+ * state unconditionally, and this is implemented in FXRSTOR_AMD_ES0. Note that
+ * FXSAVE_ES1 will only save the exception pointer state for AMD processors if
+ * ES=1.
+ *
+ * The workaround (FXRSTOR_AMD_ES0) only costs 1 cycle more than just doing an
+ * fxrstor, on both AMD Opteron and Intel Core CPUs.
+ */
+#if defined(__GNUC__)
+
+static INLINE void 
+FXSAVE_ES1(uint8 *save)
+{
+   __asm__ __volatile__ ("fxsaveq %0  \n" : "=m" (*save) : : "memory");
+}
+
+static INLINE void 
+FXSAVE_COMPAT_ES1(uint8 *save)
+{
+   __asm__ __volatile__ ("fxsave %0  \n" : "=m" (*save) : : "memory");
+}
+
+static INLINE void 
+FXRSTOR_ES1(const uint8 *load)
+{
+   __asm__ __volatile__ ("fxrstorq %0 \n" : : "m" (*load) : "memory");
+}
+
+static INLINE void 
+FXRSTOR_COMPAT_ES1(const uint8 *load)
+{
+   __asm__ __volatile__ ("fxrstor %0 \n" : : "m" (*load) : "memory");
+}
+
+static INLINE void 
+FXRSTOR_AMD_ES0(const uint8 *load)
+{
+   uint64 dummy = 0;
+      
+   __asm__ __volatile__ 
+       ("fnstsw  %%ax    \n"     // Grab x87 ES bit
+        "bt      $7,%%ax \n"     // Test ES bit
+        "jnc     1f      \n"     // Jump if ES=0
+        "fnclex          \n"     // ES=1. Clear it so fild doesn't trap
+        "1:              \n"
+        "ffree   %%st(7) \n"     // Clear tag bit - avoid poss. stack overflow
+        "fildl   %0      \n"     // Dummy Load from "safe address" changes all
+                                 // x87 exception pointers.
+        "fxrstorq %1 \n"
+        :
+        : "m" (dummy), "m" (*load)
+        : "ax", "memory");
+}
+
+#endif /* __GNUC__ */
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Mul64x3264 --
+ *
+ *    Unsigned integer by fixed point multiplication:
+ *       result = multiplicand * multiplier >> shift
+ * 
+ *       Unsigned 64-bit integer multiplicand.
+ *       Unsigned 32-bit fixed point multiplier, represented as
+ *         multiplier >> shift, where shift < 64.
+ *       Unsigned 64-bit integer product.
+ *
+ * Implementation:
+ *    Multiply 64x64 bits to yield a full 128-bit product.
+ *    Shift result in RDX:RAX right by "shift".
+ *    Return the low-order 64 bits of the above.
+ *
+ * Result:
+ *    Product
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__)
+
+static INLINE uint64
+Mul64x3264(uint64 multiplicand,
+           uint32 multiplier,
+           uint32 shift)
+{
+   uint64 result, dummy;
+   const uint64 multiplier64 = multiplier;
+
+   __asm__("mulq    %3      \n\t"
+           "shrdq   %1, %0  \n\t"
+           : "=a" (result),
+             "=d" (dummy)
+           : "0"  (multiplier64),
+             "rm" (multiplicand),
+         "c"  (shift)
+           : "cc");
+   return result;
+}
+
+#elif defined(_MSC_VER)
+
+static INLINE uint64
+Mul64x3264(uint64 multiplicand, uint32 multiplier, uint32 shift)
+{
+   uint64 tmplo, tmphi;
+   tmplo = _umul128(multiplicand, multiplier, &tmphi);
+   return __shiftright128(tmplo, tmphi, (uint8) shift);
+}
+
+#endif
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Muls64x32s64 --
+ *
+ *    Signed integer by fixed point multiplication:
+ *       result = multiplicand * multiplier >> shift
+ * 
+ *       Signed 64-bit integer multiplicand.
+ *       Unsigned 32-bit fixed point multiplier, represented as
+ *         multiplier >> shift, where shift < 64.
+ *       Signed 64-bit integer product.
+ *
+ * Implementation:
+ *    Multiply 64x64 bits to yield a full 128-bit product.
+ *    Shift result in RDX:RAX right by "shift".
+ *    Return the low-order 64 bits of the above.
+ *
+ *    Note: using an unsigned shift instruction is correct because
+ *    shift < 64 and we return only the low 64 bits of the shifted
+ *    result.
+ *
+ * Result:
+ *    Product
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__)
+
+static inline int64
+Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift)
+{
+   int64 result, dummy;
+   const int64 multiplier64 = multiplier;
+
+   __asm__("imulq   %3      \n\t"
+       "shrdq   %1, %0  \n\t"
+       : "=a" (result),
+         "=d" (dummy)
+       : "0"  (multiplier64),
+         "rm" (multiplicand),
+         "c"  (shift)
+       : "cc");
+   return result;
+}
+
+#elif defined(_MSC_VER)
+
+static INLINE int64
+Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift)
+{
+   int64 tmplo, tmphi;
+   tmplo = _mul128(multiplicand, multiplier, &tmphi);
+   return __shiftright128(tmplo, tmphi, (uint8) shift);
+}
+
+#endif
+
+
+#if defined(__GNUC__)
+
+static INLINE void *
+uint64set(void *dst, uint64 val, uint64 count)
+{
+   int dummy0;
+   int dummy1;
+   __asm__ __volatile__("\t"
+                        "cld"            "\n\t"
+                        "rep ; stosq"    "\n"
+                        : "=c" (dummy0), "=D" (dummy1)
+                        : "0" (count), "1" (dst), "a" (val)
+                        : "memory", "cc");
+   return dst;
+}
+
+#endif
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Div643232 --
+ *
+ *    Unsigned integer division:
+ *       The dividend is 64-bit wide
+ *       The divisor  is 32-bit wide
+ *       The quotient is 32-bit wide
+ *
+ *    Use this function if you are certain that the quotient will fit in 32 bits,
+ *    If that is not the case, a #DE exception was generated in 32-bit version,
+ *    but not in this 64-bit version. So please be careful.
+ *
+ * Results:
+ *    Quotient and remainder
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__) || defined(_MSC_VER)
+
+static INLINE void
+Div643232(uint64 dividend,   // IN
+          uint32 divisor,    // IN
+          uint32 *quotient,  // OUT
+          uint32 *remainder) // OUT
+{
+   *quotient = (uint32)(dividend / divisor);
+   *remainder = (uint32)(dividend % divisor);
+}
+
+#endif
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Div643264 --
+ *
+ *    Unsigned integer division:
+ *       The dividend is 64-bit wide
+ *       The divisor  is 32-bit wide
+ *       The quotient is 64-bit wide
+ *
+ * Results:
+ *    Quotient and remainder
+ *
+ * Side effects:
+ *    None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+#if defined(__GNUC__)
+
+static INLINE void
+Div643264(uint64 dividend,   // IN
+          uint32 divisor,    // IN
+          uint64 *quotient,  // OUT
+          uint32 *remainder) // OUT
+{
+   *quotient = dividend / divisor;
+   *remainder = dividend % divisor;
+}
+
+#endif
+
+#endif // _VM_BASIC_ASM_X86_64_H_
diff --git a/open-vm-tools/modules/linux/vsock/include/vm_basic_math.h b/open-vm-tools/modules/linux/vsock/include/vm_basic_math.h
new file mode 100644 (file)
index 0000000..9262afb
--- /dev/null
@@ -0,0 +1,67 @@
+/*********************************************************
+ * Copyright (C) 2008 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ *********************************************************/
+
+/*
+ * vm_basic_math.h --
+ *
+ *     Standard mathematical macros for VMware source code.
+ */
+
+#ifndef _VM_BASIC_MATH_H_
+#define _VM_BASIC_MATH_H_
+
+#define INCLUDE_ALLOW_USERLEVEL
+#define INCLUDE_ALLOW_VMMEXT
+#define INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_VMMON
+#define INCLUDE_ALLOW_VMNIXMOD
+#define INCLUDE_ALLOW_VMKERNEL
+#define INCLUDE_ALLOW_VMKDRIVERS
+#define INCLUDE_ALLOW_VMK_MODULE
+#define INCLUDE_ALLOW_DISTRIBUTE
+#define INCLUDE_ALLOW_VMCORE
+#define INCLUDE_ALLOW_VMIROM
+#include "includeCheck.h"
+#include "vm_basic_types.h" // For INLINE.
+#include "vm_basic_asm.h"   // For Div64...
+
+
+static INLINE uint32
+RatioOf(uint32 numer1, uint32 numer2, uint32 denom)
+{
+   uint64 numer = (uint64)numer1 * numer2;
+   /* Calculate "(numer1 * numer2) / denom" avoiding round-off errors. */
+#if defined(VMM)
+   return numer / denom;
+#else
+   uint32 ratio;
+   uint32 unused;
+   Div643232(numer, denom, &ratio, &unused);
+   return ratio;
+#endif
+}
+
+static INLINE uint32
+ExponentialAvg(uint32 avg, uint32 value, uint32 gainNumer, uint32 gainDenom)
+{
+   uint32 term1 = gainNumer * avg;
+   uint32 term2 = (gainDenom - gainNumer) * value;
+   return (term1 + term2) / gainDenom;
+}
+
+#endif // ifndef _VM_BASIC_MATH_H_
index 5e5e7cd0310a44052a8cece31f6144f86b4471ff..53ee917468e986573da078bd0048708d24d81dfd 100644 (file)
@@ -83,8 +83,6 @@ typedef char           Bool;
 #endif
 
 #ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-typedef signed __int64 int64;
 
 #pragma warning (3 :4505) // unreferenced local function
 #pragma warning (disable :4018) // signed/unsigned mismatch
@@ -95,6 +93,45 @@ typedef signed __int64 int64;
 #pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned
 #pragma warning (disable :4142) // benign redefinition of type
 
+#endif
+
+#if defined(__APPLE__) || defined(HAVE_STDINT_H)
+
+/*
+ * TODO: This is a C99 standard header.  We should be able to test for
+ * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build
+ * (which doesn't have stdint.h).
+ */
+
+#include <stdint.h>
+
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint8_t uint8;
+
+/*
+ * XXX: int8_t is defined to be 'signed char' on Mac hosts.
+ *
+ * Unfortunately, GCC 4.0.1 warns when doing pointer assignment or
+ * comparison between signed char * and char * (even if char is
+ * signed).
+ *
+ * If we want to use int8_t to define int8, we need to go through and
+ * replace uses of char * with signed char * to prevent warnings.
+ */
+typedef char int8;
+
+#else /* !HAVE_STDINT_H */
+
+#ifdef _MSC_VER
+
+typedef unsigned __int64 uint64;
+typedef signed __int64 int64;
+
 #elif __GNUC__
 /* The Xserver source compiles with -ansi -pendantic */
 #ifndef __STRICT_ANSI__
@@ -111,7 +148,7 @@ typedef long long int64;
 #endif
 #else
 #error - Need compiler define for int64/uint64
-#endif
+#endif /* _MSC_VER */
 
 typedef unsigned int       uint32;
 typedef unsigned short     uint16;
@@ -121,6 +158,8 @@ typedef int       int32;
 typedef short     int16;
 typedef char      int8;
 
+#endif /* HAVE_STDINT_H */
+
 /*
  * FreeBSD (for the tools build) unconditionally defines these in
  * sys/inttypes.h so don't redefine them if this file has already
@@ -143,9 +182,6 @@ typedef char      int8;
 #ifdef HAVE_SYS_INTTYPES_H
 #include <sys/inttypes.h>
 #endif
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -231,6 +267,12 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       #define FMTPD      "I"
       #define FMTH       "I"
    #endif
+#elif defined __APPLE__
+   /* Mac OS hosts use the same formatters for 32- and 64-bit. */
+   #define FMT64 "ll"
+   #define FMTSZ "z"
+   #define FMTPD "l"
+   #define FMTH ""
 #elif __GNUC__
    #define FMTH ""
    #if defined(N_PLAT_NLM) || defined(sun) || \
@@ -252,10 +294,10 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
       || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \
       || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \
       || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L)
-      /* BSD/Darwin, Linux */
+      /* BSD, Linux */
       #define FMTSZ     "z"
 
-      #if defined(VM_X86_64) || defined(__APPLE__)
+      #if defined(VM_X86_64)
          #define FMTPD  "l"
       #else
          #define FMTPD  ""
@@ -271,7 +313,7 @@ typedef int64 VmTimeVirtualClock;  /* Virtual Clock kept in CPU cycles */
    #endif
    #ifdef VM_X86_64
       #define FMT64     "l"
-   #elif defined(sun) || defined(__APPLE__) || defined(__FreeBSD__)
+   #elif defined(sun) || defined(__FreeBSD__)
       #define FMT64     "ll"
    #else
       #define FMT64     "L"
diff --git a/open-vm-tools/modules/linux/vsock/include/x86cpuid.h b/open-vm-tools/modules/linux/vsock/include/x86cpuid.h
new file mode 100644 (file)
index 0000000..0a2f3c6
--- /dev/null
@@ -0,0 +1,970 @@
+/*********************************************************
+ * Copyright (C) 1998-2008 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ *
+ *********************************************************/
+
+#ifndef _X86CPUID_H_
+#define _X86CPUID_H_
+
+/* http://www.sandpile.org/ia32/cpuid.htm */
+
+#define INCLUDE_ALLOW_USERLEVEL
+#define INCLUDE_ALLOW_VMX
+#define INCLUDE_ALLOW_VMMEXT
+#define INCLUDE_ALLOW_VMKERNEL
+#define INCLUDE_ALLOW_MODULE
+#define INCLUDE_ALLOW_VMNIXMOD
+#define INCLUDE_ALLOW_DISTRIBUTE
+#define INCLUDE_ALLOW_VMK_MODULE
+#define INCLUDE_ALLOW_VMCORE
+#define INCLUDE_ALLOW_VMMON
+#include "includeCheck.h"
+
+#include "vm_basic_types.h"
+
+/*
+ * The linux kernel's ptrace.h stupidly defines the bare
+ * EAX/EBX/ECX/EDX, which wrecks havoc with our preprocessor tricks.
+ */
+#undef EAX
+#undef EBX
+#undef ECX
+#undef EDX
+
+typedef struct CPUIDRegs {
+   uint32 eax, ebx, ecx, edx;
+} CPUIDRegs;
+
+typedef union CPUIDRegsUnion {
+   uint32 array[4];
+   CPUIDRegs regs;
+} CPUIDRegsUnion;
+
+/*
+ * Results of calling cpuid(eax, ecx) on all host logical CPU.
+ */
+#ifdef _MSC_VER
+#pragma warning (disable :4200) // non-std extension: zero-sized array in struct
+#endif
+
+typedef
+#include "vmware_pack_begin.h"
+struct CPUIDReply {
+   /*
+    * Unique host logical CPU identifier. It does not change across queries, so
+    * we use it to correlate the replies of multiple queries.
+    */
+   uint64 tag;                // OUT
+
+   CPUIDRegs regs;            // OUT
+}
+#include "vmware_pack_end.h"
+CPUIDReply;
+
+typedef
+#include "vmware_pack_begin.h"
+struct CPUIDQuery {
+   uint32 eax;                // IN
+   uint32 ecx;                // IN
+   uint32 numLogicalCPUs;     // IN/OUT
+   CPUIDReply logicalCPUs[0]; // OUT
+}
+#include "vmware_pack_end.h"
+CPUIDQuery;
+
+/*
+ * CPUID levels the monitor caches and ones that are not cached, but
+ * have fields defined below (short name and actual value).
+ * 
+ * The first parameter defines whether the level is masked/tested
+ * during power-on/migration.  Any level which is marked as FALSE here
+ * *must* have all field masks defined as IGNORE in CPUID_FIELD_DATA.
+ * A static assert in lib/cpuidcompat/cpuidcompat.c will check this.
+ *
+ * IMPORTANT: WHEN ADDING A NEW FIELD TO THE CACHED LEVELS, make sure
+ * you update vmcore/vmm/cpu/priv.c:Priv_CPUID() and vmcore/vmm64/bt/
+ * cpuid_shared.S (and geninfo) to include the new level.
+ */
+
+#define CPUID_CACHED_LEVELS                     \
+   CPUIDLEVEL(TRUE,  0,  0)                     \
+   CPUIDLEVEL(TRUE,  1,  1)                     \
+   CPUIDLEVEL(FALSE,400, 0x40000000)            \
+   CPUIDLEVEL(FALSE,410, 0x40000010)            \
+   CPUIDLEVEL(FALSE, 80, 0x80000000)            \
+   CPUIDLEVEL(TRUE,  81, 0x80000001)            \
+   CPUIDLEVEL(FALSE, 88, 0x80000008)            \
+   CPUIDLEVEL(TRUE,  8A, 0x8000000A)
+
+#define CPUID_UNCACHED_LEVELS                   \
+   CPUIDLEVEL(FALSE, 4, 4)                      \
+   CPUIDLEVEL(FALSE, 5, 5)                      \
+   CPUIDLEVEL(FALSE, 6, 6)                      \
+   CPUIDLEVEL(FALSE, A, 0xA)                    \
+   CPUIDLEVEL(FALSE, 86, 0x80000006)            \
+   CPUIDLEVEL(FALSE, 87, 0x80000007)            \
+
+#define CPUID_ALL_LEVELS                        \
+   CPUID_CACHED_LEVELS                          \
+   CPUID_UNCACHED_LEVELS
+
+/* Define cached CPUID levels in the form: CPUID_LEVEL_<ShortName> */
+typedef enum {
+#define CPUIDLEVEL(t, s, v) CPUID_LEVEL_##s,
+   CPUID_CACHED_LEVELS
+#undef CPUIDLEVEL
+   CPUID_NUM_LEVELS
+} CpuidLevels;
+
+/*
+ * CPUID result registers
+ */
+
+#define CPUID_REGS                              \
+   CPUIDREG(EAX, eax)                           \
+   CPUIDREG(EBX, ebx)                           \
+   CPUIDREG(ECX, ecx)                           \
+   CPUIDREG(EDX, edx)
+
+typedef enum {
+#define CPUIDREG(uc, lc) CPUID_REG_##uc,
+   CPUID_REGS
+#undef CPUIDREG
+   CPUID_NUM_REGS
+} CpuidRegs;
+
+/*
+ * CPU vendors
+ */
+
+typedef enum {
+   CPUID_VENDOR_UNKNOWN,
+   CPUID_VENDOR_COMMON,
+   CPUID_VENDOR_INTEL,
+   CPUID_VENDOR_AMD,
+   CPUID_VENDOR_CYRIX,
+   CPUID_VENDOR_VIA,
+   CPUID_NUM_VENDORS
+} CpuidVendors;
+
+#define CPUID_INTEL_VENDOR_STRING       "GenuntelineI"
+#define CPUID_AMD_VENDOR_STRING         "AuthcAMDenti"
+#define CPUID_CYRIX_VENDOR_STRING       "CyriteadxIns"
+#define CPUID_VIA_VENDOR_STRING         "CentaulsaurH"
+#define CPUID_HYPERV_HYPERVISOR_VENDOR_STRING  "Microsoft Hv"
+#define CPUID_INTEL_VENDOR_STRING_FIXED "GenuineIntel"
+#define CPUID_AMD_VENDOR_STRING_FIXED   "AuthenticAMD"
+#define CPUID_CYRIX_VENDOR_STRING_FIXED "CyrixInstead"
+#define CPUID_VIA_VENDOR_STRING_FIXED   "CentaurHauls"
+
+/*
+ * FIELDDEF can be defined to process the CPUID information provided
+ * in the following CPUID_FIELD_DATA macro.  The first parameter is
+ * the CPUID level of the feature (must be defined in CPUID_*_LEVELS.
+ * The second parameter is the register the field is contained in
+ * (defined in CPUID_REGS).  The third field is the vendor this
+ * feature applies to.  "COMMON" means all vendors apply.  UNKNOWN may
+ * not be used here.  The fourth and fifth parameters are the bit
+ * position of the field and the width, respectively.  The sixth is
+ * the text name of the field.
+ *
+ * The seventh and eighth parameters specify the default CPUID
+ * behavior for power-on, guest view, and migration tests (cpt/rsm &
+ * vmotion).  The eighth parameter is ignored for types other than
+ * MASK & TEST, and must be zero in this case.
+ *
+ * When adding a new field, be sure to consider its purpose.  The
+ * following list of types is provided in order of likely use.
+ *
+ * NOTE: this form of representation is separate from the masking
+ * system specified via the config file.  That is because this
+ * representation must take into account multi-bit fields.
+ *
+ * HOST    - Passthrough host value and cannot change during migration.
+ * MASK, 0 - Hide from the guest, because we don't support it or we
+ *           don't want the guest to know that it exists.
+ * IGNORE  - Ignore this field for all tests
+ *
+ *    (Think twice before using the below mask types/combinations)
+ *
+ * MASK, x - Force the guest to always see x, and don't compare for
+ *           migration -- only APIC as of today; it is controlled by
+ *           software and we know how to toggle it
+ * TEST, x - Require host CPUID field to be x for power-on
+ * RSVD    - Hidden from the guest, but compared during migration
+ *
+ *
+ * Table to explain mask type meanings:
+ *
+ *                         IGNR   MASK   TEST   HOST   RSVD
+ * --------------------------------------------------------
+ * Req'd val for power-on   -      -      x      -      -
+ * Value guest sees         *      x      *      *      0
+ * Checked on migration?    N      N      Y      Y      Y
+ *
+ * * - initial host's power-on CPUID value
+ *
+ * FIELDDEFA takes a ninth parameter, the name used when creating
+ * accessor functions in lib/public/cpuidInfoFuncs.h.
+ *
+ * FLAGDEF/FLAGDEFA is defined identically to fields, but their
+ * accessors are more appropriate for 1-bit flags.
+ */
+
+typedef enum {
+   CPUID_FIELD_MASK_IGNORE,
+   CPUID_FIELD_MASK_MASK,
+   CPUID_FIELD_MASK_TEST,
+   CPUID_FIELD_MASK_HOST,
+   CPUID_FIELD_MASK_RSVD,
+   CPUID_NUM_FIELD_MASKS
+} CpuidFieldMasks;
+
+
+typedef enum {
+   CPUID_FIELD_SUPPORTED_NO,
+   CPUID_FIELD_SUPPORTED_YES,
+   CPUID_FIELD_SUPPORTED_ANY,
+   CPUID_FIELD_SUPPORTED_NA,
+   CPUID_NUM_FIELD_SUPPORTEDS
+} CpuidFieldSupported;
+
+
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_0                                               \
+FIELDDEF(  0, EAX, COMMON,  0, 32, NUMLEVELS,           ANY, IGNORE, 0, FALSE)     \
+FIELDDEF(  0, EBX, COMMON,  0, 32, VENDOR1,             YES, HOST,   0, TRUE)      \
+FIELDDEF(  0, ECX, COMMON,  0, 32, VENDOR3,             YES, HOST,   0, TRUE)      \
+FIELDDEF(  0, EDX, COMMON,  0, 32, VENDOR2,             YES, HOST,   0, TRUE)
+                                                        
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_1                                               \
+FIELDDEFA( 1, EAX, COMMON,  0,  4, STEPPING,            ANY, IGNORE, 0, FALSE, STEPPING)  \
+FIELDDEFA( 1, EAX, COMMON,  4,  4, MODEL,               ANY, IGNORE, 0, FALSE, MODEL)     \
+FIELDDEFA( 1, EAX, COMMON,  8,  4, FAMILY,              YES, HOST,   0, FALSE, FAMILY)    \
+FIELDDEF(  1, EAX, COMMON, 12,  2, TYPE,                ANY, IGNORE, 0, FALSE)            \
+FIELDDEFA( 1, EAX, COMMON, 16,  4, EXTMODEL,            ANY, IGNORE, 0, FALSE, EXT_MODEL) \
+FIELDDEFA( 1, EAX, COMMON, 20,  8, EXTFAMILY,           YES, HOST,   0, FALSE, EXT_FAMILY) \
+FIELDDEF(  1, EBX, COMMON,  0,  8, BRAND_ID,            ANY, IGNORE, 0, FALSE)            \
+FIELDDEF(  1, EBX, COMMON,  8,  8, CLFL_SIZE,           ANY, IGNORE, 0, FALSE)            \
+FIELDDEFA( 1, EBX, COMMON, 16,  8, LCPU_COUNT,          ANY, IGNORE, 0, FALSE, LCPU_COUNT) \
+FIELDDEFA( 1, EBX, COMMON, 24,  8, APICID,              ANY, IGNORE, 0, FALSE, APICID)    \
+FLAGDEFA(  1, ECX, COMMON, 0,   1, SSE3,                YES, HOST,   0, TRUE,  SSE3)      \
+FLAGDEF(   1, ECX, INTEL,  2,   1, NDA2,                NO,  MASK,   0, FALSE)            \
+FLAGDEFA(  1, ECX, COMMON, 3,   1, MWAIT,               NO,  MASK,   0, FALSE, MWAIT)     \
+FLAGDEFA(  1, ECX, INTEL,  4,   1, DSCPL,               NO,  MASK,   0, FALSE, DSCPL)     \
+FLAGDEFA(  1, ECX, INTEL,  5,   1, VMX,                 NO,  MASK,   0, FALSE, VMX)       \
+FLAGDEF(   1, ECX, INTEL,  6,   1, SMX,                 NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, ECX, INTEL,  7,   1, EST,                 NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, ECX, INTEL,  8,   1, TM2,                 NO,  MASK,   0, FALSE)            \
+FLAGDEFA(  1, ECX, COMMON, 9,   1, SSSE3,               YES, HOST,   0, TRUE,  SSSE3)     \
+FLAGDEF(   1, ECX, INTEL,  10,  1, HTCACHE,             NO,  MASK,   0, FALSE)            \
+FLAGDEFA(  1, ECX, COMMON, 13,  1, CMPX16,              YES, HOST,   0, TRUE,  CMPX16)    \
+FLAGDEF(   1, ECX, INTEL,  14,  1, xPPR,                NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, ECX, INTEL,  15,  1, PERF_MSR,            NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, ECX, INTEL,  18,  1, DCA,                 NO,  MASK,   0, FALSE)            \
+FLAGDEFA(  1, ECX, INTEL,  19,  1, SSE41,               YES, HOST,   0, TRUE,  SSE41)     \
+FLAGDEFA(  1, ECX, INTEL,  20,  1, SSE42,               YES, HOST,   0, TRUE,  SSE42)     \
+FLAGDEF(   1, ECX, INTEL,  21,  1, X2APIC,              NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, ECX, INTEL,  22,  1, MOVBE,               NO,  RSVD,   0, TRUE)             \
+FLAGDEFA(  1, ECX, COMMON, 23,  1, POPCNT,              YES, HOST,   0, TRUE,  POPCNT)    \
+FLAGDEF(   1, ECX, INTEL,  24,  1, ULE,                 NO,  RSVD,   0, TRUE)             \
+FLAGDEF(   1, ECX, INTEL,  26,  1, XSAVE,               NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, ECX, INTEL,  27,  1, OSXSAVE,             NO,  RSVD,   0, TRUE)             \
+FLAGDEFA(  1, ECX, COMMON, 31,  1, HYPERVISOR,          ANY, IGNORE, 0, FALSE, HYPERVISOR)\
+FLAGDEFA(  1, EDX, COMMON, 0,   1, FPU,                 YES, HOST,   0, TRUE, FPU)        \
+FLAGDEFA(  1, EDX, COMMON, 1,   1, VME,                 YES, HOST,   0, FALSE, VME)       \
+FLAGDEF(   1, EDX, COMMON, 2,   1, DBGE,                YES, HOST,   0, FALSE)            \
+FLAGDEF(   1, EDX, COMMON, 3,   1, PGSZE,               YES, HOST,   0, FALSE)            \
+FLAGDEFA(  1, EDX, COMMON, 4,   1, TSC,                 YES, HOST,   0, TRUE, TSC)        \
+FLAGDEF(   1, EDX, COMMON, 5,   1, MSR,                 YES, HOST,   0, FALSE)            \
+FLAGDEFA(  1, EDX, COMMON, 6,   1, PAE,                 YES, HOST,   0, FALSE, PAE)       \
+FLAGDEF(   1, EDX, COMMON, 7,   1, MCK,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(   1, EDX, COMMON, 8,   1, CPMX,                YES, HOST,   0, TRUE)             \
+FLAGDEFA(  1, EDX, COMMON, 9,   1, APIC,                ANY, MASK,   1, FALSE, APIC)      \
+FLAGDEFA(  1, EDX, COMMON, 11,  1, SEP,                 YES, HOST,   0, TRUE,  SEP)       \
+FLAGDEFA(  1, EDX, COMMON, 12,  1, MTRR,                YES, HOST,   0, FALSE, MTRR)      \
+FLAGDEFA(  1, EDX, COMMON, 13,  1, PGE,                 YES, HOST,   0, FALSE, PGE)       \
+FLAGDEFA(  1, EDX, COMMON, 14,  1, MCA,                 YES, HOST,   0, FALSE, MCA)       \
+FLAGDEFA(  1, EDX, COMMON, 15,  1, CMOV,                YES, HOST,   0, TRUE,  CMOV)      \
+FLAGDEFA(  1, EDX, COMMON, 16,  1, PAT,                 YES, HOST,   0, FALSE, PAT)       \
+FLAGDEF(   1, EDX, COMMON, 17,  1, 36PG,                YES, HOST,   0, FALSE)            \
+FLAGDEF(   1, EDX, INTEL,  18,  1, PSN,                 YES, HOST,   0, FALSE)            \
+FLAGDEFA(  1, EDX, COMMON, 19,  1, CLFL,                YES, HOST,   0, TRUE,  CLFL)      \
+FLAGDEF(   1, EDX, INTEL,  21,  1, DTES,                YES, HOST,   0, FALSE)            \
+FLAGDEF(   1, EDX, INTEL,  22,  1, ACPI,                YES, HOST,   0, FALSE)            \
+FLAGDEFA(  1, EDX, COMMON, 23,  1, MMX,                 YES, HOST,   0, TRUE,  MMX)       \
+FLAGDEFA(  1, EDX, COMMON, 24,  1, FXSAVE,              YES, HOST,   0, TRUE,  FXSAVE)    \
+FLAGDEFA(  1, EDX, COMMON, 25,  1, SSE,                 YES, HOST,   0, TRUE,  SSE)       \
+FLAGDEFA(  1, EDX, COMMON, 26,  1, SSE2,                YES, HOST,   0, TRUE,  SSE2)      \
+FLAGDEF(   1, EDX, INTEL,  27,  1, SS,                  YES, HOST,   0, FALSE)            \
+FLAGDEFA(  1, EDX, COMMON, 28,  1, HT,                  NO,  MASK,   0, FALSE, HT)        \
+FLAGDEF(   1, EDX, INTEL,  29,  1, TM,                  NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, EDX, INTEL,  30,  1, IA64,                NO,  MASK,   0, FALSE)            \
+FLAGDEF(   1, EDX, INTEL,  31,  1, PBE,                 NO,  MASK,   0, FALSE)
+
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_4                                               \
+FIELDDEF(  4, EAX, INTEL,   0,  5, CACHE_TYPE,          NA,  IGNORE, 0, FALSE)            \
+FIELDDEF(  4, EAX, INTEL,   5,  3, CACHE_LEVEL,         NA,  IGNORE, 0, FALSE)            \
+FIELDDEF(  4, EAX, INTEL,  14, 12, CACHE_NUMHT_SHARING, NA,  IGNORE, 0, FALSE)            \
+FIELDDEFA( 4, EAX, INTEL,  26,  6, CORE_COUNT,          NA,  IGNORE, 0, FALSE, INTEL_CORE_COUNT)  \
+FIELDDEF(  4, EBX, INTEL,   0, 12, CACHE_LINE,          NA,  IGNORE, 0, FALSE)            \
+FIELDDEF(  4, EBX, INTEL,  12, 10, CACHE_PART,          NA,  IGNORE, 0, FALSE)            \
+FIELDDEF(  4, EBX, INTEL,  22, 10, CACHE_WAYS,          NA,  IGNORE, 0, FALSE)
+
+/*     LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_5                                           \
+FIELDDEF(  5, EAX, COMMON,  0, 16, MWAIT_MIN_SIZE,      NA,  IGNORE, 0, FALSE) \
+FIELDDEF(  5, EBX, COMMON,  0, 16, MWAIT_MAX_SIZE,      NA,  IGNORE, 0, FALSE) \
+FLAGDEF(   5, ECX, COMMON,  0,  1, MWAIT_EXTENSIONS,    NA,  IGNORE, 0, FALSE) \
+FLAGDEF(   5, ECX, COMMON,  1,  1, MWAIT_INTR_BREAK,    NA,  IGNORE, 0, FALSE) \
+FIELDDEF(  5, EDX, INTEL,   0,  4, MWAIT_C0_SUBSTATE,   NA,  IGNORE, 0, FALSE) \
+FIELDDEF(  5, EDX, INTEL,   4,  4, MWAIT_C1_SUBSTATE,   NA,  IGNORE, 0, FALSE) \
+FIELDDEF(  5, EDX, INTEL,   8,  4, MWAIT_C2_SUBSTATE,   NA,  IGNORE, 0, FALSE) \
+FIELDDEF(  5, EDX, INTEL,  12,  4, MWAIT_C3_SUBSTATE,   NA,  IGNORE, 0, FALSE) \
+FIELDDEF(  5, EDX, INTEL,  16,  4, MWAIT_C4_SUBSTATE,   NA,  IGNORE, 0, FALSE)
+
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_6                                               \
+FLAGDEF(   6, EAX, INTEL,   0,  1, THERMAL_SENSOR,      NA,  IGNORE, 0, FALSE)     \
+FLAGDEF(   6, EAX, INTEL,   1,  1, TURBO_MODE,          NA,  IGNORE, 0, FALSE)     \
+FIELDDEF(  6, EBX, INTEL,   0,  4, NUM_INTR_THRESHOLDS, NA,  IGNORE, 0, FALSE)     \
+FLAGDEF(   6, ECX, INTEL,   0,  1, HW_COORD_FEEDBACK,   NA,  IGNORE, 0, FALSE)
+
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_A                                               \
+FIELDDEFA( A, EAX, INTEL,   0,  8, PMC_VERSION,         NA,  IGNORE, 0, FALSE, PMC_VERSION) \
+FIELDDEFA( A, EAX, INTEL,   8,  8, NUM_PMCS,            NA,  IGNORE, 0, FALSE, NUM_PMCS)  \
+FIELDDEF(  A, EAX, INTEL,  16,  8, PMC_BIT_WIDTH,       NA,  IGNORE, 0, FALSE)            \
+FIELDDEFA( A, EAX, INTEL,  24,  8, PMC_EBX_LENGTH,      NA,  IGNORE, 0, FALSE, PMC_EBX_LENGTH) \
+FLAGDEF(   A, EBX, INTEL,   0,  1, PMC_CORE_CYCLE,      NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(   A, EBX, INTEL,   1,  1, PMC_INSTR_RETIRED,   NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(   A, EBX, INTEL,   2,  1, PMC_REF_CYCLES,      NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(   A, EBX, INTEL,   3,  1, PMC_LAST_LVL_CREF,   NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(   A, EBX, INTEL,   4,  1, PMC_LAST_LVL_CMISS,  NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(   A, EBX, INTEL,   5,  1, PMC_BR_INST_RETIRED, NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(   A, EBX, INTEL,   6,  1, PMC_BR_MISS_RETIRED, NA,  IGNORE, 0, FALSE)            \
+FIELDDEF(  A, EDX, INTEL,   0,  5, PMC_FIXED_NUM,       NA,  IGNORE, 0, FALSE)            \
+FIELDDEF(  A, EDX, INTEL,   5,  8, PMC_FIXED_SIZE,      NA,  IGNORE, 0, FALSE)
+
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_80                                              \
+FIELDDEF( 80, EAX, COMMON,  0, 32, NUM_EXT_LEVELS,      NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 80, EBX, AMD,     0, 32, AMD_VENDOR1,         NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 80, ECX, AMD,     0, 32, AMD_VENDOR3,         NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 80, EDX, AMD,     0, 32, AMD_VENDOR2,         NA,  IGNORE, 0, FALSE)
+                                                        
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_81                                              \
+FIELDDEF( 81, EAX, INTEL,   0, 32, UNKNOWN81EAX,        ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EAX, AMD,     0,  4, STEPPING,            ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EAX, AMD,     4,  4, MODEL,               ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EAX, AMD,     8,  4, FAMILY,              ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EAX, AMD,    12,  2, TYPE,                ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EAX, AMD,    16,  4, EXTMODEL,            ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EAX, AMD,    20,  8, EXTFAMILY,           ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EBX, INTEL,   0, 32, UNKNOWN81EBX,        ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EBX, AMD,     0, 16, BRAND_ID,            ANY, IGNORE, 0, FALSE)            \
+FIELDDEF( 81, EBX, AMD,    16, 16, UNDEF,               ANY, IGNORE, 0, FALSE)            \
+FLAGDEFA( 81, ECX, COMMON,  0,  1, LAHF,                YES, HOST,   0, TRUE,  LAHF64)    \
+FLAGDEFA( 81, ECX, AMD,     1,  1, CMPLEGACY,           NO,  MASK,   0, FALSE, CMPLEGACY) \
+FLAGDEFA( 81, ECX, AMD,     2,  1, SVM,                 NO,  MASK,   0, FALSE, SVM)       \
+FLAGDEFA( 81, ECX, AMD,     3,  1, EXTAPICSPC,          YES, HOST,   0, FALSE, EXTAPICSPC) \
+FLAGDEFA( 81, ECX, AMD,     4,  1, CR8AVAIL,            NO,  MASK,   0, FALSE, CR8AVAIL)  \
+FLAGDEFA( 81, ECX, AMD,     5,  1, ABM,                 YES, HOST,   0, TRUE,  ABM)       \
+FLAGDEFA( 81, ECX, AMD,     6,  1, SSE4A,               YES, HOST,   0, TRUE,  SSE4A)     \
+FLAGDEF(  81, ECX, AMD,     7,  1, MISALIGNED_SSE,      YES, HOST,   0, TRUE)             \
+FLAGDEFA( 81, ECX, AMD,     8,  1, 3DNPREFETCH,         YES, HOST,   0, TRUE, 3DNPREFETCH) \
+FLAGDEF(  81, ECX, AMD,     9,  1, OSVW,                NO,  MASK,   0, FALSE)            \
+FLAGDEF(  81, ECX, AMD,    10,  1, IBS,                 NO,  MASK,   0, FALSE)            \
+FLAGDEF(  81, ECX, AMD,    11,  1, SSE5,                NO,  RSVD,   0, TRUE)             \
+FLAGDEF(  81, ECX, AMD,    12,  1, SKINIT,              NO,  MASK,   0, FALSE)            \
+FLAGDEF(  81, ECX, AMD,    13,  1, WATCHDOG,            NO,  MASK,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,     0,  1, FPU,                 YES, HOST,   0, TRUE)             \
+FLAGDEF(  81, EDX, AMD,     1,  1, VME,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,     2,  1, DBGE,                YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,     3,  1, PGSZE,               YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,     4,  1, TSC,                 YES, HOST,   0, TRUE)             \
+FLAGDEF(  81, EDX, AMD,     5,  1, MSR,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,     6,  1, PAE,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,     7,  1, MCK,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,     8,  1, CPMX,                YES, HOST,   0, TRUE)             \
+FLAGDEF(  81, EDX, AMD,     9,  1, APIC,                ANY, MASK,   1, FALSE)            \
+FLAGDEFA( 81, EDX, COMMON, 11,  1, SYSC,                ANY, IGNORE, 0, TRUE, SYSC)       \
+FLAGDEF(  81, EDX, AMD,    12,  1, MTRR,                YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,    13,  1, PGE,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,    14,  1, MCA,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,    15,  1, CMOV,                YES, HOST,   0, TRUE)             \
+FLAGDEF(  81, EDX, AMD,    16,  1, PAT,                 YES, HOST,   0, FALSE)            \
+FLAGDEF(  81, EDX, AMD,    17,  1, 36PG,                YES, HOST,   0, FALSE)            \
+FLAGDEFA( 81, EDX, COMMON, 20,  1, NX,                  YES, HOST,   0, FALSE, NX)        \
+FLAGDEFA( 81, EDX, AMD,    22,  1, MMXEXT,              YES, HOST,   0, TRUE,  MMXEXT)    \
+FLAGDEF(  81, EDX, AMD,    23,  1, MMX,                 YES, HOST,   0, TRUE)             \
+FLAGDEF(  81, EDX, AMD,    24,  1, FXSAVE,              YES, HOST,   0, TRUE)             \
+FLAGDEFA( 81, EDX, AMD,    25,  1, FFXSR,               YES, HOST,   0, FALSE, FFXSR)     \
+FLAGDEF(  81, EDX, AMD,    26,  1, PDPE1GB,             NO,  MASK,   0, FALSE)            \
+FLAGDEFA( 81, EDX, COMMON, 27,  1, RDTSCP,              YES, HOST,   0, TRUE,  RDTSCP)    \
+FLAGDEFA( 81, EDX, COMMON, 29,  1, LM,                  YES, TEST,   1, FALSE, LM) \
+FLAGDEFA( 81, EDX, AMD,    30,  1, 3DNOWPLUS,           YES, HOST,   0, TRUE,  3DNOWPLUS) \
+FLAGDEFA( 81, EDX, AMD,    31,  1, 3DNOW,               YES, HOST,   0, TRUE,  3DNOW)
+
+/*    LEVEL, REG, VENDOR, POS, SIZE, NAME,       MON SUPP, MASK TYPE, SET TO, CPL3, [FUNC] */
+#define CPUID_FIELD_DATA_LEVEL_8x                                              \
+FIELDDEF( 86, ECX, AMD,     0,  8, L2CACHE_LINE,        NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 86, ECX, AMD,     8,  4, L2CACHE_LINE_PER_TAG, NA, IGNORE, 0, FALSE)            \
+FIELDDEF( 86, ECX, AMD,    12,  4, L2CACHE_WAYS,        NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 86, ECX, AMD,    16, 16, L2CACHE_SIZE,        NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 86, EDX, AMD,     0,  8, L3CACHE_LINE,        NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 86, EDX, AMD,     8,  4, L3CACHE_LINE_PER_TAG,NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 86, EDX, AMD,    12,  4, L3CACHE_WAYS,        NA,  IGNORE, 0, FALSE)            \
+FIELDDEF( 86, EDX, AMD,    18, 14, L3CACHE_SIZE,        NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     0,  1, TS,                  NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     1,  1, FID,                 NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     2,  1, VID,                 NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     3,  1, TTP,                 NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     4,  1, TM,                  NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     5,  1, STC,                 NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     6,  1, 100MHZSTEPS,         NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     7,  1, HWPSTATE,            NA,  IGNORE, 0, FALSE)            \
+FLAGDEF(  87, EDX, AMD,     8,  1, TSC_INVARIANT,       NA,  IGNORE, 0, FALSE)            \
+FIELDDEFA(88, EAX, COMMON,  0,  8, PHYSBITS,            NA,  IGNORE, 0, FALSE, PHYS_BITS) \
+FIELDDEFA(88, EAX, COMMON,  8,  8, VIRTBITS,            NA,  IGNORE, 0, FALSE, VIRT_BITS) \
+FIELDDEFA(88, ECX, AMD,     0,  8, CORE_COUNT,          NA,  IGNORE, 0, FALSE, AMD_CORE_COUNT) \
+FIELDDEFA(88, ECX, AMD,    12,  4, APICID_COREID_SIZE,  NA,  IGNORE, 0, FALSE, AMD_APICID_COREID_SIZE) \
+FIELDDEFA(8A, EAX, AMD,     0,  8, SVM_REVISION,        NO,  MASK,   0, FALSE, SVM_REVISION) \
+FLAGDEF(  8A, EAX, AMD,     8,  1, SVM_HYPERVISOR,      NO,  MASK,   0, FALSE)            \
+FIELDDEF( 8A, EAX, AMD,     9, 23, SVMEAX_RSVD,         NO,  MASK,   0, FALSE)            \
+FIELDDEF( 8A, EBX, AMD,     0, 32, SVM_N_ASIDS,         NO,  MASK,   0, FALSE)            \
+FIELDDEF( 8A, ECX, AMD,     0, 32, SVMECX_RSVD,         NO,  MASK,   0, FALSE)            \
+FLAGDEFA( 8A, EDX, AMD,     0,  1, SVM_NP,              NO,  MASK,   0, FALSE, NPT)       \
+FLAGDEF(  8A, EDX, AMD,     1,  1, SVM_LBR,             NO,  MASK,   0, FALSE)            \
+FLAGDEF(  8A, EDX, AMD,     2,  1, SVM_LOCK,            NO,  MASK,   0, FALSE)            \
+FLAGDEF(  8A, EDX, AMD,     3,  1, SVM_NRIP,            NO,  MASK,   0, FALSE)            \
+FIELDDEF( 8A, EDX, AMD,     4, 28, SVMEDX_RSVD,         NO,  MASK,   0, FALSE)
+
+#define CPUID_FIELD_DATA                                              \
+   CPUID_FIELD_DATA_LEVEL_0                                           \
+   CPUID_FIELD_DATA_LEVEL_1                                           \
+   CPUID_FIELD_DATA_LEVEL_4                                           \
+   CPUID_FIELD_DATA_LEVEL_5                                           \
+   CPUID_FIELD_DATA_LEVEL_6                                           \
+   CPUID_FIELD_DATA_LEVEL_A                                           \
+   CPUID_FIELD_DATA_LEVEL_80                                          \
+   CPUID_FIELD_DATA_LEVEL_81                                          \
+   CPUID_FIELD_DATA_LEVEL_8x
+
+/*
+ * Define all field and flag values as an enum.  The result is a full
+ * set of values taken from the table above in the form:
+ *
+ * CPUID_FEATURE_<vendor>_ID<level><reg>_<name> == mask for feature
+ * CPUID_<vendor>_ID<level><reg>_<name>_MASK    == mask for field
+ * CPUID_<vendor>_ID<level><reg>_<name>_SHIFT   == offset of field
+ *
+ * e.g. - CPUID_FEATURE_COMMON_ID1EDX_FPU     = 0x1
+ *      - CPUID_COMMON_ID88EAX_VIRTBITS_MASK  = 0xff00
+ *      - CPUID_COMMON_ID88EAX_VIRTBITS_SHIFT = 8
+ *
+ * Note: The FEATURE/MASK definitions must use some gymnastics to get
+ * around a warning when shifting left by 32.
+ */
+#define VMW_BIT_MASK(shift)  (((1 << (shift - 1)) << 1) - 1)
+
+#define FIELDDEF(lvl, reg, vend, bitpos, size, name, s, m, v, c3)       \
+   CPUID_##vend##_ID##lvl##reg##_##name##_SHIFT = bitpos,               \
+   CPUID_##vend##_ID##lvl##reg##_##name##_MASK  =                       \
+                      VMW_BIT_MASK(size) << bitpos,                     \
+   CPUID_FEATURE_##vend##_ID##lvl##reg##_##name =                       \
+                      CPUID_##vend##_ID##lvl##reg##_##name##_MASK,
+
+/* Before simplifying this take a look at bug 293638... */
+#define FIELDDEFA(lvl, reg, vend, bitpos, size, name, s, m, v, c3, f)   \
+   CPUID_##vend##_ID##lvl##reg##_##name##_SHIFT = bitpos,               \
+   CPUID_##vend##_ID##lvl##reg##_##name##_MASK  =                       \
+                      VMW_BIT_MASK(size) << bitpos,                     \
+   CPUID_FEATURE_##vend##_ID##lvl##reg##_##name =                       \
+                      CPUID_##vend##_ID##lvl##reg##_##name##_MASK,
+
+#define FLAGDEFA FIELDDEFA
+#define FLAGDEF FIELDDEF
+
+enum {
+   /* Define data for every CPUID field we have */
+   CPUID_FIELD_DATA
+};
+#undef VMW_BIT_MASK
+#undef FIELDDEF
+#undef FLAGDEF
+#undef FIELDDEFA
+#undef FLAGDEFA
+
+/*
+ * Legal CPUID config file mask characters.  For a description of the
+ * cpuid masking system, please see:
+ *
+ * http://vmweb.vmware.com/~mts/cgi-bin/view.cgi/Apps/CpuMigrationChecks
+ */
+
+#define CPUID_MASK_HIDE_CHR    '0'
+#define CPUID_MASK_HIDE_STR    "0"
+#define CPUID_MASK_FORCE_CHR   '1'
+#define CPUID_MASK_FORCE_STR   "1"
+#define CPUID_MASK_PASS_CHR    '-'
+#define CPUID_MASK_PASS_STR    "-"
+#define CPUID_MASK_TRUE_CHR    'T'
+#define CPUID_MASK_TRUE_STR    "T"
+#define CPUID_MASK_FALSE_CHR   'F'
+#define CPUID_MASK_FALSE_STR   "F"
+#define CPUID_MASK_IGNORE_CHR  'X'
+#define CPUID_MASK_IGNORE_STR  "X"
+#define CPUID_MASK_HOST_CHR    'H'
+#define CPUID_MASK_HOST_STR    "H"
+#define CPUID_MASK_RSVD_CHR    'R'
+#define CPUID_MASK_RSVD_STR    "R"
+#define CPUID_MASK_INSTALL_CHR 'I'
+#define CPUID_MASK_INSTALL_STR "I"
+
+/*
+ * If a level is listed as not masked/tested in CPUID_LEVELS above,
+ * use all "don't care" values for its mask.
+ */
+
+#define CPT_DFLT_UNDEFINED_MASK "XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX"
+
+/*
+ * When LM is disabled, we overlay the following masks onto the
+ * guest's default masks.  Any level that is not defined below should
+ * be treated as all "-"s
+ */
+
+#define CPT_ID1ECX_LM_DISABLED  "----:----:----:----:--0-:----:----:----"
+#define CPT_ID81EDX_LM_DISABLED "--0-:----:----:----:----:----:----:----"
+#define CPT_ID81ECX_LM_DISABLED "----:----:----:----:----:----:----:---0"
+
+#define CPT_GET_LM_DISABLED_MASK(lvl, reg)                                  \
+   ((lvl == 1 && reg == CPUID_REG_ECX) ? CPT_ID1ECX_LM_DISABLED :           \
+    (lvl == 0x80000001 && reg == CPUID_REG_ECX) ? CPT_ID81ECX_LM_DISABLED : \
+    (lvl == 0x80000001 && reg == CPUID_REG_EDX) ? CPT_ID81EDX_LM_DISABLED : \
+    NULL)
+
+/*
+ * Macro to define GET and SET functions for various common CPUID
+ * fields.  To create function for a new field, simply name it (CPUID_
+ * and CPUID_SET_ are automatically prepended), and list the field
+ * name that it needs to use.
+ */
+
+#define FIELD_FUNC(name, field)                                 \
+   static INLINE uint32 CPUID_##name(uint32 reg)                \
+   {                                                            \
+      return (reg & field##_MASK) >> field##_SHIFT;             \
+   }                                                            \
+   static INLINE void CPUID_SET_##name(uint32 *reg, uint32 val) \
+   {                                                            \
+      *reg = (*reg & ~field##_MASK) | (val << field##_SHIFT);   \
+   }
+
+FIELD_FUNC(STEPPING,         CPUID_COMMON_ID1EAX_STEPPING)
+FIELD_FUNC(MODEL,            CPUID_COMMON_ID1EAX_MODEL)
+FIELD_FUNC(FAMILY,           CPUID_COMMON_ID1EAX_FAMILY)
+FIELD_FUNC(TYPE,             CPUID_COMMON_ID1EAX_TYPE)
+FIELD_FUNC(EXTENDED_MODEL,   CPUID_COMMON_ID1EAX_EXTMODEL)
+FIELD_FUNC(EXTENDED_FAMILY,  CPUID_COMMON_ID1EAX_EXTFAMILY)
+FIELD_FUNC(LCPU_COUNT,       CPUID_COMMON_ID1EBX_LCPU_COUNT)
+FIELD_FUNC(APICID,           CPUID_COMMON_ID1EBX_APICID)
+FIELD_FUNC(PA_BITS,          CPUID_COMMON_ID88EAX_PHYSBITS)
+FIELD_FUNC(VIRT_BITS,        CPUID_COMMON_ID88EAX_VIRTBITS)
+FIELD_FUNC(SVM_REVISION,     CPUID_AMD_ID8AEAX_SVM_REVISION)
+FIELD_FUNC(SVM_N_ASIDS,      CPUID_AMD_ID8AEBX_SVM_N_ASIDS)
+FIELD_FUNC(INTEL_CORE_COUNT, CPUID_INTEL_ID4EAX_CORE_COUNT)
+FIELD_FUNC(AMD_CORE_COUNT,   CPUID_AMD_ID88ECX_CORE_COUNT)
+FIELD_FUNC(AMD_APICID_COREID_SIZE, CPUID_AMD_ID88ECX_APICID_COREID_SIZE)
+FIELD_FUNC(AMD_EXTAPICSPC,   CPUID_AMD_ID81ECX_EXTAPICSPC)
+FIELD_FUNC(NUM_PMCS,         CPUID_INTEL_IDAEAX_NUM_PMCS)
+FIELD_FUNC(MWAIT_MIN_SIZE,   CPUID_COMMON_ID5EAX_MWAIT_MIN_SIZE)
+FIELD_FUNC(MWAIT_MAX_SIZE,   CPUID_COMMON_ID5EBX_MWAIT_MAX_SIZE)
+FIELD_FUNC(MWAIT_C0_SUBSTATE, CPUID_INTEL_ID5EDX_MWAIT_C0_SUBSTATE)
+FIELD_FUNC(MWAIT_C1_SUBSTATE, CPUID_INTEL_ID5EDX_MWAIT_C1_SUBSTATE)
+FIELD_FUNC(MWAIT_C2_SUBSTATE, CPUID_INTEL_ID5EDX_MWAIT_C2_SUBSTATE)
+FIELD_FUNC(MWAIT_C3_SUBSTATE, CPUID_INTEL_ID5EDX_MWAIT_C3_SUBSTATE)
+FIELD_FUNC(MWAIT_C4_SUBSTATE, CPUID_INTEL_ID5EDX_MWAIT_C4_SUBSTATE)
+#undef FIELD_FUNC
+
+
+/*
+ * Definitions of various fields' values and more complicated
+ * macros/functions for reading cpuid fields.
+ */
+
+/* Effective Intel CPU Families */
+#define CPUID_FAMILY_486      4
+#define CPUID_FAMILY_P5       5
+#define CPUID_FAMILY_P6       6
+#define CPUID_FAMILY_P4       15
+
+/* Effective AMD CPU Families */
+#define CPUID_FAMILY_5x86     4
+#define CPUID_FAMILY_K5       5
+#define CPUID_FAMILY_K6       5
+#define CPUID_FAMILY_K7       6
+#define CPUID_FAMILY_K8       15
+#define CPUID_FAMILY_K8L      16
+#define CPUID_FAMILY_K8MOBILE 17
+#define CPUID_FAMILY_EXTENDED 15
+
+/* Intel model information */
+#define CPUID_MODEL_PPRO       1
+#define CPUID_MODEL_PII_03     3
+#define CPUID_MODEL_PII_05     5
+#define CPUID_MODEL_CELERON_06 6
+#define CPUID_MODEL_PM_09      9
+#define CPUID_MODEL_PM_0D      13
+#define CPUID_MODEL_PM_0E      14    // Yonah / Sossaman
+#define CPUID_MODEL_CORE_0F    15    // Conroe / Merom
+#define CPUID_MODEL_CORE_17    0x17  // Penryn
+#define CPUID_MODEL_NEHALEM_1A 0x1a  // Nehalem / Gainestown
+#define CPUID_MODEL_ATOM_1C    0x1c  // Silverthorne / Diamondville
+#define CPUID_MODEL_CORE_1D    0x1d  // Dunnington
+
+#define CPUID_MODEL_PIII_07    7
+#define CPUID_MODEL_PIII_08    8
+#define CPUID_MODEL_PIII_0A    10
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CPUID_IsVendor{AMD,Intel} --
+ *
+ *      Determines if the vendor string in cpuid id0 is from {AMD,Intel}.
+ *
+ * Results:
+ *      True iff vendor string is CPUID_{AMD,INTEL}_VENDOR_STRING
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------
+ */
+static INLINE Bool
+CPUID_IsRawVendor(CPUIDRegs *id0, const char* vendor)
+{
+   // hard to get strcmp() in some environments, so do it in the raw
+   return (id0->ebx == *(const uint32 *) (vendor + 0) &&
+           id0->ecx == *(const uint32 *) (vendor + 4) &&
+           id0->edx == *(const uint32 *) (vendor + 8));   
+}
+
+static INLINE Bool
+CPUID_IsVendorAMD(CPUIDRegs *id0)
+{
+   return CPUID_IsRawVendor(id0, CPUID_AMD_VENDOR_STRING);
+}
+
+static INLINE Bool
+CPUID_IsVendorIntel(CPUIDRegs *id0)
+{
+   return CPUID_IsRawVendor(id0, CPUID_INTEL_VENDOR_STRING);
+}
+
+
+static INLINE uint32
+CPUID_EFFECTIVE_FAMILY(uint32 v) /* %eax from CPUID with %eax=1. */
+{
+   return CPUID_FAMILY(v) +
+      (CPUID_FAMILY(v) == CPUID_FAMILY_EXTENDED ? CPUID_EXTENDED_FAMILY(v) : 0);
+}
+
+/* Normally only used when FAMILY==CPUID_FAMILY_EXTENDED, but Intel is
+ * now using the extended model field for FAMILY==CPUID_FAMILY_P6 to
+ * refer to the newer Core2 CPUs
+ */
+static INLINE uint32
+CPUID_EFFECTIVE_MODEL(uint32 v) /* %eax from CPUID with %eax=1. */
+{
+   return CPUID_MODEL(v) + (CPUID_EXTENDED_MODEL(v) << 4); 
+}
+
+/*
+ * Notice that CPUID families for Intel and AMD overlap. The following macros
+ * should only be used AFTER the manufacturer has been established (through
+ * the use of CPUID standard function 0).
+ */
+static INLINE Bool
+CPUID_FAMILY_IS_486(uint32 _eax)
+{
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_486;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_P5(uint32 _eax)
+{
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_P5;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_P6(uint32 _eax)
+{
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_P6;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_PENTIUM4(uint32 _eax)
+{
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_P4;
+}
+
+/*
+ * Intel Pentium M processors are Yonah/Sossaman or an older P-M
+ */
+static INLINE Bool
+CPUID_UARCH_IS_PENTIUM_M(uint32 v) // IN: %eax from CPUID with %eax=1.
+{
+   /* Assumes the CPU manufacturer is Intel. */
+   return CPUID_FAMILY_IS_P6(v) &&
+          (CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_PM_09 ||
+           CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_PM_0D ||
+           CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_PM_0E);
+}
+
+/*
+ * Intel Core processors are Merom, Conroe, Woodcrest, Clovertown,
+ * Penryn, Dunnington, Kentsfield, Yorktown, Harpertown, ........
+ */
+static INLINE Bool
+CPUID_UARCH_IS_CORE(uint32 v) // IN: %eax from CPUID with %eax=1.
+{
+   uint32 model = CPUID_EFFECTIVE_MODEL(v);
+   /* Assumes the CPU manufacturer is Intel. */
+   return CPUID_FAMILY_IS_P6(v) &&
+          model >= CPUID_MODEL_CORE_0F &&
+          (model < CPUID_MODEL_NEHALEM_1A ||
+           model == CPUID_MODEL_CORE_1D);
+}
+
+
+/*
+ * Intel Nehalem processors are: Nehalem, Gainestown.
+ */
+static INLINE Bool
+CPUID_UARCH_IS_NEHALEM(uint32 v) // IN: %eax from CPUID with %eax=1.
+{
+   /* Assumes the CPU manufacturer is Intel. */
+   return CPUID_FAMILY_IS_P6(v) &&
+          CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_NEHALEM_1A;
+}
+
+
+static INLINE Bool
+CPUID_FAMILY_IS_K7(uint32 _eax)
+{
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_K7;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_K8(uint32 _eax)
+{
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_K8;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_K8EXT(uint32 _eax)
+{
+   /*
+    * We check for this pattern often enough that it's
+    * worth a separate function, for syntactic sugar.
+    */
+   return CPUID_FAMILY_IS_K8(_eax) &&
+          CPUID_EXTENDED_MODEL(_eax) != 0;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_K8L(uint32 _eax)
+{
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_K8L;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_K8MOBILE(uint32 _eax)
+{
+   /* Essentially a K8 (not K8L) part, but with mobile features. */
+   return CPUID_EFFECTIVE_FAMILY(_eax) == CPUID_FAMILY_K8MOBILE;
+}
+
+static INLINE Bool
+CPUID_FAMILY_IS_K8STAR(uint32 _eax)
+{
+   /*
+    * Read function name as "K8*", as in wildcard.
+    * Matches K8 or K8L or K8MOBILE
+    */
+   return CPUID_FAMILY_IS_K8(_eax) || CPUID_FAMILY_IS_K8L(_eax) ||
+          CPUID_FAMILY_IS_K8MOBILE(_eax);
+}
+
+
+#define CPUID_TYPE_PRIMARY     0
+#define CPUID_TYPE_OVERDRIVE   1
+#define CPUID_TYPE_SECONDARY   2
+
+#define CPUID_INTEL_ID4EAX_CACHE_TYPE_NULL      0
+#define CPUID_INTEL_ID4EAX_CACHE_TYPE_DATA      1
+#define CPUID_INTEL_ID4EAX_CACHE_TYPE_INST      2
+#define CPUID_INTEL_ID4EAX_CACHE_TYPE_UNIF      3
+
+#define CPUID_INTEL_ID4EAX_CACHE_SELF_INIT      0x00000100
+#define CPUID_INTEL_ID4EAX_CACHE_FULLY_ASSOC    0x00000200
+
+
+/*
+ * On AMD chips before Opteron and Intel chips before P4 model 3,
+ * WRMSR(TSC) clears the upper half of the TSC instead of using %edx.
+ */
+static INLINE Bool
+CPUID_FullyWritableTSC(Bool isIntel, // IN
+                       uint32 v)     // IN: %eax from CPUID with %eax=1.
+{
+   /*
+    * Returns FALSE if:
+    *   - Intel && P6 (pre-core) or
+    *   - Intel && P4 (model < 3) or
+    *   - !Intel && pre-K8 Opteron
+    * Otherwise, returns TRUE.
+    */
+   return !((isIntel &&
+             ((CPUID_FAMILY_IS_P6(v) &&
+               CPUID_EFFECTIVE_MODEL(v) < CPUID_MODEL_PM_0E) ||
+              (CPUID_FAMILY_IS_PENTIUM4(v) &&
+               CPUID_EFFECTIVE_MODEL(v) < 3))) ||
+            (!isIntel &&
+             CPUID_FAMILY(v) < CPUID_FAMILY_K8));
+}
+
+
+/*
+ * For certain AMD processors, an lfence instruction is necessary at various
+ * places to ensure ordering.
+ */
+
+static INLINE Bool
+CPUID_VendorRequiresFence(CpuidVendors vendor)
+{
+   return vendor == CPUID_VENDOR_AMD;
+}
+
+static INLINE Bool
+CPUID_VersionRequiresFence(uint32 version)
+{
+   return CPUID_EFFECTIVE_FAMILY(version) == CPUID_FAMILY_K8 &&
+          CPUID_EFFECTIVE_MODEL(version) < 0x40;
+}
+
+static INLINE Bool
+CPUID_ID0RequiresFence(CPUIDRegs *id0)
+{
+   if (id0->eax == 0) {
+      return FALSE;
+   }
+   return CPUID_IsVendorAMD(id0);
+}
+
+static INLINE Bool
+CPUID_ID1RequiresFence(CPUIDRegs *id1)
+{
+   return CPUID_VersionRequiresFence(id1->eax);
+}
+
+static INLINE Bool
+CPUID_RequiresFence(CpuidVendors vendor, // IN
+                    uint32 version)      // IN: %eax from CPUID with %eax=1.
+{
+   return CPUID_VendorRequiresFence(vendor) &&
+         CPUID_VersionRequiresFence(version);
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CPUID_CountsCPUIDAsBranch --
+ *
+ *      Returns TRUE iff the cpuid given counts CPUID as a branch
+ *      (i.e. is a pre-Merom E CPU).
+ *
+ *----------------------------------------------------------------------
+ */
+
+static INLINE Bool
+CPUID_CountsCPUIDAsBranch(uint32 v) /* %eax from CPUID with %eax=1 */
+{
+   /* 
+    * CPUID no longer a branch starting with Merom E. Bug 148411.
+    * Penryn (Extended Model: 1) also has this fixed.
+    *
+    * Merom E is: CPUID.1.eax & 0xfff = 0x6f9
+    */
+   return !(CPUID_FAMILY_IS_P6(v) &&
+            (CPUID_EFFECTIVE_MODEL(v) > CPUID_MODEL_CORE_0F ||
+             (CPUID_EFFECTIVE_MODEL(v) == CPUID_MODEL_CORE_0F &&
+              CPUID_STEPPING(v) >= 9)));
+}
+
+/*
+ * On Merom and later Intel chips, not present PDPTEs with reserved bits
+ * set do not fault with a #GP. See PR# 109120.
+ */
+static INLINE Bool
+CPUID_FaultOnNPReservedPDPTE(uint32 v) // IN: %eax from CPUID with %eax=1.
+{
+   return !(CPUID_FAMILY_IS_P6(v) &&
+            (CPUID_EFFECTIVE_MODEL(v) >= CPUID_MODEL_CORE_0F));
+}
+
+
+/* 
+ * The following low-level functions compute the number of
+ * cores per cpu.  They should be used cautiously because
+ * they do not necessarily work on all types of CPUs.
+ * High-level functions that are correct for all CPUs are
+ * available elsewhere: see lib/cpuidInfo/cpuidInfo.c.
+ */
+
+static INLINE uint32
+CPUID_IntelCoresPerPackage(uint32 v) /* %eax from CPUID with %eax=4 and %ecx=0. */
+{
+   // Note: This is not guaranteed to work on older Intel CPUs.
+   return 1 + CPUID_INTEL_CORE_COUNT(v);
+}
+
+static INLINE uint32
+CPUID_AMDCoresPerPackage(uint32 v) /* %ecx from CPUID with %eax=0x80000008. */
+{
+   // Note: This is not guaranteed to work on older AMD CPUs.
+   return 1 + CPUID_AMD_CORE_COUNT(v);
+}
+
+/*
+ * Hypervisor CPUID space is 0x400000XX.
+ */
+static INLINE Bool
+CPUID_IsHypervisorLevel(uint32 level, uint32 *offset)
+{
+   *offset = level & 0xff;
+   return (level & 0xffffff00) == 0x40000000;
+}
+
+
+#endif
index 8dda1a585656931d0c76ad906c46fc28da05b764..2b5c1ad62e5ba1ce9b3ca87b14a8022d31c7f6c6 100644 (file)
@@ -132,6 +132,7 @@ sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
 #endif
 
 #include "vmware.h"
+#include "vm_basic_math.h"
 
 #include "vsockCommon.h"
 #include "vsockPacket.h"
@@ -440,10 +441,19 @@ static VMCIId qpResumedSubId = VMCI_INVALID_ID;
 #  define VSOCK_OPTIMIZATION_FLOW_CONTROL 1
 #endif
 
-/* Comment this out to turn off datagram counting. */
-//#define VSOCK_CONTROL_PACKET_COUNT 1
-#ifdef VSOCK_CONTROL_PACKET_COUNT
+/*
+ * Define VSOCK_GATHER_STATISTICS to turn on statistics gathering.
+ * Currently this consists of 2 types of stats:
+ * 1. The number of control datagram messages sent.
+ * 2. The level of queuepair fullness (in 10% buckets) whenever data is
+ *    about to be enqueued or dequeued from the queuepair.
+ */
+//#define VSOCK_GATHER_STATISTICS 1
+#ifdef VSOCK_GATHER_STATISTICS
+#define VSOCK_NUM_QUEUE_LEVEL_BUCKETS 10
 uint64 controlPacketCount[VSOCK_PACKET_TYPE_MAX];
+uint64 consumeQueueLevel[VSOCK_NUM_QUEUE_LEVEL_BUCKETS];
+uint64 produceQueueLevel[VSOCK_NUM_QUEUE_LEVEL_BUCKETS];
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 9)
@@ -550,6 +560,11 @@ VSockVmci_GetAFValue(void)
 }
 
 
+/*
+ * Helper functions.
+ */
+
+
 /*
  *----------------------------------------------------------------------------
  *
@@ -578,11 +593,47 @@ VSockVmciTestUnregister(void)
    }
 }
 
-
+#ifdef VSOCK_GATHER_STATISTICS
 /*
- * Helper functions.
+ *----------------------------------------------------------------------------
+ *
+ * VSockVmciUpdateQueueBucketCount --
+ *
+ *      Given a queue, determine how much data is enqueued and add that to
+ *      the specified queue level statistic bucket.
+ *
+ * Results:
+ *      None.
+ *
+ * Side effects:
+ *      None.
+ *
+ *----------------------------------------------------------------------------
  */
 
+static inline void
+VSockVmciUpdateQueueBucketCount(VMCIQueue *mainQueue,  // IN
+                                VMCIQueue *otherQueue, // IN
+                               uint64 mainQueueSize,  // IN
+                                uint64 queueLevel[])   // IN
+{
+   uint64 bucket = 0;
+   uint32 remainder = 0;
+   uint64 dataReady = VMCIQueue_BufReady(mainQueue,
+                                        otherQueue,
+                                        mainQueueSize);
+   /*
+    * We can't do 64 / 64 = 64 bit divides on linux because it requires a libgcc
+    * which is not linked into the kernel module. Since this code is only used by
+    * developers we just limit the mainQueueSize to be less than MAX_UINT for now.
+    */
+   ASSERT(mainQueueSize <= MAX_UINT32);
+   Div643264(dataReady * 10, mainQueueSize, &bucket, &remainder);
+   ASSERT(bucket < VSOCK_NUM_QUEUE_LEVEL_BUCKETS);
+   ++queueLevel[bucket];
+}
+#endif
+
 
 #ifdef VMX86_TOOLS
 /*
@@ -2157,7 +2208,7 @@ VSockVmciSendControlPktBH(struct sockaddr_vm *src,      // IN
    VSockPacket_Init(&pkt, src, dst, type, size, mode, wait, handle);
 
    LOG_PACKET(&pkt);
-#ifdef VSOCK_CONTROL_PACKET_COUNT
+#ifdef VSOCK_GATHER_STATISTICS
    controlPacketCount[pkt.type]++;
 #endif
    return VMCIDatagram_Send(&pkt.dg);
@@ -2226,7 +2277,7 @@ VSockVmciSendControlPkt(struct sock *sk,        // IN
       return VSockVmci_ErrorToVSockError(err);
    }
 
-#ifdef VSOCK_CONTROL_PACKET_COUNT
+#ifdef VSOCK_GATHER_STATISTICS
    controlPacketCount[pkt->type]++;
 #endif
 
@@ -2857,13 +2908,24 @@ VSockVmciSkDestruct(struct sock *sk) // IN
    VSockVmciTestUnregister();
    up(&registrationMutex);
 
-#ifdef VSOCK_CONTROL_PACKET_COUNT
+#ifdef VSOCK_GATHER_STATISTICS
    {
       uint32 index;
       for (index = 0; index < ARRAYSIZE(controlPacketCount); index++) {
          Warning("Control packet count: Type = %u, Count = %"FMT64"u\n",
                  index, controlPacketCount[index]);
       }
+
+      for (index = 0; index < ARRAYSIZE(consumeQueueLevel); index++) {
+         Warning("Consume Bucket: %u Count: %"FMT64"u\n",
+                 index, consumeQueueLevel[index]);
+      }
+
+      for (index = 0; index < ARRAYSIZE(produceQueueLevel); index++) {
+         Warning("Produce Bucket: %u Count: %"FMT64"u\n",
+                 index, produceQueueLevel[index]);
+      }
+
    }
 #endif
 }
@@ -2984,12 +3046,21 @@ VSockVmciUnregisterProto(void)
    proto_unregister(&vsockVmciProto);
 #endif
 
-#ifdef VSOCK_CONTROL_PACKET_COUNT
+#ifdef VSOCK_GATHER_STATISTICS
    {
       uint32 index;
       for (index = 0; index < ARRAYSIZE(controlPacketCount); index++) {
          controlPacketCount[index] = 0;
       }
+
+      for (index = 0; index < ARRAYSIZE(consumeQueueLevel); index++) {
+        consumeQueueLevel[index] = 0;
+      }
+
+      for (index = 0; index < ARRAYSIZE(produceQueueLevel); index++) {
+        produceQueueLevel[index] = 0;
+      }
+
    }
 #endif
 }
@@ -4315,6 +4386,13 @@ VSockVmciStreamSendmsg(struct kiocb *kiocb,          // UNUSED
          goto outWait;
       }
 
+#if defined(VSOCK_GATHER_STATISTICS)
+      VSockVmciUpdateQueueBucketCount(vsk->produceQ,
+                                     vsk->consumeQ,
+                                     vsk->produceSize,
+                                     produceQueueLevel);
+#endif
+
       /*
        * Note that enqueue will only write as many bytes as are free in the
        * produce queue, so we don't need to ensure len is smaller than the queue
@@ -4707,6 +4785,13 @@ VSockVmciStreamRecvmsg(struct kiocb *kiocb,          // UNUSED
       err = 0;
       goto outWait;
    }
+#if defined(VSOCK_GATHER_STATISTICS)
+   VSockVmciUpdateQueueBucketCount(vsk->consumeQ,
+                                  vsk->produceQ,
+                                  vsk->consumeSize,
+                                  consumeQueueLevel);
+#endif
+
 
    /*
     * Now consume up to len bytes from the queue.  Note that since we have the
index 9026e819983bdb9d8d27a18de501abe566472656..c70d92d149da3f08b173c7e807e2cb4fb30e355b 100644 (file)
 ################################################################################
 
 COMMON =
-COMMON += ../lib/conf/libConf.a
-COMMON += ../lib/eventManager/libEventManager.a
-COMMON += ../lib/file/libFile.a
-COMMON += ../lib/hgfs/libHgfs.a
-COMMON += ../lib/procMgr/libProcMgr.a
-COMMON += ../lib/rpcIn/libRpcIn.a
-COMMON += ../lib/rpcOut/libRpcOut.a
-COMMON += ../lib/string/libString.a
-COMMON += ../lib/system/libSystem.a
-COMMON += ../lib/user/libUser.a
-COMMON += ../lib/vmCheck/libVmCheck.a
-COMMON += ../lib/vmSignal/libVmSignal.a
-COMMON += ../lib/wiper/libWiper.a
+COMMON += ../lib/conf/libConf.la
+COMMON += ../lib/eventManager/libEventManager.la
+COMMON += ../lib/file/libFile.la
+COMMON += ../lib/hgfs/libHgfs.la
+COMMON += ../lib/procMgr/libProcMgr.la
+COMMON += ../lib/rpcIn/libRpcIn.la
+COMMON += ../lib/rpcOut/libRpcOut.la
+COMMON += ../lib/string/libString.la
+COMMON += ../lib/system/libSystem.la
+COMMON += ../lib/user/libUser.la
+COMMON += ../lib/vmCheck/libVmCheck.la
+COMMON += ../lib/vmSignal/libVmSignal.la
+COMMON += ../lib/wiper/libWiper.la
 # In the absence of the linker options --start-group and --end-group (which
 # can't be put in LDADD), we need to bring the following libraries out of
 # the alphabetical order so their symbols are properly resolved.
-COMMON += ../lib/err/libErr.a
-COMMON += ../lib/backdoor/libBackdoor.a
-COMMON += ../lib/dict/libDict.a
-COMMON += ../lib/message/libMessage.a
-COMMON += ../lib/unicode/libUnicode.a
-COMMON += ../lib/sync/libSync.a
-COMMON += ../lib/misc/libMisc.a
-COMMON += ../lib/panicDefault/libPanicDefault.a
-COMMON += ../lib/panic/libPanic.a
-COMMON += ../lib/stubs/libStubs.a
+COMMON += ../lib/err/libErr.la
+COMMON += ../lib/backdoor/libBackdoor.la
+COMMON += ../lib/dict/libDict.la
+COMMON += ../lib/message/libMessage.la
+COMMON += ../lib/unicode/libUnicode.la
+COMMON += ../lib/sync/libSync.la
+COMMON += ../lib/misc/libMisc.la
+COMMON += ../lib/panicDefault/libPanicDefault.la
+COMMON += ../lib/panic/libPanic.la
+COMMON += ../lib/stubs/libStubs.la
 
 bin_PROGRAMS =
 if HAVE_X11
@@ -49,7 +49,7 @@ if HAVE_X11
 
    AM_CFLAGS = @GTK_CPPFLAGS@
    vmware_toolbox_LDADD =
-   vmware_toolbox_LDADD += ../lib/guestApp/libGuestAppX11.a
+   vmware_toolbox_LDADD += ../lib/guestApp/libGuestAppX11.la
    vmware_toolbox_LDADD += $(COMMON)
 
    vmware_toolbox_LDADD += @COMMON_XLIBS@
@@ -91,23 +91,25 @@ endif
        -$(RM) -rf $(DESTDIR)/usr/share/pixmaps/vmware
 endif
 
-bin_PROGRAMS += vmware-toolbox-cmd
+if ENABLE_CORE_SERVICES
+   bin_PROGRAMS += vmware-toolbox-cmd
 
-vmware_toolbox_cmd_LDADD =
-vmware_toolbox_cmd_LDADD += ../libguestlib/libguestlib.la
-vmware_toolbox_cmd_LDADD += ../lib/guestInfo/libGuestInfo.a
-vmware_toolbox_cmd_LDADD += ../lib/guestApp/libGuestApp.a
-vmware_toolbox_cmd_LDADD += $(COMMON)
+   vmware_toolbox_cmd_LDADD =
+   vmware_toolbox_cmd_LDADD += ../libguestlib/libguestlib.la
+   vmware_toolbox_cmd_LDADD += @VMTOOLS_LIBS@
 
-vmware_toolbox_cmd_SOURCES =
-vmware_toolbox_cmd_SOURCES += debugStdio.c
-vmware_toolbox_cmd_SOURCES += toolbox-cmd.c
-vmware_toolbox_cmd_SOURCES += toolboxcmd-devices.c
-vmware_toolbox_cmd_SOURCES += toolboxcmd-scripts.c
-vmware_toolbox_cmd_SOURCES += toolboxcmd-shrink.c
-vmware_toolbox_cmd_SOURCES += toolboxcmd-stat.c
-vmware_toolbox_cmd_SOURCES += toolboxcmd-time.c
-vmware_toolbox_cmd_SOURCES += toolboxcmd-record.c
+   vmware_toolbox_cmd_CPPFLAGS =
+   vmware_toolbox_cmd_CPPFLAGS += @VMTOOLS_CPPFLAGS@
+
+   vmware_toolbox_cmd_SOURCES =
+   vmware_toolbox_cmd_SOURCES += debugStdio.c
+   vmware_toolbox_cmd_SOURCES += toolbox-cmd.c
+   vmware_toolbox_cmd_SOURCES += toolboxcmd-devices.c
+   vmware_toolbox_cmd_SOURCES += toolboxcmd-scripts.c
+   vmware_toolbox_cmd_SOURCES += toolboxcmd-shrink.c
+   vmware_toolbox_cmd_SOURCES += toolboxcmd-stat.c
+   vmware_toolbox_cmd_SOURCES += toolboxcmd-time.c
+   vmware_toolbox_cmd_SOURCES += toolboxcmd-record.c
 
 if HAVE_ICU
    vmware_toolbox_cmd_LDADD += @ICU_LIBS@
@@ -118,3 +120,6 @@ if HAVE_ICU
 else
    vmware_toolbox_cmd_LINK = $(LINK)
 endif
+
+endif
+
index e3d6dd90aa3eda94b9dfaab490dacffb69c8b38b..8f1659e76a8a9574aef9c8e61e726c0807d0dcc1 100644 (file)
@@ -75,11 +75,12 @@ static const char **gNativeEnviron;
 
 /* Help pages. These need to be in the same order as the tabs in the UI. */
 static const char *gHelpPages[] = {
-   "index.html",
+   "index.htm",
    "tools_options.htm",
    "tools_devices.htm",
    "tools_scripts.htm",
    "tools_shrink.htm",
+   NULL,                        // Record/Replay
    "tools_about.htm",
 };
 
@@ -215,9 +216,14 @@ ToolsMain_OpenHelp(const char *help) // IN
       return;
    }
 
-   if (help == NULL) {
-      ToolsMain_MsgBox("Error", "No help was found for the page.");
-      return;
+   Str_Snprintf(helpPage, sizeof helpPage, "file:%s/%s", hlpDir, help);
+
+   {
+      const gchar *localPath = &helpPage[sizeof "file:" - 1];
+      if (help == NULL || !g_file_test(localPath, G_FILE_TEST_IS_REGULAR)) {
+         ToolsMain_MsgBox("Error", "No Help page was found for this tab.");
+         return;
+      }
    }
 
    Str_Snprintf(helpPage, sizeof helpPage, "file:%s/%s", hlpDir, help);
@@ -586,6 +592,11 @@ ToolsMain_Create(void)
    }
    free(result);
 
+   /**
+    * @note If adding or removing tabs to the notebook, make sure to update
+    *       @ref gHelpPages.  The indices between these tabs directly correspond
+    *       to that variable's list of pages.
+    */
 #ifdef GTK2
    gtk_notebook_append_page(GTK_NOTEBOOK(notebookMain), Scripts_Create(ToolsMain),
                             gtk_label_new_with_mnemonic(TAB_LABEL_SCRIPTS));
index d9d37b062cd87612071682287949b3b16fcdbaaa..45a3d7bedf14b549a98fe8caa842d66dbed953b3 100644 (file)
@@ -29,9 +29,7 @@
 #include <sys/stat.h>
 #if defined(__FreeBSD__)
 #include <sys/param.h>
-#if __FreeBSD_version >= 530000
-#include <syslimits.h>
-#endif
+#include <sys/syslimits.h>
 #endif
 
 #include "toolboxGtkInt.h"
index e556477a3de4643963767f2bcf766d2664c2b83a..6d3930b5c6ceb4329d0718f9151af7cabbd87538 100644 (file)
@@ -450,7 +450,7 @@ StartVMwareUser(char *const envp[])
          Error("could not parse file descriptor (%d)\n", fd);
          argv[1] = NULL;
       } else {
-         argv[1] = "-blockFd";
+         argv[1] = "--blockFd";
          argv[2] = fdStr;
          argv[3] = NULL;
       }
index 1cd0a8429a61ec4dd4e269e76830ac62c52d2e85..e2ef67b3185676c55471a35a4d5cd98e5b0e1ae3 100644 (file)
@@ -24,67 +24,67 @@ AM_CFLAGS += -I$(top_builddir)/include
 AM_CFLAGS += -DRESOLUTION_X11
 
 vmware_user_LDADD =
-vmware_user_LDADD += ../lib/conf/libConf.a
-vmware_user_LDADD += ../lib/dnd/libDnd.a
-vmware_user_LDADD += ../lib/eventManager/libEventManager.a
-vmware_user_LDADD += ../lib/file/libFile.a
+vmware_user_LDADD += ../lib/conf/libConf.la
+vmware_user_LDADD += ../lib/dnd/libDnd.la
+vmware_user_LDADD += ../lib/eventManager/libEventManager.la
+vmware_user_LDADD += ../lib/file/libFile.la
 if ENABLE_UNITY
-   vmware_user_LDADD += ../lib/ghIntegration/libGhIntegration.a
+   vmware_user_LDADD += ../lib/ghIntegration/libGhIntegration.la
 else
-   vmware_user_LDADD += ../lib/ghIntegrationStub/libGhIntegrationStub.a
+   vmware_user_LDADD += ../lib/ghIntegrationStub/libGhIntegrationStub.la
 endif
-vmware_user_LDADD += ../lib/guestApp/libGuestAppX11.a
-vmware_user_LDADD += ../lib/guestInfo/libGuestInfo.a
-vmware_user_LDADD += ../lib/hgfsServer/libHgfsServer.a
-vmware_user_LDADD += ../lib/hgfsServerManagerGuest/libHgfsServerManagerGuest.a
-vmware_user_LDADD += ../lib/hgfsServerPolicyGuest/libHgfsServerPolicyGuest.a
-vmware_user_LDADD += ../lib/impersonate/libImpersonate.a
-vmware_user_LDADD += ../lib/netUtil/libNetUtil.a
-vmware_user_LDADD += ../lib/printer/libPrinter.a
-vmware_user_LDADD += ../lib/resolution/libResolution.a
-vmware_user_LDADD += ../lib/rpcIn/libRpcIn.a
-vmware_user_LDADD += ../lib/rpcOut/libRpcOut.a
-vmware_user_LDADD += ../lib/rpcVmx/libRpcVmx.a
-vmware_user_LDADD += ../lib/SLPv2Parser/libSLPv2Parser.a
-vmware_user_LDADD += ../lib/socketMgr/libSocketMgr.a
-vmware_user_LDADD += ../lib/string/libString.a
-vmware_user_LDADD += ../lib/sync/libSync.a
-vmware_user_LDADD += ../lib/syncDriver/libSyncDriver.a
-vmware_user_LDADD += ../lib/system/libSystem.a
+vmware_user_LDADD += ../lib/guestApp/libGuestAppX11.la
+vmware_user_LDADD += ../lib/guestInfo/libGuestInfo.la
+vmware_user_LDADD += ../lib/hgfsServer/libHgfsServer.la
+vmware_user_LDADD += ../lib/hgfsServerManagerGuest/libHgfsServerManagerGuest.la
+vmware_user_LDADD += ../lib/hgfsServerPolicyGuest/libHgfsServerPolicyGuest.la
+vmware_user_LDADD += ../lib/impersonate/libImpersonate.la
+vmware_user_LDADD += ../lib/netUtil/libNetUtil.la
+vmware_user_LDADD += ../lib/printer/libPrinter.la
+vmware_user_LDADD += ../lib/resolution/libResolution.la
+vmware_user_LDADD += ../lib/rpcIn/libRpcIn.la
+vmware_user_LDADD += ../lib/rpcOut/libRpcOut.la
+vmware_user_LDADD += ../lib/rpcVmx/libRpcVmx.la
+vmware_user_LDADD += ../lib/SLPv2Parser/libSLPv2Parser.la
+vmware_user_LDADD += ../lib/socketMgr/libSocketMgr.la
+vmware_user_LDADD += ../lib/string/libString.la
+vmware_user_LDADD += ../lib/sync/libSync.la
+vmware_user_LDADD += ../lib/syncDriver/libSyncDriver.la
+vmware_user_LDADD += ../lib/system/libSystem.la
 if ENABLE_UNITY
-   vmware_user_LDADD += ../lib/unity/libUnity.a
-   vmware_user_LDADD += ../lib/unityWindowTracker/libUnityWindowTracker.a
+   vmware_user_LDADD += ../lib/unity/libUnity.la
+   vmware_user_LDADD += ../lib/unityWindowTracker/libUnityWindowTracker.la
 else
-   vmware_user_LDADD += ../lib/unityStub/libUnityStub.a
+   vmware_user_LDADD += ../lib/unityStub/libUnityStub.la
 endif
-vmware_user_LDADD += ../lib/guestRpc/libGuestRpc.a
-vmware_user_LDADD += ../lib/user/libUser.a
-vmware_user_LDADD += ../lib/vixTools/libVixTools.a
-vmware_user_LDADD += ../lib/vmCheck/libVmCheck.a
-vmware_user_LDADD += ../lib/vmSignal/libVmSignal.a
-vmware_user_LDADD += ../lib/wiper/libWiper.a
+vmware_user_LDADD += ../lib/guestRpc/libGuestRpc.la
+vmware_user_LDADD += ../lib/user/libUser.la
+vmware_user_LDADD += ../lib/vixTools/libVixTools.la
+vmware_user_LDADD += ../lib/vmCheck/libVmCheck.la
+vmware_user_LDADD += ../lib/vmSignal/libVmSignal.la
+vmware_user_LDADD += ../lib/wiper/libWiper.la
 # In the absence of the linker options --start-group and --end-group (which
 # can't be put in LDADD), we need to bring the following libraries out of
 # the alphabetical order so their symbols are properly resolved.
-vmware_user_LDADD += ../lib/err/libErr.a
-vmware_user_LDADD += ../lib/foundryMsg/libFoundryMsg.a
-vmware_user_LDADD += ../lib/backdoor/libBackdoor.a
-vmware_user_LDADD += ../lib/dict/libDict.a
-vmware_user_LDADD += ../lib/dynxdr/libDynxdr.a
-vmware_user_LDADD += ../lib/hgfs/libHgfs.a
-vmware_user_LDADD += ../lib/message/libMessage.a
-vmware_user_LDADD += ../lib/unicode/libUnicode.a
-vmware_user_LDADD += ../lib/misc/libMisc.a
-vmware_user_LDADD += ../lib/procMgr/libProcMgr.a
-vmware_user_LDADD += ../lib/auth/libAuth.a
-vmware_user_LDADD += ../lib/panicDefault/libPanicDefault.a
-vmware_user_LDADD += ../lib/panic/libPanic.a
-vmware_user_LDADD += ../lib/stubs/libStubs.a
+vmware_user_LDADD += ../lib/err/libErr.la
+vmware_user_LDADD += ../lib/foundryMsg/libFoundryMsg.la
+vmware_user_LDADD += ../lib/backdoor/libBackdoor.la
+vmware_user_LDADD += ../lib/dict/libDict.la
+vmware_user_LDADD += ../lib/dynxdr/libDynxdr.la
+vmware_user_LDADD += ../lib/hgfs/libHgfs.la
+vmware_user_LDADD += ../lib/message/libMessage.la
+vmware_user_LDADD += ../lib/unicode/libUnicode.la
+vmware_user_LDADD += ../lib/misc/libMisc.la
+vmware_user_LDADD += ../lib/procMgr/libProcMgr.la
+vmware_user_LDADD += ../lib/auth/libAuth.la
+vmware_user_LDADD += ../lib/panicDefault/libPanicDefault.la
+vmware_user_LDADD += ../lib/panic/libPanic.la
+vmware_user_LDADD += ../lib/stubs/libStubs.la
 if ENABLE_UNITY
-   vmware_user_LDADD += ../lib/appUtil/libAppUtil.a
-   vmware_user_LDADD += ../lib/image/libImage.a
-   vmware_user_LDADD += ../lib/raster/libRaster.a
-   vmware_user_LDADD += ../lib/region/libRegion.a
+   vmware_user_LDADD += ../lib/appUtil/libAppUtil.la
+   vmware_user_LDADD += ../lib/image/libImage.la
+   vmware_user_LDADD += ../lib/raster/libRaster.la
+   vmware_user_LDADD += ../lib/region/libRegion.la
 endif
 vmware_user_LDADD += -lcrypt
 vmware_user_LDADD += @GTK_LIBS@
index d23e03beaa7061db10077daadba5c5e8a954b3b1..926a85f3a41db8131a68ca2030b5e41be1bd6479 100644 (file)
@@ -328,9 +328,10 @@ DnDRpcInEnterCB(char const **result,     // OUT
    unsigned int index = 0;
    int nFormats;
    int i;
+   GtkWidget *mainWnd;
 
    Debug("Got DnDRpcInEnterCB\n");
-   GtkWidget *mainWnd = GTK_WIDGET(clientData);
+   mainWnd = GTK_WIDGET(clientData);
    if (mainWnd == NULL) {
       return RpcIn_SetRetVals(result, resultLen,
                               "bad clientData passed to callback", FALSE);
@@ -2435,9 +2436,10 @@ Bool
 DnD_Register(GtkWidget *hgWnd, // IN: The widget to register as a drag source.
              GtkWidget *ghWnd) // IN: The widget to register as a drag target.
 {
-   gDragCtx = NULL;
    uint32 i;
 
+   gDragCtx = NULL;
+
    ASSERT(hgWnd);
    ASSERT(ghWnd);
 
index 0178f982b08a53e29da71fb595b0f84f10973a62..68c48506d98b00bf49fab600bac74f1e185cab39 100644 (file)
@@ -177,6 +177,10 @@ GetMenu(void)
 Bool
 Modules_Init(void)
 {
+   const char *libdir;
+   char *moduleListPath;
+   GList *modules, *modulesNotInstalled;
+
    if (!InstallerDB_Init("/etc/vmware-tools", TRUE)) {
       return FALSE;
    }
@@ -194,10 +198,10 @@ Modules_Init(void)
       return FALSE;
    }
 
-   const char *libdir = InstallerDB_GetLibDir();
-   char *moduleListPath = g_build_filename(libdir, "modules/modules.xml", NULL);
-   GList *modules = ModConf_GetModulesList(moduleListPath);
-   GList *modulesNotInstalled = ModConf_GetModulesNotInstalled(modules);
+   libdir = InstallerDB_GetLibDir();
+   moduleListPath = g_build_filename(libdir, "modules/modules.xml", NULL);
+   modules = ModConf_GetModulesList(moduleListPath);
+   modulesNotInstalled = ModConf_GetModulesNotInstalled(modules);
 
    if (modulesNotInstalled != NULL) {
       Notify_Notify(30, "Kernel modules out-of-date",
index 9800d02d90765f9365965852c9563d18706a4f97..095e68f51e45417c385ef58a41054766869b930b 100644 (file)
@@ -100,31 +100,33 @@ LoadLibNotify(void)
     * define them above, with file-level scope, and then add them to this
     * list.
     */
-   struct FuncEntry
    {
-      void **funcPtr;
-      const char *symName;
-   } vtable[] = {
-      { (void **) &notify_init, "notify_init" },
-      { (void **) &notify_uninit, "notify_uninit" },
-      { (void **) &notify_notification_show, "notify_notification_show" },
-      { (void **) &notify_notification_new_with_status_icon,
-         "notify_notification_new_with_status_icon" },
-      { (void **) &notify_notification_set_timeout,
-         "notify_notification_set_timeout" },
-      { NULL, NULL }
-   };
-
-   /*
-    * Load each of the above symbols from libnotify, checking to make sure
-    * that they exist.
-    */
-   for (i = 0; vtable[i].funcPtr != NULL; i++) {
-      *(vtable[i].funcPtr) = dlsym(libNotifyHandle, vtable[i].symName);
-      if ( *(vtable[i].funcPtr) == NULL) {
-         Debug("Could not find %s in libnotify\n", vtable[i].symName);
-         UnloadLibNotify();
-         return FALSE;
+      struct FuncEntry
+      {
+         void **funcPtr;
+         const char *symName;
+      } vtable[] = {
+         { (void **) &notify_init, "notify_init" },
+         { (void **) &notify_uninit, "notify_uninit" },
+         { (void **) &notify_notification_show, "notify_notification_show" },
+         { (void **) &notify_notification_new_with_status_icon,
+           "notify_notification_new_with_status_icon" },
+         { (void **) &notify_notification_set_timeout,
+           "notify_notification_set_timeout" },
+         { NULL, NULL }
+      };
+
+      /*
+       * Load each of the above symbols from libnotify, checking to make sure
+       * that they exist.
+       */
+      for (i = 0; vtable[i].funcPtr != NULL; i++) {
+         *(vtable[i].funcPtr) = dlsym(libNotifyHandle, vtable[i].symName);
+         if ( *(vtable[i].funcPtr) == NULL) {
+            Debug("Could not find %s in libnotify\n", vtable[i].symName);
+            UnloadLibNotify();
+            return FALSE;
+         }
       }
    }
 
@@ -275,12 +277,13 @@ Notify_Notify(int secs,                  // IN: Number of seconds to display
                                          // IN: The left-click callback
 {
    char *iconPath;
+   Notifier *n;
 
    if (!initialized) {
       return FALSE;
    }
 
-   Notifier *n = g_new0(Notifier, 1);
+   n = g_new0(Notifier, 1);
    iconPath = Str_Asprintf(NULL, "%s/share/icons/vmware.png", vmLibDir);
    n->statusIcon = gtk_status_icon_new_from_file(iconPath);
    gtk_status_icon_set_tooltip(n->statusIcon, shortMsg);
index ba8e41583ef0dec1056ab136b6756bded677b110..6a8d0b5abddb204745e835959cd44e3931889d34 100644 (file)
@@ -76,7 +76,7 @@ static char THIS_FILE[] = __FILE__;
 #define INVALID_VALUE "Invalid option"
 #define INVALID_OPTION "Invalid value"
 #define INVALID_COMMAND "Invalid command format"
-#define OPTION_BLOCK_FD "-blockFd"
+#define OPTION_BLOCK_FD "--blockFd"
 
 /*
  * Forward Declarations
@@ -701,6 +701,14 @@ VMwareUserConfFileLoop(void *clientData) // IN
 int
 main(int argc, char *argv[])
 {
+   struct sigaction olds[ARRAYSIZE(gSignals)];
+   int index;
+   GuestApp_Dict *confDict;
+   const char *pathName;
+#ifdef USE_NOTIFY
+   Bool notifyPresent = TRUE;
+#endif
+
    gOpenUrlRegistered = FALSE;
    gDnDRegistered = FALSE;
    gCopyPasteRegistered = FALSE;
@@ -709,13 +717,6 @@ main(int argc, char *argv[])
    gReloadSelf = FALSE;
    gYieldBlock = FALSE;
    gSigExit = FALSE;
-   struct sigaction olds[ARRAYSIZE(gSignals)];
-   int index;
-   GuestApp_Dict *confDict;
-   const char *pathName;
-#ifdef USE_NOTIFY
-   Bool notifyPresent = TRUE;
-#endif
 
    Atomic_Init();
 
index 60dc1b282c781b8d00fb4f362b8cb377c5433cf3..a649717569c3bbaffe10d8a5cbd81a27e038628e 100644 (file)
@@ -1,4 +1,3 @@
-
 /*********************************************************
  * Copyright (C) 2005 VMware, Inc. All rights reserved.
  *
@@ -48,7 +47,7 @@
 
 #define RPCIN_POLL_TIME        10  /* in 1/1000ths of a second */
 #define POINTER_POLL_TIME      15  /* in 1/1000ths of a second */
-#define UNGRABBED_POS -100
+#define UNGRABBED_POS (-100)
 #define DEBUG_PREFIX           "vmusr"
 
 #define FCP_FILE_TRANSFER_NOT_YET            0
index 255d1237bcb894ef8d73026126b2e4276e66ee06..1e89082c74e6941be23bc333afae7261748e817c 100644 (file)
 bin_PROGRAMS = vmware-xferlogs
 
 vmware_xferlogs_LDADD =
-vmware_xferlogs_LDADD += ../lib/rpcVmx/libRpcVmx.a
-vmware_xferlogs_LDADD += ../lib/string/libString.a
+vmware_xferlogs_LDADD += ../lib/rpcVmx/libRpcVmx.la
+vmware_xferlogs_LDADD += ../lib/string/libString.la
 # In the absence of the linker options --start-group and --end-group (which can't
 # be put in LDADD), we need to bring the following libraries out of the alphebetical
 # order so their symbols are properly resolved.
-vmware_xferlogs_LDADD += ../lib/rpcOut/libRpcOut.a
-vmware_xferlogs_LDADD += ../lib/message/libMessage.a
-vmware_xferlogs_LDADD += ../lib/backdoor/libBackdoor.a
-vmware_xferlogs_LDADD += ../lib/misc/libMisc.a
+vmware_xferlogs_LDADD += ../lib/rpcOut/libRpcOut.la
+vmware_xferlogs_LDADD += ../lib/message/libMessage.la
+vmware_xferlogs_LDADD += ../lib/backdoor/libBackdoor.la
+vmware_xferlogs_LDADD += ../lib/misc/libMisc.la
 
 vmware_xferlogs_SOURCES =
 vmware_xferlogs_SOURCES += xferlogs.c