Changeset 93c2e0a
- Timestamp:
- Aug 11, 2018, 5:04:35 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- e765794
- Parents:
- a37133c
- Location:
- src/libcfa
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/bits/locks.h
ra37133c r93c2e0a 10 10 // Created On : Tue Oct 31 15:14:38 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 30 18:18:13201813 // Update Count : 912 // Last Modified On : Sat Aug 11 15:42:24 2018 13 // Update Count : 10 14 14 // 15 15 … … 50 50 struct { 51 51 // Align lock on 128-bit boundary 52 __ALIGN__ volatile _Bool lock;52 __ALIGN__ volatile bool lock; 53 53 }; 54 54 #ifdef __CFA_DEBUG__ … … 79 79 80 80 // Lock the spinlock, return false if already acquired 81 static inline _Bool try_lock ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) {82 _Bool result = (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0);81 static inline bool try_lock ( __spinlock_t & this __cfaabi_dbg_ctx_param2 ) { 82 bool result = (this.lock == 0) && (__atomic_test_and_set( &this.lock, __ATOMIC_ACQUIRE ) == 0); 83 83 if( result ) { 84 84 disable_interrupts(); -
src/libcfa/fstream
ra37133c r93c2e0a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 5 10:20:25201813 // Update Count : 13 112 // Last Modified On : Sat Aug 11 13:54:27 2018 13 // Update Count : 132 14 14 // 15 15 … … 21 21 struct ofstream { 22 22 void * file; 23 _Bool sepDefault;24 _Bool sepOnOff;25 _Bool sawNL;23 bool sepDefault; 24 bool sepOnOff; 25 bool sawNL; 26 26 const char * sepCur; 27 27 char separator[sepSize]; … … 30 30 31 31 // private 32 _Bool sepPrt( ofstream & );32 bool sepPrt( ofstream & ); 33 33 void sepReset( ofstream & ); 34 void sepReset( ofstream &, _Bool );34 void sepReset( ofstream &, bool ); 35 35 const char * sepGetCur( ofstream & ); 36 36 void sepSetCur( ofstream &, const char * ); 37 _Bool getNL( ofstream & );38 void setNL( ofstream &, _Bool );37 bool getNL( ofstream & ); 38 void setNL( ofstream &, bool ); 39 39 40 40 // public 41 41 void sepOn( ofstream & ); 42 42 void sepOff( ofstream & ); 43 _Bool sepDisable( ofstream & );44 _Bool sepEnable( ofstream & );43 bool sepDisable( ofstream & ); 44 bool sepEnable( ofstream & ); 45 45 46 46 const char * sepGet( ofstream & ); -
src/libcfa/fstream.c
ra37133c r93c2e0a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 5 17:02:56201813 // Update Count : 28 112 // Last Modified On : Fri Aug 10 18:19:40 2018 13 // Update Count : 284 14 14 // 15 15 … … 27 27 #define IO_MSG "I/O error: " 28 28 29 void ?{}( ofstream & os, void * file, _Bool sepDefault, _Bool sepOnOff, const char * separator, const char * tupleSeparator ) {29 void ?{}( ofstream & os, void * file, bool sepDefault, bool sepOnOff, const char * separator, const char * tupleSeparator ) { 30 30 os.file = file; 31 31 os.sepDefault = sepDefault; … … 37 37 38 38 // private 39 _Bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; }39 bool sepPrt( ofstream & os ) { setNL( os, false ); return os.sepOnOff; } 40 40 void sepReset( ofstream & os ) { os.sepOnOff = os.sepDefault; } 41 void sepReset( ofstream & os, _Bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; }41 void sepReset( ofstream & os, bool reset ) { os.sepDefault = reset; os.sepOnOff = os.sepDefault; } 42 42 const char * sepGetCur( ofstream & os ) { return os.sepCur; } 43 43 void sepSetCur( ofstream & os, const char * sepCur ) { os.sepCur = sepCur; } 44 _Bool getNL( ofstream & os ) { return os.sawNL; }45 void setNL( ofstream & os, _Bool state ) { os.sawNL = state; }44 bool getNL( ofstream & os ) { return os.sawNL; } 45 void setNL( ofstream & os, bool state ) { os.sawNL = state; } 46 46 47 47 // public … … 58 58 void sepOff( ofstream & os ) { os.sepOnOff = false; } 59 59 60 _Bool sepDisable( ofstream & os ) {61 _Bool temp = os.sepDefault;60 bool sepDisable( ofstream & os ) { 61 bool temp = os.sepDefault; 62 62 os.sepDefault = false; 63 63 sepReset( os ); … … 65 65 } // sepDisable 66 66 67 _Bool sepEnable( ofstream & os ) {68 _Bool temp = os.sepDefault;67 bool sepEnable( ofstream & os ) { 68 bool temp = os.sepDefault; 69 69 os.sepDefault = true; 70 70 if ( os.sepOnOff ) sepReset( os ); // start of line ? … … 96 96 void open( ofstream & os, const char * name, const char * mode ) { 97 97 FILE *file = fopen( name, mode ); 98 // if ( file == 0 ) { // do not change unless successful 99 // fprintf( stderr, IO_MSG "open output file \"%s\", ", name ); 100 // perror( 0 ); 101 // exit( EXIT_FAILURE ); 102 // } // if 98 #ifdef __CFA_DEBUG__ 99 if ( file == 0 ) { 100 fprintf( stderr, IO_MSG "open output file \"%s\", ", name ); 101 perror( 0 ); 102 exit( EXIT_FAILURE ); 103 } // if 104 #endif // __CFA_DEBUG__ 103 105 (os){ file, true, false, " ", ", " }; 104 106 } // open … … 178 180 void open( ifstream & is, const char * name, const char * mode ) { 179 181 FILE *file = fopen( name, mode ); 180 // if ( file == 0 ) { // do not change unless successful 181 // fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); 182 // perror( 0 ); 183 // exit( EXIT_FAILURE ); 184 // } // if 182 #ifdef __CFA_DEBUG__ 183 if ( file == 0 ) { 184 fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); 185 perror( 0 ); 186 exit( EXIT_FAILURE ); 187 } // if 188 #endif // __CFA_DEBUG__ 185 189 is.file = file; 186 190 } // open -
src/libcfa/heap.c
ra37133c r93c2e0a 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 31 18:08:50201813 // Update Count : 4 7012 // Last Modified On : Sat Aug 11 08:22:16 2018 13 // Update Count : 495 14 14 // 15 15 … … 75 75 76 76 77 static _Bool traceHeap = false;78 79 inline _Bool traceHeap() {77 static bool traceHeap = false; 78 79 inline bool traceHeap() { 80 80 return traceHeap; 81 81 } // traceHeap 82 82 83 _Bool traceHeapOn() {84 _Bool temp = traceHeap;83 bool traceHeapOn() { 84 bool temp = traceHeap; 85 85 traceHeap = true; 86 86 return temp; 87 87 } // traceHeapOn 88 88 89 _Bool traceHeapOff() {90 _Bool temp = traceHeap;89 bool traceHeapOff() { 90 bool temp = traceHeap; 91 91 traceHeap = false; 92 92 return temp; … … 94 94 95 95 96 static _Bool checkFree = false;97 98 inline _Bool checkFree() {96 static bool checkFree = false; 97 98 inline bool checkFree() { 99 99 return checkFree; 100 100 } // checkFree 101 101 102 _Bool checkFreeOn() {103 _Bool temp = checkFree;102 bool checkFreeOn() { 103 bool temp = checkFree; 104 104 checkFree = true; 105 105 return temp; 106 106 } // checkFreeOn 107 107 108 _Bool checkFreeOff() {109 _Bool temp = checkFree;108 bool checkFreeOff() { 109 bool temp = checkFree; 110 110 checkFree = false; 111 111 return temp; … … 113 113 114 114 115 // static _Bool traceHeapTerm = false;116 117 // inline _Bool traceHeapTerm() {115 // static bool traceHeapTerm = false; 116 117 // inline bool traceHeapTerm() { 118 118 // return traceHeapTerm; 119 119 // } // traceHeapTerm 120 120 121 // _Bool traceHeapTermOn() {122 // _Bool temp = traceHeapTerm;121 // bool traceHeapTermOn() { 122 // bool temp = traceHeapTerm; 123 123 // traceHeapTerm = true; 124 124 // return temp; 125 125 // } // traceHeapTermOn 126 126 127 // _Bool traceHeapTermOff() {128 // _Bool temp = traceHeapTerm;127 // bool traceHeapTermOff() { 128 // bool temp = traceHeapTerm; 129 129 // traceHeapTerm = false; 130 130 // return temp; … … 133 133 134 134 #ifdef __CFA_DEBUG__ 135 static unsigned int allocfree; // running total of allocations minus frees 136 static unsigned int appStart; // storage allocation when application starts 135 static unsigned int allocFree; // running total of allocations minus frees 137 136 138 137 static void checkUnfreed() { 139 unsigned int total = allocfree - appStart; 140 if ( total != 0 ) { 138 if ( allocFree != 0 ) { 141 139 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT. 142 140 // char helpText[512]; 143 // int len = snprintf( helpText, 512, "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"141 // int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n" 144 142 // "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n", 145 // (long int)getpid(), total, total); // always print the UNIX pid143 // (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid 146 144 // __cfaabi_dbg_bits_write( helpText, len ); 147 145 } // if … … 150 148 extern "C" { 151 149 void heapAppStart() { // called by __cfaabi_appready_startup 152 a ppStart = allocfree;150 allocFree = 0; 153 151 } // heapAppStart 154 152 155 153 void heapAppStop() { // called by __cfaabi_appready_startdown 154 fclose( stdin ); fclose( stdout ); 156 155 checkUnfreed(); 157 156 } // heapAppStop … … 191 190 #endif // LOCKFREE 192 191 }; 193 } real; 192 } real; // RealHeader 194 193 struct FakeHeader { 195 194 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ … … 202 201 uint32_t alignment; // low-order bits of home/blockSize used for tricks 203 202 #endif // __ORDER_BIG_ENDIAN__ 204 } fake; 205 } kind; 203 } fake; // FakeHeader 204 } kind; // Kind 206 205 } header; // Header 207 206 char pad[ALIGN - sizeof( Header )]; … … 264 263 265 264 #ifdef __CFA_DEBUG__ 266 static _Bool heapBoot = 0; // detect recursion during boot265 static bool heapBoot = 0; // detect recursion during boot 267 266 #endif // __CFA_DEBUG__ 268 267 static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing 269 268 270 269 271 static inline _Bool setMmapStart( size_t value ) {270 static inline bool setMmapStart( size_t value ) { 272 271 if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true; 273 272 mmapStart = value; // set global … … 363 362 static void printStats() { 364 363 char helpText[512]; 365 __cfaabi_dbg_bits_print_buffer( helpText, 512,364 __cfaabi_dbg_bits_print_buffer( helpText, sizeof(helpText), 366 365 "\nHeap statistics:\n" 367 366 " malloc: calls %u / storage %llu\n" … … 389 388 static int printStatsXML( FILE * stream ) { 390 389 char helpText[512]; 391 int len = snprintf( helpText, 512,390 int len = snprintf( helpText, sizeof(helpText), 392 391 "<malloc version=\"1\">\n" 393 392 "<heap nr=\"0\">\n" … … 433 432 434 433 435 static inline _Bool setHeapExpand( size_t value ) {434 static inline bool setHeapExpand( size_t value ) { 436 435 if ( heapExpand < pageSize ) return true; 437 436 heapExpand = value; … … 440 439 441 440 442 static inline void checkHeader( _Bool check, const char * name, void * addr ) {441 static inline void checkHeader( bool check, const char * name, void * addr ) { 443 442 if ( unlikely( check ) ) { // bad address ? 444 443 abort( "Attempt to %s storage %p with address outside the heap.\n" … … 463 462 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) )) 464 463 465 static inline _Bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {464 static inline bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) { 466 465 header = headerAddr( addr ); 467 466 … … 589 588 #ifdef __CFA_DEBUG__ 590 589 assert( ((uintptr_t)area & (libAlign() - 1)) == 0 ); // minimum alignment ? 591 __atomic_add_fetch( &alloc free, tsize, __ATOMIC_SEQ_CST );590 __atomic_add_fetch( &allocFree, tsize, __ATOMIC_SEQ_CST ); 592 591 if ( traceHeap() ) { 593 592 enum { BufferSize = 64 }; … … 646 645 647 646 #ifdef __CFA_DEBUG__ 648 __atomic_add_fetch( &alloc free, -size, __ATOMIC_SEQ_CST );647 __atomic_add_fetch( &allocFree, -size, __ATOMIC_SEQ_CST ); 649 648 if ( traceHeap() ) { 650 enum { BufferSize = 64 }; 651 char helpText[BufferSize]; 652 int len = snprintf( helpText, BufferSize, "Free( %p ) size:%zu\n", addr, size ); 649 char helpText[64]; 650 int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size ); 653 651 __cfaabi_dbg_bits_write( helpText, len ); 654 652 } // if … … 758 756 HeapManager.FreeHeader * freeElem; 759 757 size_t asize, alignment; 760 _Bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment );758 bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment ); 761 759 #ifndef __CFA_DEBUG__ 762 760 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. … … 781 779 HeapManager.FreeHeader * freeElem; 782 780 size_t asize; 783 _Bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment );781 bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment ); 784 782 #ifndef __CFA_DEBUG__ 785 783 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. … … 826 824 if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ? 827 825 assert( (header->kind.real.blockSize & 1) == 0 ); 828 _Bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment );826 bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment ); 829 827 #ifndef __CFA_DEBUG__ 830 828 // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero. … … 889 887 } // free 890 888 889 891 890 int mallopt( int option, int value ) { 892 891 choose( option ) { … … 929 928 930 929 931 _Bool malloc_zero_fill( void * addr ) {930 bool malloc_zero_fill( void * addr ) { 932 931 if ( unlikely( addr == 0 ) ) return false; // null allocation is not zero fill 933 932 HeapManager.Storage.Header * header = (HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ); -
src/libcfa/iostream
ra37133c r93c2e0a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S un Jul 1 12:12:22201813 // Update Count : 15 512 // Last Modified On : Sat Aug 11 08:22:49 2018 13 // Update Count : 156 14 14 // 15 15 … … 20 20 trait ostream( dtype ostype ) { 21 21 // private 22 _Bool sepPrt( ostype & ); // return separator state (on/off)22 bool sepPrt( ostype & ); // return separator state (on/off) 23 23 void sepReset( ostype & ); // set separator state to default state 24 void sepReset( ostype &, _Bool ); // set separator and default state24 void sepReset( ostype &, bool ); // set separator and default state 25 25 const char * sepGetCur( ostype & ); // get current separator string 26 26 void sepSetCur( ostype &, const char * ); // set current separator string 27 _Bool getNL( ostype & ); // check newline28 void setNL( ostype &, _Bool ); // saw newline27 bool getNL( ostype & ); // check newline 28 void setNL( ostype &, bool ); // saw newline 29 29 // public 30 30 void sepOn( ostype & ); // turn separator state on 31 31 void sepOff( ostype & ); // turn separator state off 32 _Bool sepDisable( ostype & ); // set default state to off, and return previous state33 _Bool sepEnable( ostype & ); // set default state to on, and return previous state32 bool sepDisable( ostype & ); // set default state to off, and return previous state 33 bool sepEnable( ostype & ); // set default state to on, and return previous state 34 34 35 35 const char * sepGet( ostype & ); // get separator string … … 57 57 58 58 forall( dtype ostype | ostream( ostype ) ) { 59 ostype & ?|?( ostype &, _Bool );59 ostype & ?|?( ostype &, bool ); 60 60 61 61 ostype & ?|?( ostype &, char ); … … 127 127 128 128 forall( dtype istype | istream( istype ) ) { 129 istype & ?|?( istype &, _Bool & );129 istype & ?|?( istype &, bool & ); 130 130 131 131 istype & ?|?( istype &, char & ); -
src/libcfa/iostream.c
ra37133c r93c2e0a 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 2 08:24:56201813 // Update Count : 47 112 // Last Modified On : Sat Aug 11 13:56:43 2018 13 // Update Count : 473 14 14 // 15 15 … … 27 27 28 28 forall( dtype ostype | ostream( ostype ) ) { 29 ostype & ?|?( ostype & os, _Bool b ) {29 ostype & ?|?( ostype & os, bool b ) { 30 30 if ( sepPrt( os ) ) fmt( os, "%s", sepGetCur( os ) ); 31 31 fmt( os, "%s", b ? "true" : "false" ); … … 275 275 276 276 forall( dtype istype | istream( istype ) ) { 277 istype & ?|?( istype & is, _Bool & b ) {277 istype & ?|?( istype & is, bool & b ) { 278 278 char val[6]; 279 279 fmt( is, "%5s", val ); … … 281 281 else if ( strcmp( val, "false" ) == 0 ) b = false; 282 282 else { 283 fprintf( stderr, "invalid _Boolconstant\n" );283 fprintf( stderr, "invalid Boolean constant\n" ); 284 284 abort(); 285 285 } // if -
src/libcfa/stdhdr/malloc.h
ra37133c r93c2e0a 10 10 // Created On : Thu Jul 20 15:58:16 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 31 10:01:10201813 // Update Count : 912 // Last Modified On : Sat Aug 11 09:06:31 2018 13 // Update Count : 10 14 14 // 15 15 … … 18 18 size_t default_heap_expansion(); 19 19 20 _Bool traceHeap();21 _Bool traceHeapOn();22 _Bool traceHeapOff();20 bool traceHeap(); 21 bool traceHeapOn(); 22 bool traceHeapOff(); 23 23 24 _Bool traceHeapTerm();25 _Bool traceHeapTermOn();26 _Bool traceHeapTermOff();24 bool traceHeapTerm(); 25 bool traceHeapTermOn(); 26 bool traceHeapTermOff(); 27 27 28 _Bool checkFree();29 _Bool checkFreeOn();30 _Bool checkFreeOff();28 bool checkFree(); 29 bool checkFreeOn(); 30 bool checkFreeOff(); 31 31 32 32 extern "C" { 33 33 size_t malloc_alignment( void * ); 34 _Bool malloc_zero_fill( void * );34 bool malloc_zero_fill( void * ); 35 35 int malloc_stats_fd( int fd ); 36 36 void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ); -
src/libcfa/time
ra37133c r93c2e0a 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 2 21:28:38201813 // Update Count : 64 112 // Last Modified On : Sat Aug 11 13:55:33 2018 13 // Update Count : 642 14 14 // 15 15 … … 52 52 Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; } 53 53 54 _Bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; }55 _Bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; }56 _Bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tv < rhs.tv; }57 _Bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; }58 _Bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tv > rhs.tv; }59 _Bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; }60 61 _Bool ?==?( Duration lhs, zero_t ) { return lhs.tv == 0; }62 _Bool ?!=?( Duration lhs, zero_t ) { return lhs.tv != 0; }63 _Bool ?<? ( Duration lhs, zero_t ) { return lhs.tv < 0; }64 _Bool ?<=?( Duration lhs, zero_t ) { return lhs.tv <= 0; }65 _Bool ?>? ( Duration lhs, zero_t ) { return lhs.tv > 0; }66 _Bool ?>=?( Duration lhs, zero_t ) { return lhs.tv >= 0; }54 bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; } 55 bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; } 56 bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tv < rhs.tv; } 57 bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; } 58 bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tv > rhs.tv; } 59 bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; } 60 61 bool ?==?( Duration lhs, zero_t ) { return lhs.tv == 0; } 62 bool ?!=?( Duration lhs, zero_t ) { return lhs.tv != 0; } 63 bool ?<? ( Duration lhs, zero_t ) { return lhs.tv < 0; } 64 bool ?<=?( Duration lhs, zero_t ) { return lhs.tv <= 0; } 65 bool ?>? ( Duration lhs, zero_t ) { return lhs.tv > 0; } 66 bool ?>=?( Duration lhs, zero_t ) { return lhs.tv >= 0; } 67 67 68 68 Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; } … … 106 106 timeval ?+?( timeval & lhs, timeval rhs ) { return (timeval)@{ lhs.tv_sec + rhs.tv_sec, lhs.tv_usec + rhs.tv_usec }; } 107 107 timeval ?-?( timeval & lhs, timeval rhs ) { return (timeval)@{ lhs.tv_sec - rhs.tv_sec, lhs.tv_usec - rhs.tv_usec }; } 108 _Bool ?==?( timeval lhs, timeval rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_usec == rhs.tv_usec; }109 _Bool ?!=?( timeval lhs, timeval rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_usec != rhs.tv_usec; }108 bool ?==?( timeval lhs, timeval rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_usec == rhs.tv_usec; } 109 bool ?!=?( timeval lhs, timeval rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_usec != rhs.tv_usec; } 110 110 } // distribution 111 111 … … 121 121 timespec ?+?( timespec & lhs, timespec rhs ) { return (timespec)@{ lhs.tv_sec + rhs.tv_sec, lhs.tv_nsec + rhs.tv_nsec }; } 122 122 timespec ?-?( timespec & lhs, timespec rhs ) { return (timespec)@{ lhs.tv_sec - rhs.tv_sec, lhs.tv_nsec - rhs.tv_nsec }; } 123 _Bool ?==?( timespec lhs, timespec rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_nsec == rhs.tv_nsec; }124 _Bool ?!=?( timespec lhs, timespec rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_nsec != rhs.tv_nsec; }123 bool ?==?( timespec lhs, timespec rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_nsec == rhs.tv_nsec; } 124 bool ?!=?( timespec lhs, timespec rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_nsec != rhs.tv_nsec; } 125 125 } // distribution 126 126 … … 166 166 Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; } 167 167 Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; } 168 _Bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; }169 _Bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; }170 _Bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; }171 _Bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; }172 _Bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; }173 _Bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; }168 bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; } 169 bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; } 170 bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; } 171 bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; } 172 bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; } 173 bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; } 174 174 } // distribution 175 175
Note: See TracChangeset
for help on using the changeset viewer.