[前][次][番号順一覧][スレッド一覧]

ruby-changes:59502

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 27 Dec 2019 02:43:40 +0900 (JST)
Subject: [ruby-changes:59502] 8184adabe5 (master): internal/stdbool.h rework

https://git.ruby-lang.org/ruby.git/commit/?id=8184adabe5

From 8184adabe5018ff930fde64456029471c1ebcd2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Wed, 25 Dec 2019 13:40:10 +0900
Subject: internal/stdbool.h rework

Noticed that internal/stdbool.h and addr2line.c are the only two place
where missing/stdbool.h is included.  Why not delete the file so that
we can merge internal/stdbool.h and missing/stdbool.h into one.

diff --git a/addr2line.c b/addr2line.c
index 635194b..c670485 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -25,11 +25,7 @@ https://github.com/ruby/ruby/blob/trunk/addr2line.c#L25
 #include <libproc.h>
 #endif
 
-#ifdef HAVE_STDBOOL_H
-#include <stdbool.h>
-#else
-#include "missing/stdbool.h"
-#endif
+#include "internal/stdbool.h"
 
 #if defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H)
 
diff --git a/internal/stdbool.h b/internal/stdbool.h
index 4c103b4..e090e57 100644
--- a/internal/stdbool.h
+++ b/internal/stdbool.h
@@ -13,8 +13,22 @@ https://github.com/ruby/ruby/blob/trunk/internal/stdbool.h#L13
 
 #ifdef HAVE_STDBOOL_H
 # include <stdbool.h>
+#endif
+
+/* Note that we assume the compiler isn't C++. */
+#ifdef __bool_true_false_are_defined
+# undef bool
+# undef true
+# undef false
+# undef __bool_true_false_are_defined
 #else
-# include "missing/stdbool.h"
+typedef unsigned char _Bool;
 #endif
 
+/* See also http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2229.htm */
+#define bool  _Bool
+#define true  ((_Bool)+1)
+#define false ((_Bool)+0)
+#define __bool_true_false_are_defined
+
 #endif /* INTERNAL_STDBOOL_H */
diff --git a/missing/stdbool.h b/missing/stdbool.h
deleted file mode 100644
index f370e01..0000000
--- a/missing/stdbool.h
+++ /dev/null
@@ -1,20 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/internal/stdbool.h#L0
-/*
- * missing/stdbool.h: Quick alternative of C99 stdbool.h
- */
-
-#ifndef _MISSING_STDBOOL_H_
-#define _MISSING_STDBOOL_H_
-
-#ifndef __bool_true_false_are_defined
-# ifndef __cplusplus
-#  undef bool
-#  undef false
-#  undef true
-#  define bool signed char
-#  define false 0
-#  define true 1
-#  define __bool_true_false_are_defined 1
-# endif
-#endif
-
-#endif /* _MISSING_STDBOOL_H_ */
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]