Skip to content
Snippets Groups Projects
Commit 4af3f2e5 authored by Federico's avatar Federico
Browse files

Miosix support for libatomic

parent f9cab5f1
Branches
Tags
No related merge requests found
......@@ -56,8 +56,15 @@ AFLAGS := $(AFLAGS_BASE)
LFLAGS := $(LFLAGS_BASE)
DFLAGS := -MMD -MP
LINK_LIBS := $(LIBS) -L$(KPATH) -Wl,--start-group -lmiosix -lstdc++ -lc \
-lm -lgcc -Wl,--end-group
## libmiosix.a is among stdlibs because needs to be within start/end group
STDLIBS := -lmiosix -lstdc++ -lc -lm -lgcc
GCCMAJOR := $(shell $(CC) --version | perl -e '$$_=<>;/\(GCC\) (\d+)/;print "$$1"')
ifneq ($(GCCMAJOR),4)
STDLIBS += -latomic
endif
LINK_LIBS := $(LIBS) -L$(KPATH) -Wl,--start-group $(STDLIBS) -Wl,--end-group
all: all-recursive main
......
......@@ -303,3 +303,33 @@ extern "C" void __cxa_guard_abort(__guard *g) noexcept
}
} //namespace __cxxabiv1
//
// libatomic support, to provide thread safe atomic operation fallbacks
// ====================================================================
// Not using the fast version, as these may be used before the kernel is started
extern "C" unsigned int libat_quick_lock_n(void *ptr)
{
miosix::disableInterrupts();
return 0;
}
extern "C" void libat_quick_unlock_n(void *ptr, unsigned int token)
{
miosix::enableInterrupts();
}
// These are to implement "heavy" atomic operations, which are not used in
// libstdc++. For now let's keep them disbaled.
// extern "C" void libat_lock_n(void *ptr, size_t n)
// {
// miosix::pauseKernel();
// }
//
// extern "C" void libat_unlock_n(void *ptr, size_t n)
// {
// miosix::restartKernel();
// }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment