Changeset 8e4aa05 for libcfa/src/fstream.cfa
- Timestamp:
- Mar 4, 2021, 7:40:25 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 77d601f
- Parents:
- 342af53 (diff), a5040fe (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/fstream.cfa
r342af53 r8e4aa05 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 19 16:24:54 202013 // Update Count : 38412 // Last Modified On : Mon Mar 1 21:12:15 2021 13 // Update Count : 424 14 14 // 15 15 … … 25 25 #include <errno.h> // errno 26 26 27 28 27 // *********************************** ofstream *********************************** 29 28 … … 38 37 os.$prt = false; 39 38 os.$sawNL = false; 39 os.$acquired = false; 40 40 $sepSetCur( os, sepGet( os ) ); 41 41 sepSet( os, " " ); … … 109 109 if ( &os == &exit ) exit( EXIT_FAILURE ); 110 110 if ( &os == &abort ) abort(); 111 if ( os.$acquired ) { os.$acquired = false; release( os ); } 111 112 } // ends 112 113 … … 171 172 } // fmt 172 173 174 inline void acquire( ofstream & os ) { 175 lock( os.$lock ); 176 if ( ! os.$acquired ) os.$acquired = true; 177 else unlock( os.$lock ); 178 } // acquire 179 180 inline void release( ofstream & os ) { 181 unlock( os.$lock ); 182 } // release 183 184 void ?{}( osacquire & acq, ofstream & os ) { &acq.os = &os; lock( os.$lock ); } 185 void ^?{}( osacquire & acq ) { release( acq.os ); } 186 173 187 static ofstream soutFile = { (FILE *)stdout }; 174 188 ofstream & sout = soutFile, & stdout = soutFile; … … 176 190 ofstream & serr = serrFile, & stderr = serrFile; 177 191 192 static ofstream lsoutFile = { (FILE *)stdout }; 193 ofstream & lsout = lsoutFile; 194 178 195 static ofstream exitFile = { (FILE *)stdout }; 179 196 ofstream & exit = exitFile; … … 189 206 is.$file = file; 190 207 is.$nlOnOff = false; 208 is.$acquired = false; 191 209 } // ?{} 192 210 … … 213 231 return is.$file == 0p || ferror( (FILE *)(is.$file) ); 214 232 } // fail 233 234 void ends( ifstream & is ) { 235 if ( is.$acquired ) { is.$acquired = false; release( is ); } 236 } // ends 215 237 216 238 int eof( ifstream & is ) { … … 279 301 } // fmt 280 302 303 inline void acquire( ifstream & is ) { 304 lock( is.$lock ); 305 if ( ! is.$acquired ) is.$acquired = true; 306 else unlock( is.$lock ); 307 } // acquire 308 309 inline void release( ifstream & is ) { 310 unlock( is.$lock ); 311 } // release 312 313 void ?{}( isacquire & acq, ifstream & is ) { &acq.is = &is; lock( is.$lock ); } 314 void ^?{}( isacquire & acq ) { release( acq.is ); } 315 281 316 static ifstream sinFile = { (FILE *)stdin }; 282 317 ifstream & sin = sinFile, & stdin = sinFile;
Note:
See TracChangeset
for help on using the changeset viewer.