Changeset 13f066d for libcfa/src
- Timestamp:
- Mar 4, 2023, 1:35:31 PM (22 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 231e1ae
- Parents:
- 1e38178 (diff), a8667ab (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:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/cluster.cfa
r1e38178 r13f066d 69 69 } 70 70 71 #if defined(CFA_HAVE_LINUX_LIBRSEQ)72 // No forward declaration needed73 #define __kernel_rseq_register rseq_register_current_thread74 #define __kernel_rseq_unregister rseq_unregister_current_thread75 #elif defined(CFA_HAVE_LINUX_RSEQ_H)76 static void __kernel_raw_rseq_register (void);77 static void __kernel_raw_rseq_unregister(void);78 79 #define __kernel_rseq_register __kernel_raw_rseq_register80 #define __kernel_rseq_unregister __kernel_raw_rseq_unregister81 #else82 // No forward declaration needed83 // No initialization needed84 static inline void noop(void) {}85 86 #define __kernel_rseq_register noop87 #define __kernel_rseq_unregister noop88 #endif89 90 71 //======================================================================= 91 72 // Cluster wide reader-writer lock … … 110 91 // Lock-Free registering/unregistering of threads 111 92 unsigned register_proc_id( void ) with(__scheduler_lock.lock) { 112 __kernel_rseq_register();113 114 93 bool * handle = (bool *)&kernelTLS().sched_lock; 115 94 … … 161 140 162 141 __atomic_store_n(cell, 0p, __ATOMIC_RELEASE); 163 164 __kernel_rseq_unregister();165 142 } 166 143 … … 504 481 /* paranoid */ verify( mock_head(this) == this.l.prev ); 505 482 } 506 507 #if defined(CFA_HAVE_LINUX_LIBRSEQ)508 // No definition needed509 #elif defined(CFA_HAVE_LINUX_RSEQ_H)510 511 #if defined( __x86_64 ) || defined( __i386 )512 #define RSEQ_SIG 0x53053053513 #elif defined( __ARM_ARCH )514 #ifdef __ARMEB__515 #define RSEQ_SIG 0xf3def5e7 /* udf #24035 ; 0x5de3 (ARMv6+) */516 #else517 #define RSEQ_SIG 0xe7f5def3 /* udf #24035 ; 0x5de3 */518 #endif519 #endif520 521 extern void __disable_interrupts_hard();522 extern void __enable_interrupts_hard();523 524 static void __kernel_raw_rseq_register (void) {525 /* paranoid */ verify( __cfaabi_rseq.cpu_id == RSEQ_CPU_ID_UNINITIALIZED );526 527 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, (sigset_t *)0p, _NSIG / 8);528 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), 0, RSEQ_SIG);529 if(ret != 0) {530 int e = errno;531 switch(e) {532 case EINVAL: abort("KERNEL ERROR: rseq register invalid argument");533 case ENOSYS: abort("KERNEL ERROR: rseq register no supported");534 case EFAULT: abort("KERNEL ERROR: rseq register with invalid argument");535 case EBUSY : abort("KERNEL ERROR: rseq register already registered");536 case EPERM : abort("KERNEL ERROR: rseq register sig argument on unregistration does not match the signature received on registration");537 default: abort("KERNEL ERROR: rseq register unexpected return %d", e);538 }539 }540 }541 542 static void __kernel_raw_rseq_unregister(void) {543 /* paranoid */ verify( __cfaabi_rseq.cpu_id >= 0 );544 545 // int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, (sigset_t *)0p, _NSIG / 8);546 int ret = syscall(__NR_rseq, &__cfaabi_rseq, sizeof(struct rseq), RSEQ_FLAG_UNREGISTER, RSEQ_SIG);547 if(ret != 0) {548 int e = errno;549 switch(e) {550 case EINVAL: abort("KERNEL ERROR: rseq unregister invalid argument");551 case ENOSYS: abort("KERNEL ERROR: rseq unregister no supported");552 case EFAULT: abort("KERNEL ERROR: rseq unregister with invalid argument");553 case EBUSY : abort("KERNEL ERROR: rseq unregister already registered");554 case EPERM : abort("KERNEL ERROR: rseq unregister sig argument on unregistration does not match the signature received on registration");555 default: abort("KERNEL ERROR: rseq unregisteunexpected return %d", e);556 }557 }558 }559 #else560 // No definition needed561 #endif -
libcfa/src/concurrency/kernel/private.hfa
r1e38178 r13f066d 10 10 // Created On : Mon Feb 13 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 12 08:21:33 202013 // Update Count : 912 // Last Modified On : Thu Mar 2 16:04:46 2023 13 // Update Count : 11 14 14 // 15 15 … … 29 29 30 30 extern "C" { 31 #if defined(CFA_HAVE_LINUX_LIBRSEQ)32 #include <rseq/rseq.h>33 #elif defined(CFA_HAVE_LINUX_RSEQ_H)34 #include <linux/rseq.h>35 #else36 #ifndef _GNU_SOURCE37 #error kernel/private requires gnu_source38 #endif39 31 #include <sched.h> 40 #endif41 32 } 42 33 … … 110 101 // Hardware 111 102 112 #if defined(CFA_HAVE_LINUX_LIBRSEQ)113 // No data needed114 #elif defined(CFA_HAVE_LINUX_RSEQ_H)115 extern "Cforall" {116 extern __attribute__((aligned(64))) __thread volatile struct rseq __cfaabi_rseq;117 }118 #else119 // No data needed120 #endif121 122 103 static inline int __kernel_getcpu() { 123 104 /* paranoid */ verify( ! __preemption_enabled() ); 124 #if defined(CFA_HAVE_LINUX_LIBRSEQ)125 return rseq_current_cpu();126 #elif defined(CFA_HAVE_LINUX_RSEQ_H)127 int r = __cfaabi_rseq.cpu_id;128 /* paranoid */ verify( r >= 0 );129 return r;130 #else131 105 return sched_getcpu(); 132 #endif133 106 } 134 107 -
libcfa/src/concurrency/kernel/startup.cfa
r1e38178 r13f066d 147 147 __scheduler_RWLock_t __scheduler_lock @= { 0 }; 148 148 149 #if defined(CFA_HAVE_LINUX_LIBRSEQ)150 // No data needed151 #elif defined(CFA_HAVE_LINUX_RSEQ_H)152 extern "Cforall" {153 __attribute__((aligned(64))) __thread volatile struct rseq __cfaabi_rseq @= {154 .cpu_id : RSEQ_CPU_ID_UNINITIALIZED,155 };156 }157 #else158 // No data needed159 #endif160 161 149 //----------------------------------------------------------------------------- 162 150 // Struct to steal stack -
libcfa/src/containers/array.hfa
r1e38178 r13f066d 9 9 10 10 11 // 12 // Single-dim array sruct (with explicit packing and atom) 13 // 14 11 // 12 // The `array` macro is the public interface. 13 // It computes the type of a dense (trivially strided) array. 14 // All user-declared objects are dense arrays. 15 // 16 // The `arpk` (ARray with PacKing info explicit) type is, generally, a slice with _any_ striding. 17 // This type is meant for internal use. 18 // CFA programmers should not instantiate it directly, nor access its field. 19 // CFA programmers should call ?[?] on it. 20 // Yet user-given `array(stuff)` expands to `arpk(stuff')`. 21 // The comments here explain the resulting internals. 22 // 23 // Just as a plain-C "multidimesional" array is really array-of-array-of-..., 24 // so does arpk generally show up as arpk-of-arpk-of... 25 // 26 // In the example of `array(float, 3, 4, 5) a;`, 27 // `typeof(a)` is an `arpk` instantiation. 28 // These comments explain _its_ arguments, i.e. those of the topmost `arpk` level. 29 // 30 // [N] : the number of elements in `a`; 3 in the example 31 // S : carries the stride size (distance in bytes between &myA[0] and &myA[1]), in sizeof(S); 32 // same as Timmed when striding is trivial, same as Timmed in the example 33 // Timmed : (T-immediate) the inner type; conceptually, `typeof(a)` is "arpk of Timmed"; 34 // array(float, 4, 5) in the example 35 // Tbase : (T-base) the deepest element type that is not arpk; float in the example 36 // 15 37 forall( [N], S & | sized(S), Timmed &, Tbase & ) { 38 39 // 40 // Single-dim array sruct (with explicit packing and atom) 41 // 16 42 struct arpk { 17 43 S strides[N]; -
libcfa/src/interpose.cfa
r1e38178 r13f066d 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 24 15:31:03202313 // Update Count : 1 8512 // Last Modified On : Thu Mar 2 13:56:26 2023 13 // Update Count : 191 14 14 // 15 15 … … 53 53 54 54 static generic_fptr_t interpose_symbol( const char symbol[], const char version[] ) { 55 static void * library; 56 static void * pthread_library; 57 55 void * library; 56 #if defined( RTLD_NEXT ) 57 library = RTLD_NEXT; 58 #else 59 library = dlopen( "libc.so.6", RTLD_LAZY ); 58 60 if ( ! library ) { 59 library = dlopen( "libc.so.6", RTLD_LAZY );60 61 const char * error = dlerror(); 61 62 if ( error ) { … … 63 64 } // if 64 65 } // if 65 if ( ! pthread_library ) { 66 pthread_library = dlopen( "libpthread.so", RTLD_LAZY ); 67 const char * error = dlerror(); 68 if ( error ) { 69 abort( "interpose_symbol : failed to open libpthread, %s\n", error ); 70 } // if 71 } // if 66 #endif 72 67 73 68 return do_interpose_symbol(library, symbol, version); … … 108 103 109 104 if(__cfathreadabi_interpose_startup) __cfathreadabi_interpose_startup( do_interpose_symbol ); 105 106 // SKULLDUGGERY: In Ubuntu 22.04, someone augmented signal.h to allow SIGSTKSZ to be "sysconf(_SC_SIGSTKSZ)" in 107 // sigstksz.h, as well as 8192 in sigstack.h. HOWEVER, they forgot to provide a mechanism to tell signal.h to 108 // use sigstack.h rather than sigstksz.h. (I'm not happy.) By undefining _GNU_SOURCE before signal.h and 109 // redefining it afterwards, you can get 8192, but then nothing works correctly inside of signal.h without 110 // _GNU_SOURCE defined. So what is needed is a way to get signal.h to use sigstack.h WITH _GNU_SOURCE defined. 111 // Basically something is wrong with features.h and its use in signal.h. 112 113 #undef SIGSTKSZ 114 #define SIGSTKSZ 8192 110 115 111 116 // As a precaution (and necessity), errors that result in termination are delivered on a separate stack because -
libcfa/src/interpose_thread.cfa
r1e38178 r13f066d 39 39 const char version[] 40 40 ) libcfa_public { 41 static void * library; 41 void * library; 42 #if defined( RTLD_NEXT ) 43 library = RTLD_NEXT; 44 #else 45 // missing RTLD_NEXT => must hard-code library name, assuming libstdc++ 46 library = dlopen( "libthread_db.so", RTLD_LAZY ); 42 47 if ( ! library ) { 43 library = dlopen( "libpthread.so", RTLD_LAZY );44 48 const char * error = dlerror(); 45 49 if ( error ) { … … 47 51 } 48 52 } // if 53 #endif // RTLD_NEXT 49 54 50 55 return do_interpose_symbol(library, symbol, version);
Note: See TracChangeset
for help on using the changeset viewer.