diff options
Diffstat (limited to 'winsup/cygwin/lib')
-rw-r--r-- | winsup/cygwin/lib/_cygwin_crt0_common.cc | 73 | ||||
-rw-r--r-- | winsup/cygwin/lib/pthreadconst.S | 17 |
2 files changed, 85 insertions, 5 deletions
diff --git a/winsup/cygwin/lib/_cygwin_crt0_common.cc b/winsup/cygwin/lib/_cygwin_crt0_common.cc index d356a50..a22528a 100644 --- a/winsup/cygwin/lib/_cygwin_crt0_common.cc +++ b/winsup/cygwin/lib/_cygwin_crt0_common.cc @@ -22,6 +22,18 @@ details. */ #define REAL_ZDAPV _SYMSTR (__real__ZdaPv) #define REAL_ZDLPV_NOTHROW_T _SYMSTR (__real__ZdlPvRKSt9nothrow_t) #define REAL_ZDAPV_NOTHROW_T _SYMSTR (__real__ZdaPvRKSt9nothrow_t) +#define REAL_ZDLPVM _SYMSTR (__real__ZdlPvm) +#define REAL_ZDAPVM _SYMSTR (__real__ZdaPvm) +#define REAL_ZNWX_ALIGN_VAL_T "__real__ZnwmSt11align_val_t" +#define REAL_ZNAX_ALIGN_VAL_T "__real__ZnamSt11align_val_t" +#define REAL_ZDLPV_ALIGN_VAL_T _SYMSTR (__real__ZdlPvSt11align_val_t) +#define REAL_ZDAPV_ALIGN_VAL_T _SYMSTR (__real__ZdaPvSt11align_val_t) +#define REAL_ZDLPVM_ALIGN_VAL_T _SYMSTR (__real__ZdlPvmSt11align_val_t) +#define REAL_ZDAPVM_ALIGN_VAL_T _SYMSTR (__real__ZdaPvmSt11align_val_t) +#define REAL_ZNWX_ALIGN_VAL_T_NOTHROW_T "__real__ZnwmSt11align_val_tRKSt9nothrow_t" +#define REAL_ZNAX_ALIGN_VAL_T_NOTHROW_T "__real__ZnamSt11align_val_tRKSt9nothrow_t" +#define REAL_ZDLPV_ALIGN_VAL_T_NOTHROW_T _SYMSTR (__real__ZdlPvSt11align_val_tRKSt9nothrow_t) +#define REAL_ZDAPV_ALIGN_VAL_T_NOTHROW_T _SYMSTR (__real__ZdaPvSt11align_val_tRKSt9nothrow_t) /* Use asm names to bypass the --wrap that is being applied to redirect all other references to these operators toward the redirectors in the Cygwin DLL; this @@ -43,6 +55,30 @@ extern WEAK void operator delete(void *p, const std::nothrow_t &nt) noexcept (tr __asm__ (REAL_ZDLPV_NOTHROW_T); extern WEAK void operator delete[](void *p, const std::nothrow_t &nt) noexcept (true) __asm__ (REAL_ZDAPV_NOTHROW_T); +extern WEAK void operator delete(void *p, std::size_t sz) noexcept (true) + __asm__ (REAL_ZDLPVM); +extern WEAK void operator delete[](void *p, std::size_t sz) noexcept (true) + __asm__ (REAL_ZDAPVM); +extern WEAK void *operator new(std::size_t sz, std::align_val_t al) noexcept (false) + __asm__ (REAL_ZNWX_ALIGN_VAL_T); +extern WEAK void *operator new[](std::size_t sz, std::align_val_t al) noexcept (false) + __asm__ (REAL_ZNAX_ALIGN_VAL_T); +extern WEAK void operator delete(void *p, std::align_val_t al) noexcept (true) + __asm__ (REAL_ZDLPV_ALIGN_VAL_T); +extern WEAK void operator delete[](void *p, std::align_val_t al) noexcept (true) + __asm__ (REAL_ZDAPV_ALIGN_VAL_T); +extern WEAK void operator delete(void *p, std::size_t sz, std::align_val_t al) noexcept (true) + __asm__ (REAL_ZDLPVM_ALIGN_VAL_T); +extern WEAK void operator delete[](void *p, std::size_t sz, std::align_val_t al) noexcept (true) + __asm__ (REAL_ZDAPVM_ALIGN_VAL_T); +extern WEAK void *operator new(std::size_t sz, std::align_val_t al, const std::nothrow_t &nt) noexcept (true) + __asm__ (REAL_ZNWX_ALIGN_VAL_T_NOTHROW_T); +extern WEAK void *operator new[](std::size_t sz, std::align_val_t al, const std::nothrow_t &nt) noexcept (true) + __asm__ (REAL_ZNAX_ALIGN_VAL_T_NOTHROW_T); +extern WEAK void operator delete(void *p, std::align_val_t al, const std::nothrow_t &nt) noexcept (true) + __asm__ (REAL_ZDLPV_ALIGN_VAL_T_NOTHROW_T); +extern WEAK void operator delete[](void *p, std::align_val_t al, const std::nothrow_t &nt) noexcept (true) + __asm__ (REAL_ZDAPV_ALIGN_VAL_T_NOTHROW_T); /* Avoid an info message from linker when linking applications. */ extern __declspec(dllimport) struct _reent *_impure_ptr; @@ -65,6 +101,17 @@ struct per_process_cxx_malloc __cygwin_cxx_malloc = { &(operator new), &(operator new[]), &(operator delete), &(operator delete[]), + /* nothrow new/delete */ + &(operator new), &(operator new[]), + &(operator delete), &(operator delete[]), + /* C++14 sized delete */ + &(operator delete), &(operator delete[]), + /* C++17 aligned new/delete */ + &(operator new), &(operator new[]), + &(operator delete), &(operator delete[]), + /* aligned + sized delete */ + &(operator delete), &(operator delete[]), + /* aligned + nothrow new/delete */ &(operator new), &(operator new[]), &(operator delete), &(operator delete[]) }; @@ -77,6 +124,8 @@ _cygwin_crt0_common (MainFunc f, per_process *u) { per_process *newu = (per_process *) cygwin_internal (CW_USER_DATA); bool uwasnull; + bool new_dll_with_additional_operators = + CYGWIN_VERSION_CHECK_FOR_CXX17_OVERLOADS (newu); /* u is non-NULL if we are in a DLL, and NULL in the main exe. newu is the Cygwin DLL's internal per_process and never NULL. */ @@ -129,12 +178,13 @@ _cygwin_crt0_common (MainFunc f, per_process *u) /* Likewise for the C++ memory operators, if any, but not if we were dlopen()'d, as we might get dlclose()'d and that would leave stale function pointers behind. */ - if (newu && newu->cxx_malloc && !__dynamically_loaded) + if (!__dynamically_loaded) { /* Inherit what we don't override. */ #define CONDITIONALLY_OVERRIDE(MEMBER) \ - if (!__cygwin_cxx_malloc.MEMBER) \ - __cygwin_cxx_malloc.MEMBER = newu->cxx_malloc->MEMBER; + if (__cygwin_cxx_malloc.MEMBER) \ + newu->cxx_malloc->MEMBER = __cygwin_cxx_malloc.MEMBER; + CONDITIONALLY_OVERRIDE(oper_new); CONDITIONALLY_OVERRIDE(oper_new__); CONDITIONALLY_OVERRIDE(oper_delete); @@ -143,8 +193,21 @@ _cygwin_crt0_common (MainFunc f, per_process *u) CONDITIONALLY_OVERRIDE(oper_new___nt); CONDITIONALLY_OVERRIDE(oper_delete_nt); CONDITIONALLY_OVERRIDE(oper_delete___nt); - /* Now update the resulting set into the global redirectors. */ - *newu->cxx_malloc = __cygwin_cxx_malloc; + if (new_dll_with_additional_operators) + { + CONDITIONALLY_OVERRIDE(oper_delete_sz); + CONDITIONALLY_OVERRIDE(oper_delete___sz); + CONDITIONALLY_OVERRIDE(oper_new_al); + CONDITIONALLY_OVERRIDE(oper_new___al); + CONDITIONALLY_OVERRIDE(oper_delete_al); + CONDITIONALLY_OVERRIDE(oper_delete___al); + CONDITIONALLY_OVERRIDE(oper_delete_sz_al); + CONDITIONALLY_OVERRIDE(oper_delete___sz_al); + CONDITIONALLY_OVERRIDE(oper_new_al_nt); + CONDITIONALLY_OVERRIDE(oper_new___al_nt); + CONDITIONALLY_OVERRIDE(oper_delete_al_nt); + CONDITIONALLY_OVERRIDE(oper_delete___al_nt); + } } /* Setup the module handle so fork can get the path name. */ diff --git a/winsup/cygwin/lib/pthreadconst.S b/winsup/cygwin/lib/pthreadconst.S new file mode 100644 index 0000000..6e55a83 --- /dev/null +++ b/winsup/cygwin/lib/pthreadconst.S @@ -0,0 +1,17 @@ +#if defined(__i386__) +# define SYM(x) _##x +#else +# define SYM(x) x +#endif + +/* these should all be too low to ever be valid addresses */ +.globl SYM(__pthread_recursive_mutex_initializer_np) +.set __pthread_recursive_mutex_initializer_np, 18 +.globl SYM(__pthread_normal_mutex_initializer_np) +.set __pthread_normal_mutex_initializer_np, 19 +.globl SYM(__pthread_errorcheck_mutex_initializer_np) +.set __pthread_errorcheck_mutex_initializer_np, 20 +.globl SYM(__pthread_cond_initializer) +.set __pthread_cond_initializer, 21 +.globl SYM(__pthread_rwlock_initializer) +.set __pthread_rwlock_initializer, 22 |