Changeset 8a9a3ab for libcfa/src
- Timestamp:
- Sep 1, 2023, 3:54:42 PM (9 months ago)
- Branches:
- master
- Children:
- 4b30318b
- Parents:
- 4269d1b (diff), 4c0fa03 (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:
-
- 12 edited
- 18 moved
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/Makefile.am
r4269d1b r8a9a3ab 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Mon Aug 14 17:10:51202314 ## Update Count : 26 213 ## Last Modified On : Wed Aug 30 21:22:45 2023 14 ## Update Count : 263 15 15 ############################################################################### 16 16 … … 52 52 bits/algorithm.hfa \ 53 53 bits/align.hfa \ 54 bits/co ntainers.hfa \54 bits/collections.hfa \ 55 55 bits/debug.hfa \ 56 56 bits/defs.hfa \ … … 63 63 concurrency/iofwd.hfa \ 64 64 concurrency/barrier.hfa \ 65 co ntainers/array.hfa \66 co ntainers/list.hfa \67 co ntainers/lockfree.hfa \68 co ntainers/string_sharectx.hfa \69 co ntainers/vector2.hfa \65 collections/array.hfa \ 66 collections/list.hfa \ 67 collections/lockfree.hfa \ 68 collections/string_sharectx.hfa \ 69 collections/vector2.hfa \ 70 70 vec/vec.hfa \ 71 71 vec/vec2.hfa \ … … 89 89 bits/weakso_locks.hfa \ 90 90 algorithms/range_iterator.hfa \ 91 co ntainers/maybe.hfa \92 co ntainers/pair.hfa \93 co ntainers/result.hfa \94 co ntainers/string.hfa \95 co ntainers/string_res.hfa \96 co ntainers/vector.hfa \91 collections/maybe.hfa \ 92 collections/pair.hfa \ 93 collections/result.hfa \ 94 collections/string.hfa \ 95 collections/string_res.hfa \ 96 collections/vector.hfa \ 97 97 device/cpu.hfa 98 98 -
libcfa/src/bits/collections.hfa
r4269d1b r8a9a3ab 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // bits/co ntainers.hfa -- Intrusive generic containers.hfa7 // bits/collections.hfa -- Intrusive generic collections 8 8 // 9 9 // Author : Thierry Delisle 10 10 // Created On : Tue Oct 31 16:38:50 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:33:08202313 // Update Count : 2912 // Last Modified On : Wed Aug 30 21:26:39 2023 13 // Update Count : 30 14 14 15 15 #pragma once -
libcfa/src/bits/weakso_locks.hfa
r4269d1b r8a9a3ab 20 20 #include "bits/locks.hfa" 21 21 #include "bits/sequence.hfa" 22 #include "bits/co ntainers.hfa"23 #include "co ntainers/list.hfa"22 #include "bits/collections.hfa" 23 #include "collections/list.hfa" 24 24 25 25 struct select_node; -
libcfa/src/collections/maybe.cfa
r4269d1b r8a9a3ab 10 10 // Created On : Wed May 24 15:40:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 17 11:22:03 201913 // Update Count : 312 // Last Modified On : Wed Aug 30 21:26:55 2023 13 // Update Count : 4 14 14 // 15 15 16 #include <co ntainers/maybe.hfa>16 #include <collections/maybe.hfa> 17 17 #include <assert.h> 18 18 -
libcfa/src/collections/pair.cfa
r4269d1b r8a9a3ab 6 6 // Author : Aaron Moss 7 7 // Created On : Wed Apr 12 15:32:00 2017 8 // Last Modified By : Aaron Moss9 // Last Modified On : Wed A pr 12 15:32:00 201710 // Update Count : 18 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Wed Aug 30 21:27:12 2023 10 // Update Count : 2 11 11 // 12 12 13 #include <co ntainers/pair.hfa>13 #include <collections/pair.hfa> 14 14 15 15 forall(R, S -
libcfa/src/collections/result.cfa
r4269d1b r8a9a3ab 10 10 // Created On : Wed May 24 15:40:00 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 17 11:24:04 201913 // Update Count : 312 // Last Modified On : Wed Aug 30 21:27:22 2023 13 // Update Count : 4 14 14 // 15 15 16 #include <co ntainers/result.hfa>16 #include <collections/result.hfa> 17 17 #include <assert.h> 18 18 -
libcfa/src/collections/string.cfa
r4269d1b r8a9a3ab 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 28 19:00:45202313 // Update Count : 1 4612 // Last Modified On : Thu Aug 31 13:20:41 2023 13 // Update Count : 161 14 14 // 15 15 … … 118 118 } 119 119 120 static void readstr( ifstream & is, _Istream_str f, char fmtstr[], char cstr[] ) {121 int check = f.rwd - 1;122 123 if ( ! f.flags.rwd ) cstr[check] = '\0'; // insert sentinel124 int len = fmt( is, fmtstr, cstr );125 // fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, cstr[check], cstr );126 127 if ( ! f.flags.rwd && cstr[check] != '\0' ) // sentinel overwritten ?128 throw (cstring_length){ &cstring_length_vt };129 130 if ( f.flags.delimit ) { // getline ?131 if ( len == 0 ) cstr[0] = '\0'; // empty read => argument unchanged => set empty132 if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter133 } //if134 } // readstr135 136 120 ifstream & ?|?( ifstream & is, _Istream_str f ) { 137 121 // skip, same as for char * 138 122 if ( ! &f.s ) { 139 123 // fprintf( stderr, "skip %s %d\n", f.scanset, f.wd ); 140 if ( f. rwd == -1 ) fmt( is, f.scanset, "" ); // no input arguments141 else for ( f. rwd ) fmt( is, "%*c" );124 if ( f.wd == -1 ) fmt( is, f.scanset, "" ); // no input arguments 125 else for ( f.wd ) fmt( is, "%*c" ); 142 126 return is; 143 127 } // if 144 128 145 enum { gwd = 16 + 2, wd = gwd - 1 }; // guarded and unguarded width 129 // .---------------, 130 // | | | | |...|0|0| check and guard 131 // `---------------' 132 enum { gwd = 128 + 2, wd = gwd - 1 }; // guarded and unguarded width 146 133 char cstr[gwd]; // read in chunks 147 bool cont = false;; 148 149 if ( f.rwd == -1 ) f.rwd = wd; 150 const char * scanset = f.scanset;; 151 if ( f.flags.delimit ) scanset = f.delimit; // getline ? 152 153 size_t len = 0; 154 if ( scanset ) len = strlen( scanset ); 155 char fmtstr[len + 16]; 156 int start = 1; 157 fmtstr[0] = '%'; 158 if ( f.flags.ignore ) { fmtstr[1] = '*'; start += 1; } 159 if ( f.rwd != -1 ) { start += sprintf( &fmtstr[start], "%d", f.rwd ); } 160 161 if ( ! scanset ) { 162 // %s, %*s, %ws, %*ws 163 fmtstr[start] = 's'; fmtstr[start + 1] = '\0'; 164 // printf( "cstr %s\n", fmtstr ); 165 } else { 166 // incl %[xxx], %*[xxx], %w[xxx], %*w[xxx] 167 // excl %[^xxx], %*[^xxx], %w[^xxx], %*w[^xxx] 168 fmtstr[start] = '['; start += 1; 169 if ( f.flags.inex ) { fmtstr[start] = '^'; start += 1; } 170 strcpy( &fmtstr[start], scanset ); // copy includes '\0' 171 len += start; 172 fmtstr[len] = ']'; fmtstr[len + 1] = '\0'; 173 // printf( "incl/excl %s\n", fmtstr ); 174 } // if 134 bool cont = false; 135 136 if ( f.wd == -1 ) f.wd = wd; 137 _Istream_Cstr cfmt = { cstr, (_Istream_str_base)f }; 175 138 176 139 cstr[wd] = '\0'; // guard null terminate string 177 140 try { 178 readstr( is, f, fmtstr, cstr );141 is | cfmt; 179 142 } catch( cstring_length * ) { 180 143 cont = true; … … 185 148 cont = false; 186 149 try { 187 readstr( is, f, fmtstr, cstr );150 is | cfmt; 188 151 } catch( cstring_length * ) { 189 152 cont = true; // continue not allowed … … 199 162 } 200 163 201 // void getline( ifstream & in, string & str, const char delimit = '\n' ) {202 // // .---------------,203 // // | | | | |...|0|0| check and guard204 // // `---------------'205 // enum { gwd = 128 + 2, wd = gwd - 1 }; // guarded and unguarded width206 // char cstr[gwd]; // read in chunks207 // bool cont = false;;208 209 // cstr[wd] = '\0'; // guard null terminate string210 // try {211 // in | getline( wdi( wd, cstr ), delimit ); // must have room for string terminator212 // if ( eof( in ) ) return; // do not change argument213 // } catch( cstring_length * ) {214 // cont = true;215 // } finally {216 // str = cstr; // ok to initialize string217 // } // try218 // for ( ; cont; ) { // overflow read ?219 // cont = false;220 // try {221 // in | getline( wdi( wd, cstr ), delimit ); // must have room for string terminator222 // if ( eof( in ) ) return;223 // } catch( cstring_length * ) {224 // cont = true; // continue not allowed225 // } finally {226 // str += cstr; // build string chunk at a time227 // } // try228 // } // for229 // }230 231 164 //////////////////////////////////////////////////////// 232 165 // Slicing -
libcfa/src/collections/string.hfa
r4269d1b r8a9a3ab 10 10 // Created On : Fri Sep 03 11:00:00 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 28 18:32:59202313 // Update Count : 4 012 // Last Modified On : Thu Aug 31 11:47:27 2023 13 // Update Count : 49 14 14 // 15 15 … … 58 58 void ?|?( ifstream & in, string & this ); 59 59 60 61 60 struct _Istream_str { 62 61 string & s; 63 union { 64 const char * scanset; 65 char delimit[2]; 66 }; 67 int rwd; // read width 68 union { 69 unsigned char all; 70 struct { 71 unsigned char ignore:1; // do not change input argument 72 unsigned char inex:1; // include/exclude characters in scanset 73 unsigned char delimit:1; // delimit character 74 unsigned char rwd:1; // read width 75 } flags; 76 }; 62 inline _Istream_str_base; 77 63 }; // _Istream_str 78 64 79 65 static inline { 80 66 // read width does not include null terminator 81 _Istream_str wdi( unsigned int rwd, string & s ) { return (_Istream_str)@{ s, { 0p}, rwd, {.flags.rwd : true} }; }82 _Istream_str skip( const char scanset[] ) { return (_Istream_str)@{ *0p, { scanset}, -1, {.all : 0} }; }83 _Istream_str skip( unsigned int wd ) { return (_Istream_str)@{ *0p, { 0p}, wd, {.all : 0} }; }67 _Istream_str wdi( unsigned int rwd, string & s ) { return (_Istream_str)@{ s, {{0p}, rwd, {.flags.rwd : true}} }; } 68 _Istream_str skip( const char scanset[] ) { return (_Istream_str)@{ *0p, {{scanset}, -1, {.all : 0}} }; } 69 _Istream_str skip( unsigned int wd ) { return (_Istream_str)@{ *0p, {{0p}, wd, {.all : 0}} }; } 84 70 _Istream_str getline( string & s, const char delimit = '\n' ) { 85 return (_Istream_str)@{ s, { .delimit : { delimit, '\0' } }, -1, {.flags.delimit : true, .flags.inex : true} };71 return (_Istream_str)@{ s, {{.delimit : { delimit, '\0' } }, -1, {.flags.delimit : true, .flags.inex : true}} }; 86 72 } 87 73 _Istream_str & getline( _Istream_str & fmt, const char delimit = '\n' ) { 88 74 fmt.delimit[0] = delimit; fmt.delimit[1] = '\0'; fmt.flags.delimit = true; fmt.flags.inex = true; return fmt; 89 75 } 90 _Istream_str incl( const char scanset[], string & s ) { return (_Istream_str)@{ s, { scanset}, -1, {.flags.inex : false} }; }76 _Istream_str incl( const char scanset[], string & s ) { return (_Istream_str)@{ s, {{scanset}, -1, {.flags.inex : false}} }; } 91 77 _Istream_str & incl( const char scanset[], _Istream_str & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; } 92 _Istream_str excl( const char scanset[], string & s ) { return (_Istream_str)@{ s, { scanset}, -1, {.flags.inex : true} }; }78 _Istream_str excl( const char scanset[], string & s ) { return (_Istream_str)@{ s, {{scanset}, -1, {.flags.inex : true}} }; } 93 79 _Istream_str & excl( const char scanset[], _Istream_str & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; } 94 _Istream_str ignore( string & s ) { return (_Istream_str)@{ s, { 0p}, -1, {.flags.ignore : true} }; }80 _Istream_str ignore( string & s ) { return (_Istream_str)@{ s, {{0p}, -1, {.flags.ignore : true}} }; } 95 81 _Istream_str & ignore( _Istream_str & fmt ) { fmt.flags.ignore = true; return fmt; } 96 82 } // distribution 97 83 ifstream & ?|?( ifstream & is, _Istream_str f ); 98 84 void ?|?( ifstream & is, _Istream_str t ); 99 void getline( ifstream & in, string & this, const char delimit = '\n' );100 85 101 86 // Concatenation -
libcfa/src/collections/vector.cfa
r4269d1b r8a9a3ab 10 10 // Created On : Tue Jul 5 18:07:52 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 5 18:08:31 201613 // Update Count : 212 // Last Modified On : Wed Aug 30 21:27:31 2023 13 // Update Count : 3 14 14 // 15 15 16 #include <co ntainers/vector.hfa>16 #include <collections/vector.hfa> 17 17 18 18 #include <stdlib.hfa> -
libcfa/src/concurrency/alarm.hfa
r4269d1b r8a9a3ab 10 10 // Created On : Fri Jun 2 11:31:25 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 26 16:25:41 201813 // Update Count : 1 112 // Last Modified On : Wed Aug 30 21:27:40 2023 13 // Update Count : 12 14 14 // 15 15 … … 23 23 #include "time.hfa" 24 24 25 #include "co ntainers/list.hfa"25 #include "collections/list.hfa" 26 26 27 27 struct thread$; -
libcfa/src/concurrency/invoke.h
r4269d1b r8a9a3ab 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 13:39:31 202313 // Update Count : 5912 // Last Modified On : Wed Aug 30 21:27:51 2023 13 // Update Count : 60 14 14 // 15 15 16 16 // No not use #pragma once was this file is included twice in some places. It has its own guard system. 17 17 18 #include "bits/co ntainers.hfa"18 #include "bits/collections.hfa" 19 19 #include "bits/defs.hfa" 20 20 #include "bits/locks.hfa" … … 23 23 24 24 #ifdef __cforall 25 #include "co ntainers/list.hfa"25 #include "collections/list.hfa" 26 26 extern "C" { 27 27 #endif -
libcfa/src/concurrency/kernel.hfa
r4269d1b r8a9a3ab 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 4 12:29:26 202013 // Update Count : 2 212 // Last Modified On : Wed Aug 30 21:28:46 2023 13 // Update Count : 23 14 14 // 15 15 … … 20 20 #include "coroutine.hfa" 21 21 22 #include "co ntainers/list.hfa"22 #include "collections/list.hfa" 23 23 24 24 extern "C" { -
libcfa/src/concurrency/locks.hfa
r4269d1b r8a9a3ab 21 21 22 22 #include "bits/weakso_locks.hfa" 23 #include "co ntainers/lockfree.hfa"24 #include "co ntainers/list.hfa"23 #include "collections/lockfree.hfa" 24 #include "collections/list.hfa" 25 25 26 26 #include "limits.hfa" -
libcfa/src/concurrency/once.hfa
r4269d1b r8a9a3ab 16 16 #pragma once 17 17 18 #include "co ntainers/lockfree.hfa"18 #include "collections/lockfree.hfa" 19 19 #include "kernel/fwd.hfa" 20 20 -
libcfa/src/concurrency/select.hfa
r4269d1b r8a9a3ab 17 17 #pragma once 18 18 19 #include "co ntainers/list.hfa"19 #include "collections/list.hfa" 20 20 #include "alarm.hfa" 21 21 #include "kernel.hfa" -
libcfa/src/executor.baseline.txt
r4269d1b r8a9a3ab 5 5 6 6 #include <thread.hfa> 7 #include <co ntainers/list.hfa>7 #include <collections/list.hfa> 8 8 9 9 forall( T & | $dlistable(T, T) ) { -
libcfa/src/executor.cfa
r4269d1b r8a9a3ab 5 5 6 6 #include <thread.hfa> 7 #include <co ntainers/list.hfa>7 #include <collections/list.hfa> 8 8 9 9 forall( T &, TLink& = dlink(T) | embedded(T, TLink, dlink(T)) ) { -
libcfa/src/iostream.cfa
r4269d1b r8a9a3ab 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 28 13:36:16 202313 // Update Count : 15 2712 // Last Modified On : Thu Aug 31 11:27:56 2023 13 // Update Count : 1545 14 14 // 15 15 … … 971 971 } // if 972 972 973 int check = f.wd - 1; 974 const char * scanset = f.scanset;; 973 const char * scanset = f.scanset; 975 974 if ( f.flags.delimit ) scanset = f.delimit; // getline ? 976 977 // getline978 // if ( f.flags.delimit ) {979 // enum { size = 32 };980 // char fmtstr[size];981 // snprintf( fmtstr, size, "%%%d[^%c]s", f.wd, f.delimit );982 // if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel983 // int len = fmt( is, fmtstr, f.s ); // read upto delimiter984 // if ( ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ?985 // throw (cstring_length){ &cstring_length_vt };986 // if ( len == 0 ) f.s[0] = '\0'; // empty read => argument unchanged => set empty987 // // fprintf( stderr, "getline %s %s %d %d %d '%c'\n", fmtstr, f.s, len, f.wd, check, f.s[check] );988 // if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter989 // return is;990 // } // if991 975 992 976 size_t len = 0; … … 1013 997 } // if 1014 998 999 int check = f.wd - 1; 1015 1000 if ( ! f.flags.rwd ) f.s[check] = '\0'; // insert sentinel 1016 1001 len = fmt( is, fmtstr, f.s ); 1017 1002 //fprintf( stderr, "KK %s %zd %d %c %s\n", fmtstr, len, check, f.s[check], f.s ); 1003 1018 1004 if ( ! f.flags.rwd && f.s[check] != '\0' ) // sentinel overwritten ? 1019 1005 throw (cstring_length){ &cstring_length_vt }; 1020 1006 1021 1007 if ( f.flags.delimit ) { // getline ? 1022 1023 1008 if ( len == 0 ) f.s[0] = '\0'; // empty read => argument unchanged => set empty 1009 if ( ! eof( is ) ) fmt( is, "%*c" ); // ignore delimiter 1024 1010 } //if 1025 1011 return is; -
libcfa/src/iostream.hfa
r4269d1b r8a9a3ab 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Aug 25 14:55:06202313 // Update Count : 5 3512 // Last Modified On : Thu Aug 31 10:55:35 2023 13 // Update Count : 544 14 14 // 15 15 … … 406 406 // *********************************** manipulators *********************************** 407 407 408 struct _Istream_Cstr { 409 char * s; 408 struct _Istream_str_base { 410 409 union { 411 410 const char * scanset; … … 422 421 } flags; 423 422 }; 423 }; // _Istream_str_base 424 425 struct _Istream_Cstr { 426 char * s; 427 inline _Istream_str_base; 424 428 }; // _Istream_Cstr 425 429 426 430 static inline { 427 431 // width must include room for null terminator 428 _Istream_Cstr wdi( unsigned int wd, char s[] ) { return (_Istream_Cstr)@{ s, { 0p}, wd, {.all : 0} }; }432 _Istream_Cstr wdi( unsigned int wd, char s[] ) { return (_Istream_Cstr)@{ s, { {0p}, wd, {.all : 0} } }; } 429 433 // read width does not include null terminator 430 434 _Istream_Cstr wdi( unsigned int wd, unsigned int rwd, char s[] ) { 431 435 if ( wd <= rwd ) throw (cstring_length){ &cstring_length_vt }; 432 return (_Istream_Cstr)@{ s, { 0p}, rwd, {.flags.rwd : true} };436 return (_Istream_Cstr)@{ s, { {0p}, rwd, {.flags.rwd : true} } }; 433 437 } 434 _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr)@{ 0p, { scanset}, -1, {.all : 0} }; }435 _Istream_Cstr skip( unsigned int wd ) { return (_Istream_Cstr)@{ 0p, { 0p}, wd, {.all : 0} }; }438 _Istream_Cstr skip( const char scanset[] ) { return (_Istream_Cstr)@{ 0p, { {scanset}, -1, {.all : 0} } }; } 439 _Istream_Cstr skip( unsigned int wd ) { return (_Istream_Cstr)@{ 0p, { {0p}, wd, {.all : 0} } }; } 436 440 _Istream_Cstr & getline( _Istream_Cstr & fmt, const char delimit = '\n' ) { 437 441 fmt.delimit[0] = delimit; fmt.delimit[1] = '\0'; fmt.flags.delimit = true; fmt.flags.inex = true; return fmt; } 438 442 _Istream_Cstr & incl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = false; return fmt; } 439 443 _Istream_Cstr & excl( const char scanset[], _Istream_Cstr & fmt ) { fmt.scanset = scanset; fmt.flags.inex = true; return fmt; } 440 _Istream_Cstr ignore( char s[] ) { return (_Istream_Cstr)@{ s, { 0p}, -1, {.flags.ignore : true} }; }444 _Istream_Cstr ignore( char s[] ) { return (_Istream_Cstr)@{ s, { {0p}, -1, {.flags.ignore : true} } }; } 441 445 _Istream_Cstr & ignore( _Istream_Cstr & fmt ) { fmt.flags.ignore = true; return fmt; } 442 446 } // distribution
Note: See TracChangeset
for help on using the changeset viewer.