- Timestamp:
- Jun 24, 2020, 5:00:59 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- c953163
- Parents:
- 9791ab5 (diff), 7f9968ad (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:
- libcfa/src
- Files:
-
- 1 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/debug.cfa
r9791ab5 r8b58bae 10 10 // Created On : Thu Mar 30 12:30:01 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 13:03:16202013 // Update Count : 1 112 // Last Modified On : Wed Jun 17 11:07:13 2020 13 // Update Count : 12 14 14 // 15 15 16 extern "C" {17 16 #include <stdio.h> 18 17 #include <stdlib.h> … … 21 20 #include <stdarg.h> 22 21 #include <unistd.h> 23 }24 22 25 23 enum { buffer_size = 4096 }; -
libcfa/src/bits/signal.hfa
r9791ab5 r8b58bae 19 19 #include "bits/defs.hfa" 20 20 21 extern "C" {22 21 #include <errno.h> 23 22 #define __USE_GNU … … 26 25 #include <stdlib.h> 27 26 #include <string.h> 28 }29 27 30 28 // Short hands for signal context information -
libcfa/src/concurrency/alarm.cfa
r9791ab5 r8b58bae 10 10 // Created On : Fri Jun 2 11:31:25 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 08:41:36202013 // Update Count : 6912 // Last Modified On : Wed Jun 17 16:11:35 2020 13 // Update Count : 75 14 14 // 15 15 16 16 #define __cforall_thread__ 17 17 18 extern "C" {19 18 #include <errno.h> 20 19 #include <stdio.h> 20 #include <unistd.h> 21 21 #include <string.h> 22 #include <unistd.h>23 22 #include <sys/time.h> 24 }25 23 26 24 #include "alarm.hfa" … … 55 53 } 56 54 57 void ?{}( alarm_node_t & this, processor 55 void ?{}( alarm_node_t & this, processor * proc, Time alarm, Duration period ) with( this ) { 58 56 this.proc = proc; 59 57 this.alarm = alarm; -
libcfa/src/concurrency/preemption.cfa
r9791ab5 r8b58bae 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 5 16:34:05 201913 // Update Count : 4 312 // Last Modified On : Wed Jun 17 11:36:25 2020 13 // Update Count : 46 14 14 // 15 15 … … 19 19 #include <assert.h> 20 20 21 extern "C" {22 21 #include <errno.h> 23 22 #include <stdio.h> … … 25 24 #include <unistd.h> 26 25 #include <limits.h> // PTHREAD_STACK_MIN 27 }28 26 29 27 #include "bits/signal.hfa" -
libcfa/src/containers/stackLockFree.hfa
r9791ab5 r8b58bae 9 9 // Created On : Wed May 13 20:58:58 2020 10 10 // Last Modified By : Peter A. Buhr 11 // Last Modified On : Mon May 18 13:30:08202012 // Update Count : 5511 // Last Modified On : Sun Jun 14 13:25:09 2020 12 // Update Count : 64 13 13 // 14 14 … … 19 19 forall( dtype T ) 20 20 union Link { 21 struct { // 32/64-bit x 221 struct { // 32/64-bit x 2 22 22 T * volatile top; // pointer to stack top 23 uintptr_t count; // count each push23 uintptr_t count; // count each push 24 24 }; 25 25 #if __SIZEOF_INT128__ == 16 26 __int128 // gcc, 128-bit integer26 __int128 // gcc, 128-bit integer 27 27 #else 28 uint64_t // 64-bit integer28 uint64_t // 64-bit integer 29 29 #endif // __SIZEOF_INT128__ == 16 30 30 atom; 31 31 }; // Link 32 32 33 forall( otype T | { Link(T) * ?`next( T * ); } ) {33 forall( otype T | sized(T) | { Link(T) * ?`next( T * ); } ) { 34 34 struct StackLF { 35 35 Link(T) stack; … … 42 42 43 43 void push( StackLF(T) & this, T & n ) with(this) { 44 *( &n )`next = stack; // atomic assignment unnecessary, or use CAA 44 45 for () { // busy wait 45 *( &n )`next = stack; // atomic assignment unnecessary, or use CAA46 46 if ( __atomic_compare_exchange_n( &stack.atom, &( &n )`next->atom, (Link(T))@{ {&n, ( &n )`next->count + 1} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) break; // attempt to update top node 47 47 } // for … … 49 49 50 50 T * pop( StackLF(T) & this ) with(this) { 51 Link(T) t @= {};51 Link(T) t @= stack; // atomic assignment unnecessary, or use CAA 52 52 for () { // busy wait 53 t = stack; // atomic assignment unnecessary, or use CAA54 53 if ( t.top == 0p ) return 0p; // empty stack ? 55 54 if ( __atomic_compare_exchange_n( &stack.atom, &t.atom, (Link(T))@{ {( t.top )`next->top, t.count} }.atom, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) ) return t.top; // attempt to update top node -
libcfa/src/containers/vector.hfa
r9791ab5 r8b58bae 10 10 // Created On : Tue Jul 5 18:00:07 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 10:01:18 201713 // Update Count : 312 // Last Modified On : Wed Jun 17 11:02:46 2020 13 // Update Count : 4 14 14 // 15 15 16 16 #pragma once 17 17 18 extern "C" {19 18 #include <stdbool.h> 20 }21 19 22 20 //------------------------------------------------------------------------------ -
libcfa/src/fstream.cfa
r9791ab5 r8b58bae 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 7 19:01:01202013 // Update Count : 3 6312 // Last Modified On : Fri Jun 19 16:24:54 2020 13 // Update Count : 384 14 14 // 15 15 … … 26 26 27 27 28 // *********************************** ofstream ***********************************28 // *********************************** ofstream *********************************** 29 29 30 30 … … 123 123 #ifdef __CFA_DEBUG__ 124 124 if ( file == 0p ) { 125 abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 125 throw (Open_Failure){ os }; 126 // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno ); 126 127 } // if 127 128 #endif // __CFA_DEBUG__ … … 134 135 135 136 void close( ofstream & os ) { 136 if ( (FILE *)(os.$file) == stdout || (FILE *)(os.$file) == stderr ) return; 137 if ( (FILE *)(os.$file) == 0p ) return; 138 if ( (FILE *)(os.$file) == (FILE *)stdout || (FILE *)(os.$file) == (FILE *)stderr ) return; 137 139 138 140 if ( fclose( (FILE *)(os.$file) ) == EOF ) { 139 141 abort | IO_MSG "close output" | nl | strerror( errno ); 140 142 } // if 143 os.$file = 0p; 141 144 } // close 142 145 … … 179 182 180 183 181 // *********************************** ifstream ***********************************184 // *********************************** ifstream *********************************** 182 185 183 186 … … 219 222 #ifdef __CFA_DEBUG__ 220 223 if ( file == 0p ) { 221 abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 224 throw (Open_Failure){ is }; 225 // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno ); 222 226 } // if 223 227 #endif // __CFA_DEBUG__ … … 230 234 231 235 void close( ifstream & is ) { 232 if ( (FILE *)(is.$file) == stdin ) return; 236 if ( (FILE *)(is.$file) == 0p ) return; 237 if ( (FILE *)(is.$file) == (FILE *)stdin ) return; 233 238 234 239 if ( fclose( (FILE *)(is.$file) ) == EOF ) { 235 240 abort | IO_MSG "close input" | nl | strerror( errno ); 236 241 } // if 242 is.$file = 0p; 237 243 } // close 238 244 … … 276 282 ifstream & sin = sinFile, & stdin = sinFile; 277 283 284 285 // *********************************** exceptions *********************************** 286 287 288 void ?{}( Open_Failure & this, ofstream & ostream ) { 289 VTABLE_INIT(this, Open_Failure); 290 this.ostream = &ostream; 291 this.tag = 1; 292 } 293 void ?{}( Open_Failure & this, ifstream & istream ) { 294 VTABLE_INIT(this, Open_Failure); 295 this.istream = &istream; 296 this.tag = 0; 297 } 298 const char * Open_Failure_msg(Open_Failure * this) { 299 return "Open_Failure"; 300 } 301 VTABLE_INSTANCE(Open_Failure)(Open_Failure_msg); 302 void throwOpen_Failure( ofstream & ostream ) { 303 Open_Failure exc = { ostream }; 304 } 305 void throwOpen_Failure( ifstream & istream ) { 306 Open_Failure exc = { istream }; 307 } 308 278 309 // Local Variables: // 279 310 // tab-width: 4 // -
libcfa/src/fstream.hfa
r9791ab5 r8b58bae 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Feb 17 08:29:23202013 // Update Count : 1 7512 // Last Modified On : Fri Jun 19 16:29:17 2020 13 // Update Count : 189 14 14 // 15 15 … … 17 17 18 18 #include "iostream.hfa" 19 #include <exception.hfa> 19 20 20 21 21 // *********************************** ofstream ***********************************22 // *********************************** ofstream *********************************** 22 23 23 24 … … 78 79 79 80 80 // *********************************** ifstream ***********************************81 // *********************************** ifstream *********************************** 81 82 82 83 … … 106 107 extern ifstream & sin, & stdin; // aliases 107 108 109 110 // *********************************** exceptions *********************************** 111 112 113 DATA_EXCEPTION(Open_Failure)( 114 union { 115 ofstream * ostream; 116 ifstream * istream; 117 }; 118 // TEMPORARY: need polymorphic exceptions 119 int tag; // 1 => ostream; 0 => istream 120 ); 121 122 void ?{}( Open_Failure & this, ofstream & ostream ); 123 void ?{}( Open_Failure & this, ifstream & istream ); 124 108 125 // Local Variables: // 109 126 // mode: c // -
libcfa/src/heap.cfa
r9791ab5 r8b58bae 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed May 27 15:08:49202013 // Update Count : 77012 // Last Modified On : Sat Jun 13 22:42:15 2020 13 // Update Count : 805 14 14 // 15 15 … … 208 208 209 209 #if BUCKETLOCK == LOCKFREE 210 static inline Link(HeapManager.Storage) * ?`next( HeapManager.Storage * this ) { return &this->header.kind.real.next; } 211 static inline void ?{}( HeapManager.FreeHeader & ) {} 212 static inline void ^?{}( HeapManager.FreeHeader & ) {} 210 static inline { 211 Link(HeapManager.Storage) * ?`next( HeapManager.Storage * this ) { return &this->header.kind.real.next; } 212 void ?{}( HeapManager.FreeHeader & ) {} 213 void ^?{}( HeapManager.FreeHeader & ) {} 214 } // distribution 213 215 #endif // LOCKFREE 214 216 -
libcfa/src/iostream.cfa
r9791ab5 r8b58bae 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat May 2 18:30:25202013 // Update Count : 101 712 // Last Modified On : Fri Jun 19 16:15:34 2020 13 // Update Count : 1019 14 14 // 15 15 16 16 #include "iostream.hfa" 17 17 18 extern "C" {19 18 #include <stdio.h> 20 19 #include <stdbool.h> // true/false 21 20 #include <stdint.h> // UINT64_MAX 21 #include <float.h> // DBL_DIG, LDBL_DIG 22 #include <math.h> // isfinite 23 #include <complex.h> // creal, cimag 22 24 //#include <string.h> // strlen, strcmp 25 extern "C" { 23 26 extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); 24 27 extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); 25 28 extern char *strcpy (char *__restrict __dest, const char *__restrict __src) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 26 29 extern void *memcpy (void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); 27 #include <float.h> // DBL_DIG, LDBL_DIG28 #include <math.h> // isfinite29 #include <complex.h> // creal, cimag30 30 } // extern "C" 31 31 … … 33 33 34 34 35 // *********************************** ostream ***********************************35 // *********************************** ostream *********************************** 36 36 37 37 … … 447 447 } // distribution 448 448 449 // *********************************** manipulators ***********************************450 451 // *********************************** integral ***********************************449 // *********************************** manipulators *********************************** 450 451 // *********************************** integral *********************************** 452 452 453 453 static const char * shortbin[] = { "0", "1", "10", "11", "100", "101", "110", "111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111" }; … … 664 664 #endif // __SIZEOF_INT128__ 665 665 666 // *********************************** floating point ***********************************666 // *********************************** floating point *********************************** 667 667 668 668 #define PrintWithDP2( os, format, val, ... ) \ … … 720 720 FloatingPointFMTImpl( long double, "% *L ", "% *.*L " ) 721 721 722 // *********************************** character ***********************************722 // *********************************** character *********************************** 723 723 724 724 forall( dtype ostype | ostream( ostype ) ) { … … 753 753 } // distribution 754 754 755 // *********************************** C string ***********************************755 // *********************************** C string *********************************** 756 756 757 757 forall( dtype ostype | ostream( ostype ) ) { … … 800 800 801 801 802 // *********************************** istream ***********************************802 // *********************************** istream *********************************** 803 803 804 804 … … 946 946 } // distribution 947 947 948 // *********************************** manipulators ***********************************948 // *********************************** manipulators *********************************** 949 949 950 950 forall( dtype istype | istream( istype ) ) -
libcfa/src/iostream.hfa
r9791ab5 r8b58bae 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 20 15:30:56 202013 // Update Count : 33 712 // Last Modified On : Fri Jun 19 16:15:56 2020 13 // Update Count : 338 14 14 // 15 15 … … 19 19 20 20 21 // *********************************** ostream ***********************************21 // *********************************** ostream *********************************** 22 22 23 23 … … 156 156 } // distribution 157 157 158 // *********************************** manipulators ***********************************158 // *********************************** manipulators *********************************** 159 159 160 160 forall( otype T ) … … 175 175 }; // _Ostream_Manip 176 176 177 // *********************************** integral ***********************************177 // *********************************** integral *********************************** 178 178 179 179 // See 6.7.9. 19) The initialization shall occur in initializer list order, each initializer provided for a particular … … 217 217 #endif 218 218 219 // *********************************** floating point ***********************************219 // *********************************** floating point *********************************** 220 220 221 221 // Default suffix for values with no fraction is "." … … 246 246 FloatingPointFMTDecl( long double ) 247 247 248 // *********************************** character ***********************************248 // *********************************** character *********************************** 249 249 250 250 static inline { … … 263 263 } // ?|? 264 264 265 // *********************************** C string ***********************************265 // *********************************** C string *********************************** 266 266 267 267 static inline { … … 282 282 283 283 284 // *********************************** istream ***********************************284 // *********************************** istream *********************************** 285 285 286 286 … … 336 336 } // distribution 337 337 338 // *********************************** manipulators ***********************************338 // *********************************** manipulators *********************************** 339 339 340 340 struct _Istream_Cstr { … … 413 413 414 414 415 // *********************************** time ***********************************415 // *********************************** time *********************************** 416 416 417 417 -
libcfa/src/time.hfa
r9791ab5 r8b58bae 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 08:24:32202013 // Update Count : 6 5412 // Last Modified On : Wed Jun 17 16:13:00 2020 13 // Update Count : 663 14 14 // 15 15 … … 20 20 21 21 #include <time.h> // timespec 22 extern "C" {23 22 #include <sys/time.h> // timeval 24 }25 23 #include <time_t.hfa> // Duration/Time types 26 24 … … 91 89 int64_t ?`w( Duration dur ) { return dur.tn / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); } 92 90 91 double ?`dns( Duration dur ) { return dur.tn; } 92 double ?`dus( Duration dur ) { return dur.tn / ((double)TIMEGRAN / 1_000_000.); } 93 double ?`dms( Duration dur ) { return dur.tn / ((double)TIMEGRAN / 1_000.); } 94 double ?`ds( Duration dur ) { return dur.tn / (double)TIMEGRAN; } 95 double ?`dm( Duration dur ) { return dur.tn / (60. * TIMEGRAN); } 96 double ?`dh( Duration dur ) { return dur.tn / (60. * 60. * (double)TIMEGRAN); } 97 double ?`dd( Duration dur ) { return dur.tn / (24. * 60. * 60. * (double)TIMEGRAN); } 98 double ?`dw( Duration dur ) { return dur.tn / (7. * 24. * 60. * 60. * (double)TIMEGRAN); } 99 93 100 Duration max( Duration lhs, Duration rhs ) { return (lhs.tn < rhs.tn) ? rhs : lhs;} 94 101 Duration min( Duration lhs, Duration rhs ) { return !(rhs.tn < lhs.tn) ? lhs : rhs;}
Note:
See TracChangeset
for help on using the changeset viewer.