[PATCH] D57251: [libunwind] Use placement new to avoid dependency C++ library
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 25 13:40:03 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352245: [libunwind] Use placement new to avoid dependency C++ library (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D57251?vs=183611&id=183613#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57251/new/
https://reviews.llvm.org/D57251
Files:
libunwind/trunk/src/libunwind.cpp
Index: libunwind/trunk/src/libunwind.cpp
===================================================================
--- libunwind/trunk/src/libunwind.cpp
+++ libunwind/trunk/src/libunwind.cpp
@@ -14,8 +14,6 @@
#ifndef NDEBUG
#include <cstdlib> // getenv
#endif
-#include <new>
-#include <algorithm>
#include "libunwind_ext.h"
#include "config.h"
@@ -122,12 +120,14 @@
_LIBUNWIND_EXPORT unw_addr_space_t unw_create_addr_space_for_task(task_t task) {
#if __i386__
if (is64bit(task)) {
- unw_addr_space_x86_64 *as = new unw_addr_space_x86_64(task);
+ unw_addr_space_x86_64 *as = malloc(sizeof(unw_addr_space_x86_64));
+ new (as) unw_addr_space_x86_64(task);
as->taskPort = task;
as->cpuType = CPU_TYPE_X86_64;
//as->oas
} else {
- unw_addr_space_i386 *as = new unw_addr_space_i386(task);
+ unw_addr_space_i386 *as = malloc(sizeof(unw_addr_space_i386));
+ new (as) unw_addr_space_i386(task);
as->taskPort = task;
as->cpuType = CPU_TYPE_I386;
//as->oas
@@ -144,18 +144,21 @@
#if __i386__ || __x86_64__
case CPU_TYPE_I386: {
unw_addr_space_i386 *as = (unw_addr_space_i386 *)asp;
- delete as;
+ as->~unw_addr_space_i386();
+ free(as);
}
break;
case CPU_TYPE_X86_64: {
unw_addr_space_x86_64 *as = (unw_addr_space_x86_64 *)asp;
- delete as;
+ as->~unw_addr_space_x86_64();
+ free(as);
}
break;
#endif
case CPU_TYPE_POWERPC: {
unw_addr_space_ppc *as = (unw_addr_space_ppc *)asp;
- delete as;
+ as->~unw_addr_space_ppc();
+ free(as);
}
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57251.183613.patch
Type: text/x-patch
Size: 1564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190125/8622dc82/attachment.bin>
More information about the llvm-commits
mailing list