aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2013-08-06 13:39:28 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-08-06 13:39:28 -0700
commita08768d46fa5e3087d0fbd288366c53495ee2773 (patch)
tree3213ed1f714068e7ccf4d8bb66b57e479b4b9856
parent1ecad8f8e96b67d5f8c43af44375abafa7d40eff (diff)
parent48cd745480738c026312931877ecb8ebecb1c64e (diff)
downloadlibbcc-a08768d46fa5e3087d0fbd288366c53495ee2773.tar.gz
am 48cd7454: Fix Windows build issues for libbcc.
* commit '48cd745480738c026312931877ecb8ebecb1c64e': Fix Windows build issues for libbcc.
-rwxr-xr-xAndroid.mk2
-rw-r--r--bcinfo/Android.mk2
-rw-r--r--include/bcc/Support/OutputFile.h6
-rw-r--r--lib/ExecutionEngine/SymbolResolvers.cpp26
-rw-r--r--lib/Renderscript/RSInfo.cpp2
-rw-r--r--lib/Support/FileBase.cpp12
-rw-r--r--lib/Support/OutputFile.cpp53
-rw-r--r--tools/bcc_compat/Android.mk3
-rw-r--r--tools/bcc_compat/Main.cpp1
-rw-r--r--tools/bcc_strip_attr/Android.mk5
10 files changed, 51 insertions, 61 deletions
diff --git a/Android.mk b/Android.mk
index 5995aea..13fe13e 100755
--- a/Android.mk
+++ b/Android.mk
@@ -131,7 +131,9 @@ LOCAL_STATIC_LIBRARIES += \
LOCAL_SHARED_LIBRARIES := libbcinfo libLLVM
+ifndef USE_MINGW
LOCAL_LDLIBS := -ldl -lpthread
+endif
# Generate build information (Build time + Build git revision + Build Semi SHA1)
include $(LIBBCC_ROOT_PATH)/libbcc-gen-build-info.mk
diff --git a/bcinfo/Android.mk b/bcinfo/Android.mk
index d88a737..1da7d16 100644
--- a/bcinfo/Android.mk
+++ b/bcinfo/Android.mk
@@ -83,7 +83,9 @@ LOCAL_STATIC_LIBRARIES += $(libbcinfo_STATIC_LIBRARIES)
LOCAL_STATIC_LIBRARIES += libcutils liblog
LOCAL_SHARED_LIBRARIES += libLLVM
+ifndef USE_MINGW
LOCAL_LDLIBS := -ldl -lpthread
+endif
include $(LLVM_ROOT_PATH)/llvm-host-build.mk
include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/include/bcc/Support/OutputFile.h b/include/bcc/Support/OutputFile.h
index 5e5c868..9781e0a 100644
--- a/include/bcc/Support/OutputFile.h
+++ b/include/bcc/Support/OutputFile.h
@@ -29,12 +29,6 @@ namespace bcc {
class OutputFile : public File<FileBase::kWriteMode> {
typedef File<FileBase::kWriteMode> super;
public:
- // Generate a unique temporary filename from pFileTemplate and open it in
- // an OutputFile returned. The filename will be pFileTemplate with
- // a dot ('.') plus six random characters appended. Return NULL on error.
- static OutputFile *CreateTemporary(const std::string &pFileTemplate,
- unsigned pFlags);
-
OutputFile(const std::string &pFilename, unsigned pFlags = 0);
ssize_t write(const void *pBuf, size_t count);
diff --git a/lib/ExecutionEngine/SymbolResolvers.cpp b/lib/ExecutionEngine/SymbolResolvers.cpp
index 62914ac..3d21e7d 100644
--- a/lib/ExecutionEngine/SymbolResolvers.cpp
+++ b/lib/ExecutionEngine/SymbolResolvers.cpp
@@ -16,7 +16,33 @@
#include "bcc/ExecutionEngine/SymbolResolvers.h"
+#if !defined(_WIN32) /* TODO create a HAVE_DLFCN_H */
#include <dlfcn.h>
+#else
+/* TODO hack: definitions from bionic/libc/include/dlfcn.h */
+void* dlopen(const char* filename, int flag) {
+ return NULL;
+}
+
+int dlclose(void* handle) {
+ return -1;
+}
+
+const char* dlerror(void) {
+ return "Unspecified error!";
+}
+
+void* dlsym(void* handle, const char* symbol) {
+ return NULL;
+}
+
+#define RTLD_NOW 0
+#define RTLD_LAZY 1
+#define RTLD_LOCAL 0
+#define RTLD_GLOBAL 2
+#define RTLD_DEFAULT ((void*) 0xffffffff)
+#define RTLD_NEXT ((void*) 0xfffffffe)
+#endif
#include <cassert>
#include <cstdio>
diff --git a/lib/Renderscript/RSInfo.cpp b/lib/Renderscript/RSInfo.cpp
index 4aa2e69..496f739 100644
--- a/lib/Renderscript/RSInfo.cpp
+++ b/lib/Renderscript/RSInfo.cpp
@@ -17,7 +17,9 @@
//#define LOG_NDEBUG 0
#include "bcc/Renderscript/RSInfo.h"
+#if !defined(_WIN32) /* TODO create a HAVE_DLFCN_H */
#include <dlfcn.h>
+#endif
#include <cstring>
#include <new>
diff --git a/lib/Support/FileBase.cpp b/lib/Support/FileBase.cpp
index 5dc9944..99600eb 100644
--- a/lib/Support/FileBase.cpp
+++ b/lib/Support/FileBase.cpp
@@ -30,6 +30,18 @@
using namespace bcc;
+#ifdef _WIN32
+// TODO: Fix flock usage under windows
+#define LOCK_SH 0
+#define LOCK_EX 0
+#define LOCK_NB 0
+#define LOCK_UN 0
+
+int flock(int fd, int operation) {
+ return 0;
+}
+#endif // _WIN32
+
FileBase::FileBase(const std::string &pFilename,
unsigned pOpenFlags,
unsigned pFlags)
diff --git a/lib/Support/OutputFile.cpp b/lib/Support/OutputFile.cpp
index 6d969d0..a30975b 100644
--- a/lib/Support/OutputFile.cpp
+++ b/lib/Support/OutputFile.cpp
@@ -24,59 +24,6 @@
using namespace bcc;
-OutputFile *OutputFile::CreateTemporary(const std::string &pFileTemplate,
- unsigned pFlags) {
- char *tmp_filename = NULL;
- int tmp_fd;
- OutputFile *result = NULL;
-
- // Allocate memory to hold the generated unique temporary filename.
- tmp_filename =
- new (std::nothrow) char [ pFileTemplate.length() + /* .XXXXXX */7 + 1 ];
- if (tmp_filename == NULL) {
- ALOGE("Out of memory when allocates memory for filename %s in "
- "OutputFile::CreateTemporary()!", pFileTemplate.c_str());
- return NULL;
- }
-
- // Construct filename template for mkstemp().
- if (pFileTemplate.length() > 0)
- ::memcpy(tmp_filename, pFileTemplate.c_str(), pFileTemplate.length());
- ::strncpy(tmp_filename + pFileTemplate.length(), ".XXXXXX", 7);
-
- // POSIX mkstemp() never returns EINTR.
- tmp_fd = ::mkstemp(tmp_filename);
- if (tmp_fd < 0) {
- llvm::error_code err(errno, llvm::posix_category());
- ALOGE("Failed to create temporary file using mkstemp() for %s! (%s)",
- tmp_filename, err.message().c_str());
- delete [] tmp_filename;
- return NULL;
- }
-
- // Create result OutputFile. Temporary file is always truncated.
- result = new (std::nothrow) OutputFile(tmp_filename,
- pFlags | FileBase::kTruncate);
- if (result == NULL) {
- ALOGE("Out of memory when creates OutputFile for %s!", tmp_filename);
- // Fall through to the clean-up codes.
- } else {
- if (result->hasError()) {
- ALOGE("Failed to open temporary output file %s! (%s)",
- result->getName().c_str(), result->getErrorMessage().c_str());
- delete result;
- result = NULL;
- // Fall through to the clean-up codes.
- }
- }
-
- // Clean up.
- delete [] tmp_filename;
- ::close(tmp_fd);
-
- return result;
-}
-
OutputFile::OutputFile(const std::string &pFilename, unsigned pFlags)
: super(pFilename, pFlags) { }
diff --git a/tools/bcc_compat/Android.mk b/tools/bcc_compat/Android.mk
index b8be047..51ac17e 100644
--- a/tools/bcc_compat/Android.mk
+++ b/tools/bcc_compat/Android.mk
@@ -34,7 +34,10 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../include
+ifndef USE_MINGW
LOCAL_LDLIBS = -ldl
+endif
+
LOCAL_SRC_FILES := Main.cpp
include $(LIBBCC_HOST_BUILD_MK)
diff --git a/tools/bcc_compat/Main.cpp b/tools/bcc_compat/Main.cpp
index d0a6f27..4399893 100644
--- a/tools/bcc_compat/Main.cpp
+++ b/tools/bcc_compat/Main.cpp
@@ -32,7 +32,6 @@
#include <bcc/Compiler.h>
#include <bcc/Config/BuildInfo.h>
#include <bcc/Config/Config.h>
-#include <bcc/ExecutionEngine/ObjectLoader.h>
#include <bcc/ExecutionEngine/SymbolResolverProxy.h>
#include <bcc/ExecutionEngine/SymbolResolvers.h>
#include <bcc/Renderscript/RSCompilerDriver.h>
diff --git a/tools/bcc_strip_attr/Android.mk b/tools/bcc_strip_attr/Android.mk
index 2355d2f..e8414da 100644
--- a/tools/bcc_strip_attr/Android.mk
+++ b/tools/bcc_strip_attr/Android.mk
@@ -31,7 +31,10 @@ LOCAL_SHARED_LIBRARIES := libLLVM
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../include
-LOCAL_LDLIBS += -lpthread -lm -ldl
+LOCAL_LDLIBS += -lm
+ifndef USE_MINGW
+LOCAL_LDLIBS += -lpthread -ldl
+endif
LOCAL_SRC_FILES := bcc_strip_attr.cpp
include $(LIBBCC_HOST_BUILD_MK)