1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Avoid libc conflicts with libstdc++.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-03-18 14:22:17 +01:00
parent 358f2c4524
commit 33bf0d93ad
4 changed files with 78 additions and 10 deletions

View file

@ -522,7 +522,7 @@ ifeq ($(HOST),x86_64-sortix)
SORTIXFLAGS:=$(SORTIXFLAGS) -mno-red-zone
endif
BINS=libc.a libg.a libpthread.a libstdc++.a $(CRTOBJ)
BINS=libc.a libg.a libpthread.a $(CRTOBJ)
BINSKERNEL=libc-sortix.a
INSTALLLIBS:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINS))
INSTALLLIBSKERNEL:=$(addprefix $(DESTDIR)$(LIBDIR)/,$(BINSKERNEL))
@ -550,9 +550,6 @@ libg.a:
libpthread.a:
$(HOSTAR) rcs $@
libstdc++.a:
$(HOSTAR) rcs $@
crt1.o: $(CPUDIR)/crt1.o
ln -f $< $@

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
This file is part of the Sortix C Library.
@ -18,14 +18,38 @@
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
aux/op-new.cpp
C++ allocation operators.
C++ allocation operators. This is a hack to work around that libstdc++ is
yet to be integrated into Sortix.
*******************************************************************************/
#include <stddef.h>
#include <stdlib.h>
void* operator new(size_t size) { return malloc(size); }
void* operator new[](size_t size) { return malloc(size); }
void operator delete (void* addr) { return free(addr); }
void operator delete[](void* addr) { return free(addr); }
#if __STDC_HOSTED__
__attribute__((weak))
void* operator new(size_t size)
{
return malloc(size);
}
__attribute__((weak))
void* operator new[](size_t size)
{
return malloc(size);
}
__attribute__((weak))
void operator delete(void* addr)
{
return free(addr);
}
__attribute__((weak))
void operator delete[](void* addr)
{
return free(addr);
}
#endif

View file

@ -114,6 +114,7 @@ logterminal.o \
memorymanagement.o \
mtable.o \
net/fs.o \
op-new.o \
panic.o \
partition.o \
pci.o \

46
sortix/op-new.cpp Normal file
View file

@ -0,0 +1,46 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
This file is part of Sortix.
Sortix is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
Sortix. If not, see <http://www.gnu.org/licenses/>.
op-new.cpp
C++ allocation operators.
*******************************************************************************/
#include <stddef.h>
#include <stdlib.h>
void* operator new(size_t size)
{
return malloc(size);
}
void* operator new[](size_t size)
{
return malloc(size);
}
void operator delete(void* addr)
{
return free(addr);
}
void operator delete[](void* addr)
{
return free(addr);
}