From 23ae48412093e4acbd5270536aace226d5869679 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 31 Jan 2013 08:21:49 -0500 Subject: [PATCH] KWSys 2013-01-31 (5b0d1bd9) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 5b0d1bd9 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 6fa1c99f..5b0d1bd9 Alan Hourihane (2): e81e2b72 DynamicLoader: Implement on Atari FreeMINT 5c4dcb2b ProcessUNIX: No select on Atari FreeMINT Sean McBride (2): bff2ea07 Glob: Fix clang -Wdocumentation warning 5b0d1bd9 Fix clang -Weverything warnings Change-Id: I8b342bea8bc9c7b92a856ddc948e1b56f5e74b98 --- DynamicLoader.cxx | 52 ++++++++++++++++++++++++++++++++++++ Glob.cxx | 2 +- IOStream.cxx | 1 + ProcessUNIX.c | 2 +- SystemInformation.cxx | 5 +++- SystemTools.cxx | 4 +-- testCommandLineArguments.cxx | 16 +++++------ testDynamicLoader.cxx | 2 +- testProcess.c | 22 +++++++-------- testSystemTools.cxx | 26 +++++++++--------- 10 files changed, 94 insertions(+), 38 deletions(-) diff --git a/DynamicLoader.cxx b/DynamicLoader.cxx index c4ee09551..fd83752c0 100644 --- a/DynamicLoader.cxx +++ b/DynamicLoader.cxx @@ -428,6 +428,58 @@ const char* DynamicLoader::LastError() } // namespace KWSYS_NAMESPACE #endif +#ifdef __MINT__ +#define DYNAMICLOADER_DEFINED 1 +#define _GNU_SOURCE /* for program_invocation_name */ +#include +#include +#include +#include + +namespace KWSYS_NAMESPACE +{ + +//---------------------------------------------------------------------------- +DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname ) +{ + char *name = (char *)calloc(1, strlen(libname) + 1); + dld_init(program_invocation_name); + strncpy(name, libname, strlen(libname)); + dld_link(libname); + return (void *)name; +} + +//---------------------------------------------------------------------------- +int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib) +{ + dld_unlink_by_file((char *)lib, 0); + free(lib); + return 0; +} + +//---------------------------------------------------------------------------- +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.pvoid = dld_get_symbol(sym); + return result.psym; +} + +//---------------------------------------------------------------------------- +const char* DynamicLoader::LastError() +{ + return dld_strerror(dld_errno); +} + +} // namespace KWSYS_NAMESPACE +#endif + // --------------------------------------------------------------- // 6. Implementation for default UNIX machines. // if nothing has been defined then use this diff --git a/Glob.cxx b/Glob.cxx index 513eb6408..46a7e4f44 100644 --- a/Glob.cxx +++ b/Glob.cxx @@ -399,7 +399,7 @@ bool Glob::FindFiles(const kwsys_stl::string& inexpr) if ( last_slash > 0 ) { //kwsys_ios::cout << "I can skip: " << fexpr.substr(0, last_slash) - //<< kwsys_ios::endl; + // << kwsys_ios::endl; skip = last_slash; } if ( skip == 0 ) diff --git a/IOStream.cxx b/IOStream.cxx index 57b696eb3..a31f8c846 100644 --- a/IOStream.cxx +++ b/IOStream.cxx @@ -272,6 +272,7 @@ namespace KWSYS_NAMESPACE // Create one public symbol in this object file to avoid warnings from // archivers. +void IOStreamSymbolToAvoidWarning(); void IOStreamSymbolToAvoidWarning() { } diff --git a/ProcessUNIX.c b/ProcessUNIX.c index 2db12544c..fc9e8bf67 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -102,7 +102,7 @@ static inline void kwsysProcess_usleep(unsigned int msec) * pipes' file handles to be non-blocking and just poll them directly * without select(). */ -#if !defined(__BEOS__) && !defined(__VMS) +#if !defined(__BEOS__) && !defined(__VMS) && !defined(__MINT__) # define KWSYSPE_USE_SELECT 1 #endif diff --git a/SystemInformation.cxx b/SystemInformation.cxx index b20d72458..f057e0fcb 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -2466,7 +2466,9 @@ bool SystemInformationImplementation::RetrieveCPUPowerManagement() #endif } -void SystemInformationStripLeadingSpace(kwsys_stl::string& str) +#if USE_CPUID +// Used only in USE_CPUID implementation below. +static void SystemInformationStripLeadingSpace(kwsys_stl::string& str) { // Because some manufacturers have leading white space - we have to post-process the name. kwsys_stl::string::size_type pos = str.find_first_not_of(" "); @@ -2475,6 +2477,7 @@ void SystemInformationStripLeadingSpace(kwsys_stl::string& str) str = str.substr(pos); } } +#endif /** */ bool SystemInformationImplementation::RetrieveExtendedCPUIdentity() diff --git a/SystemTools.cxx b/SystemTools.cxx index b75993ea6..881c49a37 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3037,7 +3037,7 @@ void SystemTools::CheckTranslationPath(kwsys_stl::string & path) path.erase(path.end()-1, path.end()); } -void +static void SystemToolsAppendComponents( kwsys_stl::vector& out_components, kwsys_stl::vector::const_iterator first, @@ -4704,7 +4704,7 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL, // ---------------------------------------------------------------------- // These must NOT be initialized. Default initialization to zero is // necessary. -unsigned int SystemToolsManagerCount; +static unsigned int SystemToolsManagerCount; SystemToolsTranslationMap *SystemTools::TranslationMap; SystemToolsTranslationMap *SystemTools::LongPathMap; #ifdef __CYGWIN__ diff --git a/testCommandLineArguments.cxx b/testCommandLineArguments.cxx index e75a87e86..72e65447b 100644 --- a/testCommandLineArguments.cxx +++ b/testCommandLineArguments.cxx @@ -24,9 +24,9 @@ #include /* size_t */ #include /* strcmp */ -void* random_ptr = reinterpret_cast(0x123); +static void* random_ptr = reinterpret_cast(0x123); -int argument(const char* arg, const char* value, void* call_data) +static int argument(const char* arg, const char* value, void* call_data) { kwsys_ios::cout << "Got argument: \"" << arg << "\" value: \"" << (value?value:"(null)") << "\"" << kwsys_ios::endl; if ( call_data != random_ptr ) @@ -37,7 +37,7 @@ int argument(const char* arg, const char* value, void* call_data) return 1; } -int unknown_argument(const char* argument, void* call_data) +static int unknown_argument(const char* argument, void* call_data) { kwsys_ios::cout << "Got unknown argument: \"" << argument << "\"" << kwsys_ios::endl; if ( call_data != random_ptr ) @@ -48,12 +48,12 @@ int unknown_argument(const char* argument, void* call_data) return 1; } -bool CompareTwoItemsOnList(bool i1, bool i2) { return i1 == i2; } -bool CompareTwoItemsOnList(int i1, int i2) { return i1 == i2; } -bool CompareTwoItemsOnList(double i1, double i2) { return i1 == i2; } -bool CompareTwoItemsOnList(const char* i1, +static bool CompareTwoItemsOnList(bool i1, bool i2) { return i1 == i2; } +static bool CompareTwoItemsOnList(int i1, int i2) { return i1 == i2; } +static bool CompareTwoItemsOnList(double i1, double i2) { return i1 == i2; } +static bool CompareTwoItemsOnList(const char* i1, const char* i2) { return strcmp(i1, i2) == 0; } -bool CompareTwoItemsOnList(const kwsys_stl::string& i1, +static bool CompareTwoItemsOnList(const kwsys_stl::string& i1, const kwsys_stl::string& i2) { return i1 == i2; } int testCommandLineArguments(int argc, char* argv[]) diff --git a/testDynamicLoader.cxx b/testDynamicLoader.cxx index cbfb65b1c..61c157291 100644 --- a/testDynamicLoader.cxx +++ b/testDynamicLoader.cxx @@ -35,7 +35,7 @@ // left on disk. #include -kwsys_stl::string GetLibName(const char* lname) +static kwsys_stl::string GetLibName(const char* lname) { // Construct proper name of lib kwsys_stl::string slname; diff --git a/testProcess.c b/testProcess.c index 269b84ba8..6d5eb71fd 100644 --- a/testProcess.c +++ b/testProcess.c @@ -47,7 +47,7 @@ int runChild(const char* cmd[], int state, int exception, int value, int share, int output, int delay, double timeout, int poll, int repeat, int disown); -int test1(int argc, const char* argv[]) +static int test1(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout from test returning 0.\n"); @@ -55,7 +55,7 @@ int test1(int argc, const char* argv[]) return 0; } -int test2(int argc, const char* argv[]) +static int test2(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout from test returning 123.\n"); @@ -63,7 +63,7 @@ int test2(int argc, const char* argv[]) return 123; } -int test3(int argc, const char* argv[]) +static int test3(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output before sleep on stdout from timeout test.\n"); @@ -80,7 +80,7 @@ int test3(int argc, const char* argv[]) return 0; } -int test4(int argc, const char* argv[]) +static int test4(int argc, const char* argv[]) { /* Prepare a pointer to an invalid address. Don't use null, because dereferencing null is undefined behaviour and compilers are free to @@ -109,7 +109,7 @@ int test4(int argc, const char* argv[]) return 0; } -int test5(int argc, const char* argv[]) +static int test5(int argc, const char* argv[]) { int r; const char* cmd[4]; @@ -132,7 +132,7 @@ int test5(int argc, const char* argv[]) } #define TEST6_SIZE (4096*2) -void test6(int argc, const char* argv[]) +static void test6(int argc, const char* argv[]) { int i; char runaway[TEST6_SIZE+1]; @@ -156,7 +156,7 @@ void test6(int argc, const char* argv[]) delaying 1/10th of a second should ever have to poll. */ #define MINPOLL 5 #define MAXPOLL 20 -int test7(int argc, const char* argv[]) +static int test7(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout before sleep.\n"); @@ -176,7 +176,7 @@ int test7(int argc, const char* argv[]) return 0; } -int test8(int argc, const char* argv[]) +static int test8(int argc, const char* argv[]) { /* Create a disowned grandchild to test handling of processes that exit before their children. */ @@ -200,7 +200,7 @@ int test8(int argc, const char* argv[]) return r; } -int test8_grandchild(int argc, const char* argv[]) +static int test8_grandchild(int argc, const char* argv[]) { (void)argc; (void)argv; fprintf(stdout, "Output on stdout from grandchild before sleep.\n"); @@ -221,7 +221,7 @@ int test8_grandchild(int argc, const char* argv[]) return 0; } -int runChild2(kwsysProcess* kp, +static int runChild2(kwsysProcess* kp, const char* cmd[], int state, int exception, int value, int share, int output, int delay, double timeout, int poll, int disown) @@ -505,7 +505,7 @@ int main(int argc, const char* argv[]) fprintf(stderr, "Output on stderr after test %d.\n", n); fflush(stdout); fflush(stderr); -#if _WIN32 +#if defined(_WIN32) if(argv0) { free(argv0); } #endif return r; diff --git a/testSystemTools.cxx b/testSystemTools.cxx index 3ac0cb399..1690fd51a 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -32,7 +32,7 @@ #include /* strcmp */ //---------------------------------------------------------------------------- -const char* toUnixPaths[][2] = +static const char* toUnixPaths[][2] = { { "/usr/local/bin/passwd", "/usr/local/bin/passwd" }, { "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" }, @@ -52,8 +52,8 @@ const char* toUnixPaths[][2] = {0, 0} }; -bool CheckConvertToUnixSlashes(kwsys_stl::string input, - kwsys_stl::string output) +static bool CheckConvertToUnixSlashes(kwsys_stl::string input, + kwsys_stl::string output) { kwsys_stl::string result = input; kwsys::SystemTools::ConvertToUnixSlashes(result); @@ -69,17 +69,17 @@ bool CheckConvertToUnixSlashes(kwsys_stl::string input, } //---------------------------------------------------------------------------- -const char* checkEscapeChars[][4] = +static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2"}, { " {} ", "{}", "#", " #{#} "}, {0, 0, 0, 0} }; -bool CheckEscapeChars(kwsys_stl::string input, - const char *chars_to_escape, - char escape_char, - kwsys_stl::string output) +static bool CheckEscapeChars(kwsys_stl::string input, + const char *chars_to_escape, + char escape_char, + kwsys_stl::string output) { kwsys_stl::string result = kwsys::SystemTools::EscapeChars( input.c_str(), chars_to_escape, escape_char); @@ -95,7 +95,7 @@ bool CheckEscapeChars(kwsys_stl::string input, } //---------------------------------------------------------------------------- -bool CheckFileOperations() +static bool CheckFileOperations() { bool res = true; @@ -129,7 +129,7 @@ bool CheckFileOperations() } //---------------------------------------------------------------------------- -bool CheckStringOperations() +static bool CheckStringOperations() { bool res = true; @@ -329,7 +329,7 @@ bool CheckStringOperations() //---------------------------------------------------------------------------- -bool CheckPutEnv(const char* env, const char* name, const char* value) +static bool CheckPutEnv(const char* env, const char* name, const char* value) { if(!kwsys::SystemTools::PutEnv(env)) { @@ -348,7 +348,7 @@ bool CheckPutEnv(const char* env, const char* name, const char* value) return true; } -bool CheckUnPutEnv(const char* env, const char* name) +static bool CheckUnPutEnv(const char* env, const char* name) { if(!kwsys::SystemTools::UnPutEnv(env)) { @@ -365,7 +365,7 @@ bool CheckUnPutEnv(const char* env, const char* name) return true; } -bool CheckEnvironmentOperations() +static bool CheckEnvironmentOperations() { bool res = true; res &= CheckPutEnv("A=B", "A", "B");