diff options
Diffstat (limited to 'ace/OS_NS_dlfcn.inl')
-rw-r--r-- | ace/OS_NS_dlfcn.inl | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/ace/OS_NS_dlfcn.inl b/ace/OS_NS_dlfcn.inl index 6c4caeaf3e8..542660d66d9 100644 --- a/ace/OS_NS_dlfcn.inl +++ b/ace/OS_NS_dlfcn.inl @@ -1,5 +1,4 @@ // -*- C++ -*- -// // $Id$ #include "ace/OS_NS_macros.h" @@ -20,8 +19,6 @@ # include "ace/OS_NS_string.h" #endif /* ACE_USES_ASM_SYMBOL_IN_DLSYM */ -ACE_BEGIN_VERSIONED_NAMESPACE_DECL - ACE_INLINE int ACE_OS::dlclose (ACE_SHLIB_HANDLE handle) { @@ -89,12 +86,12 @@ ACE_OS::dlerror (void) # if defined (ACE_USES_WCHAR) const size_t BufLen = 256; static wchar_t buf[BufLen]; - ACE_OS::strncpy (buf, ACE_TEXT_CHAR_TO_TCHAR (err), BufLen); + ACE_OS::string_copy (buf, err, BufLen); return buf; # else return const_cast <char *> (err); # endif /* ACE_USES_WCHAR */ -# elif defined (__hpux) || defined (ACE_VXWORKS) +# elif defined (__hpux) || defined (VXWORKS) ACE_OSCALL_RETURN (::strerror(errno), char *, 0); # elif defined (ACE_WIN32) static ACE_TCHAR buf[128]; @@ -115,23 +112,32 @@ ACE_OS::dlerror (void) # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ } +# if defined (ACE_HAS_CHARPTR_DL) +typedef ACE_TCHAR * ACE_DL_TYPE; +# else +typedef const ACE_TCHAR * ACE_DL_TYPE; +# endif /* ACE_HAS_CHARPTR_DL */ + ACE_INLINE ACE_SHLIB_HANDLE ACE_OS::dlopen (const ACE_TCHAR *fname, int mode) { ACE_OS_TRACE ("ACE_OS::dlopen"); + // Get the correct OS type. + ACE_DL_TYPE filename = const_cast<ACE_DL_TYPE> (fname); + # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) void *handle; # if defined (ACE_HAS_SGIDLADD) ACE_OSCALL - (::sgidladd (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle); + (::sgidladd (ACE_TEXT_TO_CHAR_IN (filename), mode), void *, 0, handle); # elif defined (_M_UNIX) ACE_OSCALL - (::_dlopen (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle); + (::_dlopen (ACE_TEXT_TO_CHAR_IN (filename), mode), void *, 0, handle); # else ACE_OSCALL - (::dlopen (ACE_TEXT_ALWAYS_CHAR (fname), mode), void *, 0, handle); + (::dlopen (ACE_TEXT_TO_CHAR_IN (filename), mode), void *, 0, handle); # endif /* ACE_HAS_SGIDLADD */ # if !defined (ACE_HAS_AUTOMATIC_INIT_FINI) if (handle != 0) @@ -154,18 +160,18 @@ ACE_OS::dlopen (const ACE_TCHAR *fname, # elif defined (ACE_WIN32) ACE_UNUSED_ARG (mode); - ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (fname), ACE_SHLIB_HANDLE, 0); + ACE_WIN32CALL_RETURN (ACE_TEXT_LoadLibrary (filename), ACE_SHLIB_HANDLE, 0); # elif defined (__hpux) # if defined(__GNUC__) || __cplusplus >= 199707L - ACE_OSCALL_RETURN (::shl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0); + ACE_OSCALL_RETURN (::shl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0); # else - ACE_OSCALL_RETURN (::cxxshl_load(fname, mode, 0L), ACE_SHLIB_HANDLE, 0); + ACE_OSCALL_RETURN (::cxxshl_load(filename, mode, 0L), ACE_SHLIB_HANDLE, 0); # endif /* aC++ vs. Hp C++ */ -# elif defined (ACE_VXWORKS) && !defined (__RTP__) - MODULE* handle = 0; +# elif defined (VXWORKS) + MODULE* handle; // Open readonly - ACE_HANDLE filehandle = ACE_OS::open (fname, + ACE_HANDLE filehandle = ACE_OS::open (filename, O_RDONLY, ACE_DEFAULT_FILE_PERMS); @@ -179,8 +185,8 @@ ACE_OS::dlopen (const ACE_TCHAR *fname, if ( (loaderror != 0) && (handle != 0) ) { // ouch something went wrong most likely unresolved externals - if (handle) - ::unldByModuleId ( handle, 0 ); + if (handle) + ::unldByModuleId ( handle, 0 ); handle = 0; } } @@ -191,7 +197,7 @@ ACE_OS::dlopen (const ACE_TCHAR *fname, } return handle; # else - ACE_UNUSED_ARG (fname); + ACE_UNUSED_ARG (filename); ACE_UNUSED_ARG (mode); ACE_NOTSUP_RETURN (0); # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ @@ -210,24 +216,15 @@ ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, #endif /* ACE_HAS_DLSYM_SEGFAULT_ON_INVALID_HANDLE */ // Get the correct OS type. + // Define symbolname #if defined (ACE_HAS_WINCE) - // CE (at least thru Pocket PC 2003) offers GetProcAddressW, not ...A, so - // we always need a wide-char string. - const wchar_t *symbolname = 0; -# if defined (ACE_USES_WCHAR) - symbolname = sname; -# else - ACE_Ascii_To_Wide sname_xlate (sname); - symbolname = sname_xlate.wchar_rep (); -# endif /* ACE_USES_WCHAR */ -#elif defined (ACE_USES_WCHAR) - // WinCE is WCHAR always; other platforms need a char * symbol name - ACE_Wide_To_Ascii w_sname (sname); - char *symbolname = w_sname.char_rep (); -#elif defined (ACE_VXWORKS) - char *symbolname = const_cast<char *> (sname); + // WinCE expects a wchar + ACE::String_Conversion::Convert_In< wchar_t, char > convert (sname); + const wchar_t *symbolname = convert.c_str(); #else - const char *symbolname = sname; + // Otherwise we make certain we have an ANSI char version + ACE::String_Conversion::Convert_In< char, wchar_t > convert (sname); + const char *symbolname = convert.c_str(); #endif /* ACE_HAS_WINCE */ # if defined (ACE_HAS_SVR4_DYNAMIC_LINKING) @@ -260,7 +257,7 @@ ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, ACE_OSCALL (::shl_findsym(&_handle, symbolname, TYPE_UNDEFINED, &value), int, -1, status); return status == 0 ? value : 0; -# elif defined (ACE_VXWORKS) && !defined (__RTP__) +# elif defined (VXWORKS) // For now we use the VxWorks global symbol table // which resolves the most recently loaded symbols .. which resolve mostly what we want.. @@ -280,5 +277,3 @@ ACE_OS::dlsym (ACE_SHLIB_HANDLE handle, # endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ } - -ACE_END_VERSIONED_NAMESPACE_DECL |