]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Mon, 15 Oct 2012 04:49:43 +0000 (21:49 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Fri, 19 Oct 2012 18:32:39 +0000 (11:32 -0700)
Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/include/util.h

index f056e8180af42c2c5d3ed1cd35d73ccf823a2547..7460b2abd09ff2d6ea4d228211ff7157bd93d48e 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2012 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
    #endif
 #else
    #include <sys/types.h>
+   #include "errno.h"
 #endif
-
 #include "vm_assert.h"
 #include "unicodeTypes.h"
 
 
 /*
- * Define the Util_ThreadID type.
+ * Define the Util_ThreadID type, and assorted standard bits.
  */
-#if defined(__APPLE__) || defined(__FreeBSD__)
-#include <pthread.h>
-typedef pthread_t Util_ThreadID;
-#elif defined(_WIN32)
-typedef DWORD Util_ThreadID;
-#else // Linux et al
-#include <unistd.h>
-typedef pid_t Util_ThreadID;
+#if defined(_WIN32)
+   typedef DWORD Util_ThreadID;
+#else
+   #include <unistd.h>
+   #if defined(__APPLE__) || defined(__FreeBSD__)
+      #include <pthread.h>
+      typedef pthread_t Util_ThreadID;
+   #else // Linux et al
+      typedef pid_t Util_ThreadID;
+   #endif
 #endif
 
-
 uint32 CRC_Compute(const uint8 *buf, int len);
 uint32 Util_Checksum32(const uint32 *buf, int len);
 uint32 Util_Checksum(const uint8 *buf, int len);
@@ -605,4 +606,29 @@ Util_FreeStringList(char **list,      // IN/OUT: the list to free
    Util_FreeList((void **) list, length);
 }
 
+#ifndef _WIN32
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Util_IsFileDescriptorOpen --
+ *
+ *      Check if given file descriptor is open.
+ *
+ * Results:
+ *      TRUE if fd is open.
+ *
+ * Side effects:
+ *      Clobbers errno.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static INLINE Bool
+Util_IsFileDescriptorOpen(int fd)   // IN
+{
+   lseek(fd, 0L, SEEK_CUR);
+   return errno != EBADF;
+}
+#endif /* !_WIN32 */
+
 #endif /* UTIL_H */