rtdl: use get_current_tcb instead of getCurrentTcb
This commit is contained in:
parent
7418726feb
commit
e90b4c966d
|
@ -4,6 +4,7 @@ fs = import('fs')
|
|||
|
||||
rtdl_include_dirs = [
|
||||
include_directories('options/internal/include'),
|
||||
include_directories('options/internal' / host_machine.cpu_family() + '-include'),
|
||||
include_directories('options/rtdl/include'),
|
||||
]
|
||||
libc_include_dirs = [
|
||||
|
@ -217,7 +218,6 @@ internal_sources = [
|
|||
'options/internal/gcc/initfini.cpp',
|
||||
'options/internal/gcc-extra/cxxabi.cpp',
|
||||
'options/internal' / host_machine.cpu_family() / 'setjmp.S',
|
||||
'options/internal' / host_machine.cpu_family() / 'thread.cpp',
|
||||
]
|
||||
|
||||
if not static
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <mlibc/thread.hpp>
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <mlibc/tcb.hpp>
|
||||
|
||||
namespace mlibc {
|
||||
|
||||
Tcb *get_current_tcb() {
|
||||
inline Tcb *get_current_tcb() {
|
||||
uintptr_t ptr;
|
||||
asm ("mrs %0, tpidr_el0" : "=r"(ptr));
|
||||
return reinterpret_cast<Tcb *>(ptr);
|
|
@ -1,9 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <mlibc/tcb.hpp>
|
||||
|
||||
namespace mlibc {
|
||||
|
||||
Tcb *get_current_tcb();
|
||||
|
||||
} // namespace mlibc
|
|
@ -1,10 +1,11 @@
|
|||
#include <mlibc/thread.hpp>
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <mlibc/tcb.hpp>
|
||||
|
||||
namespace mlibc {
|
||||
|
||||
Tcb *get_current_tcb() {
|
||||
inline Tcb *get_current_tcb() {
|
||||
uintptr_t ptr;
|
||||
asm ("movq %%fs:0, %0" : "=r"(ptr));
|
||||
return reinterpret_cast<Tcb *>(ptr);
|
|
@ -67,20 +67,6 @@ void closeOrDie(int fd) {
|
|||
__ensure(!"sys_close() failed");
|
||||
}
|
||||
|
||||
namespace {
|
||||
Tcb *getCurrentTcb() {
|
||||
uintptr_t ptr;
|
||||
#if defined(__x86_64__)
|
||||
asm volatile ("mov %%fs:0, %0" : "=r"(ptr));
|
||||
#elif defined(__aarch64__)
|
||||
asm volatile ("mrs %0, tpidr_el0" : "=r"(ptr));
|
||||
#else
|
||||
# error Unknown architecture
|
||||
#endif
|
||||
return reinterpret_cast<Tcb *>(ptr);
|
||||
}
|
||||
} // namespace anonymous
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ObjectRepository
|
||||
// --------------------------------------------------------
|
||||
|
@ -765,7 +751,7 @@ Tcb *allocateTcb() {
|
|||
}
|
||||
|
||||
void *accessDtv(SharedObject *object) {
|
||||
Tcb *tcb_ptr = getCurrentTcb();
|
||||
Tcb *tcb_ptr = mlibc::get_current_tcb();
|
||||
|
||||
// We might need to reallocate the DTV.
|
||||
if(object->tlsIndex >= tcb_ptr->dtvSize) {
|
||||
|
@ -793,7 +779,7 @@ void *accessDtv(SharedObject *object) {
|
|||
}
|
||||
|
||||
void *tryAccessDtv(SharedObject *object) {
|
||||
Tcb *tcb_ptr = getCurrentTcb();
|
||||
Tcb *tcb_ptr = mlibc::get_current_tcb();
|
||||
|
||||
if (object->tlsIndex >= tcb_ptr->dtvSize)
|
||||
return nullptr;
|
||||
|
@ -1165,7 +1151,7 @@ void Loader::_buildTlsMaps() {
|
|||
}
|
||||
|
||||
void Loader::initObjects() {
|
||||
initTlsObjects(getCurrentTcb(), _linkBfs, true);
|
||||
initTlsObjects(mlibc::get_current_tcb(), _linkBfs, true);
|
||||
|
||||
for(auto it = _linkBfs.begin(); it != _linkBfs.end(); ++it) {
|
||||
if(!(*it)->scheduledForInit)
|
||||
|
@ -1460,7 +1446,7 @@ void Loader::_processLazyRelocations(SharedObject *object) {
|
|||
// Access DTV for object to force the entry to be allocated and initialized
|
||||
accessDtv(target);
|
||||
|
||||
__ensure(target->tlsIndex < getCurrentTcb()->dtvSize);
|
||||
__ensure(target->tlsIndex < mlibc::get_current_tcb()->dtvSize);
|
||||
|
||||
// TODO: We should free this when the DSO gets destroyed
|
||||
auto data = frg::construct<TlsdescData>(getAllocator());
|
||||
|
|
Loading…
Reference in a new issue