From 3d0878b7aa90786eee0a95f68b130a06494d028c Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 13 Oct 2010 15:06:44 +0100 Subject: AIX port --- sal/inc/osl/endian.h | 10 ++++-- sal/inc/rtl/uuid.h | 2 ++ sal/inc/sal/alloca.h | 2 +- sal/inc/sal/config.h | 2 +- sal/inc/sal/main.h | 8 +++-- sal/osl/unx/backtrace.c | 11 +++++++ sal/osl/unx/file_error_transl.cxx | 2 ++ sal/osl/unx/file_volume.cxx | 13 +++++--- sal/osl/unx/interlck.c | 2 +- sal/osl/unx/makefile.mk | 2 +- sal/osl/unx/module.c | 66 +++++++++++++++++++++++++++++++++++++++ sal/osl/unx/nlsupport.c | 8 ++--- sal/osl/unx/process.c | 2 +- sal/osl/unx/security.c | 3 ++ sal/osl/unx/socket.c | 4 +++ sal/osl/unx/system.c | 1 + sal/osl/unx/system.h | 19 +++++++---- sal/osl/unx/tempfile.c | 18 ++++++----- sal/rtl/source/alloc.c | 4 +-- sal/rtl/source/alloc_global.c | 2 +- sal/rtl/source/macro.hxx | 2 ++ sal/rtl/source/makefile.mk | 6 ++-- 22 files changed, 150 insertions(+), 39 deletions(-) diff --git a/sal/inc/osl/endian.h b/sal/inc/osl/endian.h index e8ed472cc..fbb847932 100644 --- a/sal/inc/osl/endian.h +++ b/sal/inc/osl/endian.h @@ -104,11 +104,15 @@ extern "C" { #endif #ifdef AIX -# include +# include # if BYTE_ORDER == LITTLE_ENDIAN -# define _LITTLE_ENDIAN +# ifndef _LITTLE_ENDIAN +# define _LITTLE_ENDIAN +# endif # elif BYTE_ORDER == BIG_ENDIAN -# define _BIG_ENDIAN +# ifndef _BIG_ENDIAN +# define _BIG_ENDIAN +# endif # elif BYTE_ORDER == PDP_ENDIAN # define _PDP_ENDIAN # endif diff --git a/sal/inc/rtl/uuid.h b/sal/inc/rtl/uuid.h index efc6d833b..30018be8f 100644 --- a/sal/inc/rtl/uuid.h +++ b/sal/inc/rtl/uuid.h @@ -198,6 +198,8 @@ void SAL_CALL rtl_createNamedUuid( #define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10 #elif MACOSX #define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 100000 +#elif AIX +#define UUID_SYSTEM_TIME_RESOLUTION_100NS_TICKS 10 #else #error "System time resolution must be calculated!" #endif diff --git a/sal/inc/sal/alloca.h b/sal/inc/sal/alloca.h index 8214f9268..2879431f7 100644 --- a/sal/inc/sal/alloca.h +++ b/sal/inc/sal/alloca.h @@ -28,7 +28,7 @@ #ifndef INCLUDED_SAL_ALLOCA_H #define INCLUDED_SAL_ALLOCA_H -#if defined (SOLARIS) || defined (LINUX) || defined(__EMX__) +#if defined (SOLARIS) || defined (LINUX) || defined(__EMX__) || defined(AIX) #ifndef INCLUDED_ALLOCA_H #include diff --git a/sal/inc/sal/config.h b/sal/inc/sal/config.h index ada8cbdf0..ac600fdef 100644 --- a/sal/inc/sal/config.h +++ b/sal/inc/sal/config.h @@ -91,7 +91,7 @@ #define SAL_SYSCONFIGFILE( name ) name ".ini" #endif -#if defined(SOLARIS) || defined(LINUX) || defined(NETBSD) || defined(FREEBSD) || defined(SCO) +#if defined(SOLARIS) || defined(LINUX) || defined(NETBSD) || defined(FREEBSD) || defined(SCO) || defined(AIX) #define SAL_UNX #define SAL_DLLEXTENSION ".so" #define SAL_DLLPREFIX "lib" diff --git a/sal/inc/sal/main.h b/sal/inc/sal/main.h index 7f704325b..dd2976908 100644 --- a/sal/inc/sal/main.h +++ b/sal/inc/sal/main.h @@ -29,6 +29,9 @@ #define _SAL_MAIN_H_ #include +#if defined(AIX) +# include +#endif #ifdef __cplusplus extern "C" { @@ -44,7 +47,7 @@ int SAL_CALL main(int argc, char ** argv) \ sal_detail_initialize(argc, argv); \ ret = sal_main_with_args(argc, argv); \ sal_detail_deinitialize(); \ - return ret; \ + return x; \ } #define SAL_MAIN_IMPL \ @@ -54,10 +57,9 @@ int SAL_CALL main(int argc, char ** argv) \ sal_detail_initialize(argc, argv); \ ret = sal_main(); \ sal_detail_deinitialize(); \ - return ret; \ + return x; \ } - /* Definition macros for CRT entries */ #ifdef SAL_W32 diff --git a/sal/osl/unx/backtrace.c b/sal/osl/unx/backtrace.c index c779059a5..b0a9de306 100755 --- a/sal/osl/unx/backtrace.c +++ b/sal/osl/unx/backtrace.c @@ -357,3 +357,14 @@ void backtrace_symbols_fd( void **buffer, int size, int fd ) } #endif /* defined MACOSX */ + +#if defined(AIX) +int backtrace( void **buffer, int max_frames ) +{ + return 0; +} + +void backtrace_symbols_fd( void **buffer, int size, int fd ) +{ +} +#endif diff --git a/sal/osl/unx/file_error_transl.cxx b/sal/osl/unx/file_error_transl.cxx index 290579456..9131614ca 100644 --- a/sal/osl/unx/file_error_transl.cxx +++ b/sal/osl/unx/file_error_transl.cxx @@ -206,9 +206,11 @@ oslFileError oslTranslateFileError(sal_Bool bIsError, int Errno) osl_error = osl_File_E_NOSYS; break; +#if !defined(AIX) || !(defined(_ALL_SOURCE) && !defined(_LINUX_SOURCE_COMPAT)) case ENOTEMPTY: osl_error = osl_File_E_NOTEMPTY; break; +#endif case ELOOP: osl_error = osl_File_E_LOOP; diff --git a/sal/osl/unx/file_volume.cxx b/sal/osl/unx/file_volume.cxx index 3243eb0e7..8daacc06c 100644 --- a/sal/osl/unx/file_volume.cxx +++ b/sal/osl/unx/file_volume.cxx @@ -252,7 +252,7 @@ oslFileError osl_getVolumeInformation( rtl_uString* ustrDirectoryURL, oslVolumeI #else /* no statfs available */ # define __OSL_STATFS_STRUCT struct dummy {int i;} -# define __OSL_STATFS_INIT(a) ((void)0) +# define __OSL_STATFS_INIT(a) ((void)a) # define __OSL_STATFS(dir, sfs) (1) # define __OSL_STATFS_ISREMOTE(sfs) (0) # define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1) @@ -540,7 +540,7 @@ oslFileError osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle ) return osl_File_E_None; } -#ifndef MACOSX +#if !defined(MACOSX) && !defined(AIX) /***************************************** * osl_newVolumeDeviceHandleImpl @@ -1116,23 +1116,26 @@ osl_isFloppyMounted (oslVolumeDeviceHandleImpl* pDevice) * *****************************************************************************/ -#if (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) +#if (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(AIX)) static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath) { + (void)pszPath; return NULL; } #endif /* MACOSX */ -#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) +#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(AIX)) static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy) { + (void)hFloppy; return osl_File_E_BUSY; } #endif /* MACOSX */ -#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) +#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD) || defined(AIX)) static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy) { + (void)hFloppy; return osl_File_E_BUSY; } #endif /* MACOSX */ diff --git a/sal/osl/unx/interlck.c b/sal/osl/unx/interlck.c index dc1eade5f..436f6f5cf 100644 --- a/sal/osl/unx/interlck.c +++ b/sal/osl/unx/interlck.c @@ -93,7 +93,7 @@ oslInterlockedCount SAL_CALL osl_decrementInterlockedCount(oslInterlockedCount* return --nCount; } -#elif defined ( GCC ) && defined ( POWERPC ) +#elif defined ( GCC ) && defined ( POWERPC ) && !defined( AIX ) /*****************************************************************************/ /* osl_incrementInterlockedCount */ diff --git a/sal/osl/unx/makefile.mk b/sal/osl/unx/makefile.mk index 1dd47fb4d..d41a887b2 100644 --- a/sal/osl/unx/makefile.mk +++ b/sal/osl/unx/makefile.mk @@ -118,7 +118,7 @@ OBJFILES= $(OBJ)$/conditn.obj \ SLOFILES += $(SLO)$/osxlocale.obj .ENDIF -.IF "$(OS)"=="SOLARIS" || "$(OS)"=="FREEBSD" || "$(OS)"=="NETBSD" || "$(OS)$(CPU)"=="LINUXS" || "$(OS)"=="MACOSX" +.IF "$(OS)"=="SOLARIS" || "$(OS)"=="FREEBSD" || "$(OS)"=="NETBSD" || "$(OS)$(CPU)"=="LINUXS" || "$(OS)"=="MACOSX" || "$(OS)"=="AIX" SLOFILES += $(SLO)$/backtrace.obj OBJFILES += $(OBJ)$/backtrace.obj .ENDIF diff --git a/sal/osl/unx/module.c b/sal/osl/unx/module.c index ba859ec71..3a5533ff7 100644 --- a/sal/osl/unx/module.c +++ b/sal/osl/unx/module.c @@ -38,6 +38,10 @@ #include #endif +#ifdef AIX +#include +#endif + /* implemented in file.c */ extern int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32); @@ -201,6 +205,67 @@ osl_getFunctionSymbol(oslModule module, rtl_uString *puFunctionSymbolName) sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * addr, rtl_uString ** ppLibraryUrl) { sal_Bool result = sal_False; +#if defined(AIX) + int i; + int size = 4 * 1024; + char *buf, *filename=NULL; + struct ld_info *lp; + + if ((buf = malloc(size)) == NULL) + return result; + + while((i = loadquery(L_GETINFO, buf, size)) == -1 && errno == ENOMEM) + { + size += 4 * 1024; + if ((buf = malloc(size)) == NULL) + break; + } + + lp = (struct ld_info*) buf; + while (lp) + { + unsigned long start = (unsigned long)lp->ldinfo_dataorg; + unsigned long end = start + lp->ldinfo_datasize; + if (start <= (unsigned long)addr && end > (unsigned long)addr) + { + filename = lp->ldinfo_filename; + break; + } + if (!lp->ldinfo_next) + break; + lp = (struct ld_info*) ((char *) lp + lp->ldinfo_next); + } + + if (filename) + { + rtl_uString * workDir = NULL; + osl_getProcessWorkingDir(&workDir); + if (workDir) + { +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE("module.c::osl_getModuleURLFromAddress - %s\n", filaname); +#endif + rtl_string2UString(ppLibraryUrl, + filename, + strlen(filename), + osl_getThreadTextEncoding(), + OSTRING_TO_OUSTRING_CVTFLAGS); + + OSL_ASSERT(*ppLibraryUrl != NULL); + osl_getFileURLFromSystemPath(*ppLibraryUrl, ppLibraryUrl); + osl_getAbsoluteFileURL(workDir, *ppLibraryUrl, ppLibraryUrl); + + rtl_uString_release(workDir); + result = sal_True; + } + else + { + result = sal_False; + } + } + + free(buf); +#else Dl_info dl_info; if ((result = dladdr(addr, &dl_info)) != 0) @@ -230,6 +295,7 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress(void * addr, rtl_uString ** ppLibr result = sal_False; } } +#endif return result; } diff --git a/sal/osl/unx/nlsupport.c b/sal/osl/unx/nlsupport.c index 9fe944bfa..b1bab7275 100644 --- a/sal/osl/unx/nlsupport.c +++ b/sal/osl/unx/nlsupport.c @@ -924,7 +924,7 @@ int _imp_setProcessLocale( rtl_Locale * pLocale ) { /* only change env vars that exist already */ if( getenv( "LC_ALL" ) ) { -#if defined( FREEBSD ) || defined( NETBSD ) || defined( MACOSX ) +#if defined( FREEBSD ) || defined( NETBSD ) || defined( MACOSX ) || defined ( AIX ) setenv( "LC_ALL", locale_buf, 1); #else setenv( "LC_ALL", locale_buf ); @@ -932,7 +932,7 @@ int _imp_setProcessLocale( rtl_Locale * pLocale ) } if( getenv( "LC_CTYPE" ) ) { -#if defined( FREEBSD ) || defined( NETBSD ) || defined( MACOSX ) +#if defined( FREEBSD ) || defined( NETBSD ) || defined( MACOSX ) || defined ( AIX ) setenv("LC_CTYPE", locale_buf, 1 ); #else setenv( "LC_CTYPE", locale_buf ); @@ -940,7 +940,7 @@ int _imp_setProcessLocale( rtl_Locale * pLocale ) } if( getenv( "LANG" ) ) { -#if defined( FREEBSD ) || defined( NETBSD ) || defined( MACOSX ) +#if defined( FREEBSD ) || defined( NETBSD ) || defined( MACOSX ) || defined (AIX ) setenv("LC_CTYPE", locale_buf, 1 ); #else setenv( "LANG", locale_buf ); @@ -951,6 +951,6 @@ int _imp_setProcessLocale( rtl_Locale * pLocale ) return 0; } -#endif /* ifdef LINUX || SOLARIS || MACOSX || NETBSD */ +#endif /* ifdef LINUX || SOLARIS || MACOSX || NETBSD || AIX */ diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c index e756256d4..02f0208b8 100644 --- a/sal/osl/unx/process.c +++ b/sal/osl/unx/process.c @@ -70,7 +70,7 @@ #define MAX_ARGS 255 #define MAX_ENVS 255 -#if defined(MACOSX) || defined(IORESOURCE_TRANSFER_BSD) +#if defined(MACOSX) || defined(IORESOURCE_TRANSFER_BSD) || defined(AIX) #define CONTROLLEN (sizeof(struct cmsghdr) + sizeof(int)) #endif diff --git a/sal/osl/unx/security.c b/sal/osl/unx/security.c index 4dcef0383..92bc432ce 100644 --- a/sal/osl/unx/security.c +++ b/sal/osl/unx/security.c @@ -504,6 +504,9 @@ osl_psz_loginUser(const sal_Char* pszUserName, const sal_Char* pszPasswd, { #if defined NETBSD || defined SCO || defined AIX || defined FREEBSD || \ defined MACOSX + (void)pszUserName; + (void)pszPasswd; + (void)pSecurity; return osl_Security_E_None; diff --git a/sal/osl/unx/socket.c b/sal/osl/unx/socket.c index 7f7a2b2a6..847f3dc7e 100644 --- a/sal/osl/unx/socket.c +++ b/sal/osl/unx/socket.c @@ -802,6 +802,10 @@ static struct hostent* _osl_gethostbyname_r ( __error = gethostbyname_r (name, result, buffer, buflen, &__result, h_errnop); return __error ? NULL : __result ; +#elif defined(AIX) + *h_errnop = gethostbyname_r (name, result, (struct hostent_data *)buffer); + (void)buflen; + return *h_errnop ? NULL : result ; #else return gethostbyname_r( name, result, buffer, buflen, h_errnop); #endif diff --git a/sal/osl/unx/system.c b/sal/osl/unx/system.c index f70e83980..7d17f025a 100644 --- a/sal/osl/unx/system.c +++ b/sal/osl/unx/system.c @@ -485,6 +485,7 @@ pid_t getpid(void) #ifdef NO_PTHREAD_SEMAPHORES int sem_init(sem_t* sem, int pshared, unsigned int value) { + (void)pshared; pthread_mutex_init(&sem->mutex, PTHREAD_MUTEXATTR_DEFAULT); pthread_cond_init(&sem->increased, PTHREAD_CONDATTR_DEFAULT); diff --git a/sal/osl/unx/system.h b/sal/osl/unx/system.h index c7dec21a9..c86ed96dc 100644 --- a/sal/osl/unx/system.h +++ b/sal/osl/unx/system.h @@ -110,9 +110,13 @@ # include # include # if __BYTE_ORDER == __LITTLE_ENDIAN -# define _LITTLE_ENDIAN +# ifndef _LITTLE_ENDIAN +# define _LITTLE_ENDIAN +# endif # elif __BYTE_ORDER == __BIG_ENDIAN -# define _BIG_ENDIAN +# ifndef _BIG_ENDIAN +# define _BIG_ENDIAN +# endif # elif __BYTE_ORDER == __PDP_ENDIAN # define _PDP_ENDIAN # endif @@ -230,22 +234,25 @@ extern unsigned int nanosleep(unsigned int); # define AF_IPX -1 # include # include +# include # include # include # include # include # if BYTE_ORDER == LITTLE_ENDIAN -# define _LITTLE_ENDIAN +# ifndef _LITTLE_ENDIAN +# define _LITTLE_ENDIAN +# endif # elif BYTE_ORDER == BIG_ENDIAN -# define _BIG_ENDIAN +# ifndef _BIG_ENDIAN +# define _BIG_ENDIAN +# endif # elif BYTE_ORDER == PDP_ENDIAN # define _PDP_ENDIAN # endif -# define sched_yield() pthread_yield() # define SLEEP_TIMESPEC(timespec) nsleep(×pec, 0) # define LIBPATH "LIBPATH" # define NO_PTHREAD_SEMAPHORES -# define NO_DL_FUNCTIONS #endif #ifdef HPUX diff --git a/sal/osl/unx/tempfile.c b/sal/osl/unx/tempfile.c index 79730334e..1c3ec8f3a 100644 --- a/sal/osl/unx/tempfile.c +++ b/sal/osl/unx/tempfile.c @@ -66,16 +66,18 @@ oslFileError SAL_CALL osl_getTempDirURL( rtl_uString** pustrTempDir ) const char *pValue = getenv( "TEMP" ); if ( !pValue ) - { pValue = getenv( "TMP" ); -#if defined(SOLARIS) || defined (LINUX) || defined (FREEBSD) - if ( !pValue ) - pValue = P_tmpdir; -#elif defined(NETBSD) - if ( !pValue ) - pValue = _PATH_TMP; + +#if defined(NETBSD) + if ( !pValue ) + pValue = _PATH_TMP; +#else + if ( !pValue ) + pValue = P_tmpdir; #endif - } + + if ( !pValue ) + pValue = "/tmp"; #endif /* MACOSX */ if ( pValue ) diff --git a/sal/rtl/source/alloc.c b/sal/rtl/source/alloc.c index 5fdbec594..87c1b7540 100644 --- a/sal/rtl/source/alloc.c +++ b/sal/rtl/source/alloc.c @@ -75,7 +75,7 @@ static sal_Size __rtl_memory_vmpagesize (void) /* xBSD */ return (sal_Size)(getpagesize()); } -#elif defined(LINUX) || defined(SOLARIS) +#elif defined(LINUX) || defined(SOLARIS) || defined(AIX) static sal_Size __rtl_memory_vmpagesize (void) { /* POSIX */ @@ -87,7 +87,7 @@ static sal_Size __rtl_memory_vmpagesize (void) /* other */ return (sal_Size)(0x2000); } -#endif /* FREEBSD || NETBSD || MACOSX || LINUX || SOLARIS */ +#endif /* FREEBSD || NETBSD || MACOSX || LINUX || SOLARIS || AIX */ #ifndef PROT_HEAP #define PROT_HEAP (PROT_READ | PROT_WRITE | PROT_EXEC) diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c index e3ba39223..b7612bc6f 100644 --- a/sal/rtl/source/alloc_global.c +++ b/sal/rtl/source/alloc_global.c @@ -157,7 +157,7 @@ rtl_memory_init (void) Delegated the call to "rtl_memory_fini" into a dummy C++ object, see memory_fini.cxx . */ -#if defined(__GNUC__) && !defined(MACOSX) +#if defined(__GNUC__) && !defined(MACOSX) && !defined(AIX) static void rtl_memory_fini (void) __attribute__((destructor)); #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) #pragma fini(rtl_memory_fini) diff --git a/sal/rtl/source/macro.hxx b/sal/rtl/source/macro.hxx index 6899a2f1a..3374e97cf 100644 --- a/sal/rtl/source/macro.hxx +++ b/sal/rtl/source/macro.hxx @@ -50,6 +50,8 @@ #define THIS_OS "NetBSD" #elif defined FREEBSD #define THIS_OS "FreeBSD" +#elif defined AIX +#define THIS_OS "AIX" #endif #if ! defined THIS_OS diff --git a/sal/rtl/source/makefile.mk b/sal/rtl/source/makefile.mk index 517d2c2df..b8f401706 100644 --- a/sal/rtl/source/makefile.mk +++ b/sal/rtl/source/makefile.mk @@ -61,7 +61,9 @@ UWINAPILIB:= .IF "$(header)" == "" +.IF "$(OS)" != "AIX" ALWAYSDBGFILES=$(SLO)$/debugprint.obj +.ENDIF .IF "$(ALWAYSDBGFILES)" != "" ALWAYSDBGTARGET=do_it_alwaysdebug @@ -95,7 +97,7 @@ SLOFILES= \ $(SLO)$/alloc_cache.obj \ $(SLO)$/alloc_arena.obj -.IF "$(OS)"=="MACOSX" +.IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX" SLOFILES+=$(SLO)$/memory_fini.obj .ENDIF @@ -128,7 +130,7 @@ OBJFILES= \ $(OBJ)$/alloc_cache.obj \ $(OBJ)$/alloc_arena.obj -.IF "$(OS)"=="MACOSX" +.IF "$(OS)"=="MACOSX" || "$(OS)"=="AIX" OBJFILES+=$(OBJ)$/memory_fini.obj .ENDIF -- cgit v1.2.3