diff --git a/ftk/Makefile b/ftk/Makefile index 9e9493b..71d8597 100644 --- a/ftk/Makefile +++ b/ftk/Makefile @@ -1343,29 +1343,38 @@ libs: status clean dircheck $(ftk_static_lib) $(ftk_shared_lib) # -- *.cpp -> *$(obj_suffix) -- ifdef win_target -define cpp_to_obj_template -$$($(1)_obj_dir)/%$$(obj_suffix) : %.cpp - $$(ec)$$(compiler) $$(ccflags) /Fo$$(call hostpath,$$@) $$(call hostpath,$$<) -endef +$(lib_obj_dir)/%$(obj_suffix) : %.cpp + $(ec)$(compiler) $(ccflags) /Fo$(call hostpath,$@) $(call hostpath,$<) endif -ifdef unix_target -define cpp_to_obj_template -$$($(1)_obj_dir)/%$$(obj_suffix) : %.cpp - $$(ec)$$(gprintf) "$$<\n" - $$(ec)$$(compiler) $$(ccflags) -c $$< -o $$@ -endef +ifdef win_target +$(test_obj_dir)/%$(obj_suffix) : %.cpp + $(ec)$(compiler) $(ccflags) /Fo$(call hostpath,$@) $(call hostpath,$<) endif ifdef netware_target -define cpp_to_obj_template -$$($(1)_obj_dir)/%$(obj_suffix) : %.cpp - $$(ec)$$(gprintf) "$$(notdir $$(strip $$@))\n" - $$(ec)$$(call hostpath,$$(compiler)) $$(call hostpath,$$<) /fo=$$(call hostpath,$$@) -endef +$(lib_obj_dir)/%$(obj_suffix) : %.cpp + $(ec)$(gprintf) "$(notdir $(strip $@))\n" + $(ec)$(call hostpath,$(compiler)) $(call hostpath,$<) /fo=$(call hostpath,$@) endif -$(foreach tmpl,lib test,$(eval $(call cpp_to_obj_template,$(tmpl)))) +ifdef netware_target +$(test_obj_dir)/%$(obj_suffix) : %.cpp + $(ec)$(gprintf) "$(notdir $(strip $@))\n" + $(ec)$(call hostpath,$(compiler)) $(call hostpath,$<) /fo=$(call hostpath,$@) +endif + +ifdef unix_target +$(lib_obj_dir)/%$(obj_suffix) : %.cpp + $(ec)$(gprintf) "$<\n" + $(ec)$(compiler) $(ccflags) -c $< -o $@ +endif + +ifdef unix_target +$(test_obj_dir)/%$(obj_suffix) : %.cpp + $(ec)$(gprintf) "$<\n" + $(ec)$(compiler) $(ccflags) -c $< -o $@ +endif # -- ftk.lib and libftk.a -- diff --git a/ftk/src/ftk.h b/ftk/src/ftk.h index 04d135a..5c67bb0 100644 --- a/ftk/src/ftk.h +++ b/ftk/src/ftk.h @@ -42,6 +42,7 @@ #undef FLM_LINUX #undef FLM_SOLARIS #undef FLM_SPARC + #undef FLM_SPARC_PLUS #undef FLM_HPUX #undef FLM_OSX #undef FLM_BIG_ENDIAN @@ -111,6 +112,9 @@ #define FLM_SPARC #define FLM_BIG_ENDIAN #define FLM_STRICT_ALIGNMENT + #if defined( __sparcv8plus) || defined( __sparcv9) + #define FLM_SPARC_PLUS + #endif #endif #elif defined( sun) #define FLM_SOLARIS @@ -120,6 +124,9 @@ #if defined( sparc) || defined( __sparc) || defined( __sparc__) #define FLM_SPARC #define FLM_BIG_ENDIAN + #if defined( __sparcv8plus) || defined( __sparcv9) + #define FLM_SPARC_PLUS + #endif #endif #elif defined( __hpux) || defined( hpux) #define FLM_HPUX diff --git a/ftk/src/ftkmisc.cpp b/ftk/src/ftkmisc.cpp index 6fb009f..01b20a4 100644 --- a/ftk/src/ftkmisc.cpp +++ b/ftk/src/ftkmisc.cpp @@ -1214,7 +1214,7 @@ FLMINT32 FLMAPI f_atomicInc( { return( (FLMINT32)OSAtomicIncrement32( (int32_t *)piTarget)); } - #elif defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) + #elif defined( FLM_SOLARIS) && defined( FLM_SPARC_PLUS) && !defined( FLM_GNUC) { return( sparc_atomic_add_32( piTarget, 1)); } @@ -1263,7 +1263,7 @@ FLMINT32 FLMAPI f_atomicDec( { return( (FLMINT32)OSAtomicDecrement32( (int32_t *)piTarget)); } - #elif defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) + #elif defined( FLM_SOLARIS) && defined( FLM_SPARC_PLUS) && !defined( FLM_GNUC) { return( sparc_atomic_add_32( piTarget, -1)); } @@ -1335,7 +1335,7 @@ FLMINT32 FLMAPI f_atomicExchange( return( (FLMINT32)iOldVal); } - #elif defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) + #elif defined( FLM_SOLARIS) && defined( FLM_SPARC_PLUS) && !defined( FLM_GNUC) { return( sparc_atomic_xchg_32( piTarget, i32NewVal)); } diff --git a/ftk/src/ftksem.cpp b/ftk/src/ftksem.cpp index 658863e..28ad29b 100644 --- a/ftk/src/ftksem.cpp +++ b/ftk/src/ftksem.cpp @@ -191,7 +191,7 @@ void FLMAPI f_mutexDestroy( /**************************************************************************** Desc: ****************************************************************************/ -#if defined( FLM_SOLARIS) +#if defined( FLM_SOLARIS) void FLMAPI f_mutexDestroy( F_MUTEX * phMutex) { @@ -491,8 +491,6 @@ FINLINE int _sema_timedwait( unsigned int msecs) { int iErr = 0; - struct timeval now; - struct timespec abstime; // If timeout is F_SEM_WAITFOREVER, do sem_wait. @@ -502,20 +500,26 @@ FINLINE int _sema_timedwait( return( iErr); } - gettimeofday( &now, NULL); - abstime.tv_sec = now.tv_sec + ((msecs) ? (msecs / 1000) : 0); - abstime.tv_nsec = ( now.tv_usec + ((msecs % 1000) * 1000)) * 1000; - -Restart: - - if( (iErr = sema_timedwait( pSem, &abstime)) != 0) + for( ;;) { - if( iErr == EINTR) + if( (iErr = sema_trywait( pSem)) != 0) { - iErr = 0; - goto Restart; + if( iErr == EINTR) + { + iErr = 0; + } + + f_sleep( f_min( msecs, 10)); + msecs -= f_min( msecs, 10); + + if( !msecs) + { + iErr = -1; + goto Exit; + } + + continue; } - goto Exit; } Exit: @@ -605,11 +609,11 @@ RCODE f_semWait( f_assert( hSem != F_SEM_NULL); - //catch the F_SEM_WAITFOREVER flag so we can directly call _sema_wait - //instead of passing F_SEM_WAITFOREVER through to _sema_timedwait. - //Note that on AIX the datatype of the uiTimeout (in the timespec - //struct) is surprisingly a signed int, which makes this catch - //essential. + // Catch the F_SEM_WAITFOREVER flag so we can directly call _sema_wait + // instead of passing F_SEM_WAITFOREVER through to _sema_timedwait. + // Note that on AIX the datatype of the uiTimeout (in the timespec + // struct) is surprisingly a signed int, which makes this catch + // essential. if( uiTimeout == F_SEM_WAITFOREVER) { diff --git a/ftk/src/ftksys.h b/ftk/src/ftksys.h index 8c11161..efcee2c 100644 --- a/ftk/src/ftksys.h +++ b/ftk/src/ftksys.h @@ -183,7 +183,7 @@ /********************************************************************** Desc: **********************************************************************/ - #if defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) + #if defined( FLM_SOLARIS) && defined( FLM_SPARC_PLUS) && !defined( FLM_GNUC) extern "C" FLMINT32 sparc_atomic_add_32( volatile FLMINT32 * piTarget, FLMINT32 iDelta); @@ -192,7 +192,7 @@ /********************************************************************** Desc: **********************************************************************/ - #if defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) + #if defined( FLM_SOLARIS) && defined( FLM_SPARC_PLUS) && !defined( FLM_GNUC) extern "C" FLMINT32 sparc_atomic_xchg_32( volatile FLMINT32 * piTarget, FLMINT32 iNewValue); diff --git a/ftk/src/ftkunix.cpp b/ftk/src/ftkunix.cpp index 7a2d7ad..e0c8d7a 100644 --- a/ftk/src/ftkunix.cpp +++ b/ftk/src/ftkunix.cpp @@ -1693,7 +1693,7 @@ FLMUINT f_getFSBlockSize( /**************************************************************************** Desc: ****************************************************************************/ -#if defined( FLM_SOLARIS) && defined( FLM_SPARC) && !defined( FLM_GNUC) +#if defined( FLM_SOLARIS) && defined( FLM_SPARC_PLUS) && !defined( FLM_GNUC) static void sparc_asm_code( void) { asm( ".align 8");