This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR libstdc++/79190 add fallback aligned_alloc implementation


This provides a definition of aligned_alloc for targets which have
none of aligned_alloc, posix_memalign, memalign or _aligned_alloc.

The code is based on gcc/config/i386/gmm_malloc.h but modified to only
use sizeof(void*) not 2*sizeof(void*), because I don't understand why
that's used in gmm_malloc.h, or what the comment means.

libstdc++-v3:

	PR libstdc++/79190
	* libsupc++/del_opa.cc (operator delete(void*, std::align_val_t))
	[!_GLIBCXX_HAVE_ALIGNED_ALLOC && !_GLIBCXX_HAVE_POSIX_MEMALIGN
	&& !_GLIBCXX_HAVE_MEMALIGN && !_GLIBCXX_HAVE__ALIGNED_MALLOC]:
	Retrieve original pointer value allocated by malloc.
	* libsupc++/new_opa.cc [!_GLIBCXX_HAVE_ALIGNED_ALLOC
	&& !_GLIBCXX_HAVE_POSIX_MEMALIGN && !_GLIBCXX_HAVE_MEMALIGN
	&& !_GLIBCXX_HAVE__ALIGNED_MALLOC] (aligned_alloc(size_t, size_t)):
	Define, adjusting pointer value allocated by malloc and storing for
	retrieval by operator delete.

gcc/testsuite:

	PR libstdc++/79190
	* g++.dg/cpp1z/aligned-new3.C: Replace operator new so behaviour
	matches replaced operator delete.

Tested powerpc64le-linux, and also tested after tweaking the
preprocessor checks so the new code was used.

If this works for HPUX I plan to commit it to trunk.


Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]