Changeset 87e0b015
- Timestamp:
- May 6, 2020, 2:25:16 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:
- 5dadc9b7, be91ab4
- Parents:
- cb870e0 (diff), 171ca0d (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:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/locks.hfa
rcb870e0 r87e0b015 112 112 #endif 113 113 114 extern "C" { 115 char * strerror(int); 116 } 117 #define CHECKED(x) { int err = x; if( err != 0 ) abort("KERNEL ERROR: %s\n", strerror(err)); } 118 114 119 struct __bin_sem_t { 115 120 pthread_mutex_t lock; … … 119 124 120 125 static inline void ?{}(__bin_sem_t & this) with( this ) { 121 pthread_mutex_init(&lock, NULL); 122 pthread_cond_init (&cond, NULL); 126 // Create the mutex with error checking 127 pthread_mutexattr_t mattr; 128 pthread_mutexattr_init( &mattr ); 129 pthread_mutexattr_settype( &mattr, PTHREAD_MUTEX_ERRORCHECK_NP); 130 pthread_mutex_init(&lock, &mattr); 131 132 pthread_cond_init (&cond, 0p); 123 133 val = 0; 124 134 } 125 135 126 136 static inline void ^?{}(__bin_sem_t & this) with( this ) { 127 pthread_mutex_destroy(&lock);128 pthread_cond_destroy (&cond);137 CHECKED( pthread_mutex_destroy(&lock) ); 138 CHECKED( pthread_cond_destroy (&cond) ); 129 139 } 130 140 131 141 static inline void wait(__bin_sem_t & this) with( this ) { 132 142 verify(__cfaabi_dbg_in_kernel()); 133 pthread_mutex_lock(&lock);143 CHECKED( pthread_mutex_lock(&lock) ); 134 144 while(val < 1) { 135 145 pthread_cond_wait(&cond, &lock); 136 146 } 137 147 val -= 1; 138 pthread_mutex_unlock(&lock);148 CHECKED( pthread_mutex_unlock(&lock) ); 139 149 } 140 150 … … 142 152 bool needs_signal = false; 143 153 144 pthread_mutex_lock(&lock);154 CHECKED( pthread_mutex_lock(&lock) ); 145 155 if(val < 1) { 146 156 val += 1; … … 148 158 needs_signal = true; 149 159 } 150 pthread_mutex_unlock(&lock);160 CHECKED( pthread_mutex_unlock(&lock) ); 151 161 152 162 return needs_signal; 153 163 } 164 165 #undef CHECKED 154 166 #endif -
libcfa/src/concurrency/io.cfa
rcb870e0 r87e0b015 1007 1007 bool has_user_level_blocking( fptr_t func ) { 1008 1008 #if defined(HAVE_LINUX_IO_URING_H) 1009 if( /*func == (fptr_t)preadv2 || */1010 func == (fptr_t)cfa_preadv2 )1011 #define _CFA_IO_FEATURE_IORING_OP_READV ,1012 return IS_DEFINED(IORING_OP_READV);1013 1014 1009 #if defined(HAVE_PREADV2) 1010 if( /*func == (fptr_t)preadv2 || */ 1011 func == (fptr_t)cfa_preadv2 ) 1012 #define _CFA_IO_FEATURE_IORING_OP_READV , 1013 return IS_DEFINED(IORING_OP_READV); 1014 #endif 1015 1016 #if defined(HAVE_PWRITEV2) 1015 1017 if( /*func == (fptr_t)pwritev2 || */ 1016 1018 func == (fptr_t)cfa_pwritev2 ) … … 1019 1021 #endif 1020 1022 1021 #if defined(HAVE_PWRITEV2) 1022 if( /*func == (fptr_t)fsync || */ 1023 func == (fptr_t)cfa_fsync ) 1024 #define _CFA_IO_FEATURE_IORING_OP_FSYNC , 1025 return IS_DEFINED(IORING_OP_FSYNC); 1026 #endif 1023 if( /*func == (fptr_t)fsync || */ 1024 func == (fptr_t)cfa_fsync ) 1025 #define _CFA_IO_FEATURE_IORING_OP_FSYNC , 1026 return IS_DEFINED(IORING_OP_FSYNC); 1027 1027 1028 1028 if( /*func == (fptr_t)ync_file_range || */ -
libcfa/src/concurrency/kernel.cfa
rcb870e0 r87e0b015 250 250 } 251 251 252 pthread_join( kernel_thread, 0p ); 252 int err = pthread_join( kernel_thread, 0p ); 253 if( err != 0 ) abort("KERNEL ERROR: joining processor %p caused error %s\n", &this, strerror(err)); 254 253 255 free( this.stack ); 254 256 } … … 824 826 // Destroy the main processor and its context in reverse order of construction 825 827 // These were manually constructed so we need manually destroy them 828 void ^?{}(processor & this) with( this ){ 829 /* paranoid */ verify( this.do_terminate == true ); 830 } 831 826 832 ^(*mainProcessor){}; 827 833
Note: See TracChangeset
for help on using the changeset viewer.