summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2006-12-04 22:26:41 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2006-12-04 22:26:41 (GMT)
commit3a32cec96923cf057aad00274b4a8ab7ad82a82f (patch)
tree304527c04dbad8b51ce2bccda1a434f424bf1a9a /Source
parentde8ffcaef492e23af57ed5489dd8a21fdd7ad5d8 (diff)
downloadCMake-3a32cec96923cf057aad00274b4a8ab7ad82a82f.zip
CMake-3a32cec96923cf057aad00274b4a8ab7ad82a82f.tar.gz
CMake-3a32cec96923cf057aad00274b4a8ab7ad82a82f.tar.bz2
ENH: merge in changes for beos support
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCTest.cxx6
-rw-r--r--Source/cmDependsJavaLexer.cxx4
-rw-r--r--Source/cmDependsJavaLexer.h4
-rw-r--r--Source/cmMakefile.cxx3
-rw-r--r--Source/cmSystemTools.cxx7
-rw-r--r--Source/kwsys/DynamicLoader.cxx107
-rw-r--r--Source/kwsys/DynamicLoader.hxx.in4
-rw-r--r--Source/kwsys/SystemTools.cxx32
-rw-r--r--Source/kwsys/testDynamicLoader.cxx6
9 files changed, 170 insertions, 3 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 653fc12..8ca976d 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -48,6 +48,10 @@
#include <memory> // auto_ptr
+#if defined(__BEOS__)
+#include <be/kernel/OS.h> /* disable_debugger() API. */
+#endif
+
#define DEBUGOUT std::cout << __LINE__ << " "; std::cout
#define DEBUGERR std::cerr << __LINE__ << " "; std::cerr
@@ -589,6 +593,8 @@ void cmCTest::BlockTestErrorDiagnostics()
cmSystemTools::PutEnv("DASHBOARD_TEST_FROM_CTEST=" CMake_VERSION);
#if defined(_WIN32)
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
+#elif defined(__BEOS__)
+ disable_debugger(1);
#endif
}
diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx
index ac0da73..a168a7d 100644
--- a/Source/cmDependsJavaLexer.cxx
+++ b/Source/cmDependsJavaLexer.cxx
@@ -23,6 +23,10 @@
#include <errno.h>
#include <stdlib.h>
+#if defined(__BEOS__)
+#include <unistd.h> /* prevents a conflict with a #define later on... */
+#endif
+
/* end standard C headers. */
/* flex integer type definitions */
diff --git a/Source/cmDependsJavaLexer.h b/Source/cmDependsJavaLexer.h
index c32a364..0379c85 100644
--- a/Source/cmDependsJavaLexer.h
+++ b/Source/cmDependsJavaLexer.h
@@ -22,6 +22,10 @@
#include <errno.h>
#include <stdlib.h>
+#if defined(__BEOS__)
+#include <unistd.h> /* prevents a conflict with a #define later on... */
+#endif
+
/* end standard C headers. */
/* flex integer type definitions */
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 411dd25..e4814de 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1946,6 +1946,9 @@ void cmMakefile::AddDefaultDefinitions()
#if defined(__QNXNTO__)
this->AddDefinition("QNXNTO", "1");
#endif
+#if defined(__BEOS__)
+ this->AddDefinition("BEOS", "1");
+#endif
char temp[1024];
sprintf(temp, "%d", cmVersion::GetMinorVersion());
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 8746c7a..2a2ee91 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1432,7 +1432,12 @@ int cmSystemToolsGZStructOpen(void* call_data, const char *pathname,
return -1;
}
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#if defined(__BEOS__) && !defined(__ZETA__) // no fchmod on BeOS 5...do pathname instead.
+ if ((oflags & O_CREAT) && chmod(pathname, mode))
+ {
+ return -1;
+ }
+#elif !defined(_WIN32) || defined(__CYGWIN__)
if ((oflags & O_CREAT) && fchmod(fd, mode))
{
return -1;
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index 0bcbba0..87f957f 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -319,7 +319,112 @@ const char* DynamicLoader::LastError()
#endif //_WIN32
// ---------------------------------------------------------------
-// 4. Implementation for default UNIX machines.
+// 4. Implementation for BeOS
+#ifdef __BEOS__
+#include <string.h> // for strerror()
+#include <be/kernel/image.h>
+#include <be/support/Errors.h>
+#define DYNAMICLOADER_DEFINED 1
+
+namespace KWSYS_NAMESPACE
+{
+
+static image_id last_dynamic_err = B_OK;
+
+//----------------------------------------------------------------------------
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname )
+{
+ // image_id's are integers, errors are negative. Add one just in case we
+ // get a valid image_id of zero (is that even possible?).
+ image_id rc = load_add_on(libname);
+ if (rc < 0)
+ {
+ last_dynamic_err = rc;
+ return 0;
+ }
+
+ return rc+1;
+}
+
+//----------------------------------------------------------------------------
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ if (!lib)
+ {
+ last_dynamic_err = B_BAD_VALUE;
+ return 0;
+ }
+ else
+ {
+ // The function dlclose() returns 0 on success, and non-zero on error.
+ status_t rc = unload_add_on(lib-1);
+ if (rc != B_OK)
+ {
+ last_dynamic_err = rc;
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+//----------------------------------------------------------------------------
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const char* sym)
+{
+ // Hack to cast pointer-to-data to pointer-to-function.
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+
+ result.psym = NULL;
+
+ if (!lib)
+ {
+ last_dynamic_err = B_BAD_VALUE;
+ }
+ else
+ {
+ // !!! FIXME: BeOS can do function-only lookups...does this ever
+ // !!! FIXME: actually _want_ a data symbol lookup, or was this union
+ // !!! FIXME: a leftover of dlsym()? (s/ANY/TEXT for functions only).
+ status_t rc = get_image_symbol(lib-1,sym,B_SYMBOL_TYPE_ANY,&result.pvoid);
+ if (rc != B_OK)
+ {
+ last_dynamic_err = rc;
+ result.psym = NULL;
+ }
+ }
+ return result.psym;
+}
+
+//----------------------------------------------------------------------------
+const char* DynamicLoader::LibPrefix()
+{
+ return "lib";
+}
+
+//----------------------------------------------------------------------------
+const char* DynamicLoader::LibExtension()
+{
+ return ".so";
+}
+
+//----------------------------------------------------------------------------
+const char* DynamicLoader::LastError()
+{
+ const char *retval = strerror(last_dynamic_err);
+ last_dynamic_err = B_OK;
+ return retval;
+}
+
+} // namespace KWSYS_NAMESPACE
+#endif
+
+// ---------------------------------------------------------------
+// 5. Implementation for default UNIX machines.
// if nothing has been defined then use this
#ifndef DYNAMICLOADER_DEFINED
#define DYNAMICLOADER_DEFINED 1
diff --git a/Source/kwsys/DynamicLoader.hxx.in b/Source/kwsys/DynamicLoader.hxx.in
index ca1aa70..72dea57 100644
--- a/Source/kwsys/DynamicLoader.hxx.in
+++ b/Source/kwsys/DynamicLoader.hxx.in
@@ -25,6 +25,8 @@
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
#include <mach-o/dyld.h>
#endif
+#elif defined(__BEOS__)
+ #include <be/kernel/image.h>
#endif
namespace @KWSYS_NAMESPACE@
@@ -62,6 +64,8 @@ public:
#else
typedef void* LibraryHandle;
#endif
+#elif defined(__BEOS__)
+ typedef image_id LibraryHandle;
#else
typedef void* LibraryHandle;
#endif
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index f491cbf..33d3e64 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -108,6 +108,34 @@ public:
#define _chdir chdir
#endif
+#if defined(__BEOS__) && !defined(__ZETA__)
+#include <be/kernel/OS.h>
+#include <be/storage/Path.h>
+
+// BeOS 5 doesn't have usleep(), but it has snooze(), which is identical.
+static inline void usleep(unsigned int msec)
+{
+ ::snooze(msec);
+}
+
+// BeOS 5 also doesn't have realpath(), but its C++ API offers something close.
+static inline char *realpath(const char *path, char *resolved_path)
+{
+ const size_t maxlen = KWSYS_SYSTEMTOOLS_MAXPATH;
+ snprintf(resolved_path, maxlen, "%s", path);
+ BPath normalized(resolved_path, NULL, true);
+ const char *resolved = normalized.Path();
+ if (resolved != NULL) // NULL == No such file.
+ {
+ if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen)
+ {
+ return resolved_path;
+ }
+ }
+ return NULL; // something went wrong.
+}
+#endif
+
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
inline int Mkdir(const char* dir)
{
@@ -291,7 +319,9 @@ void SystemTools::GetPath(kwsys_stl::vector<kwsys_stl::string>& path, const char
kwsys_stl::string::size_type endpos = pathEnv.find(pathSep, start);
if(endpos != kwsys_stl::string::npos)
{
- path.push_back(pathEnv.substr(start, endpos-start));
+ kwsys_stl::string convertedPath;
+ Realpath(pathEnv.substr(start, endpos-start).c_str(), convertedPath);
+ path.push_back(convertedPath);
start = endpos+1;
}
else
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index bd4fc22..b13dec6 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -17,6 +17,10 @@
#include KWSYS_HEADER(ios/iostream)
#include KWSYS_HEADER(stl/string)
+#if defined(__BEOS__)
+#include <be/kernel/OS.h> /* disable_debugger() API. */
+#endif
+
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
@@ -88,6 +92,8 @@ int main(int argc, char *argv[])
{
#if defined(_WIN32)
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
+#elif defined(__BEOS__)
+ disable_debugger(1);
#endif
int res;
if( argc == 3 )