From: VMware, Inc <> Date: Mon, 15 Oct 2012 04:49:43 +0000 (-0700) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2012.10.14-874563~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a9d7e0276e89658a9232f50b175f54cdf2cb7ede;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/include/util.h b/open-vm-tools/lib/include/util.h index f056e8180..7460b2abd 100644 --- a/open-vm-tools/lib/include/util.h +++ b/open-vm-tools/lib/include/util.h @@ -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 @@ -41,26 +41,27 @@ #endif #else #include + #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 -typedef pthread_t Util_ThreadID; -#elif defined(_WIN32) -typedef DWORD Util_ThreadID; -#else // Linux et al -#include -typedef pid_t Util_ThreadID; +#if defined(_WIN32) + typedef DWORD Util_ThreadID; +#else + #include + #if defined(__APPLE__) || defined(__FreeBSD__) + #include + 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 */