[libcxxabi] r299435 - Fix exception address alignment test for EHABI

2017-04-04 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Tue Apr  4 09:03:54 2017
New Revision: 299435

URL: http://llvm.org/viewvc/llvm-project?rev=299435=rev
Log:
Fix exception address alignment test for EHABI

This test fails on ARM bare-metal targets because it assumes the Itanium ABI,
whereas EHABI requires the exception address to be 8-byte aligned.

I was a bit puzzled at first because this should've failed on the public
arm-linux builder too. I think the reason it passes there is because we don't
include libunwind headers in the include path when running the libcxxabi tests,
so the system unwind.h gets picked up.

Reviewers: rengolin, EricWF
Differential revision: https://reviews.llvm.org/D31178

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/lit.site.cfg.in
libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=299435=299434=299435=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Tue Apr  4 09:03:54 2017
@@ -502,9 +502,14 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+  if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
+  endif()
+
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "")
 include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
   endif()
+
   if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
 include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
   endif()

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=299435=299434=299435=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Tue Apr  4 09:03:54 2017
@@ -84,6 +84,13 @@ class Configuration(LibcxxConfiguration)
   % libcxxabi_headers)
 self.cxx.compile_flags += ['-I' + libcxxabi_headers]
 
+libunwind_headers = self.get_lit_conf('libunwind_headers', None)
+if self.get_lit_bool('llvm_unwinder', False) and libunwind_headers:
+if not os.path.isdir(libunwind_headers):
+self.lit_config.fatal("libunwind_headers='%s' is not a 
directory."
+  % libunwind_headers)
+self.cxx.compile_flags += ['-I' + libunwind_headers]
+
 def configure_compile_flags_exceptions(self):
 pass
 

Modified: libcxxabi/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/lit.site.cfg.in?rev=299435=299434=299435=diff
==
--- libcxxabi/trunk/test/lit.site.cfg.in (original)
+++ libcxxabi/trunk/test/lit.site.cfg.in Tue Apr  4 09:03:54 2017
@@ -6,6 +6,7 @@ config.libcxxabi_obj_root   = "@LIBC
 config.abi_library_path = "@LIBCXXABI_LIBRARY_DIR@"
 config.libcxx_src_root  = "@LIBCXXABI_LIBCXX_PATH@"
 config.cxx_headers  = "@LIBCXXABI_LIBCXX_INCLUDES@"
+config.libunwind_headers= "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@"
 config.cxx_library_root = "@LIBCXXABI_LIBCXX_LIBRARY_PATH@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.enable_threads   = "@LIBCXXABI_ENABLE_THREADS@"

Modified: libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp?rev=299435=299434=299435=diff
==
--- libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_address_alignment.pass.cpp Tue Apr  4 
09:03:54 2017
@@ -15,8 +15,8 @@
 // working around this failure.
 // XFAIL: darwin && libcxxabi-has-system-unwinder
 
-// Test that the address of the exception object is properly aligned to the
-// largest supported alignment for the system.
+// Test that the address of the exception object is properly aligned as 
required
+// by the relevant ABI
 
 #include 
 #include 
@@ -24,7 +24,16 @@
 #include 
 
 struct __attribute__((aligned)) AlignedType {};
-static_assert(alignof(AlignedType) == alignof(_Unwind_Exception),
+
+// EHABI  : 8-byte aligned
+// Itanium: Largest supported alignment for the system
+#if defined(_LIBUNWIND_ARM_EHABI)
+#  define EXPECTED_ALIGNMENT 8
+#else
+#  define EXPECTED_ALIGNMENT alignof(AlignedType)
+#endif
+

Re: [libunwind] r297174 - Improve readability and correctness of the OS specific libunwind bits.

2017-03-08 Thread Asiri Rathnayake via cfe-commits
@Renato: What's your take on Ed's idea?

We use phab for all sorts of reviews, but it should be possible to figure
out which repository a review is intended to land on and add cfe-commits or
llvm-commits appropriately.

Although, for throw-away reviews, it might generate too much spam.

Cheers,

/ Asiri


On Wed, Mar 8, 2017 at 3:18 PM, Ed Schouten  wrote:

> Hi Asiri,
>
> 2017-03-07 20:42 GMT+01:00 Asiri Rathnayake :
> > Could you please always include cfe-commits as a subscriber in you phab
> > reviews?
> >
> > We would like to be aware of these changes in advance before they land.
>
> Sure thing! I'll try to do that from now on.
>
> That said, if the policy is to add cfe-commits@ to all
> Clang/libunwind-related code reviews, would it make sense to configure
> Phabricator's Herald to set this up for us automatically? Looking at
> https://reviews.llvm.org/herald/new/, I suspect that can only be
> configured with admin rights.
>
> Regards,
> --
> Ed Schouten 
> Nuxi, 's-Hertogenbosch, the Netherlands
> KvK-nr.: 62051717
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libunwind] r297174 - Improve readability and correctness of the OS specific libunwind bits.

2017-03-07 Thread Asiri Rathnayake via cfe-commits
Hi Ed,

Could you please always include cfe-commits as a subscriber in you phab
reviews?

We would like to be aware of these changes in advance before they land.

Thanks.

/ Asiri


On 7 Mar 2017 6:27 p.m., "Ed Schouten via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> Author: ed
> Date: Tue Mar  7 12:15:52 2017
> New Revision: 297174
>
> URL: http://llvm.org/viewvc/llvm-project?rev=297174=rev
> Log:
> Improve readability and correctness of the OS specific libunwind bits.
>
> All of the access to __exidx_*, dl_iterate_phdr(), etc. is specific to
> the findUnwindSections() function. Right now all of the includes and
> declarations related to them are scattered throughout the source file.
> For example, for , we have a full list of operating systems
> guarding the #include, even though the code that uses dl_iterate_phdr()
> miraculously doesn't use the same list.
>
> Change the code so that findUnwindSections() is preceded by a block of
> #ifdefs that share the same structure as the function itself. First
> comes all of the macOS specific bits, followed by bare-metal ARM,
> followed by ELF EHABI + DWARF.
>
> This actually allows us to build a copy of libunwind without any
> specific ifdefs for NetBSD, CloudABI, etc. It likely also unbreaks the
> build of libunwind on FreeBSD/armv6, though I can't confirm.
>
> Reviewed by:compnerd
> Differential Revision:  https://reviews.llvm.org/D30696
>
> Modified:
> libunwind/trunk/src/AddressSpace.hpp
>
> Modified: libunwind/trunk/src/AddressSpace.hpp
> URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/
> AddressSpace.hpp?rev=297174=297173=297174=diff
> 
> ==
> --- libunwind/trunk/src/AddressSpace.hpp (original)
> +++ libunwind/trunk/src/AddressSpace.hpp Tue Mar  7 12:15:52 2017
> @@ -34,32 +34,6 @@ namespace libunwind {
>  #include "dwarf2.h"
>  #include "Registers.hpp"
>
> -#if _LIBUNWIND_ARM_EHABI
> -#if defined(_LIBUNWIND_IS_BAREMETAL)
> -// When statically linked on bare-metal, the symbols for the EH table are
> looked
> -// up without going through the dynamic loader.
> -extern char __exidx_start;
> -extern char __exidx_end;
> -#else
> -#include 
> -#endif // !defined(_LIBUNWIND_IS_BAREMETAL)
> -#endif // _LIBUNWIND_ARM_EHABI
> -
> -#if defined(__CloudABI__) || defined(__FreeBSD__) || defined(__Fuchsia__)
> ||  \
> -defined(__linux__) || defined(__NetBSD__)
> -#if _LIBUNWIND_SUPPORT_DWARF_UNWIND && _LIBUNWIND_SUPPORT_DWARF_INDEX
> -#include 
> -// Macro for machine-independent access to the ELF program headers. This
> -// macro is not available on some systems (e.g., FreeBSD). On these
> -// systems the data structures are just called Elf_XXX. Define ElfW()
> -// locally.
> -#if !defined(ElfW)
> -#define ElfW(type) Elf_##type
> -#endif
> -#include "EHHeaderParser.hpp"
> -#endif
> -#endif
> -
>  namespace libunwind {
>
>  /// Used by findUnwindSections() to return info about needed sections.
> @@ -291,6 +265,7 @@ LocalAddressSpace::getEncodedP(pint_t 
>  }
>
>  #ifdef __APPLE__
> +
>struct dyld_unwind_sections
>{
>  const struct mach_header*   mh;
> @@ -336,6 +311,30 @@ LocalAddressSpace::getEncodedP(pint_t 
>return true;
>  }
>#endif
> +
> +#elif _LIBUNWIND_ARM_EHABI && defined(_LIBUNWIND_IS_BAREMETAL)
> +
> +// When statically linked on bare-metal, the symbols for the EH table are
> looked
> +// up without going through the dynamic loader.
> +extern char __exidx_start;
> +extern char __exidx_end;
> +
> +#elif _LIBUNWIND_ARM_EHABI || _LIBUNWIND_SUPPORT_DWARF_UNWIND
> +
> +// ELF-based systems may use dl_iterate_phdr() to access sections
> +// containing unwinding information. The ElfW() macro for pointer-size
> +// independent ELF header traversal is not provided by  on some
> +// systems (e.g., FreeBSD). On these systems the data structures are
> +// just called Elf_XXX. Define ElfW() locally.
> +#include 
> +#if !defined(ElfW)
> +#define ElfW(type) Elf_##type
> +#endif
> +
> +#if _LIBUNWIND_SUPPORT_DWARF_UNWIND
> +#include "EHHeaderParser.hpp"
> +#endif
> +
>  #endif
>
>  inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r296351 - Fix LIBCXX_HAS_EXTERNAL_THREAD_API builds. NFC.

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 10:10:57 2017
New Revision: 296351

URL: http://llvm.org/viewvc/llvm-project?rev=296351=rev
Log:
Fix LIBCXX_HAS_EXTERNAL_THREAD_API builds. NFC.

Add the missing check in the __config header.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=296351=296350=296351=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Feb 27 10:10:57 2017
@@ -939,7 +939,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 
 // Thread API
 #if !defined(_LIBCPP_HAS_NO_THREADS) && \
-!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+!defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
+!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 # if defined(__FreeBSD__) || \
 defined(__Fuchsia__) || \
 defined(__NetBSD__) || \


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r296346 - Fix typo in error message. NFC.

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 09:49:51 2017
New Revision: 296346

URL: http://llvm.org/viewvc/llvm-project?rev=296346=rev
Log:
Fix typo in error message. NFC.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=296346=296345=296346=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Feb 27 09:49:51 2017
@@ -961,7 +961,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 
 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-#  error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \
+#  error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
  _LIBCPP_HAS_NO_THREADS is defined.
 #endif
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r296344 - Attempt to fix arm-native libcxxabi tests for the no-exceptions variant

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 09:31:34 2017
New Revision: 296344

URL: http://llvm.org/viewvc/llvm-project?rev=296344=rev
Log:
Attempt to fix arm-native libcxxabi tests for the no-exceptions variant

These tests embed calls to exceptions-related symbols from the abi library,
which are absent in the no-exceptions variant. The tests need to be marked
as unsupported for the no-exceptions configuration.

Modified:
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s

Modified: libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s?rev=296344=296343=296344=diff
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s 
(original)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s Mon 
Feb 27 09:31:34 2017
@@ -1,5 +1,6 @@
 @ RUN: %cxx %flags %link_flags %s -o %t.exe
 @ RUN: %exec %t.exe
+@ UNSUPPORTED: libcxxabi-no-exceptions
 
 @ PURPOSE: Check that 0x00 is a valid value for ttype encoding.  LLVM and
 @ GCC 4.6 are generating 0x00 as ttype encoding.  libc++abi should provide

Modified: libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s?rev=296344=296343=296344=diff
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s 
(original)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s Mon 
Feb 27 09:31:34 2017
@@ -1,5 +1,6 @@
 @ RUN: %cxx %flags %link_flags %s -o %t.exe
 @ RUN: %exec %t.exe
+@ UNSUPPORTED: libcxxabi-no-exceptions
 
 @ PURPOSE: Check that 0x90 is a valid value for ttype encoding.
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r296338 - Fix cmake dependency for the external-thread-library variant. NFC.

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 07:19:25 2017
New Revision: 296338

URL: http://llvm.org/viewvc/llvm-project?rev=296338=rev
Log:
Fix cmake dependency for the external-thread-library variant. NFC.

Modified:
libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=296338=296337=296338=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Mon Feb 27 07:19:25 2017
@@ -62,7 +62,7 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   set(LIBCXX_TEST_DEPS cxx_experimental)
 endif()
 
-if (LIBCXX_HAS_EXTERNAL_THREAD_API)
+if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
   list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
 endif()
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libunwind] r295948 - Revert r295944.

2017-02-23 Thread Asiri Rathnayake via cfe-commits
Hi Ed,

I have a feeling that the no-exceptions builders are missing a few
configuration bits.

"No-exceptions" libraries should not require libunwind...

Looking at the cmake configs:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/430/steps/cmake/logs/stdio

I see that it's missing the -DLIBCXXABI_ENALBE_EXCEPTIONS=OFF flag and the
-DLIBCXX_USE_LLVM_UNWINDER=ON should also be dropped I think.

I'll upload a patch to fix this soon, and ask Galina to restart the
build-master. You will be able to continue with your work afterward.

Sorry about the trouble.

/ Asiri



On Thu, Feb 23, 2017 at 9:13 AM, Ed Schouten via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ed
> Date: Thu Feb 23 03:13:22 2017
> New Revision: 295948
>
> URL: http://llvm.org/viewvc/llvm-project?rev=295948=rev
> Log:
> Revert r295944.
>
> Even though the change works perfectly fine on CloudABI, it fails to
> work on the libcxx-libcxxabi-libunwind-arm-linux-noexceptions build bot.
> Looking at the code, this may be attributed to the fact that the code
> doesn't take the PT_LOAD addresses into consideration.
>
> I will rework this change to fix that and send out an updated version
> for review in the nearby future.
>
> Modified:
> libunwind/trunk/src/AddressSpace.hpp
>
> Modified: libunwind/trunk/src/AddressSpace.hpp
> URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/
> AddressSpace.hpp?rev=295948=295947=295948=diff
> 
> ==
> --- libunwind/trunk/src/AddressSpace.hpp (original)
> +++ libunwind/trunk/src/AddressSpace.hpp Thu Feb 23 03:13:22 2017
> @@ -35,17 +35,29 @@ namespace libunwind {
>  #include "Registers.hpp"
>
>  #if _LIBUNWIND_ARM_EHABI
> +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
> +
> +typedef void *_Unwind_Ptr;
> +
> +#elif defined(__linux__)
> +
> +typedef long unsigned int *_Unwind_Ptr;
> +extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr addr, int
> *len);
> +
> +// Emulate the BSD dl_unwind_find_exidx API when on a GNU libdl system.
> +#define dl_unwind_find_exidx __gnu_Unwind_Find_exidx
> +
> +#elif !defined(_LIBUNWIND_IS_BAREMETAL)
> +#include 
> +#else // !defined(_LIBUNWIND_IS_BAREMETAL)
> +// When statically linked on bare-metal, the symbols for the EH table are
> looked
> +// up without going through the dynamic loader.
>  struct EHTEntry {
>uint32_t functionOffset;
>uint32_t unwindOpcodes;
>  };
> -#if defined(_LIBUNWIND_IS_BAREMETAL)
> -// When statically linked on bare-metal, the symbols for the EH table are
> looked
> -// up without going through the dynamic loader.
>  extern EHTEntry __exidx_start;
>  extern EHTEntry __exidx_end;
> -#else
> -#include 
>  #endif // !defined(_LIBUNWIND_IS_BAREMETAL)
>  #endif // _LIBUNWIND_ARM_EHABI
>
> @@ -356,15 +368,23 @@ inline bool LocalAddressSpace::findUnwin
>  info.compact_unwind_section_length = dyldInfo.compact_unwind_
> section_length;
>  return true;
>}
> -#elif _LIBUNWIND_ARM_EHABI && defined(_LIBUNWIND_IS_BAREMETAL)
> +#elif _LIBUNWIND_ARM_EHABI
> + #ifdef _LIBUNWIND_IS_BAREMETAL
>// Bare metal is statically linked, so no need to ask the dynamic loader
>info.arm_section =(uintptr_t)(&__exidx_start);
>info.arm_section_length = (uintptr_t)(&__exidx_end - &__exidx_start);
> + #else
> +  int length = 0;
> +  info.arm_section = (uintptr_t) dl_unwind_find_exidx(
> +  (_Unwind_Ptr) targetAddr, );
> +  info.arm_section_length = (uintptr_t)length;
> + #endif
>_LIBUNWIND_TRACE_UNWINDING("findUnwindSections: section %X length %x",
>   info.arm_section, info.arm_section_length);
>if (info.arm_section && info.arm_section_length)
>  return true;
> -#elif _LIBUNWIND_ARM_EHABI || _LIBUNWIND_SUPPORT_DWARF_UNWIND
> +#elif _LIBUNWIND_SUPPORT_DWARF_UNWIND
> +#if _LIBUNWIND_SUPPORT_DWARF_INDEX
>struct dl_iterate_cb_data {
>  LocalAddressSpace *addressSpace;
>  UnwindInfoSections *sects;
> @@ -375,6 +395,9 @@ inline bool LocalAddressSpace::findUnwin
>int found = dl_iterate_phdr(
>[](struct dl_phdr_info *pinfo, size_t, void *data) -> int {
>  auto cbdata = static_cast(data);
> +size_t object_length;
> +bool found_obj = false;
> +bool found_hdr = false;
>
>  assert(cbdata);
>  assert(cbdata->sects);
> @@ -390,14 +413,6 @@ inline bool LocalAddressSpace::findUnwin
>  typedef ElfW(Phdr) Elf_Phdr;
>  #endif
>
> - #if _LIBUNWIND_SUPPORT_DWARF_UNWIND
> -  #if !_LIBUNWIND_SUPPORT_DWARF_INDEX
> -   #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires
> _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
> -  #endif
> -size_t object_length;
> -bool found_obj = false;
> -bool found_hdr = false;
> -
>  for (Elf_Half i = 0; i < pinfo->dlpi_phnum; i++) {
>const Elf_Phdr *phdr = >dlpi_phdr[i];
>if (phdr->p_type == 

[libcxxabi] r295175 - Fix couple of test failures when using the LIBCXXABI_SILENT_TERMINATE mode.

2017-02-15 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Wed Feb 15 07:43:05 2017
New Revision: 295175

URL: http://llvm.org/viewvc/llvm-project?rev=295175=rev
Log:
Fix couple of test failures when using the LIBCXXABI_SILENT_TERMINATE mode.

When libcxxabi is built in LIBCXXABI_SILENT_TERMINATE mode, libcxx test suite 
reports
two failures:

  std/depr/exception.unexpected/set.unexpected/get_unexpected.pass.cpp
  std/depr/exception.unexpected/set.unexpected/set_unexpected.pass.cpp

This is because the default unexpected handler is set to std::abort instead of
std::terminate which these tests expect.

Modified:
libcxxabi/trunk/src/cxa_default_handlers.cpp

Modified: libcxxabi/trunk/src/cxa_default_handlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_default_handlers.cpp?rev=295175=295174=295175=diff
==
--- libcxxabi/trunk/src/cxa_default_handlers.cpp (original)
+++ libcxxabi/trunk/src/cxa_default_handlers.cpp Wed Feb 15 07:43:05 2017
@@ -90,7 +90,7 @@ static std::terminate_handler default_te
 static std::terminate_handler default_unexpected_handler = 
demangling_unexpected_handler;
 #else
 static std::terminate_handler default_terminate_handler = std::abort;
-static std::terminate_handler default_unexpected_handler = std::abort;
+static std::terminate_handler default_unexpected_handler = std::terminate;
 #endif
 
 //


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r294553 - [libcxx][CMake] Support in-tree libunwind when building as part of runtimes

2017-02-09 Thread Asiri Rathnayake via cfe-commits
Ah, ignore me please.

I should've read the patch.

/ Asiri

On Thu, Feb 9, 2017 at 9:13 AM, Asiri Rathnayake  wrote:

> Hi Petr,
>
> This is breaking static builds of the libraries, cmake complaints with:
>
> "CMake Error at projects/libcxxabi/src/CMakeLists.txt:134
> (target_link_libraries):
>   Target "unwind" of type UTILITY may not be linked into another target.
> One
>   may link only to STATIC or SHARED libraries, or to executables with the
>   ENABLE_EXPORTS property set."
>
> Our build config is:
>
>  -DLLVM_ENABLE_ASSERTIONS=ON -DLIBCXX_ENABLE_ASSERTIONS=ON
> -DLIBCXXABI_USE_LLVM_UNWINDER=ON  -DLIBCXX_ENABLE_SHARED=OFF
> -DLIBCXXABI_ENABLE_SHARED=OFF -DLIBUNWIND_ENABLE_SHARED=OFF
>
> / Asiri
>
>
> On Thu, Feb 9, 2017 at 2:19 AM, Petr Hosek via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: phosek
>> Date: Wed Feb  8 20:19:43 2017
>> New Revision: 294553
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=294553=rev
>> Log:
>> [libcxx][CMake] Support in-tree libunwind when building as part of
>> runtimes
>>
>> When building as part of runtimes, there is no predefined order in
>> which the runtimes are loaded, so the targets from other projects
>> might not be available. We need to rely on HAVE_ variables
>> instead in that case.
>>
>> Differential Revision: https://reviews.llvm.org/D29575
>>
>> Modified:
>> libcxx/trunk/CMakeLists.txt
>> libcxx/trunk/lib/CMakeLists.txt
>>
>> Modified: libcxx/trunk/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.
>> txt?rev=294553=294552=294553=diff
>> 
>> ==
>> --- libcxx/trunk/CMakeLists.txt (original)
>> +++ libcxx/trunk/CMakeLists.txt Wed Feb  8 20:19:43 2017
>> @@ -158,6 +158,7 @@ option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
>>  # Build libc++abi with libunwind. We need this option to determine
>> whether to
>>  # link with libunwind or libgcc_s while running the test cases.
>>  option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder."
>> OFF)
>> +option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM
>> unwinder." OFF)
>>
>>  # Target options --
>> 
>>  option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
>>
>> Modified: libcxx/trunk/lib/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLi
>> sts.txt?rev=294553=294552=294553=diff
>> 
>> ==
>> --- libcxx/trunk/lib/CMakeLists.txt (original)
>> +++ libcxx/trunk/lib/CMakeLists.txt Wed Feb  8 20:19:43 2017
>> @@ -89,9 +89,9 @@ add_library_flags_if(LIBCXX_HAVE_CXX_ATO
>>
>>  # Add the unwinder library.
>>  if (LIBCXXABI_USE_LLVM_UNWINDER)
>> -  if (TARGET unwind_shared)
>> +  if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR
>> HAVE_LIBUNWIND))
>>  add_interface_library(unwind_shared)
>> -  elseif (TARGET unwind_static)
>> +  elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR
>> HAVE_LIBUNWIND))
>>  add_interface_library(unwind_static)
>>else()
>>  add_interface_library(unwind)
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r294553 - [libcxx][CMake] Support in-tree libunwind when building as part of runtimes

2017-02-09 Thread Asiri Rathnayake via cfe-commits
Hi Petr,

This is breaking static builds of the libraries, cmake complaints with:

"CMake Error at projects/libcxxabi/src/CMakeLists.txt:134
(target_link_libraries):
  Target "unwind" of type UTILITY may not be linked into another target.
One
  may link only to STATIC or SHARED libraries, or to executables with the
  ENABLE_EXPORTS property set."

Our build config is:

 -DLLVM_ENABLE_ASSERTIONS=ON -DLIBCXX_ENABLE_ASSERTIONS=ON
-DLIBCXXABI_USE_LLVM_UNWINDER=ON  -DLIBCXX_ENABLE_SHARED=OFF
-DLIBCXXABI_ENABLE_SHARED=OFF -DLIBUNWIND_ENABLE_SHARED=OFF

/ Asiri


On Thu, Feb 9, 2017 at 2:19 AM, Petr Hosek via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: phosek
> Date: Wed Feb  8 20:19:43 2017
> New Revision: 294553
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294553=rev
> Log:
> [libcxx][CMake] Support in-tree libunwind when building as part of runtimes
>
> When building as part of runtimes, there is no predefined order in
> which the runtimes are loaded, so the targets from other projects
> might not be available. We need to rely on HAVE_ variables
> instead in that case.
>
> Differential Revision: https://reviews.llvm.org/D29575
>
> Modified:
> libcxx/trunk/CMakeLists.txt
> libcxx/trunk/lib/CMakeLists.txt
>
> Modified: libcxx/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/
> CMakeLists.txt?rev=294553=294552=294553=diff
> 
> ==
> --- libcxx/trunk/CMakeLists.txt (original)
> +++ libcxx/trunk/CMakeLists.txt Wed Feb  8 20:19:43 2017
> @@ -158,6 +158,7 @@ option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT
>  # Build libc++abi with libunwind. We need this option to determine
> whether to
>  # link with libunwind or libgcc_s while running the test cases.
>  option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder."
> OFF)
> +option(LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM
> unwinder." OFF)
>
>  # Target options --
> 
>  option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS})
>
> Modified: libcxx/trunk/lib/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/
> CMakeLists.txt?rev=294553=294552=294553=diff
> 
> ==
> --- libcxx/trunk/lib/CMakeLists.txt (original)
> +++ libcxx/trunk/lib/CMakeLists.txt Wed Feb  8 20:19:43 2017
> @@ -89,9 +89,9 @@ add_library_flags_if(LIBCXX_HAVE_CXX_ATO
>
>  # Add the unwinder library.
>  if (LIBCXXABI_USE_LLVM_UNWINDER)
> -  if (TARGET unwind_shared)
> +  if (NOT LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_shared OR
> HAVE_LIBUNWIND))
>  add_interface_library(unwind_shared)
> -  elseif (TARGET unwind_static)
> +  elseif (LIBCXXABI_ENABLE_STATIC_UNWINDER AND (TARGET unwind_static OR
> HAVE_LIBUNWIND))
>  add_interface_library(unwind_static)
>else()
>  add_interface_library(unwind)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r293881 - Extend XFAIL to c++98.

2017-02-02 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Feb  2 05:56:26 2017
New Revision: 293881

URL: http://llvm.org/viewvc/llvm-project?rev=293881=rev
Log:
Extend XFAIL to c++98.

NFC.

Modified:

libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp

Modified: 
libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp?rev=293881=293880=293881=diff
==
--- 
libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.observers/bool.fail.cpp
 Thu Feb  2 05:56:26 2017
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: c++03
+// XFAIL: c++98, c++03
 
 // 
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r293877 - Improve docs: Add missing #pragma push directive.

2017-02-02 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Feb  2 04:35:18 2017
New Revision: 293877

URL: http://llvm.org/viewvc/llvm-project?rev=293877=rev
Log:
Improve docs: Add missing #pragma push directive.

NFC.

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=293877=293876=293877=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Thu Feb  2 04:35:18 2017
@@ -757,6 +757,7 @@ existed.
   #if foo
   #endif foo // warning: extra tokens at end of #endif directive
 
+  #pragma clang diagnostic push
   #pragma clang diagnostic ignored "-Wextra-tokens"
 
   #if foo


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant

2017-01-26 Thread Asiri Rathnayake via cfe-commits
Hi Nico,

Hopefully I've sorted this out in r293166/r293167. Please let me know if
things are not back to normal.

(I'll keep an eye on your builder too)

/ Asiri

On Wed, Jan 25, 2017 at 8:42 PM, Asiri Rathnayake <
asiri.rathnay...@gmail.com> wrote:

> Hi Nico,
>
> Thanks for the links. I may have a clue to what is going on.
>
> I think in your Mac environment,  does not provide
> either pthread_mach_thread_np() function or define the type mach_port_t
> (is there a way for you to check this btw? just to make sure).
>
> This was not a problem before (for your builds) because this function was
> only used in libcxxabi sources. In my eagerness to get rid of all pthread
> dependencies in libcxx/libcxxabi, I have lifted this out into
> __threading_support header in libcxx (which is our new threading API for
> both libcxx and libcxxabi).
>
> @Eric: would it be OK to leave this Mac-specific pthread dependency in
> libcxxabi sources as it was? In that way, libcxx builds like Nico's won't
> be affected.
>
> Another option is to try and detect the conditions (on Mac environments)
> where pthread_mach_thread_np/mach_port_t is available, and only define
> the corresponding libcxx thread-api function (__libcpp_thread_get_port)
> when this condition is true. Unfortunately I'm not familiar with Mac enough
> to know this. Any thoughts?
>
> Side note:- Btw, if I'm correct with the above analysis, it won't be
> possible to build libcxxabi in Nico's environment (even before my changes).
> The dependency on pthread_mach_thread_np() was already there
> in __cxa_guard_acquire().
>
> Thanks.
>
> / Asiri
>
>
> On Wed, Jan 25, 2017 at 7:34 PM, Nico Weber <tha...@chromium.org> wrote:
>
>> Sure! https://build.chromium.org/p/chromium.fyi/builders/Cla
>> ngToTMacASan/builds/8565/steps/gclient%20runhooks/logs/stdio has the
>> invocations to build llvm/clang/compiler/rt, and
>> https://build.chromium.org/p/chromium.fyi/builders/Clang
>> ToTMacASan/builds/8565/steps/compile/logs/stdio is the actual build
>> using that setup.
>>
>> On Wed, Jan 25, 2017 at 1:57 PM, Asiri Rathnayake <
>> asiri.rathnay...@gmail.com> wrote:
>>
>>> @Nico: could you let me know your build configuration? (cmake options)
>>>
>>> I'm surprised this went unnoticed for so long.
>>>
>>> Thanks.
>>>
>>> / Asiri
>>>
>>> On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" <asiri.rathnay...@gmail.com>
>>> wrote:
>>>
>>>> (including cfe-commits)
>>>>
>>>> On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake <
>>>> asiri.rathnay...@gmail.com> wrote:
>>>>
>>>>> Hi Nico,
>>>>>
>>>>> On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits <
>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>
>>>>>> Is it intentional that this change affects
>>>>>> non-LIBCXX_HAS_EXTERNAL_THREAD_API builds at all?#
>>>>>>
>>>>>
>>>>> Nope. But I'm not sure how this got broken on Mac.
>>>>>
>>>>> IIRC,  defines mach_port_t type on Mac, which gets included
>>>>> when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we
>>>>> expect to be the case on Mac, normally).
>>>>>
>>>>> I'll have to build this on a Mac tomorrow. Hopefully that's OK?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> / Asiri
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber <tha...@chromium.org>
>>>>>> wrote:
>>>>>>
>>>>>>> This breaks all our mac builds with:
>>>>>>>
>>>>>>> /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+
>>>>>>> Asserts/bin/../include/c++/v1/__threading_support:154:1: error:
>>>>>>> unknown type name 'mach_port_t'
>>>>>>> mach_port_t __libcpp_thread_get_port();
>>>>>>>
>>>>>>> On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits <
>>>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>>>
>>>>>>>> Author: asiri
>>>>>>>> Date: Tue Jan  3 06:59:50 2017
>>>>>>>> New Revision: 290889
>>>>>>>>
>>>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=2908

[libcxx] r293167 - Fix chromium build (libcxx)

2017-01-26 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Jan 26 04:40:17 2017
New Revision: 293167

URL: http://llvm.org/viewvc/llvm-project?rev=293167=rev
Log:
Fix chromium build (libcxx)

Remove the reference to pthread_mach_thread_np() in libcxx headers.

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=293167=293166=293167=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Thu Jan 26 04:40:17 2017
@@ -149,11 +149,6 @@ int __libcpp_execute_once(__libcpp_exec_
   void (*init_routine)(void));
 
 // Thread id
-#if defined(__APPLE__) && !defined(__arm__)
-_LIBCPP_THREAD_ABI_VISIBILITY
-mach_port_t __libcpp_thread_get_port();
-#endif
-
 _LIBCPP_THREAD_ABI_VISIBILITY
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
 
@@ -297,12 +292,6 @@ int __libcpp_execute_once(__libcpp_exec_
 }
 
 // Thread id
-#if defined(__APPLE__) && !defined(__arm__)
-mach_port_t __libcpp_thread_get_port() {
-return pthread_mach_thread_np(pthread_self());
-}
-#endif
-
 // Returns non-zero if the thread ids are equal, otherwise 0
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
 {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r293166 - Fix chromium build (libcxxabi)

2017-01-26 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Jan 26 04:38:03 2017
New Revision: 293166

URL: http://llvm.org/viewvc/llvm-project?rev=293166=rev
Log:
Fix chromium build (libcxxabi)

Pull the dependency on pthread_mach_thread_np() back into libcxxabi.

Modified:
libcxxabi/trunk/src/cxa_guard.cpp

Modified: libcxxabi/trunk/src/cxa_guard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_guard.cpp?rev=293166=293165=293166=diff
==
--- libcxxabi/trunk/src/cxa_guard.cpp (original)
+++ libcxxabi/trunk/src/cxa_guard.cpp Thu Jan 26 04:38:03 2017
@@ -179,7 +179,19 @@ _LIBCXXABI_FUNC_VIS int __cxa_guard_acqu
 if (result)
 {
 #if defined(__APPLE__) && !defined(__arm__)
-const lock_type id = std::__libcpp_thread_get_port();
+// This is a special-case pthread dependency for Mac. We can't pull 
this
+// out into libcxx's threading API (__threading_support) because not 
all
+// supported Mac environments provide this function (in pthread.h). To
+// make it possible to build/use libcxx in those environments, we have 
to
+// keep this pthread dependency local to libcxxabi. If there is some
+// convenient way to detect precisely when pthread_mach_thread_np is
+// available in a given Mac environment, it might still be possible to
+// bury this dependency in __threading_support.
+#ifdef _LIBCPP_HAS_THREAD_API_PTHREAD
+   const lock_type id = 
pthread_mach_thread_np(std::__libcpp_thread_get_current_id());
+#else
+   #error "How do I pthread_mach_thread_np()?"
+#endif
 lock_type lock = get_lock(*guard_object);
 if (lock)
 {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant

2017-01-25 Thread Asiri Rathnayake via cfe-commits
Hi Nico,

Thanks for the links. I may have a clue to what is going on.

I think in your Mac environment,  does not provide
either pthread_mach_thread_np() function or define the type mach_port_t (is
there a way for you to check this btw? just to make sure).

This was not a problem before (for your builds) because this function was
only used in libcxxabi sources. In my eagerness to get rid of all pthread
dependencies in libcxx/libcxxabi, I have lifted this out into
__threading_support header in libcxx (which is our new threading API for
both libcxx and libcxxabi).

@Eric: would it be OK to leave this Mac-specific pthread dependency in
libcxxabi sources as it was? In that way, libcxx builds like Nico's won't
be affected.

Another option is to try and detect the conditions (on Mac environments)
where pthread_mach_thread_np/mach_port_t is available, and only define the
corresponding libcxx thread-api function (__libcpp_thread_get_port) when
this condition is true. Unfortunately I'm not familiar with Mac enough to
know this. Any thoughts?

Side note:- Btw, if I'm correct with the above analysis, it won't be
possible to build libcxxabi in Nico's environment (even before my changes).
The dependency on pthread_mach_thread_np() was already there
in __cxa_guard_acquire().

Thanks.

/ Asiri


On Wed, Jan 25, 2017 at 7:34 PM, Nico Weber <tha...@chromium.org> wrote:

> Sure! https://build.chromium.org/p/chromium.fyi/builders/
> ClangToTMacASan/builds/8565/steps/gclient%20runhooks/logs/stdio has the
> invocations to build llvm/clang/compiler/rt, and https://build.chromium.
> org/p/chromium.fyi/builders/ClangToTMacASan/builds/8565/
> steps/compile/logs/stdio is the actual build using that setup.
>
> On Wed, Jan 25, 2017 at 1:57 PM, Asiri Rathnayake <
> asiri.rathnay...@gmail.com> wrote:
>
>> @Nico: could you let me know your build configuration? (cmake options)
>>
>> I'm surprised this went unnoticed for so long.
>>
>> Thanks.
>>
>> / Asiri
>>
>> On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" <asiri.rathnay...@gmail.com>
>> wrote:
>>
>>> (including cfe-commits)
>>>
>>> On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake <
>>> asiri.rathnay...@gmail.com> wrote:
>>>
>>>> Hi Nico,
>>>>
>>>> On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits <
>>>> cfe-commits@lists.llvm.org> wrote:
>>>>
>>>>> Is it intentional that this change affects
>>>>> non-LIBCXX_HAS_EXTERNAL_THREAD_API builds at all?#
>>>>>
>>>>
>>>> Nope. But I'm not sure how this got broken on Mac.
>>>>
>>>> IIRC,  defines mach_port_t type on Mac, which gets included
>>>> when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we
>>>> expect to be the case on Mac, normally).
>>>>
>>>> I'll have to build this on a Mac tomorrow. Hopefully that's OK?
>>>>
>>>> Cheers,
>>>>
>>>> / Asiri
>>>>
>>>>
>>>>
>>>>>
>>>>> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber <tha...@chromium.org>
>>>>> wrote:
>>>>>
>>>>>> This breaks all our mac builds with:
>>>>>>
>>>>>> /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+
>>>>>> Asserts/bin/../include/c++/v1/__threading_support:154:1: error:
>>>>>> unknown type name 'mach_port_t'
>>>>>> mach_port_t __libcpp_thread_get_port();
>>>>>>
>>>>>> On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits <
>>>>>> cfe-commits@lists.llvm.org> wrote:
>>>>>>
>>>>>>> Author: asiri
>>>>>>> Date: Tue Jan  3 06:59:50 2017
>>>>>>> New Revision: 290889
>>>>>>>
>>>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=290889=rev
>>>>>>> Log:
>>>>>>> [libcxx] Add build/test support for the externally threaded
>>>>>>> libc++abi variant
>>>>>>>
>>>>>>> Differential revision: https://reviews.llvm.org/D27576
>>>>>>>
>>>>>>> Reviewers: EricWF
>>>>>>>
>>>>>>> Modified:
>>>>>>> libcxx/trunk/CMakeLists.txt
>>>>>>> libcxx/trunk/include/__threading_support
>>>>>>> libcxx/trunk/test/CMakeLists.txt
>>>>>>> libcxx/trunk/test/libcxx/test/co

Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant

2017-01-25 Thread Asiri Rathnayake via cfe-commits
@Nico: could you let me know your build configuration? (cmake options)

I'm surprised this went unnoticed for so long.

Thanks.

/ Asiri

On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" <asiri.rathnay...@gmail.com>
wrote:

> (including cfe-commits)
>
> On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake <
> asiri.rathnay...@gmail.com> wrote:
>
>> Hi Nico,
>>
>> On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Is it intentional that this change affects 
>>> non-LIBCXX_HAS_EXTERNAL_THREAD_API
>>> builds at all?#
>>>
>>
>> Nope. But I'm not sure how this got broken on Mac.
>>
>> IIRC,  defines mach_port_t type on Mac, which gets included
>> when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we expect
>> to be the case on Mac, normally).
>>
>> I'll have to build this on a Mac tomorrow. Hopefully that's OK?
>>
>> Cheers,
>>
>> / Asiri
>>
>>
>>
>>>
>>> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber <tha...@chromium.org>
>>> wrote:
>>>
>>>> This breaks all our mac builds with:
>>>>
>>>> /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+
>>>> Asserts/bin/../include/c++/v1/__threading_support:154:1: error:
>>>> unknown type name 'mach_port_t'
>>>> mach_port_t __libcpp_thread_get_port();
>>>>
>>>> On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits <
>>>> cfe-commits@lists.llvm.org> wrote:
>>>>
>>>>> Author: asiri
>>>>> Date: Tue Jan  3 06:59:50 2017
>>>>> New Revision: 290889
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=290889=rev
>>>>> Log:
>>>>> [libcxx] Add build/test support for the externally threaded libc++abi
>>>>> variant
>>>>>
>>>>> Differential revision: https://reviews.llvm.org/D27576
>>>>>
>>>>> Reviewers: EricWF
>>>>>
>>>>> Modified:
>>>>> libcxx/trunk/CMakeLists.txt
>>>>> libcxx/trunk/include/__threading_support
>>>>> libcxx/trunk/test/CMakeLists.txt
>>>>> libcxx/trunk/test/libcxx/test/config.py
>>>>> libcxx/trunk/test/lit.site.cfg.in
>>>>>
>>>>> Modified: libcxx/trunk/CMakeLists.txt
>>>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.
>>>>> txt?rev=290889=290888=290889=diff
>>>>> 
>>>>> ==
>>>>> --- libcxx/trunk/CMakeLists.txt (original)
>>>>> +++ libcxx/trunk/CMakeLists.txt Tue Jan  3 06:59:50 2017
>>>>> @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_
>>>>>" when LIBCXX_ENABLE_THREADS is also set to
>>>>> OFF.")
>>>>>  endif()
>>>>>
>>>>> -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
>>>>> -  message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
>>>>> -  " when LIBCXX_ENABLE_THREADS is also set to
>>>>> ON.")
>>>>> +if(NOT LIBCXX_ENABLE_THREADS)
>>>>> +  if(LIBCXX_HAS_PTHREAD_API)
>>>>> +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
>>>>> +" when LIBCXX_ENABLE_THREADS is also set to
>>>>> ON.")
>>>>> +  endif()
>>>>> +  if(LIBCXX_HAS_EXTERNAL_THREAD_API)
>>>>> +message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be
>>>>> set to ON"
>>>>> +" when LIBCXX_ENABLE_THREADS is also set to
>>>>> ON.")
>>>>> +  endif()
>>>>>  endif()
>>>>>
>>>>> -if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS)
>>>>> -  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be
>>>>> set to ON"
>>>>> -  " when LIBCXX_ENABLE_THREADS is also set to
>>>>> ON.")
>>>>> +if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
>>>>> +  message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
&

Re: [libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant

2017-01-25 Thread Asiri Rathnayake via cfe-commits
(including cfe-commits)

On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake <
asiri.rathnay...@gmail.com> wrote:

> Hi Nico,
>
> On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Is it intentional that this change affects non-LIBCXX_HAS_EXTERNAL_THREAD_API
>> builds at all?#
>>
>
> Nope. But I'm not sure how this got broken on Mac.
>
> IIRC,  defines mach_port_t type on Mac, which gets included
> when _LIBCPP_HAS_THREAD_API_PTHREAD is defined (which is what we expect
> to be the case on Mac, normally).
>
> I'll have to build this on a Mac tomorrow. Hopefully that's OK?
>
> Cheers,
>
> / Asiri
>
>
>
>>
>> On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber <tha...@chromium.org> wrote:
>>
>>> This breaks all our mac builds with:
>>>
>>> /b/c/b/ClangToTMac__dbg_/src/third_party/llvm-build/Release+
>>> Asserts/bin/../include/c++/v1/__threading_support:154:1: error: unknown
>>> type name 'mach_port_t'
>>> mach_port_t __libcpp_thread_get_port();
>>>
>>> On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: asiri
>>>> Date: Tue Jan  3 06:59:50 2017
>>>> New Revision: 290889
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=290889=rev
>>>> Log:
>>>> [libcxx] Add build/test support for the externally threaded libc++abi
>>>> variant
>>>>
>>>> Differential revision: https://reviews.llvm.org/D27576
>>>>
>>>> Reviewers: EricWF
>>>>
>>>> Modified:
>>>> libcxx/trunk/CMakeLists.txt
>>>> libcxx/trunk/include/__threading_support
>>>> libcxx/trunk/test/CMakeLists.txt
>>>> libcxx/trunk/test/libcxx/test/config.py
>>>> libcxx/trunk/test/lit.site.cfg.in
>>>>
>>>> Modified: libcxx/trunk/CMakeLists.txt
>>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.
>>>> txt?rev=290889=290888=290889=diff
>>>> 
>>>> ==
>>>> --- libcxx/trunk/CMakeLists.txt (original)
>>>> +++ libcxx/trunk/CMakeLists.txt Tue Jan  3 06:59:50 2017
>>>> @@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_
>>>>" when LIBCXX_ENABLE_THREADS is also set to
>>>> OFF.")
>>>>  endif()
>>>>
>>>> -if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
>>>> -  message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
>>>> -  " when LIBCXX_ENABLE_THREADS is also set to ON.")
>>>> +if(NOT LIBCXX_ENABLE_THREADS)
>>>> +  if(LIBCXX_HAS_PTHREAD_API)
>>>> +message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
>>>> +" when LIBCXX_ENABLE_THREADS is also set to
>>>> ON.")
>>>> +  endif()
>>>> +  if(LIBCXX_HAS_EXTERNAL_THREAD_API)
>>>> +message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be
>>>> set to ON"
>>>> +" when LIBCXX_ENABLE_THREADS is also set to
>>>> ON.")
>>>> +  endif()
>>>>  endif()
>>>>
>>>> -if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS)
>>>> -  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set
>>>> to ON"
>>>> -  " when LIBCXX_ENABLE_THREADS is also set to ON.")
>>>> +if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
>>>> +  message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
>>>> +  "and LIBCXX_HAS_PTHREAD_API cannot be both"
>>>> +  "set to ON at the same time.")
>>>>  endif()
>>>>
>>>>  # Ensure LLVM_USE_SANITIZER is not specified when
>>>> LIBCXX_GENERATE_COVERAGE
>>>>
>>>> Modified: libcxx/trunk/include/__threading_support
>>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__t
>>>> hreading_support?rev=290889=290888=290889=diff
>>>> 
>>>> ==
>>>> --- libcxx/tru

Re: [PATCH] D29063: [libcxx] Never use within libc++

2017-01-24 Thread Asiri Rathnayake via cfe-commits
Thanks for the lightening fast response :)

/ Asiri

On Tue, Jan 24, 2017 at 12:38 PM, Eric Fiselier via Phabricator via
cfe-commits  wrote:

> EricWF added a comment.
>
> It seems like weird usages of `_LIBCPP_ASSERT` in `` are
> causing this problem.
> Specifically the usages in `` attempt to use `_LIBCPP_ASSERT`
> in C++11 constexpr functions and this currently does not work.
>
> For now I've reverted this change in r292923.
>
>
> https://reviews.llvm.org/D29063
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r292109 - [libcxx] Follow-up to r292107

2017-01-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Jan 16 07:13:01 2017
New Revision: 292109

URL: http://llvm.org/viewvc/llvm-project?rev=292109=rev
Log:
[libcxx] Follow-up to r292107

I've missed a couple of updates. NFC.

Modified:
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/thread.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=292109=292108=292109=diff
==
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Mon Jan 16 07:13:01 2017
@@ -40,7 +40,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 thread::~thread()
 {
-if (__t_ != 0)
+if (!__libcpp_thread_isnull(&__t_))
 terminate();
 }
 
@@ -48,11 +48,11 @@ void
 thread::join()
 {
 int ec = EINVAL;
-if (__t_ != 0)
+if (!__libcpp_thread_isnull(&__t_))
 {
 ec = __libcpp_thread_join(&__t_);
 if (ec == 0)
-__t_ = 0;
+__t_ = _LIBCPP_NULL_THREAD;
 }
 
 if (ec)
@@ -63,11 +63,11 @@ void
 thread::detach()
 {
 int ec = EINVAL;
-if (__t_ != 0)
+if (!__libcpp_thread_isnull(&__t_))
 {
 ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
-__t_ = 0;
+__t_ = _LIBCPP_NULL_THREAD;
 }
 
 if (ec)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r292108 - [libcxx] Improve design documentation for the external-thread-library

2017-01-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Jan 16 06:44:08 2017
New Revision: 292108

URL: http://llvm.org/viewvc/llvm-project?rev=292108=rev
Log:
[libcxx] Improve design documentation for the external-thread-library
  configuration

NFC.

Differential revision: https://reviews.llvm.org/D28610

Reviewers: EricWF

Modified:
libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst

Modified: libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst?rev=292108=292107=292108=diff
==
--- libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst (original)
+++ libcxx/trunk/docs/DesignDocs/ThreadingSupportAPI.rst Mon Jan 16 06:44:08 
2017
@@ -33,13 +33,22 @@ interface normally provided by ``<__thre
 External Threading Library
 ==
 
-Normally ``<__threading_support>`` provides inline definitions to each internal
-threading API function it declares. However libc++ also supports using an
-external library to provide the definitions.
+libc++ can be compiled with its internal threading API delegating to an 
external
+library. Such a configuration is useful for library vendors who wish to
+distribute a thread-agnostic libc++ library, where the users of the library are
+expected to provide the implementation of the libc++ internal threading API.
 
-When ``_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL`` libc++ does not provide inline
-definitions for the internal API, instead assuming the definitions will be
-provided by an external library.
+On a production setting, this would be achieved through a custom
+``<__external_threading>`` header, which declares the libc++ internal threading
+API but leaves out the implementation.
+
+The ``-DLIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY`` option allows building libc++ in
+such a configuration while allowing it to be tested on a platform that supports
+any of the threading systems (e.g. pthread) supported in 
``__threading_support``
+header. Therefore, the main purpose of this option is to allow testing of this
+particular configuration of the library without being tied to a vendor-specific
+threading system. This option is only meant to be used by libc++ library
+developers.
 
 Threading Configuration Macros
 ==


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r292107 - [libcxx] Don't assume __libcpp_thread_t is an integral type

2017-01-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Jan 16 06:19:54 2017
New Revision: 292107

URL: http://llvm.org/viewvc/llvm-project?rev=292107=rev
Log:
[libcxx] Don't assume __libcpp_thread_t is an integral type

We have already refactored the underlying platform thread type into
__libcpp_thread_t, but there are few places in the source where we
still assume it is an integral type.

This patch refactores those points back into the threading API.

Differential revision: https://reviews.llvm.org/D28608

Reviewers: EricWF

Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/include/thread

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=292107=292106=292107=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Mon Jan 16 06:19:54 2017
@@ -61,6 +61,8 @@ typedef pthread_once_t __libcpp_exec_onc
 typedef pthread_t __libcpp_thread_id;
 
 // Thread
+#define _LIBCPP_NULL_THREAD 0U
+
 typedef pthread_t __libcpp_thread_t;
 
 // Thrad Local Storage
@@ -86,6 +88,8 @@ typedef INIT_ONCE __libcpp_exec_once_fla
 typedef DWORD __libcpp_thread_id;
 
 // Thread
+#define _LIBCPP_NULL_THREAD 0U
+
 typedef HANDLE __libcpp_thread_t;
 
 // Thread Local Storage
@@ -158,6 +162,9 @@ bool __libcpp_thread_id_less(__libcpp_th
 
 // Thread
 _LIBCPP_THREAD_ABI_VISIBILITY
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t);
+
+_LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg);
 
@@ -309,6 +316,10 @@ bool __libcpp_thread_id_less(__libcpp_th
 }
 
 // Thread
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {
@@ -506,6 +517,10 @@ __libcpp_beginthreadex_thunk(void *__raw
   return static_cast(reinterpret_cast(__func(__arg)));
 }
 
+bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
+  return *__t == 0;
+}
+
 int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
void *__arg)
 {

Modified: libcxx/trunk/include/thread
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thread?rev=292107=292106=292107=diff
==
--- libcxx/trunk/include/thread (original)
+++ libcxx/trunk/include/thread Mon Jan 16 06:19:54 2017
@@ -290,7 +290,7 @@ public:
 typedef __libcpp_thread_t native_handle_type;
 
 _LIBCPP_INLINE_VISIBILITY
-thread() _NOEXCEPT : __t_(0) {}
+thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 template http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291433 - [libcxx] Fix externally-threaded shared library builds after r291275.

2017-01-09 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Jan  9 04:38:56 2017
New Revision: 291433

URL: http://llvm.org/viewvc/llvm-project?rev=291433=rev
Log:
[libcxx] Fix externally-threaded shared library builds after r291275.

Need to allow unresolved symbols in the dylib. This was previously done for
LIBCXX_HAS_EXTERNAL_THREAD_API, but we have since split that into two with
LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY being the externally-threaded variant.

Also a minor CMakeLists.txt cleanup.

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=291433=291432=291433=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan  9 04:38:56 2017
@@ -245,16 +245,17 @@ if(NOT LIBCXX_ENABLE_THREADS)
 
 endif()
 
-if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_HAS_EXTERNAL_THREAD_API)
-  message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and "
-  "LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at "
-  "the same time")
-endif()
-
-if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
-  message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
-  "and LIBCXX_HAS_PTHREAD_API cannot be both"
-  "set to ON at the same time.")
+if (LIBCXX_HAS_EXTERNAL_THREAD_API)
+  if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
+message(FATAL_ERROR "The options LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY and "
+"LIBCXX_HAS_EXTERNAL_THREAD_API cannot both be ON at "
+"the same time")
+  endif()
+  if (LIBCXX_HAS_PTHREAD_API)
+message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
+"and LIBCXX_HAS_PTHREAD_API cannot be both"
+"set to ON at the same time.")
+  endif()
 endif()
 
 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
@@ -460,7 +461,7 @@ if (NOT LIBCXX_ENABLE_RTTI)
 endif()
 
 # Threading flags =
-if (LIBCXX_HAS_EXTERNAL_THREAD_API AND LIBCXX_ENABLE_SHARED)
+if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXX_ENABLE_SHARED)
   # Need to allow unresolved symbols if this is to work with shared library 
builds
   if (APPLE)
 add_link_flags("-undefined dynamic_lookup")


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r291331 - thread: implement sleep_for on Windows

2017-01-07 Thread Asiri Rathnayake via cfe-commits
Yup, that sounds better.

I'll put up a patch soon.

Cheers,

/ Asiri

On 7 Jan 2017 9:18 p.m., "Saleem Abdulrasool"  wrote:

> I would really rather not introduce a `__libcpp_thread_nanosleep`.
> Different systems may have different granularities for their sleep.  A
> `__libcpp_sleep_for(std::chrono::duration)` sounds reasonable however.
>
> On Fri, Jan 6, 2017 at 11:53 PM, Asiri Rathnayake <
> asiri.rathnay...@gmail.com> wrote:
>
>> Wouldn't it be better to introduce a __libcpp_thread_nanosleep() API call
>> here?
>>
>> I bumped into a similar issue with a custom thread implementation and
>> have a downstream patch like that.
>>
>> Cheers,
>>
>> / Asiri
>>
>>
>> On 7 Jan 2017 2:59 a.m., "Saleem Abdulrasool via cfe-commits" <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: compnerd
>> Date: Fri Jan  6 20:48:30 2017
>> New Revision: 291331
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291331=rev
>> Log:
>> thread: implement sleep_for on Windows
>>
>> Windows does not provide an implementation of `nanosleep`.  Round up the
>> time duration to the nearest ms and use `Sleep`.  Although this may
>> over-sleep, there is no hard real-time guarantee on the wake, so
>> sleeping a bit more is better than under-sleeping as it within the
>> specification.
>>
>> Modified:
>> libcxx/trunk/src/thread.cpp
>>
>> Modified: libcxx/trunk/src/thread.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.
>> cpp?rev=291331=291330=291331=diff
>> 
>> ==
>> --- libcxx/trunk/src/thread.cpp (original)
>> +++ libcxx/trunk/src/thread.cpp Fri Jan  6 20:48:30 2017
>> @@ -117,6 +117,12 @@ sleep_for(const chrono::nanoseconds& ns)
>>  using namespace chrono;
>>  if (ns > nanoseconds::zero())
>>  {
>> +#if defined(_LIBCPP_WIN32API)
>> +milliseconds ms = duration_cast(ns);
>> +if (ns > duration_cast(ms))
>> +  ++ms;
>> +Sleep(ms.count());
>> +#else
>>  seconds s = duration_cast(ns);
>>  timespec ts;
>>  typedef decltype(ts.tv_sec) ts_sec;
>> @@ -134,6 +140,7 @@ sleep_for(const chrono::nanoseconds& ns)
>>
>>  while (nanosleep(, ) == -1 && errno == EINTR)
>>  ;
>> +#endif
>>  }
>>  }
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r291331 - thread: implement sleep_for on Windows

2017-01-06 Thread Asiri Rathnayake via cfe-commits
Wouldn't it be better to introduce a __libcpp_thread_nanosleep() API call
here?

I bumped into a similar issue with a custom thread implementation and have
a downstream patch like that.

Cheers,

/ Asiri


On 7 Jan 2017 2:59 a.m., "Saleem Abdulrasool via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

Author: compnerd
Date: Fri Jan  6 20:48:30 2017
New Revision: 291331

URL: http://llvm.org/viewvc/llvm-project?rev=291331=rev
Log:
thread: implement sleep_for on Windows

Windows does not provide an implementation of `nanosleep`.  Round up the
time duration to the nearest ms and use `Sleep`.  Although this may
over-sleep, there is no hard real-time guarantee on the wake, so
sleeping a bit more is better than under-sleeping as it within the
specification.

Modified:
libcxx/trunk/src/thread.cpp

Modified: libcxx/trunk/src/thread.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/
thread.cpp?rev=291331=291330=291331=diff

==
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Fri Jan  6 20:48:30 2017
@@ -117,6 +117,12 @@ sleep_for(const chrono::nanoseconds& ns)
 using namespace chrono;
 if (ns > nanoseconds::zero())
 {
+#if defined(_LIBCPP_WIN32API)
+milliseconds ms = duration_cast(ns);
+if (ns > duration_cast(ms))
+  ++ms;
+Sleep(ms.count());
+#else
 seconds s = duration_cast(ns);
 timespec ts;
 typedef decltype(ts.tv_sec) ts_sec;
@@ -134,6 +140,7 @@ sleep_for(const chrono::nanoseconds& ns)

 while (nanosleep(, ) == -1 && errno == EINTR)
 ;
+#endif
 }
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r290889 - [libcxx] Add build/test support for the externally threaded libc++abi variant

2017-01-03 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Tue Jan  3 06:59:50 2017
New Revision: 290889

URL: http://llvm.org/viewvc/llvm-project?rev=290889=rev
Log:
[libcxx] Add build/test support for the externally threaded libc++abi variant

Differential revision: https://reviews.llvm.org/D27576

Reviewers: EricWF

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/include/__threading_support
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/lit.site.cfg.in

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=290889=290888=290889=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Jan  3 06:59:50 2017
@@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_
   " when LIBCXX_ENABLE_THREADS is also set to OFF.")
 endif()
 
-if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)
-  message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
-  " when LIBCXX_ENABLE_THREADS is also set to ON.")
+if(NOT LIBCXX_ENABLE_THREADS)
+  if(LIBCXX_HAS_PTHREAD_API)
+message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"
+" when LIBCXX_ENABLE_THREADS is also set to ON.")
+  endif()
+  if(LIBCXX_HAS_EXTERNAL_THREAD_API)
+message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
+" when LIBCXX_ENABLE_THREADS is also set to ON.")
+  endif()
 endif()
 
-if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS)
-  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
-  " when LIBCXX_ENABLE_THREADS is also set to ON.")
+if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API)
+  message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API"
+  "and LIBCXX_HAS_PTHREAD_API cannot be both"
+  "set to ON at the same time.")
 endif()
 
 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=290889=290888=290889=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Tue Jan  3 06:59:50 2017
@@ -67,7 +67,11 @@ typedef pthread_mutex_t __libcpp_mutex_t
 typedef pthread_cond_t __libcpp_condvar_t;
 #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
 
-// THread ID
+// Execute once
+typedef pthread_once_t __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+// Thread id
 typedef pthread_t __libcpp_thread_id;
 
 // Thread
@@ -110,7 +114,17 @@ int __libcpp_condvar_timedwait(__libcpp_
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
 
-// Thread ID
+// Execute once
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+  void (*init_routine)(void));
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+_LIBCPP_THREAD_ABI_VISIBILITY
+mach_port_t __libcpp_thread_get_port();
+#endif
+
 _LIBCPP_THREAD_ABI_VISIBILITY
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
 
@@ -145,7 +159,7 @@ _LIBCPP_THREAD_ABI_VISIBILITY
 void *__libcpp_tls_get(__libcpp_tls_key __key);
 
 _LIBCPP_THREAD_ABI_VISIBILITY
-void __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
+int __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
 defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
@@ -221,6 +235,19 @@ int __libcpp_condvar_destroy(__libcpp_co
   return pthread_cond_destroy(__cv);
 }
 
+// Execute once
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+  void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+mach_port_t __libcpp_thread_get_port() {
+return pthread_mach_thread_np(pthread_self());
+}
+#endif
+
 // Returns non-zero if the thread ids are equal, otherwise 0
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
 {
@@ -276,9 +303,9 @@ void *__libcpp_tls_get(__libcpp_tls_key
   return pthread_getspecific(__key);
 }
 
-void __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
+int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
 {
-  pthread_setspecific(__key, __p);
+return pthread_setspecific(__key, __p);
 }
 
 #endif // _LIBCPP_HAS_THREAD_API_PTHREAD

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=290889=290888=290889=diff

[libcxxabi] r290888 - [libcxxabi] Introduce an externally threaded libc++abi variant.

2017-01-03 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Tue Jan  3 06:58:34 2017
New Revision: 290888

URL: http://llvm.org/viewvc/llvm-project?rev=290888=rev
Log:
[libcxxabi] Introduce an externally threaded libc++abi variant.

r281179 Introduced an externally threaded variant of the libc++ library. This
patch adds support for a similar library variant for libc++abi.

Differential revision: https://reviews.llvm.org/D27575

Reviewers: EricWF

Removed:
libcxxabi/trunk/src/threading_support.h
Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/src/config.h
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception_storage.cpp
libcxxabi/trunk/src/cxa_guard.cpp
libcxxabi/trunk/src/cxa_thread_atexit.cpp
libcxxabi/trunk/src/fallback_malloc.cpp
libcxxabi/trunk/test/CMakeLists.txt
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/lit.site.cfg.in
libcxxabi/trunk/test/test_exception_storage.pass.cpp
libcxxabi/trunk/test/test_fallback_malloc.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=290888=290887=290888=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Tue Jan  3 06:58:34 2017
@@ -118,6 +118,9 @@ option(LIBCXXABI_USE_LLVM_UNWINDER "Buil
 option(LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON)
 option(LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of 
pthread API" OFF)
+option(LIBCXXABI_HAS_EXTERNAL_THREAD_API
+  "Build libc++abi with an externalized threading API.
+  This option may only be set to ON when LIBCXXABI_ENABLE_THREADS=ON." OFF)
 option(LIBCXXABI_BUILD_32_BITS "Build 32 bit libc++abi." ${LLVM_BUILD_32_BITS})
 set(LIBCXXABI_TARGET_TRIPLE "" CACHE STRING "Target triple for cross 
compiling.")
 set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
@@ -347,20 +350,46 @@ if (NOT LIBCXXABI_ENABLE_SHARED)
   list(APPEND LIBCXXABI_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
 endif()
 
+# Threading
 if (NOT LIBCXXABI_ENABLE_THREADS)
   if (LIBCXXABI_HAS_PTHREAD_API)
 message(FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
 " be set to ON when LIBCXXABI_ENABLE_THREADS"
 " is also set to ON.")
   endif()
+  if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
+message(FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only"
+" be set to ON when LIBCXXABI_ENABLE_THREADS"
+" is also set to ON.")
+  endif()
   add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
 endif()
 
+if (LIBCXXABI_HAS_PTHREAD_API AND LIBCXXABI_HAS_EXTERNAL_THREAD_API)
+  message(FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API"
+  "and LIBCXXABI_HAS_PTHREAD_API cannot be both"
+  "set to ON at the same time.")
+endif()
+
+if (LIBCXXABI_HAS_EXTERNAL_THREAD_API AND LIBCXXABI_ENABLE_SHARED)
+  # Need to allow unresolved symbols if this is to work with shared library 
builds
+  if (APPLE)
+add_link_flags("-undefined dynamic_lookup")
+  else()
+# Relax this restriction from HandleLLVMOptions
+string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS 
"${CMAKE_SHARED_LINKER_FLAGS}")
+  endif()
+endif()
+
 if (LIBCXXABI_HAS_PTHREAD_API)
   add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
   add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD)
 endif()
 
+if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
+  add_definitions(-D_LIBCXXABI_HAS_THREAD_API_EXTERNAL)
+endif()
+
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)
 endif()

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=290888=290887=290888=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Tue Jan  3 06:58:34 2017
@@ -42,6 +42,7 @@
 
 // Try and deduce a threading api if one has not been explicitly set.
 #if !defined(_LIBCXXABI_HAS_NO_THREADS) && \
+!defined(_LIBCXXABI_HAS_THREAD_API_EXTERNAL) && \
 !defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
   #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 0
 #define _LIBCXXABI_USE_THREAD_API_PTHREAD

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=290888=290887=290888=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Tue Jan  3 06:58:34 2017
@@ -12,7 +12,6 @@
 
//===--===//
 
 #include "config.h"
-#include "threading_support.h"
 #include "cxxabi.h"
 
 #include // for std::terminate


[libcxx] r290878 - [libcxx] Fix testing of the externally-threaded library build

2017-01-03 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Tue Jan  3 05:32:31 2017
New Revision: 290878

URL: http://llvm.org/viewvc/llvm-project?rev=290878=rev
Log:
[libcxx] Fix testing of the externally-threaded library build
 after r290850

Before r290850, building libcxx with -DLIBCXX_HAS_EXTERNAL_THREAD_API=ON had two
uses:
  - Allow platform vendors to plug-in an __external_threading header which
should take care of the entire threading infrastructure of libcxx

  - Allow testing of an externally-threaded library build; where the thread API
is declared using pthread data structures, and the implementation of this
API is provided as a separate library (test/support/external_threads.cpp)
   and linked-in when running the test suite.

r290850 breaks the second use case (pthread data structures are no longer
available). This patch re-stores the ability to build+test an
externally-threaded library variant on a pthread based system.

Modified:
libcxx/trunk/include/__threading_support
libcxx/trunk/test/support/external_threads.cpp

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=290878=290877=290878=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Tue Jan  3 05:32:31 2017
@@ -28,11 +28,23 @@
 #endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
+!__libcpp_has_include(<__external_threading>)
+// If the <__external_threading> header is absent, build libc++ against a
+// pthread-oriented thread api but leave out its implementation. This setup
+// allows building+testing of an externally-threaded library variant (on any
+// platform that supports pthreads). Here, an 'externally-threaded' library
+// variant is one where the implementation of the libc++ thread api is provided
+// as a separate library.
+#define _LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD
+#endif
+
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
 __libcpp_has_include(<__external_threading>)
 #include <__external_threading>
 #else
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
+defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
 #include 
 #include 
 #endif
@@ -45,7 +57,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
+defined(_LIBCPP_HAS_THREAD_API_EXTERNAL_PTHREAD)
 // Mutex
 typedef pthread_mutex_t __libcpp_mutex_t;
 #define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -134,7 +147,8 @@ void *__libcpp_tls_get(__libcpp_tls_key
 _LIBCPP_THREAD_ABI_VISIBILITY
 void __libcpp_tls_set(__libcpp_tls_key __key, void *__p);
 
-#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || \
+defined(_LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD)
 
 int __libcpp_recursive_mutex_init(__libcpp_mutex_t *__m)
 {

Modified: libcxx/trunk/test/support/external_threads.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/external_threads.cpp?rev=290878=290877=290878=diff
==
--- libcxx/trunk/test/support/external_threads.cpp (original)
+++ libcxx/trunk/test/support/external_threads.cpp Tue Jan  3 05:32:31 2017
@@ -6,5 +6,5 @@
 // Source Licenses. See LICENSE.TXT for details.
 //
 
//===--===//
-#define _LIBCPP_HAS_THREAD_API_PTHREAD
+#define _LIBCPP_BUILDING_THREAD_API_EXTERNAL_PTHREAD
 #include <__threading_support>


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-19 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

On the other hand, disabling `` would mean disabling some parts of 
the library as well (in this case, `std::promise::set_exception`). Perhaps 
that's a bad path to follow. Not sure.


Repository:
  rL LLVM

https://reviews.llvm.org/D26458



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-19 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D26458#594069, @EricWF wrote:

> There are cases where it is useful to be able to name `std::nested_exception` 
> while exceptions are disabled.


I was thinking about the opposite. That is, we might want to consider disabling 
the `` header altogether when compiling with `-fno-exceptions`.  My 
particular use case is to do with futures:

  void make_hello(std::promise , bool set_exception) {
if (set_exception)
  p.set_exception(std::make_exception_ptr(
   std::runtime_error {"No hellos left."}));
else
  p.set_value("Hello world!");
  }

This will compile fine with `-fno-exceptions` and when the client thread 
attempts to read from the promise, whole program would crash. May be they 
deserve it, but I feel like it's something we can help with; if we disable the 
`` header, this code wouldn't compile under `-fno-exceptions`.

In what cases do we need to allow various exception types under 
`-fno-exceptions`?

Cheers,

/ Asiri


Repository:
  rL LLVM

https://reviews.llvm.org/D26458



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-09 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D26458#590865, @rmaprath wrote:

> Not sure if either of these tests add much value to the no-exceptions 
> variant, using `std::nested_exception` with such a library seem pointless to 
> me. Perhaps marking these as `UNSUPPORTED` is a better fix?


Also, it seems like we are saving the same assert in all the three tests. If we 
want to save it that badly, perhaps creating a new test case with a `REQUIRES: 
libcpp-no-exceptions` is a better  fix.


https://reviews.llvm.org/D26458



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26139: Tests for strings conversions under libcpp-no-exceptions

2016-11-06 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D26139#587587, @mclow.lists wrote:

> >   I think it might be better to add TEST_TRY and TEST_CATCH(...) macros 
> > defined like
>
> @rogfer01 said at the top that he didn't want to add "a magical TEST_TRY 
> macro" - and I agree.  Someone tried that in another review, and I nixed it 
> there.


I had a proposal for something along those lines in 
https://reviews.llvm.org/D14653, however those TEST_TRY and TEST_CATCH macros 
were trying to be "too smart".

I agree, having macros for `try` and `catch` sounds to me like it would set the 
wrong precedent.


https://reviews.llvm.org/D26139



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26139: Tests for strings conversions under libcpp-no-exceptions

2016-11-02 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Would it be more cleaner to separate out the exceptions-related tests into 
their own functions? So, we'd have the two functions `test_withexceptions()` 
and `test_noexceptions()`; the former will only be invoked when testing the 
normal library variant, the latter will be invoked for all the library variants.

WDYT?

/ Asiri


https://reviews.llvm.org/D26139



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-10-31 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.



Comment at: test/std/strings/basic.string/string.access/at.pass.cpp:41
+const S& cs = s;
+if (pos < cs.size())
+{

rogfer01 wrote:
> rmaprath wrote:
> > For the cases where an exception //should've been// thrown, are we not 
> > entering the **undefined** domain at this point?
> > 
> > What if instead, we define two versions of the `test()` function? one 
> > containing the current code as-is, and the other only handles the cases 
> > where exceptions are not expected, and we modify the `main()` function 
> > below so that the correct `test()` case is invoked depending on the 
> > presence  / absence of exceptions? It's a bit more cumbersome than the 
> > current setup, but I'm not totally happy about treading into the undefined 
> > domain (if my understanding above is correct). 
> If I understand this test correctly, it checks for the `at` member function. 
> While certainly binding a const reference might throw, here it is bound to a 
> lvalue of the same type so no temporary construction should happen.
> 
> The original test checks both `s.size()` and `cs.size()`. Given that `size` 
> is a const member function it probably does not matter given that `cs` and 
> `s` are aliased, but see comment below.
Right, so it's the `at()` method which is expected to throw in this case. What 
you are doing here is carefully avoiding the exception throwing code-path while 
keeping the remaining assertions intact. Makes sense.

I'll go over the rest of the test cases to double check. But I'm happy with 
this.

(You need to wait for approval from @EricWF or @mclow.lists to commit)


https://reviews.llvm.org/D26136



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-10-31 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.



Comment at: test/std/strings/basic.string/string.access/at.pass.cpp:41
+const S& cs = s;
+if (pos < cs.size())
+{

For the cases where an exception //should've been// thrown, are we not entering 
the **undefined** domain at this point?

What if instead, we define two versions of the `test()` function? one 
containing the current code as-is, and the other only handles the cases where 
exceptions are not expected, and we modify the `main()` function below so that 
the correct `test()` case is invoked depending on the presence  / absence of 
exceptions? It's a bit more cumbersome than the current setup, but I'm not 
totally happy about treading into the undefined domain (if my understanding 
above is correct). 


https://reviews.llvm.org/D26136



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26075: Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: libcpp-no-exceptions" tests that only check exceptions and nothing else

2016-10-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

This looks sensible to me. I'll let @EricWF approve.

/ Asiri


https://reviews.llvm.org/D26075



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24864#570954, @vitalybuka wrote:

> Thanks, done https://reviews.llvm.org/D25636


Thanks for the fix!

/ Asiri


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24864#570935, @vitalybuka wrote:

> Maybe?
>
>   - if (UNIX AND NOT (APPLE OR CYGWIN))
>   + if (LIBCXXABI_ENABLE_THREADS AND UNIX AND NOT (APPLE OR CYGWIN))
>   list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)
>   endif()
>


Yes!

I was just about to say I don't know why it's even trying to build this, given 
that the library is configured with `-DLIBCXXABI_ENABLE_THREADS=OFF`.

Feel free to commit a fix :)

Cheers,

/ Asiri


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24864#570924, @vitalybuka wrote:

> So there is:
>
> - Looking for __cxa_thread_atexit_impl in c
> - Looking for __cxa_thread_atexit_impl in c - not found
>
>   and libcxx is configured with -DLIBCXX_ENABLE_THREADS=OFF


I think, the problem here is that `cxa_thread_atexit.cpp` is not properly 
guarded against the non-threaded use-case. If you look at the source prior to 
this patch, it refers to `pthread.h` and `pthread_key_t` unconditionally, it 
may have worked because pthread was somehow linked in.

The fix should be fairly straightforward. I will do a patch tomorrow (bit late 
in the day here), hope that's OK?

Cheers,

/ Asiri


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r284237 - [libcxx] Improve the gcc workaround for the missing __has_include macro.

2016-10-14 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Oct 14 08:56:58 2016
New Revision: 284237

URL: http://llvm.org/viewvc/llvm-project?rev=284237=rev
Log:
[libcxx] Improve the gcc workaround for the missing __has_include macro.

NFC.

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=284237=284236=284237=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Fri Oct 14 08:56:58 2016
@@ -19,20 +19,18 @@
 
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-// These checks are carefully arranged so as not to trigger a gcc pre-processor
-// defect which causes it to fail to parse the __has_include check below, the
-// redundancy is intentional.
-#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-#if !defined(__clang__) && (_GNUC_VER < 500)
-#include <__external_threading>
-#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
-#elif !defined(__has_include) || __has_include(<__external_threading>)
-#include <__external_threading>
-#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
-#endif
+#ifndef __libcpp_has_include
+  #ifndef __has_include
+#define __libcpp_has_include(x) 0
+  #else
+#define __libcpp_has_include(x) __has_include(x)
+  #endif
 #endif
 
-#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
+#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && \
+__libcpp_has_include(<__external_threading>)
+#include <__external_threading>
+#else
 #include 
 #include 
 
@@ -241,7 +239,7 @@ void __libcpp_tls_set(__libcpp_tls_key _
 
 _LIBCPP_END_NAMESPACE_STD
 
-#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+#endif // !_LIBCPP_HAS_THREAD_API_EXTERNAL || 
!__libcpp_has_include(<__external_threading>)
 
 #endif // _LIBCPP_HAS_NO_THREADS
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r284232 - [libcxx] Do not declare the thread api when __external_threading is present

2016-10-14 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Oct 14 08:00:07 2016
New Revision: 284232

URL: http://llvm.org/viewvc/llvm-project?rev=284232=rev
Log:
[libcxx] Do not declare the thread api when __external_threading is present

This fixes a small omission where even when __external_threading is provided,
we attempt to declare a pthread based threading API. Instead, we should leave
out everything for the __external_threading header to take care of.

The __threading_support header provides a proof-of-concept externally threaded
libc++ variant when _LIBCPP_HAS_THREAD_API_EXTERNAL is defined. But if the
__external_threading header is present, we should exclude all of that POC stuff.

Reviewers: EricWF

Differential revision: https://reviews.llvm.org/D25468

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=284232=284231=284232=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Fri Oct 14 08:00:07 2016
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@ void __libcpp_tls_set(__libcpp_tls_key _
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Asiri Rathnayake via cfe-commits
rmaprath closed this revision.
rmaprath added a comment.

Committed as r284128.


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-13 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@EricWF: Gentle ping.


https://reviews.llvm.org/D25468



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libunwind] r284125 - [libunwind] Add missing include. NFC.

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Had a look at the C99 spec, according to section 7.18.1.1 ("Exact-width
integer types"), the types uint_t should be available in stdint.h
itself, inttypes.h on the other hand builds on stdint.h and provides more
functionality.

I don't see a particular need to include inttypes.h here?

Cheers,

/ Asiri

On Thu, Oct 13, 2016 at 7:46 PM, Joerg Sonnenberger via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Thu, Oct 13, 2016 at 02:32:24PM -0000, Asiri Rathnayake via cfe-commits
> wrote:
> > This missing include seems to cause compilation failures on older MacOS
> > versions (< 10.9). This is because r270692 has introduced uint64_t into
> > config.h without including this header.
>
> But that would be inttypes.h, wouldn't it be?
>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxxabi] r284128 - [libcxxabi] Refactor pthread usage into a separate API

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Should be fixed in r284141.

/ Asiri

On Thu, Oct 13, 2016 at 7:20 PM, Asiri Rathnayake <
asiri.rathnay...@gmail.com> wrote:

> Looks like this broke the gcc builder: http://lab.llvm.org:
> 8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-
> gcc49-cxx11/builds/573/steps/build.libcxxabi/logs/stdio
>
> I'll have a look soon, might not be able to do so before tomorrow. Please
> feel free to revert if this is blocking.
>
> Sorry for the trouble.
>
> / Asiri
>
> On Thu, Oct 13, 2016 at 4:05 PM, Asiri Rathnayake via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: asiri
>> Date: Thu Oct 13 10:05:19 2016
>> New Revision: 284128
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=284128=rev
>> Log:
>> [libcxxabi] Refactor pthread usage into a separate API
>>
>> This patch refactors all pthread uses of libc++abi into a separate API.
>> This
>> is the first step towards supporting an externlly-threaded libc++abi
>> library.
>>
>> I've followed the conventions already used in the libc++ library for the
>> same
>> purpose.
>>
>> Patch from: Saleem Abdulrasool and Asiri Rathnayake
>>
>> Reviewed by: compnerd, EricWF
>>
>> Differential revisions:
>>   https://reviews.llvm.org/D18482 (original)
>>   https://reviews.llvm.org/D24864 (final)
>>
>> Added:
>> libcxxabi/trunk/src/threading_support.h
>> Modified:
>> libcxxabi/trunk/CMakeLists.txt
>> libcxxabi/trunk/src/config.h
>> libcxxabi/trunk/src/cxa_exception.cpp
>> libcxxabi/trunk/src/cxa_exception_storage.cpp
>> libcxxabi/trunk/src/cxa_guard.cpp
>> libcxxabi/trunk/src/cxa_thread_atexit.cpp
>> libcxxabi/trunk/src/fallback_malloc.cpp
>> libcxxabi/trunk/test/test_exception_storage.pass.cpp
>> libcxxabi/trunk/test/test_fallback_malloc.pass.cpp
>>
>> Modified: libcxxabi/trunk/CMakeLists.txt
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLis
>> ts.txt?rev=284128=284127=284128=diff
>> 
>> ==
>> --- libcxxabi/trunk/CMakeLists.txt (original)
>> +++ libcxxabi/trunk/CMakeLists.txt Thu Oct 13 10:05:19 2016
>> @@ -340,6 +340,7 @@ endif()
>>
>>  if (LIBCXXABI_HAS_PTHREAD_API)
>>add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
>> +  add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD)
>>  endif()
>>
>>  if (MSVC)
>>
>> Modified: libcxxabi/trunk/src/config.h
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/conf
>> ig.h?rev=284128=284127=284128=diff
>> 
>> ==
>> --- libcxxabi/trunk/src/config.h (original)
>> +++ libcxxabi/trunk/src/config.h Thu Oct 13 10:05:19 2016
>> @@ -16,6 +16,36 @@
>>
>>  #include 
>>
>> +// Configure inline visibility attributes
>> +#if defined(_WIN32)
>> + #if defined(_MSC_VER) && !defined(__clang__)
>> +  // Using Microsoft Visual C++ compiler
>> +  #define _LIBCXXABI_INLINE_VISIBILITY __forceinline
>> + #else
>> +  #if __has_attribute(__internal_linkage__)
>> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__internal_linkage__, __always_inline__))
>> +  #else
>> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__always_inline__))
>> +  #endif
>> + #endif
>> +#else
>> + #if __has_attribute(__internal_linkage__)
>> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__internal_linkage__, __always_inline__))
>> + #else
>> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
>> ((__visibility__("hidden"), __always_inline__))
>> + #endif
>> +#endif
>> +
>> +// Try and deduce a threading api if one has not been explicitly set.
>> +#if !defined(_LIBCXXABI_HAS_NO_THREADS) && \
>> +!defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
>> +  #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 0
>> +#define _LIBCXXABI_USE_THREAD_API_PTHREAD
>> +  #else
>> +#error "No thread API"
>> +  #endif
>> +#endif
>> +
>>  // Set this in the CXXFLAGS when you need it, because otherwise we'd
>> have to
>>  // #if !defined(__linux__) && !defined(__APPLE__) && ...
>>  // and so-on for *every* platform.
>>
>> Modified: libcxxabi/trunk/src/cxa_exception.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_
>> exception.cpp?rev=284128=284127=28412

[libcxxabi] r284141 - [libcxxabi] Fix gcc build after r284128

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct 13 13:40:57 2016
New Revision: 284141

URL: http://llvm.org/viewvc/llvm-project?rev=284141=rev
Log:
[libcxxabi] Fix gcc build after r284128

NFC.

Modified:
libcxxabi/trunk/src/config.h

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=284141=284140=284141=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Thu Oct 13 13:40:57 2016
@@ -16,6 +16,10 @@
 
 #include 
 
+#ifndef __has_attribute
+  #define __has_attribute(x) 0
+#endif
+
 // Configure inline visibility attributes
 #if defined(_WIN32)
  #if defined(_MSC_VER) && !defined(__clang__)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxxabi] r284128 - [libcxxabi] Refactor pthread usage into a separate API

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Looks like this broke the gcc builder:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11/builds/573/steps/build.libcxxabi/logs/stdio

I'll have a look soon, might not be able to do so before tomorrow. Please
feel free to revert if this is blocking.

Sorry for the trouble.

/ Asiri

On Thu, Oct 13, 2016 at 4:05 PM, Asiri Rathnayake via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: asiri
> Date: Thu Oct 13 10:05:19 2016
> New Revision: 284128
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284128=rev
> Log:
> [libcxxabi] Refactor pthread usage into a separate API
>
> This patch refactors all pthread uses of libc++abi into a separate API.
> This
> is the first step towards supporting an externlly-threaded libc++abi
> library.
>
> I've followed the conventions already used in the libc++ library for the
> same
> purpose.
>
> Patch from: Saleem Abdulrasool and Asiri Rathnayake
>
> Reviewed by: compnerd, EricWF
>
> Differential revisions:
>   https://reviews.llvm.org/D18482 (original)
>   https://reviews.llvm.org/D24864 (final)
>
> Added:
> libcxxabi/trunk/src/threading_support.h
> Modified:
> libcxxabi/trunk/CMakeLists.txt
> libcxxabi/trunk/src/config.h
> libcxxabi/trunk/src/cxa_exception.cpp
> libcxxabi/trunk/src/cxa_exception_storage.cpp
> libcxxabi/trunk/src/cxa_guard.cpp
> libcxxabi/trunk/src/cxa_thread_atexit.cpp
> libcxxabi/trunk/src/fallback_malloc.cpp
> libcxxabi/trunk/test/test_exception_storage.pass.cpp
> libcxxabi/trunk/test/test_fallback_malloc.pass.cpp
>
> Modified: libcxxabi/trunk/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/
> CMakeLists.txt?rev=284128=284127=284128=diff
> 
> ==
> --- libcxxabi/trunk/CMakeLists.txt (original)
> +++ libcxxabi/trunk/CMakeLists.txt Thu Oct 13 10:05:19 2016
> @@ -340,6 +340,7 @@ endif()
>
>  if (LIBCXXABI_HAS_PTHREAD_API)
>add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
> +  add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD)
>  endif()
>
>  if (MSVC)
>
> Modified: libcxxabi/trunk/src/config.h
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
> config.h?rev=284128=284127=284128=diff
> 
> ==
> --- libcxxabi/trunk/src/config.h (original)
> +++ libcxxabi/trunk/src/config.h Thu Oct 13 10:05:19 2016
> @@ -16,6 +16,36 @@
>
>  #include 
>
> +// Configure inline visibility attributes
> +#if defined(_WIN32)
> + #if defined(_MSC_VER) && !defined(__clang__)
> +  // Using Microsoft Visual C++ compiler
> +  #define _LIBCXXABI_INLINE_VISIBILITY __forceinline
> + #else
> +  #if __has_attribute(__internal_linkage__)
> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__internal_linkage__, __always_inline__))
> +  #else
> +   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__always_inline__))
> +  #endif
> + #endif
> +#else
> + #if __has_attribute(__internal_linkage__)
> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__internal_linkage__, __always_inline__))
> + #else
> +  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__
> ((__visibility__("hidden"), __always_inline__))
> + #endif
> +#endif
> +
> +// Try and deduce a threading api if one has not been explicitly set.
> +#if !defined(_LIBCXXABI_HAS_NO_THREADS) && \
> +!defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
> +  #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 0
> +#define _LIBCXXABI_USE_THREAD_API_PTHREAD
> +  #else
> +#error "No thread API"
> +  #endif
> +#endif
> +
>  // Set this in the CXXFLAGS when you need it, because otherwise we'd have
> to
>  // #if !defined(__linux__) && !defined(__APPLE__) && ...
>  // and so-on for *every* platform.
>
> Modified: libcxxabi/trunk/src/cxa_exception.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/
> cxa_exception.cpp?rev=284128=284127=284128=diff
> 
> ==
> --- libcxxabi/trunk/src/cxa_exception.cpp (original)
> +++ libcxxabi/trunk/src/cxa_exception.cpp Thu Oct 13 10:05:19 2016
> @@ -12,6 +12,7 @@
>  //===---
> ---===//
>
>  #include "config.h"
> +#include "threading_support.h"
>  #include "cxxabi.h"
>
>  #include // for std::terminate
>
> Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
> URL: http://llvm.org/viewvc/llvm-project/lib

[libcxxabi] r284128 - [libcxxabi] Refactor pthread usage into a separate API

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct 13 10:05:19 2016
New Revision: 284128

URL: http://llvm.org/viewvc/llvm-project?rev=284128=rev
Log:
[libcxxabi] Refactor pthread usage into a separate API

This patch refactors all pthread uses of libc++abi into a separate API. This
is the first step towards supporting an externlly-threaded libc++abi library.

I've followed the conventions already used in the libc++ library for the same
purpose.

Patch from: Saleem Abdulrasool and Asiri Rathnayake

Reviewed by: compnerd, EricWF

Differential revisions:
  https://reviews.llvm.org/D18482 (original)
  https://reviews.llvm.org/D24864 (final)

Added:
libcxxabi/trunk/src/threading_support.h
Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/src/config.h
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception_storage.cpp
libcxxabi/trunk/src/cxa_guard.cpp
libcxxabi/trunk/src/cxa_thread_atexit.cpp
libcxxabi/trunk/src/fallback_malloc.cpp
libcxxabi/trunk/test/test_exception_storage.pass.cpp
libcxxabi/trunk/test/test_fallback_malloc.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=284128=284127=284128=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Thu Oct 13 10:05:19 2016
@@ -340,6 +340,7 @@ endif()
 
 if (LIBCXXABI_HAS_PTHREAD_API)
   add_definitions(-D_LIBCPP_HAS_THREAD_API_PTHREAD)
+  add_definitions(-D_LIBCXXABI_USE_THREAD_API_PTHREAD)
 endif()
 
 if (MSVC)

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=284128=284127=284128=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Thu Oct 13 10:05:19 2016
@@ -16,6 +16,36 @@
 
 #include 
 
+// Configure inline visibility attributes
+#if defined(_WIN32)
+ #if defined(_MSC_VER) && !defined(__clang__)
+  // Using Microsoft Visual C++ compiler
+  #define _LIBCXXABI_INLINE_VISIBILITY __forceinline
+ #else
+  #if __has_attribute(__internal_linkage__)
+   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__internal_linkage__, 
__always_inline__))
+  #else
+   #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__always_inline__))
+  #endif
+ #endif
+#else
+ #if __has_attribute(__internal_linkage__)
+  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ ((__internal_linkage__, 
__always_inline__))
+ #else
+  #define _LIBCXXABI_INLINE_VISIBILITY __attribute__ 
((__visibility__("hidden"), __always_inline__))
+ #endif
+#endif
+
+// Try and deduce a threading api if one has not been explicitly set.
+#if !defined(_LIBCXXABI_HAS_NO_THREADS) && \
+!defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+  #if defined(_POSIX_THREADS) && _POSIX_THREADS >= 0
+#define _LIBCXXABI_USE_THREAD_API_PTHREAD
+  #else
+#error "No thread API"
+  #endif
+#endif
+
 // Set this in the CXXFLAGS when you need it, because otherwise we'd have to
 // #if !defined(__linux__) && !defined(__APPLE__) && ...
 // and so-on for *every* platform.

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=284128=284127=284128=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Thu Oct 13 10:05:19 2016
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "config.h"
+#include "threading_support.h"
 #include "cxxabi.h"
 
 #include // for std::terminate

Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception_storage.cpp?rev=284128=284127=284128=diff
==
--- libcxxabi/trunk/src/cxa_exception_storage.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp Thu Oct 13 10:05:19 2016
@@ -14,6 +14,7 @@
 #include "cxa_exception.hpp"
 
 #include "config.h"
+#include "threading_support.h"
 
 #if defined(_LIBCXXABI_HAS_NO_THREADS)
 
@@ -44,28 +45,27 @@ extern "C" {
 
 #else
 
-#include 
 #include "abort_message.h"
 #include "fallback_malloc.h"
 
-//  In general, we treat all pthread errors as fatal.
+//  In general, we treat all threading errors as fatal.
 //  We cannot call std::terminate() because that will in turn
 //  call __cxa_get_globals() and cause infinite recursion.
 
 namespace __cxxabiv1 {
 namespace {
-pthread_key_t  key_;
-pthread_once_t flag_ = PTHREAD_ONCE_INIT;
+__libcxxabi_tls_key key_;
+__libcxxabi_exec_once_flag flag_ = _LIBCXXABI_EXEC_ONCE_INITIALIZER;
 
 void destruct_ (void *p) {
 __free_with_fallback ( p );
-if ( 0 != ::pthread_setspecific 

[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-13 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 74519.
rmaprath added a comment.
Herald added a subscriber: modocache.

Patch re-based on the latest trunk.

I've resolved my downstream issues, will be committing soon.

/ Asiri


https://reviews.llvm.org/D24864

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/cxa_thread_atexit.cpp
  src/fallback_malloc.cpp
  src/threading_support.h
  test/test_exception_storage.pass.cpp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,9 +12,7 @@
 #include 
 #include 
 #include 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
+#include "../src/threading_support.h"
 #include 
 
 #include "../src/cxa_exception.hpp"
@@ -40,19 +38,19 @@
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
-size_t  thread_globals [ NUMTHREADS ] = { 0 };
-pthread_t   threads[ NUMTHREADS ];
+size_t thread_globals [ NUMTHREADS ] = { 0 };
+__libcxxabi_thread_t   threads[ NUMTHREADS ];
 #endif
 
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i));
+__libcxxabi_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_join ( threads [ i ], NULL );
+__libcxxabi_thread_join (  [ i ] );
 
 for ( int i = 0; i < NUMTHREADS; ++i )
 if ( 0 == thread_globals [ i ] ) {
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,107 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+mach_port_t __libcxxabi_thread_get_port()
+{
+return pthread_mach_thread_np(pthread_self());
+}
+#endif
+
+// Thread
+typedef pthread_t __libcxxabi_thread_t;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_create(__libcxxabi_thread_t* __t,
+   void* (*__func)(void*), void* __arg)
+{
+return pthread_create(__t, 0, __func, __arg);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_join(__libcxxabi_thread_t* __t)
+{
+return pthread_join(*__t, 0);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_create(__libcxxabi_tls_key *key,
+   void (*destructor)(void 

Re: libunwind build regression fix

2016-10-13 Thread Asiri Rathnayake via cfe-commits
And... apologies for that disclaimer notice.

Cheers,

/ Asiri


From: cfe-commits <cfe-commits-boun...@lists.llvm.org> on behalf of Asiri 
Rathnayake via cfe-commits <cfe-commits@lists.llvm.org>
Sent: 13 October 2016 15:42
To: Jeremy Huddleston Sequoia
Cc: cfe-commits@lists.llvm.org
Subject: Re: libunwind build regression fix

Hi Jeremy,

Thanks for the patch, committed as r284125.

Cheers,

/ Asiri


From: jerem...@apple.com <jerem...@apple.com> on behalf of Jeremy Huddleston 
Sequoia <jerem...@apple.com>
Sent: 13 October 2016 06:57
To: Asiri Rathnayake
Subject: libunwind build regression fix

Hi Asiri,

Could you please push this build fix to libunwind.  Your 
LIBUNWIND_ENABLE_CROSS_UNWINDING change a few months ago introduced a build 
failure because uint64_t is used in config.h without an include of  
(failure noticed on macOS versions older than 10.9).

Thanks,
Jeremy


From 59508d1029580fe2f95eb4b8a002175c6f87710d Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia <jerem...@apple.com>
Date: Wed, 12 Oct 2016 22:52:51 -0700
Subject: [PATCH] config.h: Add missing include of stdint.h for uint64_t usage

Regressed-in: trunk r270692
Regressed-in: d2d1ea9d75dfc4f55540f7e3cf940c6a1d6674cc
Signed-off-by: Jeremy Huddleston Sequoia <jerem...@apple.com>
CC: Asiri Rathnayake <asiri.rathnay...@arm.com>
---
 src/config.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/config.h b/src/config.h
index cfe7706..4e4dd99 100644
--- a/src/config.h
+++ b/src/config.h
@@ -16,6 +16,7 @@

 #include 
 #include 
+#include 
 #include 

 // Define static_assert() unless already defined by compiler.
--
2.9.3

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: libunwind build regression fix

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Hi Jeremy,

Thanks for the patch, committed as r284125.

Cheers,

/ Asiri


From: jerem...@apple.com  on behalf of Jeremy Huddleston 
Sequoia 
Sent: 13 October 2016 06:57
To: Asiri Rathnayake
Subject: libunwind build regression fix

Hi Asiri,

Could you please push this build fix to libunwind.  Your 
LIBUNWIND_ENABLE_CROSS_UNWINDING change a few months ago introduced a build 
failure because uint64_t is used in config.h without an include of  
(failure noticed on macOS versions older than 10.9).

Thanks,
Jeremy


From 59508d1029580fe2f95eb4b8a002175c6f87710d Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston Sequoia 
Date: Wed, 12 Oct 2016 22:52:51 -0700
Subject: [PATCH] config.h: Add missing include of stdint.h for uint64_t usage

Regressed-in: trunk r270692
Regressed-in: d2d1ea9d75dfc4f55540f7e3cf940c6a1d6674cc
Signed-off-by: Jeremy Huddleston Sequoia 
CC: Asiri Rathnayake 
---
 src/config.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/config.h b/src/config.h
index cfe7706..4e4dd99 100644
--- a/src/config.h
+++ b/src/config.h
@@ -16,6 +16,7 @@

 #include 
 #include 
+#include 
 #include 

 // Define static_assert() unless already defined by compiler.
--
2.9.3

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r284125 - [libunwind] Add missing include. NFC.

2016-10-13 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct 13 09:32:24 2016
New Revision: 284125

URL: http://llvm.org/viewvc/llvm-project?rev=284125=rev
Log:
[libunwind] Add missing  include. NFC.

This missing include seems to cause compilation failures on older MacOS
versions (< 10.9). This is because r270692 has introduced uint64_t into
config.h without including this header.

Patch from: Jeremy Huddleston Sequoia (jerem...@apple.com)

Modified:
libunwind/trunk/src/config.h

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=284125=284124=284125=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Thu Oct 13 09:32:24 2016
@@ -16,6 +16,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 // Define static_assert() unless already defined by compiler.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r284005 - Remove incorrect XFAILS

2016-10-12 Thread Asiri Rathnayake via cfe-commits
More love for no-exceptions in any case ;)

Cheers!

On Wed, Oct 12, 2016 at 12:52 PM, Eric Fiselier  wrote:

> I just committed those tests, so I kinda had to fix them :-P
>
> On Wed, Oct 12, 2016 at 5:40 AM, Asiri Rathnayake <
> asiri.rathnay...@gmail.com> wrote:
>
>> Thanks!
>>
>> I still have that no-exception cleanup in my TODO list. Just pressed on
>> time, hope to get to it soon.
>>
>> / Asiri
>>
>> On Wed, Oct 12, 2016 at 12:29 PM, Eric Fiselier via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ericwf
>>> Date: Wed Oct 12 06:29:18 2016
>>> New Revision: 284005
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=284005=rev
>>> Log:
>>> Remove incorrect XFAILS
>>>
>>> Modified:
>>> libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/copy.pass.cpp
>>> libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/move.pass.cpp
>>> libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.ctor/copy.pass.cpp
>>> libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.ctor/move.pass.cpp
>>>
>>> Modified: libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/copy.pass.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx
>>> /utilities/optional/optional.object/optional.object.assign/c
>>> opy.pass.cpp?rev=284005=284004=284005=diff
>>> 
>>> ==
>>> --- libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/copy.pass.cpp (original)
>>> +++ libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/copy.pass.cpp Wed Oct 12 06:29:18 2016
>>> @@ -8,7 +8,6 @@
>>>  //===--
>>> ===//
>>>
>>>  // UNSUPPORTED: c++98, c++03, c++11, c++14
>>> -// XFAIL: libcpp-no-exceptions
>>>  // 
>>>
>>>  // optional& operator=(const optional& rhs);
>>> @@ -45,7 +44,6 @@ struct Z2
>>>  Z2& operator=(const Z2&) = default;
>>>  };
>>>
>>> -#if __cplusplus >= 201402
>>>  template 
>>>  constexpr bool
>>>  test()
>>> @@ -55,23 +53,18 @@ test()
>>>  opt = opt2;
>>>  return true;
>>>  }
>>> -#endif
>>>
>>>  int main()
>>>  {
>>>  {
>>>  using T = int;
>>>  
>>> static_assert((std::is_trivially_copy_assignable::value),
>>> "");
>>> -#if __cplusplus >= 201402
>>>  static_assert(test(), "");
>>> -#endif
>>>  }
>>>  {
>>>  using T = X;
>>>  
>>> static_assert((std::is_trivially_copy_assignable::value),
>>> "");
>>> -#if __cplusplus >= 201402
>>>  static_assert(test(), "");
>>> -#endif
>>>  }
>>>  static_assert(!(std::is_trivially_copy_assignable::value),
>>> "");
>>>  
>>> static_assert(!(std::is_trivially_copy_assignable::value),
>>> "");
>>>
>>> Modified: libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/move.pass.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx
>>> /utilities/optional/optional.object/optional.object.assign/m
>>> ove.pass.cpp?rev=284005=284004=284005=diff
>>> 
>>> ==
>>> --- libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/move.pass.cpp (original)
>>> +++ libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.assign/move.pass.cpp Wed Oct 12 06:29:18 2016
>>> @@ -8,7 +8,6 @@
>>>  //===--
>>> ===//
>>>
>>>  // UNSUPPORTED: c++98, c++03, c++11, c++14
>>> -// XFAIL: libcpp-no-exceptions
>>>  // 
>>>
>>>  // optional& operator=(optional&& rhs);
>>> @@ -42,7 +41,6 @@ struct Z2
>>>  Z2& operator=(Z2&&) = default;
>>>  };
>>>
>>> -#if __cplusplus >= 201402
>>>  template 
>>>  constexpr bool
>>>  test()
>>> @@ -52,23 +50,18 @@ test()
>>>  opt = std::move(opt2);
>>>  return true;
>>>  }
>>> -#endif
>>>
>>>  int main()
>>>  {
>>>  {
>>>  using T = int;
>>>  
>>> static_assert((std::is_trivially_copy_constructible::value),
>>> "");
>>> -#if __cplusplus >= 201402
>>>  static_assert(test(), "");
>>> -#endif
>>>  }
>>>  {
>>>  using T = X;
>>>  
>>> static_assert((std::is_trivially_copy_constructible::value),
>>> "");
>>> -#if __cplusplus >= 201402
>>>  static_assert(test(), "");
>>> -#endif
>>>  }
>>>  static_assert(!(std::is_trivially_move_assignable::value),
>>> "");
>>>  
>>> static_assert(!(std::is_trivially_move_assignable::value),
>>> "");
>>>
>>> Modified: libcxx/trunk/test/libcxx/utilities/optional/optional.object/
>>> optional.object.ctor/copy.pass.cpp
>>> URL: 

Re: [libcxx] r284005 - Remove incorrect XFAILS

2016-10-12 Thread Asiri Rathnayake via cfe-commits
Thanks!

I still have that no-exception cleanup in my TODO list. Just pressed on
time, hope to get to it soon.

/ Asiri

On Wed, Oct 12, 2016 at 12:29 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Wed Oct 12 06:29:18 2016
> New Revision: 284005
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284005=rev
> Log:
> Remove incorrect XFAILS
>
> Modified:
> libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/copy.pass.cpp
> libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/move.pass.cpp
> libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.ctor/copy.pass.cpp
> libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.ctor/move.pass.cpp
>
> Modified: libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/copy.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/
> libcxx/utilities/optional/optional.object/optional.
> object.assign/copy.pass.cpp?rev=284005=284004=284005=diff
> 
> ==
> --- libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/copy.pass.cpp (original)
> +++ libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/copy.pass.cpp Wed Oct 12 06:29:18 2016
> @@ -8,7 +8,6 @@
>  //===---
> ---===//
>
>  // UNSUPPORTED: c++98, c++03, c++11, c++14
> -// XFAIL: libcpp-no-exceptions
>  // 
>
>  // optional& operator=(const optional& rhs);
> @@ -45,7 +44,6 @@ struct Z2
>  Z2& operator=(const Z2&) = default;
>  };
>
> -#if __cplusplus >= 201402
>  template 
>  constexpr bool
>  test()
> @@ -55,23 +53,18 @@ test()
>  opt = opt2;
>  return true;
>  }
> -#endif
>
>  int main()
>  {
>  {
>  using T = int;
>  
> static_assert((std::is_trivially_copy_assignable::value),
> "");
> -#if __cplusplus >= 201402
>  static_assert(test(), "");
> -#endif
>  }
>  {
>  using T = X;
>  
> static_assert((std::is_trivially_copy_assignable::value),
> "");
> -#if __cplusplus >= 201402
>  static_assert(test(), "");
> -#endif
>  }
>  static_assert(!(std::is_trivially_copy_assignable::value),
> "");
>  static_assert(!(std::is_trivially_copy_assignable<
> optional>::value), "");
>
> Modified: libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/move.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/
> libcxx/utilities/optional/optional.object/optional.
> object.assign/move.pass.cpp?rev=284005=284004=284005=diff
> 
> ==
> --- libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/move.pass.cpp (original)
> +++ libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.assign/move.pass.cpp Wed Oct 12 06:29:18 2016
> @@ -8,7 +8,6 @@
>  //===---
> ---===//
>
>  // UNSUPPORTED: c++98, c++03, c++11, c++14
> -// XFAIL: libcpp-no-exceptions
>  // 
>
>  // optional& operator=(optional&& rhs);
> @@ -42,7 +41,6 @@ struct Z2
>  Z2& operator=(Z2&&) = default;
>  };
>
> -#if __cplusplus >= 201402
>  template 
>  constexpr bool
>  test()
> @@ -52,23 +50,18 @@ test()
>  opt = std::move(opt2);
>  return true;
>  }
> -#endif
>
>  int main()
>  {
>  {
>  using T = int;
>  
> static_assert((std::is_trivially_copy_constructible::value),
> "");
> -#if __cplusplus >= 201402
>  static_assert(test(), "");
> -#endif
>  }
>  {
>  using T = X;
>  
> static_assert((std::is_trivially_copy_constructible::value),
> "");
> -#if __cplusplus >= 201402
>  static_assert(test(), "");
> -#endif
>  }
>  static_assert(!(std::is_trivially_move_assignable::value),
> "");
>  static_assert(!(std::is_trivially_move_assignable<
> optional>::value), "");
>
> Modified: libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.ctor/copy.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/
> libcxx/utilities/optional/optional.object/optional.
> object.ctor/copy.pass.cpp?rev=284005=284004=284005=diff
> 
> ==
> --- libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.ctor/copy.pass.cpp (original)
> +++ libcxx/trunk/test/libcxx/utilities/optional/optional.
> object/optional.object.ctor/copy.pass.cpp Wed Oct 12 06:29:18 2016
> @@ -8,7 +8,7 @@
>  //===---
> ---===//
>
>  // UNSUPPORTED: c++98, c++03, 

[PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-10-12 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D21803#567774, @tavianator wrote:

> In https://reviews.llvm.org/D21803#556857, @EricWF wrote:
>
> > @rmaprath I'll merge this if needed. Feel free to commit your patch first.
>
>
> Yeah, @rmaprath I'm happy to rebase this over your patch.


My patch got a bit stuck downstream :(

So you / @EricWF can go ahead with this patch, I'll rebase mine over yours when 
I'm ready to commit.

/ Asiri


https://reviews.llvm.org/D21803



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-11 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Added some comments to @EricWF's feedback. Will check back tomorrow (falling 
asleep...)

/ Asiri




Comment at: include/__threading_support:25
 // redundancy is intentional.
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)

EricWF wrote:
> If `_LIBCPP_HAS_THREAD_API_EXTERNAL` is defined can't we just assume that 
> `<__external_threading> is present?
So, `_LIBCPP_HAS_THREAD_API_EXTERNAL` is set from the cmake option for building 
the externally threaded variant. For the proof-of-concept implementation (that 
we use for running the test suite), we embed a pthread-based external API 
within `__threading_support` itself and provide its implementation in 
`test/support/external_threads.cpp` (which is built into a separate library 
when running the test suite).

That means, in the default externally-threaded variant (POC), we don't have a 
`__external_threading` header; the idea is to allow library vendors to drop-in 
a `__external_threading` header without conflicting with upstream sources, and 
it will be picked up automatically by `__threading_support` header. Moreover, 
this way we avoid the cost of shipping an additional header which is not 
necessary for the most common use case (direct pthread dependency).

This is why we need this contraption to detect if the externally threaded 
library is built with a `__external_threading` header (i.e. for production) or 
not (the default - vanilla upstream setup, the POC). 

Hope that makes sense? Perhaps I should explain all this in a comment as well?



Comment at: include/__threading_support:35
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 

EricWF wrote:
> Instead of using a new macro couldn't this just be 
> `_LIBCPP_HAS_THREAD_API_EXTERNAL`?
I think my comment above covers this point as well.


https://reviews.llvm.org/D25468



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25468: [libcxx] Do not declare the thread api when __external_threading is present

2016-10-11 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added a reviewer: EricWF.
rmaprath added a subscriber: cfe-commits.

This fixes a small omission where even when `__external_threading` is provided, 
we attempt to declare a pthread based threading API. Instead, we should leave 
out everything for the `__external_threading` header to take care of.

The `__threading_support` header provides a proof-of-concept externally 
threaded `libc++` variant when `_LIBCPP_HAS_THREAD_API_EXTERNAL` is defined. 
But if the `__external_threading` header is present, we should exclude all of 
that POC stuff.


https://reviews.llvm.org/D25468

Files:
  include/__threading_support


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -25,17 +25,16 @@
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #if !defined(__clang__) && (_GNUC_VER < 500)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #elif !defined(__has_include) || __has_include(<__external_threading>)
 #include <__external_threading>
-#define _LIBCPP_EXTERNAL_THREADING
+#define _LIBCPP_HAS_EXTERNAL_THREADING_HEADER
 #endif
 #endif
 
-#if !defined(_LIBCPP_EXTERNAL_THREADING)
+#if !defined(_LIBCPP_HAS_EXTERNAL_THREADING_HEADER)
 #include 
 #include 
-#endif
 
 #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 #define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS
@@ -242,6 +241,8 @@
 
 _LIBCPP_END_NAMESPACE_STD
 
+#endif // !_LIBCPP_HAS_EXTERNAL_THREADING_HEADER
+
 #endif // _LIBCPP_HAS_NO_THREADS
 
 #endif // _LIBCPP_THREADING_SUPPORT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25361: [libcxx] Add the missing limits.h header

2016-10-10 Thread Asiri Rathnayake via cfe-commits
rmaprath closed this revision.
rmaprath added a comment.

Thanks.

Committed as r283726.


https://reviews.llvm.org/D25361



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r283726 - [libcxx] Add the missing limits.h header

2016-10-10 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Oct 10 03:38:51 2016
New Revision: 283726

URL: http://llvm.org/viewvc/llvm-project?rev=283726=rev
Log:
[libcxx] Add the missing limits.h header

The implementation of [depr.c.headers] in D12747 introduced the necessary
C headers into libc++. This patch adds one more missing headers: limits.h

We spotted this due to a failing C++03 test [limits_h.pass.cpp] in our libc++
configuration; when the limits.h header is included from a C++ program, it now
bypassed the __config header and went directly into the underlying C library's
limits.h header, which is problematic for us because we use __config header to
configure the underlying C library's behaviour when used from a C++ context.

Reviewers: mclow.lists, rsmith

Differential revision: https://reviews.llvm.org/D25361

Added:
libcxx/trunk/include/limits.h

Added: libcxx/trunk/include/limits.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/limits.h?rev=283726=auto
==
--- libcxx/trunk/include/limits.h (added)
+++ libcxx/trunk/include/limits.h Mon Oct 10 03:38:51 2016
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//===--- limits.h 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_LIMITS_H
+#define _LIBCPP_LIMITS_H
+
+/*
+limits.h synopsis
+
+Macros:
+
+CHAR_BIT
+SCHAR_MIN
+SCHAR_MAX
+UCHAR_MAX
+CHAR_MIN
+CHAR_MAX
+MB_LEN_MAX
+SHRT_MIN
+SHRT_MAX
+USHRT_MAX
+INT_MIN
+INT_MAX
+UINT_MAX
+LONG_MIN
+LONG_MAX
+ULONG_MAX
+LLONG_MIN   // C99
+LLONG_MAX   // C99
+ULLONG_MAX  // C99
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_LIMITS_H


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25361: [libcxx] Add the missing limits.h header

2016-10-07 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists, rsmith.
rmaprath added a subscriber: cfe-commits.

The implementation of [depr.c.headers] in https://reviews.llvm.org/D12747 
introduced the necessary
C headers into libc++. This patch adds one more missing headers: limits.h

We spotted this due to a failing C++03 test [limits_h.pass.cpp] in our libc++
configuration; when the limits.h header is included from a C++ program, it now
bypassed the __config header and went directly into the underlying C library's
limits.h header, which is problematic for us because we use __config header to
configure the underlying C library's behaviour when used from a C++ context.


https://reviews.llvm.org/D25361

Files:
  include/limits.h


Index: include/limits.h
===
--- /dev/null
+++ include/limits.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//===--- limits.h 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_LIMITS_H
+#define _LIBCPP_LIMITS_H
+
+/*
+limits.h synopsis
+
+Macros:
+
+CHAR_BIT
+SCHAR_MIN
+SCHAR_MAX
+UCHAR_MAX
+CHAR_MIN
+CHAR_MAX
+MB_LEN_MAX
+SHRT_MIN
+SHRT_MAX
+USHRT_MAX
+INT_MIN
+INT_MAX
+UINT_MAX
+LONG_MIN
+LONG_MAX
+ULONG_MAX
+LLONG_MIN   // C99
+LLONG_MAX   // C99
+ULLONG_MAX  // C99
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_LIMITS_H


Index: include/limits.h
===
--- /dev/null
+++ include/limits.h
@@ -0,0 +1,49 @@
+// -*- C++ -*-
+//===--- limits.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_LIMITS_H
+#define _LIBCPP_LIMITS_H
+
+/*
+limits.h synopsis
+
+Macros:
+
+CHAR_BIT
+SCHAR_MIN
+SCHAR_MAX
+UCHAR_MAX
+CHAR_MIN
+CHAR_MAX
+MB_LEN_MAX
+SHRT_MIN
+SHRT_MAX
+USHRT_MAX
+INT_MIN
+INT_MAX
+UINT_MAX
+LONG_MIN
+LONG_MAX
+ULONG_MAX
+LLONG_MIN   // C99
+LLONG_MAX   // C99
+ULLONG_MAX  // C99
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_LIMITS_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-10-06 Thread Asiri Rathnayake via cfe-commits
rmaprath closed this revision.
rmaprath added a comment.

Committed as r283441.

Thanks!


https://reviews.llvm.org/D24562



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r283441 - [libcxx] Recover no-exceptions XFAILs - I

2016-10-06 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Thu Oct  6 06:15:41 2016
New Revision: 283441

URL: http://llvm.org/viewvc/llvm-project?rev=283441=rev
Log:
[libcxx] Recover no-exceptions XFAILs - I

First batch of changes to get some of these XFAILs working in the
no-exceptions libc++ variant.

Changed some XFAILs to UNSUPPORTED where the test is all about exception
handling. In other cases, used the test macros TEST_THROW and
TEST_HAS_NO_EXCEPTIONS to conditionally exclude those parts of the test
that concerns exception handling behaviour.

Reviewers: EricWF, mclow.lists

Differential revision: https://reviews.llvm.org/D24562

Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.async/async.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/dtor.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/get_future.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/move_ctor.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/set_exception.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.promise/set_value_const.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.promise/set_value_void.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.shared_future/get.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.unique_future/get.pass.cpp

libcxx/trunk/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp?rev=283441=283440=283441=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/grep.pass.cpp Thu Oct  6 
06:15:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -25,6 +24,7 @@
 
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 size_t size = strlen(data);
 if (size > 0)
 {
@@ -37,6 +37,7 @@ extern "C" void LLVMFuzzerTestOneInput(c
 }
 catch (std::regex_error &) {}
 }
+#endif
 }
 
 

Modified: libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp?rev=283441=283440=283441=diff
==
--- libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.assign/assign.pass.cpp Thu Oct  
6 06:15:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template > class 
basic_regex;
@@ -27,6 +26,7 @@ int main()
 assert(r2.mark_count() == 2);
 assert(std::regex_search("ab", r2));
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 bool caught = false;
 try { r2.assign("(def", std::regex::extended); }
 catch(std::regex_error &) { caught = true; }
@@ -34,4 +34,5 @@ int main()
 assert(r2.flags() == std::regex::ECMAScript);
 assert(r2.mark_count() == 2);
 assert(std::regex_search("ab", r2));
+#endif
 }

Modified: 
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp?rev=283441=283440=283441=diff
==
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp 
Thu Oct  6 06:15:41 2016
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
+// 

[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-10-06 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 73759.
rmaprath added a comment.

Final patch to be committed, with all the remaining comments addressed.


https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp
  test/std/re/re.regex/re.regex.assign/assign.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
  test/std/thread/futures/futures.async/async.pass.cpp
  test/std/thread/futures/futures.promise/dtor.pass.cpp
  test/std/thread/futures/futures.promise/get_future.pass.cpp
  test/std/thread/futures/futures.promise/move_ctor.pass.cpp
  test/std/thread/futures/futures.promise/set_exception.pass.cpp
  test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.promise/set_lvalue.pass.cpp
  test/std/thread/futures/futures.promise/set_value_const.pass.cpp
  test/std/thread/futures/futures.promise/set_value_void.pass.cpp
  test/std/thread/futures/futures.shared_future/get.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
  
test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
  test/std/thread/futures/futures.unique_future/get.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -33,7 +32,7 @@
 void* operator new(std::size_t s) throw(std::bad_alloc)
 {
 if (throw_one == 0)
-throw std::bad_alloc();
+TEST_THROW(std::bad_alloc());
 --throw_one;
 ++outstanding_new;
 void* ret = std::malloc(s);
@@ -118,6 +117,7 @@
 //  3 Finally check that a thread runs successfully if we throw after 'N+1'
 //allocations.
 void test_throwing_new_during_thread_creation() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
@@ -142,6 +142,7 @@
 }
 f_run = false;
 throw_one = 0xFFF;
+#endif
 }
 
 int main()
@@ -162,6 +163,7 @@
 assert(G::op_run);
 }
 G::op_run = false;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -178,6 +180,7 @@
 assert(!G::op_run);
 }
 }
+#endif
 #if TEST_STD_VER >= 11
 {
 assert(G::n_alive == 0);
Index: test/std/thread/futures/futures.unique_future/get.pass.cpp
===
--- test/std/thread/futures/futures.unique_future/get.pass.cpp
+++ test/std/thread/futures/futures.unique_future/get.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -22,6 +21,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 void func1(std::promise p)
 {
 std::this_thread::sleep_for(std::chrono::milliseconds(500));
@@ -73,6 +74,7 @@
 assert(f.get() == 3);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -89,6 +91,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef int& T;
@@ -100,6 +103,7 @@
 assert(f.get() == 5);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -116,6 +120,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef void T;
@@ -127,6 +132,7 @@
 f.get();
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -143,5 +149,6 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 }
Index: test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
===
--- test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
+++ test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
@@ -7,7 +7,6 @@
 //
 

[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-10-05 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 73661.
rmaprath added a comment.

First batch of XFAIL fixes.

I've changed some XFAILs to UNSUPPORTED where the test is all about exception 
handling. In other cases, I've used the test macro TEST_HAS_NO_EXCEPTIONS to 
conditionally exclude those parts that test
exception handling behaviour.

@EricWF: I can create a separate review if necessary, thought I'll re-use this 
review for the first batch, will be opening new reviews for the follow-ups.

/ Asiri


https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp
  test/std/re/re.regex/re.regex.assign/assign.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
  test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp
  test/std/thread/futures/futures.async/async.pass.cpp
  test/std/thread/futures/futures.promise/dtor.pass.cpp
  test/std/thread/futures/futures.promise/get_future.pass.cpp
  test/std/thread/futures/futures.promise/move_ctor.pass.cpp
  test/std/thread/futures/futures.promise/set_exception.pass.cpp
  test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.promise/set_lvalue.pass.cpp
  test/std/thread/futures/futures.promise/set_value_const.pass.cpp
  test/std/thread/futures/futures.promise/set_value_void.pass.cpp
  test/std/thread/futures/futures.shared_future/get.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/dtor.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
  
test/std/thread/futures/futures.task/futures.task.members/make_ready_at_thread_exit.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/operator.pass.cpp
  test/std/thread/futures/futures.task/futures.task.members/reset.pass.cpp
  test/std/thread/futures/futures.unique_future/get.pass.cpp
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -32,9 +31,11 @@
 
 void* operator new(std::size_t s) throw(std::bad_alloc)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 if (throw_one == 0)
 throw std::bad_alloc();
 --throw_one;
+#endif
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
@@ -118,6 +119,7 @@
 //  3 Finally check that a thread runs successfully if we throw after 'N+1'
 //allocations.
 void test_throwing_new_during_thread_creation() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
@@ -142,6 +144,7 @@
 }
 f_run = false;
 throw_one = 0xFFF;
+#endif
 }
 
 int main()
@@ -162,6 +165,7 @@
 assert(G::op_run);
 }
 G::op_run = false;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -178,6 +182,7 @@
 assert(!G::op_run);
 }
 }
+#endif
 #if TEST_STD_VER >= 11
 {
 assert(G::n_alive == 0);
Index: test/std/thread/futures/futures.unique_future/get.pass.cpp
===
--- test/std/thread/futures/futures.unique_future/get.pass.cpp
+++ test/std/thread/futures/futures.unique_future/get.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -22,6 +21,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 void func1(std::promise p)
 {
 std::this_thread::sleep_for(std::chrono::milliseconds(500));
@@ -73,6 +74,7 @@
 assert(f.get() == 3);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -89,6 +91,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef int& T;
@@ -100,6 +103,7 @@
 assert(f.get() == 5);
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -116,6 +120,7 @@
 }
 assert(!f.valid());
 }
+#endif
 }
 {
 typedef void T;
@@ -127,6 +132,7 @@
 f.get();
 assert(!f.valid());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::promise p;
 std::future f = p.get_future();
@@ -143,5 +149,6 @@
 }

[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-10-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24562#561442, @Eugene.Zelenko wrote:

> Looks like patch was not committed.


Need to replicate this to as many tests as possible (~150). I was hoping to do 
all that and upload another diff for a final review, couldn't get to it I'm 
afraid. Hope to do this very very soon.

Sorry for the delay.

/ Asiri


https://reviews.llvm.org/D24562



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24082: [CMake] Fix libc++abi arm build w/o libunwind.

2016-10-04 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

LGTM too.

@EricWF or @mclow.lists need to approve.


https://reviews.llvm.org/D24082



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Sigh. I've bumped into some downstream problems. Will commit as soon as I've 
verified these problems are not related to the patch.


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] [Updated, 223 lines] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 73033.
rmaprath added a comment.

`pthread_mach_thread_np` is Mac specific. I've introduced a Mac-only 
`__libcxxabi_thread_get_port()` API call to sort this out (didn't think it 
would be nice to leave a pthread call even if it is Mac specific).

I can revisit this if there is a better approach. Will commit now.


https://reviews.llvm.org/D24864

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  src/threading_support.h
  test/test_exception_storage.pass.cpp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,9 +12,7 @@
 #include 
 #include 
 #include 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
+#include "../src/threading_support.h"
 #include 
 
 #include "../src/cxa_exception.hpp"
@@ -40,19 +38,19 @@
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
-size_t  thread_globals [ NUMTHREADS ] = { 0 };
-pthread_t   threads[ NUMTHREADS ];
+size_t thread_globals [ NUMTHREADS ] = { 0 };
+__libcxxabi_thread_t   threads[ NUMTHREADS ];
 #endif
 
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i));
+__libcxxabi_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
 for ( int i = 0; i < NUMTHREADS; ++i )
-pthread_join ( threads [ i ], NULL );
+__libcxxabi_thread_join (  [ i ] );
 
 for ( int i = 0; i < NUMTHREADS; ++i )
 if ( 0 == thread_globals [ i ] ) {
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,107 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+mach_port_t __libcxxabi_thread_get_port()
+{
+return pthread_mach_thread_np(pthread_self());
+}
+#endif
+
+// Thread
+typedef pthread_t __libcxxabi_thread_t;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_create(__libcxxabi_thread_t* __t,
+   void* (*__func)(void*), void* __arg)
+{
+return pthread_create(__t, 0, __func, __arg);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_thread_join(__libcxxabi_thread_t* __t)
+{
+return pthread_join(*__t, 0);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY

[PATCH] [Commented On] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24864#556845, @rmaprath wrote:

> I'm going to test this on a Mac before committing.


Good call that was, wouldn't have compiled there. Attaching updated patch soon.


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] [Updated] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@ikudrin: Looks like you've reverted this soon after. I'm just about to commit 
https://reviews.llvm.org/D24864, which will affect this slightly. 
https://reviews.llvm.org/D24864 basically refactors all pthread dependencies 
behind a separate API. It would be pretty straightforward for you to update 
this patch though, just replacing pthread calls with ones in thread_support.h 
(perhaps adding anything missing).

Hope you don't mind me going first? If you are going to commit this soon, I can 
hold off https://reviews.llvm.org/D24864. Let me know.

Cheers,

/ Asiri


Repository:
  rL LLVM

https://reviews.llvm.org/D17815



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] [Updated] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-30 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@tavianator: I'm about to commit https://reviews.llvm.org/D24864, which will 
affect this patch (indirectly). https://reviews.llvm.org/D24864 basically 
refactors all pthread dependencies behind a separate API. It would be pretty 
straightforward for you to update this patch though, just replacing pthread 
calls with ones in `thread_support.h` (perhaps adding anything missing).

Hope you don't mind me going first? If you are going to commit this soon, I can 
hold off https://reviews.llvm.org/D24864. Let me know.

Cheers,

/ Asiri


https://reviews.llvm.org/D21803



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-28 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@EricWF: Gentle ping.


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r282575 - [libunwind] Add support for a single-threaded libunwind build

2016-09-28 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Wed Sep 28 05:57:15 2016
New Revision: 282575

URL: http://llvm.org/viewvc/llvm-project?rev=282575=rev
Log:
[libunwind] Add support for a single-threaded libunwind build

The EHABI unwinder is thread-agnostic, SJLJ unwinder and the DWARF unwinder have
a couple of pthread dependencies.

This patch makes it possible to build the whole of libunwind for a
single-threaded environment.

Reviewers: compnerd

Differential revision: https://reviews.llvm.org/D24984

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/CMakeLists.txt
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/Unwind_AppleExtras.cpp
libunwind/trunk/src/config.h

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=282575=282574=282575=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed Sep 28 05:57:15 2016
@@ -107,6 +107,7 @@ option(LIBUNWIND_ENABLE_SHARED "Build li
 option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding 
support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX 
registers." OFF)
+option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
 
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross 
compiling.")
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
@@ -242,6 +243,11 @@ if (NOT LIBUNWIND_ENABLE_CROSS_UNWINDING
   list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_IS_NATIVE_ONLY)
 endif()
 
+# Threading-support
+if (NOT LIBUNWIND_ENABLE_THREADS)
+  list(APPEND LIBUNWIND_COMPILE_FLAGS -D_LIBUNWIND_HAS_NO_THREADS)
+endif()
+
 # ARM WMMX register support
 if (LIBUNWIND_ENABLE_ARM_WMMX)
   # __ARM_WMMX is a compiler pre-define (as per the ACLE 2.0). Clang does not

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=282575=282574=282575=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Wed Sep 28 05:57:15 2016
@@ -53,7 +53,9 @@ set(LIBUNWIND_SOURCES
 set(libraries ${LIBUNWINDCXX_ABI_LIBRARIES})
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
-append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+if (LIBUNWIND_ENABLE_THREADS)
+  append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+endif()
 
 # Setup flags.
 append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_FPIC_FLAG -fPIC)

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=282575=282574=282575=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Wed Sep 28 05:57:15 2016
@@ -16,7 +16,9 @@
 #include 
 #include 
 #include 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#endif
 #include 
 
 #ifdef __APPLE__
@@ -60,7 +62,9 @@ private:
 
   // These fields are all static to avoid needing an initializer.
   // There is only one instance of this class per process.
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   static pthread_rwlock_t _lock;
+#endif
 #ifdef __APPLE__
   static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
   static bool _registeredForDyldUnloads;
@@ -87,8 +91,10 @@ DwarfFDECache::_bufferEnd = &_initial
 template 
 typename DwarfFDECache::entry DwarfFDECache::_initialBuffer[64];
 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
 template 
 pthread_rwlock_t DwarfFDECache::_lock = PTHREAD_RWLOCK_INITIALIZER;
+#endif
 
 #ifdef __APPLE__
 template 

Modified: libunwind/trunk/src/Unwind_AppleExtras.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind_AppleExtras.cpp?rev=282575=282574=282575=diff
==
--- libunwind/trunk/src/Unwind_AppleExtras.cpp (original)
+++ libunwind/trunk/src/Unwind_AppleExtras.cpp Wed Sep 28 05:57:15 2016
@@ -185,21 +185,29 @@ bool checkKeyMgrRegisteredFDEs(uintptr_t
 
 #if !defined(FOR_DYLD) && _LIBUNWIND_BUILD_SJLJ_APIS
 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#else
+  _Unwind_FunctionContext *fc_ = nullptr;
+#endif
 
 // Accessors to get get/set linked list of frames for sjlj based execeptions.
 _LIBUNWIND_HIDDEN
 struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   return (struct _Unwind_FunctionContext *)
 _pthread_getspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key);
+#else
+  return fc_;
+#endif
 }
 
 _LIBUNWIND_HIDDEN
 void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+#ifndef 

Re: [PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-09-28 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: rmaprath.
rmaprath added a comment.

The patch generally makes sense to me.

I wonder if the test configuration can also benefit from this; 
`test/libcxx/test/target_info.py` manually updates the link line to use 
`-lgcc_s` or `-lunwind` depending on how the build is configured. Presumably, 
this workaround will no longer be needed if the linker script does that for us?

(Note:- `-lgcc_s` is linked twice there to satisfy some weird dependency, it's 
not a mistake)


https://reviews.llvm.org/D25008



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24984: [libunwind] Add support for a single-threaded libunwind build

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: jroelofs, compnerd, logan.
rmaprath added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

The EHABI unwinder is thread-agnostic, SJLJ unwinder and the DWARF unwinder 
have a couple of `pthread` dependencies.

This patch makes it possible to build the whole of `libunwind` for a 
single-threaded environment.

https://reviews.llvm.org/D24984

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/UnwindCursor.hpp
  src/Unwind_AppleExtras.cpp
  src/config.h

Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -85,13 +85,20 @@
   } while (0)
 #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
 
+#if defined(_LIBUNWIND_HAS_NO_THREADS)
+  // only used with pthread calls, not needed for the single-threaded builds
+  #define _LIBUNWIND_LOG_NON_ZERO(x)
+#endif
+
 // Macros that define away in non-Debug builds
 #ifdef NDEBUG
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)
   #define _LIBUNWIND_TRACE_API(msg, ...)
   #define _LIBUNWIND_TRACING_UNWINDING 0
   #define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+#define _LIBUNWIND_LOG_NON_ZERO(x) x
+  #endif
 #else
   #ifdef __cplusplus
 extern "C" {
@@ -102,12 +109,14 @@
 }
   #endif
   #define _LIBUNWIND_DEBUG_LOG(msg, ...)  _LIBUNWIND_LOG(msg, __VA_ARGS__)
-  #define _LIBUNWIND_LOG_NON_ZERO(x) \
-do { \
-  int _err = x; \
-  if ( _err != 0 ) \
-_LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
- } while (0)
+  #ifndef _LIBUNWIND_LOG_NON_ZERO
+#define _LIBUNWIND_LOG_NON_ZERO(x) \
+  do { \
+int _err = x; \
+if ( _err != 0 ) \
+  _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \
+   } while (0)
+  #endif
   #define _LIBUNWIND_TRACE_API(msg, ...) \
 do { \
   if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \
Index: src/Unwind_AppleExtras.cpp
===
--- src/Unwind_AppleExtras.cpp
+++ src/Unwind_AppleExtras.cpp
@@ -185,21 +185,29 @@
 
 #if !defined(FOR_DYLD) && _LIBUNWIND_BUILD_SJLJ_APIS
 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#else
+  _Unwind_FunctionContext *fc_ = nullptr;
+#endif
 
 // Accessors to get get/set linked list of frames for sjlj based execeptions.
 _LIBUNWIND_HIDDEN
 struct _Unwind_FunctionContext *__Unwind_SjLj_GetTopOfFunctionStack() {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   return (struct _Unwind_FunctionContext *)
 _pthread_getspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key);
+#else
+  return fc_;
+#endif
 }
 
 _LIBUNWIND_HIDDEN
 void __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   _pthread_setspecific_direct(__PTK_LIBC_DYLD_Unwind_SjLj_Key, fc);
+#else
+  fc_ = fc;
+#endif
 }
 #endif
-
-
-
-
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -16,7 +16,9 @@
 #include 
 #include 
 #include 
-#include 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
+  #include 
+#endif
 #include 
 
 #ifdef __APPLE__
@@ -60,7 +62,9 @@
 
   // These fields are all static to avoid needing an initializer.
   // There is only one instance of this class per process.
+#ifndef _LIBUNWIND_HAS_NO_THREADS
   static pthread_rwlock_t _lock;
+#endif
 #ifdef __APPLE__
   static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
   static bool _registeredForDyldUnloads;
@@ -87,8 +91,10 @@
 template 
 typename DwarfFDECache::entry DwarfFDECache::_initialBuffer[64];
 
+#ifndef _LIBUNWIND_HAS_NO_THREADS
 template 
 pthread_rwlock_t DwarfFDECache::_lock = PTHREAD_RWLOCK_INITIALIZER;
+#endif
 
 #ifdef __APPLE__
 template 
Index: src/CMakeLists.txt
===
--- src/CMakeLists.txt
+++ src/CMakeLists.txt
@@ -53,7 +53,9 @@
 set(libraries ${LIBUNWINDCXX_ABI_LIBRARIES})
 append_if(libraries LIBUNWIND_HAS_C_LIB c)
 append_if(libraries LIBUNWIND_HAS_DL_LIB dl)
-append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+if (LIBUNWIND_ENABLE_THREADS)
+  append_if(libraries LIBUNWIND_HAS_PTHREAD_LIB pthread)
+endif()
 
 # Setup flags.
 append_if(LIBUNWIND_COMPILE_FLAGS LIBUNWIND_HAS_FPIC_FLAG -fPIC)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -107,6 +107,7 @@
 option(LIBUNWIND_ENABLE_STATIC "Build libunwind as a static library." ON)
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX registers." OFF)
+option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
 

Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24119#554234, @mgorny wrote:

> I'm starting to regret that I've committed this. It breaks horribly any 
> pure-LLVM build, i.e. without linking to libgcc_s. It seems that the build 
> system is completely unprepared to link to compiler-rt or libunwind when 
> linking the shared library, and with -DLIBCXX_HAS_GCC_S_LIB=OFF, it fails due 
> to a lot of missing symbols. I am going to revert this until we get the build 
> system working completely.


Doesn't `-DLIBCXXABI_USE_LLVM_UNWINDER=ON` make it possible to build without 
`libgcc_s`? Or is this something else?


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 72653.
rmaprath added a comment.
Herald added subscribers: mgorny, beanz.

Address review comments from @compnerd and @EricWF.


https://reviews.llvm.org/D24864

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  src/threading_support.h
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,82 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_USE_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_create(__libcxxabi_tls_key *key,
+   void (*destructor)(void *)) {
+  return pthread_key_create(key, destructor);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+void *__libcxxabi_tls_get(__libcxxabi_tls_key key) {
+  return pthread_getspecific(key);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_set(__libcxxabi_tls_key key, void *value) {
+  return pthread_setspecific(key, value);
+}
+#endif // _LIBCXXABI_USE_THREAD_API_PTHREAD
+#endif // !_LIBCXXABI_HAS_NO_THREADS
+#endif // _LIBCXXABI_THREADING_SUPPORT_H
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -27,25 +27,25 @@
 
 // When POSIX threads are not available, make the mutex operations a nop
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __libcxxabi_mutex_t heap_mutex = _LIBCXXABI_MUTEX_INITIALIZER;
 #else
 static void * heap_mutex = 0;
 #endif
 
 class mutexor {
 public:
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); }
-~mutexor () { pthread_mutex_unlock ( mtx_ ); }
+mutexor ( __libcxxabi_mutex_t *m ) : mtx_(m) { __libcxxabi_mutex_lock ( mtx_ ); }
+~mutexor () { __libcxxabi_mutex_unlock ( mtx_ ); }
 #else
 mutexor ( void * ) {}
 ~mutexor () {}
 #endif
 private:
 mutexor ( const mutexor  );
 mutexor & operator = ( const mutexor  );
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-pthread_mutex_t *mtx_;
+__libcxxabi_mutex_t *mtx_;
 #endif
 };
 
Index: src/cxa_guard.cpp
===
--- src/cxa_guard.cpp
+++ src/cxa_guard.cpp
@@ -11,20 +11,18 @@
 
 #include "abort_message.h"
 #include "config.h"
+#include "threading_support.h"
 
-#ifndef _LIBCXXABI_HAS_NO_THREADS
-#  include 
-#endif
 #include 
 
 /*
 This implementation must be careful to not call code external to this file
 which will turn around and try to call __cxa_guard_acquire reentrantly.
 For this reason, the headers of this 

Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: libcxx/trunk/CMakeLists.txt:329
@@ +328,3 @@
+  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ NOT LLVM_USE_SANITIZER)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")

zlei wrote:
> rmaprath wrote:
> > Perhaps we should exclude `LIBCXX_HAS_EXTERNAL_THREAD_API` as well? Because 
> > there we explicitly strip off these flags.
> I agree. Could you prepare a patch for it?
> 
> BTW, I really don't like duplicating code snippet from llvm. Is there any 
> better solution for that?
Sure, I'll do a patch.

Btw, I think this configuration is better placed in `HandleOutOfTreeLLVM.cmake` 
module.

I'll see if I can find a better way to do this.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: src/config.h:22
@@ +21,3 @@
+
+#if defined(__GNUC__) || defined(__clang__)
+#define _LIBCXXABI_PRAGMA(_parameter_) _Pragma(#_parameter_)

EricWF wrote:
> What's the point of defining `_LIBCXXABI_WARNING`? It's unused and seems 
> unneeded.
Good catch. I have copy-pasted this lot without checking.


Comment at: src/config.h:41
@@ +40,3 @@
+defined(__CloudABI__) || \
+defined(__sun__)
+#  define _LIBCXXABI_HAS_THREAD_API_PTHREAD

compnerd wrote:
> Can you change this to `defined(__sun__) && defined(_POSIX_THREADS)` at the 
> very least?  There is no reason to assume pthreads on Solaris.  Solaris 
> Threads are a valid threading model.
Not sure if I understand completely, `libcxxabi` currently either supports 
`pthread` or no-threads, either of which can be explicitly configured through a 
cmake option. So I don't see the point in checking for `_POSIX_THREADS` here as 
the only current threading option is `pthread`. When we add another threading 
system into the mix (like external threading), that too will be configurable 
with a cmake option, the defaulting to `pthread` is only when no particular 
threading system is selected.

Or is it that `pthread.h` et. al can be provided by Solaris Threads as well? 
So, the pthread API has two implementations on Solaris?


Comment at: src/config.h:42
@@ +41,3 @@
+defined(__sun__)
+#  define _LIBCXXABI_HAS_THREAD_API_PTHREAD
+# else

compnerd wrote:
> Can we use `_LIBCXXABI_USE_THREAD_API_PTHREAD` instead?  You can have more 
> than one threading API on a platform, and wish to use a specific one.
Makes sense. Need to change the convention used in `libcxx` too, but that can 
be done later.


Comment at: src/config.h:46
@@ +45,3 @@
+# endif
+#endif
+

compnerd wrote:
> I really think that we should use `_POSIX_THREADS` macro rather than this 
> enumeration approach.
`_LIBCXXABI_USE_THREAD_API_` allows us to be consistent with naming of the 
different threading variants (e.g. I'm going to add 
`_LIBCXXABI_USE_THREAD_API_EXTENRAL` soon). Is there some functional benefit to 
using `_POSIX_THREADS` for the pthread variant?


Comment at: src/fallback_malloc.ipp:30
@@ -29,3 +29,3 @@
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __libcxxabi_mutex_t heap_mutex = _LIBCXXABI_MUTEX_INITIALIZER;
 #else

Thanks for the catch.


https://reviews.llvm.org/D24864



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: rmaprath.


Comment at: libcxx/trunk/CMakeLists.txt:329
@@ +328,3 @@
+  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ NOT LLVM_USE_SANITIZER)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")

Perhaps we should exclude `LIBCXX_HAS_EXTERNAL_THREAD_API` as well? Because 
there we explicitly strip off these flags.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24903#551938, @mgorny wrote:

> I see that libcxx already has a pretty complete test for stdint.h.


Hmm, now I see that too :)

Thanks for the patch.

/ Asiri


https://reviews.llvm.org/D24903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24903#551926, @mgorny wrote:

> I'm sorry but could you be a little more specific, please? I've looked into 
> that diff, and it seems that the cstdint resembles e.g. cinttypes already -- 
> i.e. there's only the include, and 'using' lines there. Or do you mean that I 
> should copy/update the synopsis over to stdint.h?


My bad, I hadn't actually looked at the current status of ``, it 
doesn't seem to need any more work.

/ Asiri


https://reviews.llvm.org/D24903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-25 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: rmaprath.
rmaprath added a comment.

When the `` headers where split into `` and `` headers in 
https://reviews.llvm.org/D12747, we have left out `` and ``. I 
was going to put up a patch to fix this but couldn't get to it. It's good that 
you are adding ``, perhaps you can follow what was done in 
https://reviews.llvm.org/D12747 and repeat the same for ``?

You will also need a test for the new header, https://reviews.llvm.org/D12747 
has examples.

Hope this helps!

/ Asiri


https://reviews.llvm.org/D24903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-09-23 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists, jroelofs, compnerd.
rmaprath added a subscriber: cfe-commits.

This is simply a cleanup of D18482 (patch taken with permission) while adapting 
it to match what we have already implemented for libcxx.

Note that I haven't included the external-threading stuff yet, this is only 
refactoring pthread usage of libcxxabi. A follow-up patch will add the 
external-threading support.

https://reviews.llvm.org/D24864

Files:
  include/__cxxabi_config.h
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  src/threading_support.h
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include 
+#include "../src/threading_support.h"
 
 typedef std::deque container;
 
Index: src/threading_support.h
===
--- /dev/null
+++ src/threading_support.h
@@ -0,0 +1,82 @@
+//=== threading_support.h -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCXXABI_THREADING_SUPPORT_H
+#define _LIBCXXABI_THREADING_SUPPORT_H
+
+#include "__cxxabi_config.h"
+#include "config.h"
+
+#ifndef _LIBCXXABI_HAS_NO_THREADS
+
+#if defined(_LIBCXXABI_HAS_THREAD_API_PTHREAD)
+#include 
+
+#define _LIBCXXABI_THREAD_ABI_VISIBILITY inline _LIBCXXABI_INLINE_VISIBILITY
+
+// Mutex
+typedef pthread_mutex_t __libcxxabi_mutex_t;
+#define _LIBCXXABI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_lock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_lock(mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_mutex_unlock(__libcxxabi_mutex_t *mutex) {
+  return pthread_mutex_unlock(mutex);
+}
+
+// Condition variable
+typedef pthread_cond_t __libcxxabi_condvar_t;
+#define _LIBCXXABI_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_wait(__libcxxabi_condvar_t *cv,
+ __libcxxabi_mutex_t *mutex) {
+  return pthread_cond_wait(cv, mutex);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_condvar_broadcast(__libcxxabi_condvar_t *cv) {
+  return pthread_cond_broadcast(cv);
+}
+
+// Execute once
+typedef pthread_once_t __libcxxabi_exec_once_flag;
+#define _LIBCXXABI_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_execute_once(__libcxxabi_exec_once_flag *flag,
+ void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// TLS
+typedef pthread_key_t __libcxxabi_tls_key;
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_create(__libcxxabi_tls_key *key,
+   void (*destructor)(void *)) {
+  return pthread_key_create(key, destructor);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+void *__libcxxabi_tls_get(__libcxxabi_tls_key key) {
+  return pthread_getspecific(key);
+}
+
+_LIBCXXABI_THREAD_ABI_VISIBILITY
+int __libcxxabi_tls_set(__libcxxabi_tls_key key, void *value) {
+  return pthread_setspecific(key, value);
+}
+#endif // _LIBCXXABI_HAS_THREAD_API_PTHREAD
+#endif // !_LIBCXXABI_HAS_NO_THREADS
+#endif // _LIBCXXABI_THREADING_SUPPORT_H
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -27,25 +27,25 @@
 
 // When POSIX threads are not available, make the mutex operations a nop
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+static __libcxxabi_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
 #else
 static void * heap_mutex = 0;
 #endif
 
 class mutexor {
 public:
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-mutexor ( pthread_mutex_t *m ) : mtx_(m) { pthread_mutex_lock ( mtx_ ); }
-~mutexor () { pthread_mutex_unlock ( mtx_ ); }
+mutexor ( __libcxxabi_mutex_t *m ) : mtx_(m) { __libcxxabi_mutex_lock ( mtx_ ); }
+~mutexor () { __libcxxabi_mutex_unlock ( mtx_ ); }
 #else
 mutexor ( void * ) {}
 ~mutexor () {}
 #endif
 private:
 mutexor ( const mutexor  );
 mutexor & operator = ( const mutexor  );
 #ifndef _LIBCXXABI_HAS_NO_THREADS
-pthread_mutex_t *mtx_;
+__libcxxabi_mutex_t *mtx_;
 #endif
 };
 
Index: src/cxa_guard.cpp
===
--- src/cxa_guard.cpp
+++ src/cxa_guard.cpp
@@ -11,20 +11,18 @@
 
 #include "abort_message.h"
 #include "config.h"

Re: [PATCH] D24770: [libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)

2016-09-21 Thread Asiri Rathnayake via cfe-commits
rmaprath closed this revision.
rmaprath added a comment.

In https://reviews.llvm.org/D24770#547701, @jroelofs wrote:

> LGTM


Thanks!

Committed as r282062.

/ Asiri


https://reviews.llvm.org/D24770



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r282062 - [libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)

2016-09-21 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Wed Sep 21 04:09:32 2016
New Revision: 282062

URL: http://llvm.org/viewvc/llvm-project?rev=282062=rev
Log:
[libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)

Align the naming / use of the macro LIBCXXABI_HAS_NO_THREADS to follow what we
have in libcxx. NFC.

Modified:
libcxxabi/trunk/CMakeLists.txt
libcxxabi/trunk/src/config.h
libcxxabi/trunk/src/cxa_exception.cpp
libcxxabi/trunk/src/cxa_exception_storage.cpp
libcxxabi/trunk/src/cxa_guard.cpp
libcxxabi/trunk/src/fallback_malloc.ipp
libcxxabi/trunk/test/libcxxabi/test/config.py
libcxxabi/trunk/test/test_exception_storage.pass.cpp
libcxxabi/trunk/test/test_guard.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=282062=282061=282062=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed Sep 21 04:09:32 2016
@@ -326,7 +326,7 @@ if (NOT LIBCXXABI_ENABLE_THREADS)
 " be set to ON when LIBCXXABI_ENABLE_THREADS"
 " is also set to ON.")
   endif()
-  add_definitions(-DLIBCXXABI_HAS_NO_THREADS=1)
+  add_definitions(-D_LIBCXXABI_HAS_NO_THREADS)
 endif()
 
 if (LIBCXXABI_HAS_PTHREAD_API)

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=282062=282061=282062=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Wed Sep 21 04:09:32 2016
@@ -16,11 +16,6 @@
 
 #include 
 
-// Set this in the CXXFLAGS when you need it
-#if !defined(LIBCXXABI_HAS_NO_THREADS)
-#  define LIBCXXABI_HAS_NO_THREADS 0
-#endif
-
 // Set this in the CXXFLAGS when you need it, because otherwise we'd have to
 // #if !defined(__linux__) && !defined(__APPLE__) && ...
 // and so-on for *every* platform.

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=282062=282061=282062=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Sep 21 04:09:32 2016
@@ -17,7 +17,7 @@
 #include // for std::terminate
 #include   // for malloc, free
 #include   // for memset
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #  include   // for fallback_malloc.ipp's mutexes
 #endif
 #include "cxa_exception.hpp"

Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception_storage.cpp?rev=282062=282061=282062=diff
==
--- libcxxabi/trunk/src/cxa_exception_storage.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp Wed Sep 21 04:09:32 2016
@@ -15,7 +15,7 @@
 
 #include "config.h"
 
-#if LIBCXXABI_HAS_NO_THREADS
+#if defined(_LIBCXXABI_HAS_NO_THREADS)
 
 namespace __cxxabiv1 {
 extern "C" {

Modified: libcxxabi/trunk/src/cxa_guard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_guard.cpp?rev=282062=282061=282062=diff
==
--- libcxxabi/trunk/src/cxa_guard.cpp (original)
+++ libcxxabi/trunk/src/cxa_guard.cpp Wed Sep 21 04:09:32 2016
@@ -12,7 +12,7 @@
 #include "abort_message.h"
 #include "config.h"
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #  include 
 #endif
 #include 
@@ -50,7 +50,7 @@ void set_initialized(guard_type* guard_o
 }
 #endif
 
-#if LIBCXXABI_HAS_NO_THREADS || (defined(__APPLE__) && !defined(__arm__))
+#if defined(_LIBCXXABI_HAS_NO_THREADS) || (defined(__APPLE__) && 
!defined(__arm__))
 #ifdef __arm__
 
 // Test the lowest bit.
@@ -68,7 +68,7 @@ bool is_initialized(guard_type* guard_ob
 #endif
 #endif
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 pthread_mutex_t guard_mut = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t  guard_cv  = PTHREAD_COND_INITIALIZER;
 #endif
@@ -172,22 +172,7 @@ set_lock(uint32_t& x, lock_type y)
 extern "C"
 {
 
-#if LIBCXXABI_HAS_NO_THREADS
-_LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
-return !is_initialized(guard_object);
-}
-
-_LIBCXXABI_FUNC_VIS void __cxa_guard_release(guard_type *guard_object) {
-*guard_object = 0;
-set_initialized(guard_object);
-}
-
-_LIBCXXABI_FUNC_VIS void __cxa_guard_abort(guard_type *guard_object) {
-*guard_object = 0;
-}
-
-#else // !LIBCXXABI_HAS_NO_THREADS
-
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 _LIBCXXABI_FUNC_VIS int __cxa_guard_acquire(guard_type *guard_object) {
 char* initialized = (char*)guard_object;
 if (pthread_mutex_lock(_mut))
@@ -250,7 +235,22 @@ _LIBCXXABI_FUNC_VIS void 

[PATCH] D24770: [libcxxabi] cleanup the use of LIBCXXABI_HAS_NO_THREADS macro (NFC)

2016-09-20 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: mclow.lists, EricWF.
rmaprath added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Align the naming / use of the macro ``LIBCXXABI_HAS_NO_THREADS`` to follow what 
we have in `libcxx`.

This change is mostly NFC, thought of putting it up for review as it involves a 
change in naming, and sometimes that can cause disagreements.

Will commit if there isn't much interest.

https://reviews.llvm.org/D24770

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/fallback_malloc.ipp
  test/libcxxabi/test/config.py
  test/test_exception_storage.pass.cpp
  test/test_guard.pass.cpp

Index: test/test_guard.pass.cpp
===
--- test/test_guard.pass.cpp
+++ test/test_guard.pass.cpp
@@ -12,7 +12,7 @@
 
 #include 
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #include 
 #endif
 
@@ -80,7 +80,7 @@
 }
 }
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 // A simple thread test of two threads racing to initialize a variable. This
 // isn't guaranteed to catch any particular threading problems.
 namespace test4 {
@@ -132,14 +132,14 @@
 assert(run_count == 1);
 }
 }
-#endif /* LIBCXXABI_HAS_NO_THREADS */
+#endif /* _LIBCXXABI_HAS_NO_THREADS */
 
 int main()
 {
 test1::test();
 test2::test();
 test3::test();
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 test4::test();
 test5::test();
 #endif
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #  include 
 #endif
 #include 
@@ -38,29 +38,16 @@
 return parm;
 }
 
-#if !LIBCXXABI_HAS_NO_THREADS
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
 size_t  thread_globals [ NUMTHREADS ] = { 0 };
 pthread_t   threads[ NUMTHREADS ];
 #endif
 
-void print_sizes ( size_t *first, size_t *last ) {
-std::cout << "{ " << std::hex;
-for ( size_t *iter = first; iter != last; ++iter )
-std::cout << *iter << " ";
-std::cout << "}" << std::dec << std::endl;
-}
-
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 
-#if LIBCXXABI_HAS_NO_THREADS
-size_t thread_globals;
-// Check that __cxa_get_globals() is not NULL.
-if (thread_code(_globals) == 0) {
-retVal = 1;
-}
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
 pthread_create( threads + i, NULL, thread_code, (void *) (thread_globals + i));
@@ -73,15 +60,18 @@
 retVal = 1;
 }
 
-//  print_sizes ( thread_globals, thread_globals + NUMTHREADS );
 std::sort ( thread_globals, thread_globals + NUMTHREADS );
 for ( int i = 1; i < NUMTHREADS; ++i )
 if ( thread_globals [ i - 1 ] == thread_globals [ i ] ) {
 std::cerr << "Duplicate thread globals (" << i-1 << " and " << i << ")" << std::endl;
 retVal = 2;
 }
-//  print_sizes ( thread_globals, thread_globals + NUMTHREADS );
-
-#endif
-return retVal;
+#else // _LIBCXXABI_HAS_NO_THREADS
+size_t thread_globals;
+// Check that __cxa_get_globals() is not NULL.
+if (thread_code(_globals) == 0) {
+retVal = 1;
 }
+#endif // !_LIBCXXABI_HAS_NO_THREADS
+return retVal;
+}
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -47,7 +47,7 @@
 else:
 self.cxx.compile_flags += ['-fno-exceptions', '-DLIBCXXABI_HAS_NO_EXCEPTIONS']
 if not self.get_lit_bool('enable_threads', True):
-self.cxx.compile_flags += ['-DLIBCXXABI_HAS_NO_THREADS=1']
+self.cxx.compile_flags += ['-D_LIBCXXABI_HAS_NO_THREADS']
 super(Configuration, self).configure_compile_flags()
 
 def configure_compile_flags_header_includes(self):
Index: src/fallback_malloc.ipp
===
--- src/fallback_malloc.ipp
+++ src/fallback_malloc.ipp
@@ -26,25 +26,25 @@
 namespace {
 
 // When POSIX threads are not available, make the mutex operations a nop
-#if LIBCXXABI_HAS_NO_THREADS
-static void * heap_mutex = 0;
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 static pthread_mutex_t heap_mutex = PTHREAD_MUTEX_INITIALIZER;
+#else
+static void * heap_mutex = 0;
 #endif
 
 class mutexor {
 public:
-#if LIBCXXABI_HAS_NO_THREADS
-mutexor ( void * ) {}
-~mutexor () {}
-#else
+#ifndef _LIBCXXABI_HAS_NO_THREADS
 mutexor ( pthread_mutex_t *m ) : mtx_(m) { 

[libcxx] r281731 - [libcxx] Add missing c++98 xfail. NFC.

2016-09-16 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Fri Sep 16 09:32:19 2016
New Revision: 281731

URL: http://llvm.org/viewvc/llvm-project?rev=281731=rev
Log:
[libcxx] Add missing c++98 xfail. NFC.

This is the only test failing in c++98 mode at the moment.

Modified:
libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp

Modified: libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp?rev=281731=281730=281731=diff
==
--- libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/iterator.range/begin-end.pass.cpp Fri Sep 
16 09:32:19 2016
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: c++03
+// XFAIL: c++03, c++98
 
 // 
 // template  auto begin(C& c) -> decltype(c.begin());


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23926: [libcxx] Don't use C99 math ops in -std=c++03 mode

2016-09-16 Thread Asiri Rathnayake via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Abandoning: we've decided to relax our C library to expose C99 functionality in 
C++98/03 modes. This is more inline with upstream intentions and allows us to 
get rid of some fiddly downstream libc++ patches as well.

Thanks Marshall and Eric for the comments / chats.

/ Asiri


https://reviews.llvm.org/D23926



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-15 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: test/std/re/re.alg/re.alg.search/grep.pass.cpp:25
@@ -25,2 +24,3 @@
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)

EricWF wrote:
> I prefer putting the `#if` on the inside of the function so you don't also 
> have to `#ifdef` it out in `main()` below. 
> 
Thanks. That's much better.

I'll convert as much tests as possible and submit and overall patch for a final 
review.


https://reviews.llvm.org/D24562



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D24562#542630, @mclow.lists wrote:

> What an awful test.  I wonder who wrote such a steaming pile.  Probably me.


I think I've thrown quite a lot of XFAILs like this in the past, just to get 
the no-exceptions build passing. Now I've got to clean them up one by one :)

Are you OK with this way of fixing them?

Cheers,

/ Asiri


https://reviews.llvm.org/D24562



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-14 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 71349.
rmaprath added a comment.

(Added more context)


https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp

Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 
LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }


Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24562: [libcxx] Recover no-exceptions XFAILs

2016-09-14 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists.
rmaprath added a subscriber: cfe-commits.

When we added support for the no-exceptions build of `libc++`, all the tests 
that used exceptions got a blanket XFAIL for the no-exceptions variety.

Previously, we tried to fix-up these tests with an elaborate setjmp/longjmp 
hackery (see D14653), which was rejected on the grounds of being too 
complicated / obtrusive.

The current patch is a representative fix that does the most obvious thing 
instead: use pre-processor macros to exclude just the bits of the test that use 
exceptions. Unlike in the previous patch, this means we are not trying to 
associate / verify a particular behaviour of the no-exceptions library with 
respect to exceptional situations (like calling abort). Here we simply save the 
parts of the test that has nothing to do with exceptions, I think this is a 
fair compromise.

We could also split the test file into two; one that uses exceptions and one 
that does not, though I can't think of any added benefits of that approach.

If this patch is approved I'll go ahead and update the rest of the tests (~150) 
to follow the same.

https://reviews.llvm.org/D24562

Files:
  test/std/re/re.alg/re.alg.search/grep.pass.cpp

Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 
LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }


Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp
===
--- test/std/re/re.alg/re.alg.search/grep.pass.cpp
+++ test/std/re/re.alg/re.alg.search/grep.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -23,6 +22,7 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 extern "C" void LLVMFuzzerTestOneInput(const char *data)
 {
 size_t size = strlen(data);
@@ -47,6 +47,7 @@
 LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f)()XX");
 #endif
 }
+#endif
 
 int main()
 {
@@ -82,5 +83,7 @@
 assert(m.position(0) == 0);
 assert(m.str(0) == "");
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 fuzz_tests();
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r281179 - [libcxx] Introduce an externally-threaded libc++ variant.

2016-09-12 Thread Asiri Rathnayake via cfe-commits
Hi Mike,

Can you check if https://reviews.llvm.org/D24475 fixes the issue for you?
This looks like a bug in the gcc pre-processor (in older versions of gcc).

I'm a bit hesitant because my gcc (4.8.3) bumps into a different issue
(crash!) as well, but that seem to have nothing to do with my patch (can
reproduce without my patch...).

Cheers,

/ Asiri

On Mon, Sep 12, 2016 at 9:49 PM, Asiri Rathnayake <
asiri.rathnay...@gmail.com> wrote:

> OK, I'm able to reproduce locally. Looks like gcc (4.8.3 at least) does
> not like my patch.
>
> Working on a fix...
>
> On Mon, Sep 12, 2016 at 9:43 PM, Asiri Rathnayake <
> asiri.rathnay...@gmail.com> wrote:
>
>> Hi Mike,
>>
>> That does look related to my change. Is this an internal build? I was
>> looking out for the bots on llvm.org but didn't spot any issues (yet).
>>
>> Will try to reproduce locally. Would it be OK if I find a fix tomorrow?
>> (night time here in the UK), can revert if this is blocking you.
>>
>> Cheers,
>>
>> / Asiri
>>
>>
>> On Mon, Sep 12, 2016 at 9:25 PM, Mike Aizatsky via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Asiri,
>>>
>>> The boot strap build has started to fail for. Your change seems to be
>>> related, right?
>>>
>>> [14/22] Building CXX object projects/libcxx/lib/CMakeFiles
>>> /cxx_objects.dir/__/src/locale.cpp.o
>>> FAILED: /usr/bin/g++   -D_DEBUG -D_GNU_SOURCE
>>> -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D__STDC_CONSTANT_MACROS
>>> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/libcxx/lib
>>> -I/usr/local/google/home/aizatsky/
>>> src/llvm/projects/libcxx/lib -Iinclude 
>>> -I/usr/local/google/home/aizatsky/src/llvm/include
>>> -I/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/include
>>> -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unuse
>>> d-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers
>>>  -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
>>> -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -UN
>>> DEBUG -DLIBCXX_BUILDING_LIBCXXABI -std=c++11 -nostdinc++ -Wall -Wextra
>>> -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type
>>> -Wno-attributes -Wno-literal-suffix -Wno-c++14-compat -Wno-erro
>>> r -fPIC -MMD -MT projects/libcxx/lib/CMakeFiles
>>> /cxx_objects.dir/__/src/locale.cpp.o -MF projects/libcxx/lib/CMakeFiles
>>> /cxx_objects.dir/__/src/locale.cpp.o.d -o projects/libcxx/lib/CMakeFiles
>>> /cxx_objects.dir/__/
>>> src/locale.cpp.o -c /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/src/locale.cpp
>>> In file included from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/__mutex_base:17:0,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/mutex:189,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/__locale:18,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/locale:182,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/src/locale.cpp:17:
>>> /usr/local/google/home/aizatsky/src/llvm/projects/libcxx/inc
>>> lude/__threading_support:22:90: error: missing binary operator before
>>> token "("
>>>  #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) &&
>>> (!defined(__has_include) || __has_include(<__external_threading>))
>>>
>>>   ^
>>> In file included from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/algorithm:637:0,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/__string:55,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/string_view:166,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/include/string:464,
>>>  from /usr/local/google/home/aizatsk
>>> y/src/llvm/projects/libcxx/src/locale.cpp:16:
>>>
>>>
>>> On Sun, Sep 11, 2016 at 2:55 PM Asiri Rathnayake via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: asiri
>>>> Date: Sun Sep 11 16:46:40 2016
>>>> New Revision: 281179
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=281179=rev
>>&

Re: [libcxx] r281179 - [libcxx] Introduce an externally-threaded libc++ variant.

2016-09-12 Thread Asiri Rathnayake via cfe-commits
OK, I'm able to reproduce locally. Looks like gcc (4.8.3 at least) does not
like my patch.

Working on a fix...

On Mon, Sep 12, 2016 at 9:43 PM, Asiri Rathnayake <
asiri.rathnay...@gmail.com> wrote:

> Hi Mike,
>
> That does look related to my change. Is this an internal build? I was
> looking out for the bots on llvm.org but didn't spot any issues (yet).
>
> Will try to reproduce locally. Would it be OK if I find a fix tomorrow?
> (night time here in the UK), can revert if this is blocking you.
>
> Cheers,
>
> / Asiri
>
>
> On Mon, Sep 12, 2016 at 9:25 PM, Mike Aizatsky via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Asiri,
>>
>> The boot strap build has started to fail for. Your change seems to be
>> related, right?
>>
>> [14/22] Building CXX object projects/libcxx/lib/CMakeFiles
>> /cxx_objects.dir/__/src/locale.cpp.o
>> FAILED: /usr/bin/g++   -D_DEBUG -D_GNU_SOURCE
>> -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D__STDC_CONSTANT_MACROS
>> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/libcxx/lib
>> -I/usr/local/google/home/aizatsky/
>> src/llvm/projects/libcxx/lib -Iinclude 
>> -I/usr/local/google/home/aizatsky/src/llvm/include
>> -I/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/include -fPIC
>> -fvisibility-inlines-hidden -Wall -W -Wno-unuse
>> d-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers
>>  -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
>> -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -UN
>> DEBUG -DLIBCXX_BUILDING_LIBCXXABI -std=c++11 -nostdinc++ -Wall -Wextra -W
>> -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type
>> -Wno-attributes -Wno-literal-suffix -Wno-c++14-compat -Wno-erro
>> r -fPIC -MMD -MT 
>> projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o
>> -MF projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o.d
>> -o projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/
>> src/locale.cpp.o -c /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/src/locale.cpp
>> In file included from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/__mutex_base:17:0,
>>  from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/mutex:189,
>>  from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/__locale:18,
>>  from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/locale:182,
>>  from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/src/locale.cpp:17:
>> /usr/local/google/home/aizatsky/src/llvm/projects/libcxx/
>> include/__threading_support:22:90: error: missing binary operator before
>> token "("
>>  #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) &&
>> (!defined(__has_include) || __has_include(<__external_threading>))
>>
>> ^
>> In file included from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/algorithm:637:0,
>>  from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/__string:55,
>>              from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/string_view:166,
>>  from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/include/string:464,
>>  from /usr/local/google/home/aizatsk
>> y/src/llvm/projects/libcxx/src/locale.cpp:16:
>>
>>
>> On Sun, Sep 11, 2016 at 2:55 PM Asiri Rathnayake via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: asiri
>>> Date: Sun Sep 11 16:46:40 2016
>>> New Revision: 281179
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=281179=rev
>>> Log:
>>> [libcxx] Introduce an externally-threaded libc++ variant.
>>>
>>> This patch further decouples libc++ from pthread, allowing libc++ to be
>>> built
>>> against other threading systems. There are two main use cases:
>>>
>>> - Building libc++ against a thread library other than pthreads.
>>>
>>> - Building libc++ with an "external" thread API, allowing a separate
>>> library to
>>>   provide the implementation of that API.
>>>
>>> The two use cases are quite similar, the second one being sligtly more
>>> de-coupled than the first. The cmake option
>>> LIBCXX_HAS_EXTERNAL_THREAD_API
>>> enables both kinds of builds. One needs t

Re: [libcxx] r281179 - [libcxx] Introduce an externally-threaded libc++ variant.

2016-09-12 Thread Asiri Rathnayake via cfe-commits
Hi Mike,

That does look related to my change. Is this an internal build? I was
looking out for the bots on llvm.org but didn't spot any issues (yet).

Will try to reproduce locally. Would it be OK if I find a fix tomorrow?
(night time here in the UK), can revert if this is blocking you.

Cheers,

/ Asiri


On Mon, Sep 12, 2016 at 9:25 PM, Mike Aizatsky via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Asiri,
>
> The boot strap build has started to fail for. Your change seems to be
> related, right?
>
> [14/22] Building CXX object projects/libcxx/lib/
> CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o
> FAILED: /usr/bin/g++   -D_DEBUG -D_GNU_SOURCE 
> -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Iprojects/libcxx/lib -I/usr/local/google/home/aizatsky/
> src/llvm/projects/libcxx/lib -Iinclude 
> -I/usr/local/google/home/aizatsky/src/llvm/include
> -I/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/include -fPIC
> -fvisibility-inlines-hidden -Wall -W -Wno-unuse
> d-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers
>  -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
> -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -UN
> DEBUG -DLIBCXX_BUILDING_LIBCXXABI -std=c++11 -nostdinc++ -Wall -Wextra -W
> -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type
> -Wno-attributes -Wno-literal-suffix -Wno-c++14-compat -Wno-erro
> r -fPIC -MMD -MT 
> projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o
> -MF projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/locale.cpp.o.d
> -o projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/
> src/locale.cpp.o -c /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/src/locale.cpp
> In file included from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/__mutex_base:17:0,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/mutex:189,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/__locale:18,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/locale:182,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/src/locale.cpp:17:
> /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/__threading_support:22:90: error: missing binary operator
> before token "("
>  #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && (!defined(__has_include)
> || __has_include(<__external_threading>))
>
> ^
> In file included from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/algorithm:637:0,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/__string:55,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/string_view:166,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/include/string:464,
>  from /usr/local/google/home/aizatsky/src/llvm/projects/
> libcxx/src/locale.cpp:16:
>
>
> On Sun, Sep 11, 2016 at 2:55 PM Asiri Rathnayake via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: asiri
>> Date: Sun Sep 11 16:46:40 2016
>> New Revision: 281179
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=281179=rev
>> Log:
>> [libcxx] Introduce an externally-threaded libc++ variant.
>>
>> This patch further decouples libc++ from pthread, allowing libc++ to be
>> built
>> against other threading systems. There are two main use cases:
>>
>> - Building libc++ against a thread library other than pthreads.
>>
>> - Building libc++ with an "external" thread API, allowing a separate
>> library to
>>   provide the implementation of that API.
>>
>> The two use cases are quite similar, the second one being sligtly more
>> de-coupled than the first. The cmake option LIBCXX_HAS_EXTERNAL_THREAD_API
>> enables both kinds of builds. One needs to place an <__external_threading>
>> header file containing an implementation of the "libc++ thread API"
>> declared
>> in the <__threading_support> header.
>>
>> For the second use case, the implementation of the libc++ thread API can
>> delegate to a custom "external" thread API where the implementation of
>> this
>> external API is provided in a seperate library. This mechanism allows
>> toolchain
>> vendors to distribute a build of libc++ with a custom
>> thread-porting-layer API
>> (which is the "ext

[libcxx] r281179 - [libcxx] Introduce an externally-threaded libc++ variant.

2016-09-11 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Sun Sep 11 16:46:40 2016
New Revision: 281179

URL: http://llvm.org/viewvc/llvm-project?rev=281179=rev
Log:
[libcxx] Introduce an externally-threaded libc++ variant.

This patch further decouples libc++ from pthread, allowing libc++ to be built
against other threading systems. There are two main use cases:

- Building libc++ against a thread library other than pthreads.

- Building libc++ with an "external" thread API, allowing a separate library to
  provide the implementation of that API.

The two use cases are quite similar, the second one being sligtly more
de-coupled than the first. The cmake option LIBCXX_HAS_EXTERNAL_THREAD_API
enables both kinds of builds. One needs to place an <__external_threading>
header file containing an implementation of the "libc++ thread API" declared
in the <__threading_support> header.

For the second use case, the implementation of the libc++ thread API can
delegate to a custom "external" thread API where the implementation of this
external API is provided in a seperate library. This mechanism allows toolchain
vendors to distribute a build of libc++ with a custom thread-porting-layer API
(which is the "external" API above), platform vendors (recipients of the
toolchain/libc++) are then required to provide their implementation of this API
to be linked with (end-user) C++ programs.

Note that the second use case still requires establishing the basic types that
get passed between the external thread library and the libc++ library
(e.g. __libcpp_mutex_t). These cannot be opaque pointer types (libc++ sources
won't compile otherwise). It should also be noted that the second use case can
have a slight performance penalty; as all the thread constructs need to cross a
library boundary through an additional function call.

When the header <__external_threading> is omitted, libc++ is built with the
"libc++ thread API" (declared in <__threading_support>) as the "external" thread
API (basic types are pthread based). An implementation (pthread based) of this
API is provided in test/support/external_threads.cpp, which is built into a
separate DSO and linked in when running the libc++ test suite. A test run
therefore demonstrates the second use case (less the intermediate custom API).

Differential revision: https://reviews.llvm.org/D21968

Reviewers: bcraig, compnerd, EricWF, mclow.lists

Added:
libcxx/trunk/test/support/external_threads.cpp
  - copied, changed from r280988, 
libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/include/__config
libcxx/trunk/include/__config_site.in
libcxx/trunk/include/__threading_support
libcxx/trunk/include/thread
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/test/libcxx/test/config.py

libcxx/trunk/test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp

libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
libcxx/trunk/test/lit.site.cfg.in

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=281179=281178=281179=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Sun Sep 11 16:46:40 2016
@@ -140,6 +140,9 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK
This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON)
 option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" 
OFF)
 option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread 
API" OFF)
+option(LIBCXX_HAS_EXTERNAL_THREAD_API
+  "Build libc++ with an externalized threading API.
+   This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
 
 # Misc options 
 # FIXME: Turn -pedantic back ON. It is currently off because it warns
@@ -197,6 +200,11 @@ if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX
   " when LIBCXX_ENABLE_THREADS is also set to ON.")
 endif()
 
+if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS)
+  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set to ON"
+  " when LIBCXX_ENABLE_THREADS is also set to ON.")
+endif()
+
 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
 # is ON.
 if 

Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-09-09 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 70840.
rmaprath added a comment.
Herald added a subscriber: beanz.

Final patch incorporating all the changes from @EricWF and @compnerd.

Will commit tomorrow (@mclow.lists gave approval earlier)

/ Asiri


https://reviews.llvm.org/D21968

Files:
  CMakeLists.txt
  include/__config
  include/__config_site.in
  include/__threading_support
  include/thread
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  
test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
  
test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
  
test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
  test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
  test/lit.site.cfg.in
  test/support/external_threads.cpp

Index: test/support/external_threads.cpp
===
--- /dev/null
+++ test/support/external_threads.cpp
@@ -0,0 +1,10 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+#define _LIBCPP_BUILDING_EXTERNAL_THREADS
+#include <__threading_support>
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -26,6 +26,7 @@
 config.use_libatomic= "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
 
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
+config.libcxx_external_thread_api  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
===
--- test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
+++ test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
+++ test/libcxx/thread/thread.threads/thread.thread.class/thread.thread.member/native_handle.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
+++ test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.recursive/native_handle.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
+++ test/libcxx/thread/thread.mutex/thread.mutex.requirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 //
-// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
 
 // 
 
Index: test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
===
--- test/libcxx/thread/thread.condition/thread.condition.condvar/native_handle.pass.cpp
+++ 

Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-09-08 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In https://reviews.llvm.org/D21968#534462, @EricWF wrote:

> This looks great.  Two comments:
>
> 1. The declarations should be used in both the inline and external pthread 
> implementation. They also need visibility declarations.
> 2. Why can't we use the inline implementation to implement 
> `external_threads.cpp`?
>
>   I took a stab at it here 
> .


Yup, that looks better.

I will incorporate this change and also address the remaining comments from 
@compnerd before I commit.

Thanks all!

/ Asiri


https://reviews.llvm.org/D21968



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >