[libcxx] r290448 - Don't use posix_memalign on Windows platforms

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 23 12:17:23 PST 2016


Author: ericwf
Date: Fri Dec 23 14:17:23 2016
New Revision: 290448

URL: http://llvm.org/viewvc/llvm-project?rev=290448&view=rev
Log:
Don't use posix_memalign on Windows platforms

Modified:
    libcxx/trunk/src/new.cpp

Modified: libcxx/trunk/src/new.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/new.cpp?rev=290448&r1=290447&r2=290448&view=diff
==============================================================================
--- libcxx/trunk/src/new.cpp (original)
+++ libcxx/trunk/src/new.cpp Fri Dec 23 14:17:23 2016
@@ -70,7 +70,11 @@ operator new(std::size_t size, std::alig
     if (static_cast<size_t>(alignment) < sizeof(void*))
       alignment = std::align_val_t(sizeof(void*));
     void* p;
+#if defined(_WIN32)
+    while ((p = _aligned_malloc(size, static_cast<size_t>(alignment))) == nullptr)
+#else
     while (::posix_memalign(&p, static_cast<size_t>(alignment), size) != 0)
+#endif
     {
         // If posix_memalign fails and there is a new_handler,
         // call it to try free up memory.




More information about the cfe-commits mailing list