[PATCH] D12747: Implement [depr.c.headers]

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 15:42:11 PDT 2015


<setjmp.h>, an easy one. We guarantee a setjmp macro exists even if this
header is somehow included from C (the C standard allows that, so it's not
worth checking for __cplusplus).

On Tue, Oct 6, 2015 at 3:36 PM, Richard Smith <richard at metafoo.co.uk> wrote:

> Split <math.h> out of <cmath>. This is a big change, but the same pattern
> as the prior ones.
>
> On Tue, Oct 6, 2015 at 3:28 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>
>> Likewise for <errno.h>, <float.h>, <inttypes.h>
>>
>> On Tue, Oct 6, 2015 at 3:20 PM, Richard Smith <richard at metafoo.co.uk>
>> wrote:
>>
>>> Split <ctype.h> header out of <cctype>
>>>
>>> On Tue, Oct 6, 2015 at 3:07 PM, Richard Smith <richard at metafoo.co.uk>
>>> wrote:
>>>
>>>> Next: factoring the definition of std::nullptr_t out into a separate
>>>> file, so that <cstddef> and <stddef.h> can both use it, without <stddef.h>
>>>> including <cstddef> and without <cstddef> providing a ::nullptr_t like
>>>> <stddef.h> does.
>>>>
>>>> On Tue, Oct 6, 2015 at 3:02 PM, Eric Fiselier <eric at efcs.ca> wrote:
>>>>
>>>>> LGTM.
>>>>>
>>>>> On Tue, Oct 6, 2015 at 3:58 PM, Richard Smith <richard at metafoo.co.uk>
>>>>> wrote:
>>>>> > On Mon, Oct 5, 2015 at 7:10 PM, Eric Fiselier <eric at efcs.ca> wrote:
>>>>> >>
>>>>> >> EricWF added a comment.
>>>>> >>
>>>>> >> I think thing change will help us close a number out outstanding
>>>>> bugs. I
>>>>> >> don't have any fundamental objections to this approach.  However
>>>>> the size of
>>>>> >> this patch scares me.  I understand the changes are mostly
>>>>> mechanical but
>>>>> >> their size can hide things. For example has anybody noticed that
>>>>> your
>>>>> >> internal changes to `<deque>` are in this patch? It would be nice
>>>>> to break
>>>>> >> this down into more digestible pieces that could be quickly spot
>>>>> checked.
>>>>> >
>>>>> >
>>>>> > OK. First such patch is attached. It just removes the macro-capturing
>>>>> > wrapper functions.
>>>>>
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151006/d183c451/attachment.html>
-------------- next part --------------
diff --git include/csetjmp include/csetjmp
index d0b2c07..58a9c73 100644
--- include/csetjmp
+++ include/csetjmp
@@ -38,10 +38,6 @@ void longjmp(jmp_buf env, int val);
 #pragma GCC system_header
 #endif
 
-#ifndef setjmp
-#define setjmp(env) setjmp(env)
-#endif
-
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::jmp_buf;
diff --git include/setjmp.h include/setjmp.h
new file mode 100644
index 0000000..d429c86
--- /dev/null
+++ include/setjmp.h
@@ -0,0 +1,40 @@
+// -*- C++ -*-
+//===--------------------------- setjmp.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_SETJMP_H
+#define _LIBCPP_SETJMP_H
+
+/*
+    setjmp.h synopsis
+
+Macros:
+
+    setjmp
+
+Types:
+
+    jmp_buf
+
+void longjmp(jmp_buf env, int val);
+
+*/
+
+#include <__config>
+#include_next <setjmp.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#ifndef setjmp
+#define setjmp(env) setjmp(env)
+#endif
+
+#endif  // _LIBCPP_SETJMP_H
diff --git test/std/depr/depr.c.headers/setjmp_h.pass.cpp test/std/depr/depr.c.headers/setjmp_h.pass.cpp
index 36f4253..9bc35b7 100644
--- test/std/depr/depr.c.headers/setjmp_h.pass.cpp
+++ test/std/depr/depr.c.headers/setjmp_h.pass.cpp
@@ -12,6 +12,10 @@
 #include <setjmp.h>
 #include <type_traits>
 
+#ifndef setjmp
+#error setjmp not defined
+#endif
+
 int main()
 {
     jmp_buf jb;


More information about the cfe-commits mailing list