Changeset 3d560060 for src/libcfa/bits
- Timestamp:
- Nov 30, 2017, 3:05:25 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 557435e, 5da9d6a
- Parents:
- dd9b59e (diff), c2b9f21 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/libcfa/bits
- Files:
-
- 1 added
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/bits/align.h
rdd9b59e r3d560060 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // libdebug.h --7 // align.h -- 8 8 // 9 9 // Author : Thierry Delisle -
src/libcfa/bits/containers.h
rdd9b59e r3d560060 15 15 #pragma once 16 16 17 #include "bits/align.h" 17 18 #include "bits/defs.h" 18 #include "libhdr.h"19 19 20 20 //----------------------------------------------------------------------------- -
src/libcfa/bits/debug.c
rdd9b59e r3d560060 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // libdebug.c --7 // debug.c -- 8 8 // 9 9 // Author : Thierry Delisle … … 28 28 extern "C" { 29 29 30 void __ lib_debug_write( const char *in_buffer, int len ) {30 void __cfaabi_dbg_bits_write( const char *in_buffer, int len ) { 31 31 // ensure all data is written 32 32 for ( int count = 0, retcode; count < len; count += retcode ) { … … 44 44 } 45 45 46 void __ lib_debug_acquire() __attribute__((__weak__)) {}47 void __ lib_debug_release() __attribute__((__weak__)) {}46 void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {} 47 void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {} 48 48 49 void __ lib_debug_print_safe ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) {49 void __cfaabi_dbg_bits_print_safe ( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) { 50 50 va_list args; 51 51 52 52 va_start( args, fmt ); 53 __ lib_debug_acquire();53 __cfaabi_dbg_bits_acquire(); 54 54 55 55 int len = vsnprintf( buffer, buffer_size, fmt, args ); 56 __ lib_debug_write( buffer, len );56 __cfaabi_dbg_bits_write( buffer, len ); 57 57 58 __ lib_debug_release();58 __cfaabi_dbg_bits_release(); 59 59 va_end( args ); 60 60 } 61 61 62 void __ lib_debug_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) {62 void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format (printf, 1, 2) )) { 63 63 va_list args; 64 64 … … 66 66 67 67 int len = vsnprintf( buffer, buffer_size, fmt, args ); 68 __ lib_debug_write( buffer, len );68 __cfaabi_dbg_bits_write( buffer, len ); 69 69 70 70 va_end( args ); 71 71 } 72 72 73 void __ lib_debug_print_vararg( const char fmt[], va_list args ) {73 void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) { 74 74 int len = vsnprintf( buffer, buffer_size, fmt, args ); 75 __ lib_debug_write( buffer, len );75 __cfaabi_dbg_bits_write( buffer, len ); 76 76 } 77 77 78 void __ lib_debug_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) )) {78 void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format (printf, 3, 4) )) { 79 79 va_list args; 80 80 … … 82 82 83 83 int len = vsnprintf( in_buffer, in_buffer_size, fmt, args ); 84 __ lib_debug_write( in_buffer, len );84 __cfaabi_dbg_bits_write( in_buffer, len ); 85 85 86 86 va_end( args ); -
src/libcfa/bits/defs.h
rdd9b59e r3d560060 32 32 #define __cfa_anonymous_object __cfa_anonymous_object 33 33 #endif 34 35 #ifdef __cforall 36 extern "C" { 37 #endif 38 void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)); 39 #ifdef __cforall 40 } 41 #endif -
src/libcfa/bits/locks.h
rdd9b59e r3d560060 16 16 #pragma once 17 17 18 #include "bits/debug.h" 18 19 #include "bits/defs.h" 19 20 #include "libhdr.h"21 20 22 21 // pause to prevent excess processor bus usage … … 65 64 66 65 // Lock the spinlock, return false if already acquired 67 static inline _Bool try_lock ( __spinlock_t & this DEBUG_CTX_PARAM2 ) {66 static inline _Bool try_lock ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) { 68 67 _Bool result = __lock_test_and_test_and_set( this.lock ); 69 LIB_DEBUG_DO(68 __cfaabi_dbg_debug_do( 70 69 if( result ) { 71 70 this.prev_name = caller; … … 77 76 78 77 // Lock the spinlock, spin if already acquired 79 static inline void lock( __spinlock_t & this DEBUG_CTX_PARAM2 ) {78 static inline void lock( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) { 80 79 #ifndef NOEXPBACK 81 80 enum { SPIN_START = 4, SPIN_END = 64 * 1024, }; … … 98 97 #endif 99 98 } 100 LIB_DEBUG_DO(99 __cfaabi_dbg_debug_do( 101 100 this.prev_name = caller; 102 101 this.prev_thrd = this_thread; … … 105 104 106 105 // Lock the spinlock, spin if already acquired 107 static inline void lock_yield( __spinlock_t & this DEBUG_CTX_PARAM2 ) {106 static inline void lock_yield( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) { 108 107 for ( unsigned int i = 1;; i += 1 ) { 109 108 if ( __lock_test_and_test_and_set( this.lock ) ) break; 110 109 yield( i ); 111 110 } 112 LIB_DEBUG_DO(111 __cfaabi_dbg_debug_do( 113 112 this.prev_name = caller; 114 113 this.prev_thrd = this_thread;
Note: See TracChangeset
for help on using the changeset viewer.