From 925137cf842814a49e9ddd852348e645b9c42b1a Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 9 Feb 2011 01:16:43 +0000 Subject: [PATCH] Pull support for the shared and exclusive lock since this wasn't available on linux. And conditionalize the availablility of the fcntl() command F_GETPATH. llvm-svn: 125152 --- lldb/include/lldb/Host/File.h | 4 +--- lldb/include/lldb/Host/freebsd/Config.h | 2 ++ lldb/include/lldb/Host/linux/Config.h | 2 ++ lldb/include/lldb/Host/macosx/Config.h | 2 ++ lldb/include/lldb/Host/mingw/Config.h | 2 ++ lldb/source/Host/common/File.cpp | 14 +++++++------- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h index 3fd64e4bd7bf..949324774ee3 100644 --- a/lldb/include/lldb/Host/File.h +++ b/lldb/include/lldb/Host/File.h @@ -35,9 +35,7 @@ public: eOpenOptionAppend = (1u << 2), // Don't truncate file when opening, append to end of file eOpenOptionNonBlocking = (1u << 3), // File reads eOpenOptionCanCreate = (1u << 4), // Create file if doesn't already exist - eOpenOptionCanCreateNewOnly = (1u << 5), // Can create file only if it doesn't already exist - eOpenOptionSharedLock = (1u << 6), // Open file and get shared lock - eOpenOptionExclusiveLock = (1u << 7) // Open file and get exclusive lock + eOpenOptionCanCreateNewOnly = (1u << 5) // Can create file only if it doesn't already exist }; enum Permissions diff --git a/lldb/include/lldb/Host/freebsd/Config.h b/lldb/include/lldb/Host/freebsd/Config.h index b91d7d398775..2d66b67741c0 100644 --- a/lldb/include/lldb/Host/freebsd/Config.h +++ b/lldb/include/lldb/Host/freebsd/Config.h @@ -25,4 +25,6 @@ //#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 +//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1 + #endif // #ifndef liblldb_Platform_Config_h_ \ No newline at end of file diff --git a/lldb/include/lldb/Host/linux/Config.h b/lldb/include/lldb/Host/linux/Config.h index 9408936f15f3..0caff065a59c 100644 --- a/lldb/include/lldb/Host/linux/Config.h +++ b/lldb/include/lldb/Host/linux/Config.h @@ -25,4 +25,6 @@ //#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 +//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1 + #endif // #ifndef liblldb_Platform_Config_h_ diff --git a/lldb/include/lldb/Host/macosx/Config.h b/lldb/include/lldb/Host/macosx/Config.h index 6735a92bfdc6..3e5ebe08d768 100644 --- a/lldb/include/lldb/Host/macosx/Config.h +++ b/lldb/include/lldb/Host/macosx/Config.h @@ -25,4 +25,6 @@ #define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 +#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1 + #endif // #ifndef liblldb_Platform_Config_h_ diff --git a/lldb/include/lldb/Host/mingw/Config.h b/lldb/include/lldb/Host/mingw/Config.h index a90cfc754a21..93e7f2ff5c0b 100644 --- a/lldb/include/lldb/Host/mingw/Config.h +++ b/lldb/include/lldb/Host/mingw/Config.h @@ -25,4 +25,6 @@ //#define LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED 1 +//#define LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED 1 + #endif // #ifndef liblldb_Platform_Config_h_ diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index e2dd32cca00b..e8ba529de944 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -13,6 +13,7 @@ #include #include "lldb/Core/Error.h" +#include "lldb/Host/Config.h" #include "lldb/Host/FileSpec.h" using namespace lldb; @@ -202,13 +203,6 @@ File::Open (const char *path, uint32_t options, uint32_t permissions) if (options & eOpenOptionCanCreateNewOnly) oflag |= O_CREAT | O_EXCL; - - if (options & eOpenOptionSharedLock) - oflag |= O_SHLOCK; - - if (options & eOpenOptionExclusiveLock) - oflag |= O_EXLOCK; - mode_t mode = 0; if (permissions & ePermissionsUserRead) mode |= S_IRUSR; if (permissions & ePermissionsUserWrite) mode |= S_IWUSR; @@ -262,6 +256,7 @@ Error File::GetFileSpec (FileSpec &file_spec) const { Error error; +#ifdef LLDB_CONFIG_FCNTL_GETPATH_SUPPORTED if (IsValid ()) { char path[PATH_MAX]; @@ -271,7 +266,12 @@ File::GetFileSpec (FileSpec &file_spec) const file_spec.SetFile (path, false); } else + { error.SetErrorString("invalid file handle"); + } +#else + error.SetErrorString ("fcntl (fd, F_GETPATH, ...) is not supported on this platform"); +#endif if (error.Fail()) file_spec.Clear();