You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2017/02/04 17:47:32 UTC
[01/11] lucy-clownfish git commit: Remove unused CFISH_SIZEOF_* macros
Repository: lucy-clownfish
Updated Branches:
refs/heads/master 2794cf2eb -> 088a359d3
Remove unused CFISH_SIZEOF_* macros
These macros were only needed by the old Perl labeled params
code.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/fa81ff19
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/fa81ff19
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/fa81ff19
Branch: refs/heads/master
Commit: fa81ff191f9a70187cc7feb43c87c018b3e22fdb
Parents: 2794cf2
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 13:19:35 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 15:10:39 2017 +0100
----------------------------------------------------------------------
compiler/src/CFCBindCore.c | 10 ----------
1 file changed, 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/fa81ff19/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index 95e0206..fc02dd2 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -613,11 +613,6 @@ S_charmony_string_defines() {
"#define CFISH_INLINE %s\n"
"#define CFISH_EXPORT %s\n"
"#define CFISH_IMPORT %s\n"
- "#define CFISH_SIZEOF_CHAR %s\n"
- "#define CFISH_SIZEOF_SHORT %s\n"
- "#define CFISH_SIZEOF_INT %s\n"
- "#define CFISH_SIZEOF_LONG %s\n"
- "#define CFISH_SIZEOF_SIZE_T %s\n"
"#define CFISH_FUNC_MACRO %s\n"
"#define CFISH_U64_TO_DOUBLE(x) %s\n";
char *defines
@@ -625,11 +620,6 @@ S_charmony_string_defines() {
XSTRING(CHY_INLINE),
XSTRING(CHY_EXPORT),
XSTRING(CHY_IMPORT),
- XSTRING(CHY_SIZEOF_CHAR),
- XSTRING(CHY_SIZEOF_SHORT),
- XSTRING(CHY_SIZEOF_INT),
- XSTRING(CHY_SIZEOF_LONG),
- XSTRING(CHY_SIZEOF_SIZE_T),
XSTRING(CHY_FUNC_MACRO),
XSTRING(CHY_U64_TO_DOUBLE(x)));
[11/11] lucy-clownfish git commit: Use chaz_OS_exe_ext() for
executables on the host OS
Posted by nw...@apache.org.
Use chaz_OS_exe_ext() for executables on the host OS
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/088a359d
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/088a359d
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/088a359d
Branch: refs/heads/master
Commit: 088a359d3316bf586e8bd0437012ad832eb744bc
Parents: e65b995
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Feb 4 16:12:18 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 18:13:35 2017 +0100
----------------------------------------------------------------------
compiler/common/charmonizer.c | 23 +++++++++++++++++++----
runtime/common/charmonizer.c | 27 +++++++++++++++++++++------
runtime/common/charmonizer.main | 4 ++--
3 files changed, 42 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/088a359d/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index d45c84a..ec8083c 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -983,6 +983,13 @@ chaz_OS_dir_sep(void);
int
chaz_OS_shell_type(void);
+/* Return the file extension for executables on this system. This can be
+ * a different value than returned by chaz_CC_exe_ext() when
+ * cross-compiling.
+ */
+const char*
+chaz_OS_exe_ext(void);
+
/* Initialize the Charmonizer/Core/OperatingSystem module.
*/
void
@@ -4802,8 +4809,6 @@ S_chaz_Make_audition(const char *make) {
chaz_MakeFile*
chaz_MakeFile_new() {
chaz_MakeFile *self = (chaz_MakeFile*)calloc(1, sizeof(chaz_MakeFile));
- const char *exe_ext = chaz_CC_exe_ext();
- const char *obj_ext = chaz_CC_obj_ext();
char *generated;
self->vars = (chaz_MakeVar**)calloc(1, sizeof(chaz_MakeVar*));
@@ -4813,8 +4818,9 @@ chaz_MakeFile_new() {
self->clean = S_chaz_MakeRule_new("clean", NULL);
self->distclean = S_chaz_MakeRule_new("distclean", "clean");
- generated = chaz_Util_join("", "charmonizer", exe_ext, " charmonizer",
- obj_ext, " charmony.h Makefile", NULL);
+ /* MSVC leaves .obj files around when creating executables. */
+ generated = chaz_Util_join("", "charmonizer", chaz_OS_exe_ext(),
+ " charmonizer.obj charmony.h Makefile", NULL);
chaz_MakeRule_add_rm_command(self->distclean, generated);
free(generated);
@@ -5901,6 +5907,15 @@ chaz_OS_shell_type(void) {
return chaz_OS.shell_type;
}
+const char*
+chaz_OS_exe_ext(void) {
+#ifdef _WIN32
+ return ".exe";
+#else
+ return "";
+#endif
+}
+
int
chaz_OS_remove(const char *name) {
/*
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/088a359d/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index e989f0a..9df40d7 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -983,6 +983,13 @@ chaz_OS_dir_sep(void);
int
chaz_OS_shell_type(void);
+/* Return the file extension for executables on this system. This can be
+ * a different value than returned by chaz_CC_exe_ext() when
+ * cross-compiling.
+ */
+const char*
+chaz_OS_exe_ext(void);
+
/* Initialize the Charmonizer/Core/OperatingSystem module.
*/
void
@@ -4802,8 +4809,6 @@ S_chaz_Make_audition(const char *make) {
chaz_MakeFile*
chaz_MakeFile_new() {
chaz_MakeFile *self = (chaz_MakeFile*)calloc(1, sizeof(chaz_MakeFile));
- const char *exe_ext = chaz_CC_exe_ext();
- const char *obj_ext = chaz_CC_obj_ext();
char *generated;
self->vars = (chaz_MakeVar**)calloc(1, sizeof(chaz_MakeVar*));
@@ -4813,8 +4818,9 @@ chaz_MakeFile_new() {
self->clean = S_chaz_MakeRule_new("clean", NULL);
self->distclean = S_chaz_MakeRule_new("distclean", "clean");
- generated = chaz_Util_join("", "charmonizer", exe_ext, " charmonizer",
- obj_ext, " charmony.h Makefile", NULL);
+ /* MSVC leaves .obj files around when creating executables. */
+ generated = chaz_Util_join("", "charmonizer", chaz_OS_exe_ext(),
+ " charmonizer.obj charmony.h Makefile", NULL);
chaz_MakeRule_add_rm_command(self->distclean, generated);
free(generated);
@@ -5901,6 +5907,15 @@ chaz_OS_shell_type(void) {
return chaz_OS.shell_type;
}
+const char*
+chaz_OS_exe_ext(void) {
+#ifdef _WIN32
+ return ".exe";
+#else
+ return "";
+#endif
+}
+
int
chaz_OS_remove(const char *name) {
/*
@@ -8884,8 +8899,8 @@ cfish_MakeFile_write_c_cfc_rules(cfish_MakeFile *self) {
chaz_MakeRule *rule;
- const char *dir_sep = chaz_OS_dir_sep();
- const char *exe_ext = chaz_CC_exe_ext();
+ const char *dir_sep = chaz_OS_dir_sep();
+ const char *exe_ext = chaz_OS_exe_ext();
char *cfc_dir;
char *cfc_exe;
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/088a359d/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index 22b8f01..c2d2ff5 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -503,8 +503,8 @@ cfish_MakeFile_write_c_cfc_rules(cfish_MakeFile *self) {
chaz_MakeRule *rule;
- const char *dir_sep = chaz_OS_dir_sep();
- const char *exe_ext = chaz_CC_exe_ext();
+ const char *dir_sep = chaz_OS_dir_sep();
+ const char *exe_ext = chaz_OS_exe_ext();
char *cfc_dir;
char *cfc_exe;
[02/11] lucy-clownfish git commit: Remove U64_TO_DOUBLE macro
Posted by nw...@apache.org.
Remove U64_TO_DOUBLE macro
It was only needed for MSVC6.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/2b8147d3
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/2b8147d3
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/2b8147d3
Branch: refs/heads/master
Commit: 2b8147d3a728326732cd9d7b50b4154624d7836d
Parents: fa81ff1
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 13:28:36 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 15:10:50 2017 +0100
----------------------------------------------------------------------
compiler/common/charmonizer.c | 33 ---------------------
compiler/src/CFCBindCore.c | 6 ++--
compiler/src/CFCPerlTypeMap.c | 9 ++----
runtime/common/charmonizer.c | 33 ---------------------
runtime/core/Clownfish/TestHarness/TestUtils.c | 2 +-
runtime/test/Clownfish/Test/Util/TestMemory.c | 5 ++--
6 files changed, 7 insertions(+), 81 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index d53ebc0..895f63a 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -7278,17 +7278,6 @@ static const char chaz_Integers_literal64_code[] =
CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( } );
-static const char chaz_Integers_u64_to_double_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( unsigned %s int_num = 0; )
- CHAZ_QUOTE( double float_num; )
- CHAZ_QUOTE( float_num = (double)int_num; )
- CHAZ_QUOTE( printf("%%f\n", float_num); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
void
chaz_Integers_run(void) {
char *output;
@@ -7558,28 +7547,6 @@ chaz_Integers_run(void) {
}
}
- /* Create macro for converting uint64_t to double. */
- if (has_64) {
- /*
- * Determine whether unsigned 64-bit integers can be converted to
- * double. Older MSVC versions don't support this conversion.
- */
- sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
- free(output);
- }
- else {
- chaz_ConfWriter_add_def(
- "U64_TO_DOUBLE(num)",
- "((num) & UINT64_C(0x8000000000000000) ? "
- "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
- "9223372036854775808.0 : "
- "(double)(int64_t)(num))");
- }
- }
-
chaz_ConfWriter_end_module();
/* Integer typedefs. */
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index fc02dd2..0bca5e6 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -613,15 +613,13 @@ S_charmony_string_defines() {
"#define CFISH_INLINE %s\n"
"#define CFISH_EXPORT %s\n"
"#define CFISH_IMPORT %s\n"
- "#define CFISH_FUNC_MACRO %s\n"
- "#define CFISH_U64_TO_DOUBLE(x) %s\n";
+ "#define CFISH_FUNC_MACRO %s\n";
char *defines
= CFCUtil_sprintf(pattern,
XSTRING(CHY_INLINE),
XSTRING(CHY_EXPORT),
XSTRING(CHY_IMPORT),
- XSTRING(CHY_FUNC_MACRO),
- XSTRING(CHY_U64_TO_DOUBLE(x)));
+ XSTRING(CHY_FUNC_MACRO));
return defines;
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/compiler/src/CFCPerlTypeMap.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlTypeMap.c b/compiler/src/CFCPerlTypeMap.c
index d416284..bc35ad9 100644
--- a/compiler/src/CFCPerlTypeMap.c
+++ b/compiler/src/CFCPerlTypeMap.c
@@ -153,10 +153,7 @@ CFCPerlTypeMap_to_perl(CFCType *type, const char *cf_var) {
result = CFCUtil_sprintf("newSViv(%s)", cf_var);
}
else if (strcmp(specifier, "uint64_t") == 0) {
- char pattern[] =
- "sizeof(UV) == 8 ? "
- "newSVuv((UV)%s) : newSVnv((NV)CFISH_U64_TO_DOUBLE(%s))";
- result = CFCUtil_sprintf(pattern, cf_var, cf_var);
+ result = CFCUtil_sprintf("newSVuv(%s)", cf_var);
}
else if (strcmp(specifier, "uint32_t") == 0) {
result = CFCUtil_sprintf("newSVuv(%s)", cf_var);
@@ -245,9 +242,7 @@ static const char typemap_output[] =
"\n"
"CFISH_BIG_UNSIGNED_INT\n"
" if (sizeof(UV) == 8) { sv_setuv($arg, (UV)$var); }\n"
- " else {\n"
- " sv_setnv($arg, (NV)CFISH_U64_TO_DOUBLE($var));\n"
- " }\n"
+ " else { sv_setnv($arg, (NV)$var); }\n"
"\n";
void
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 840fa5a..64bf01f 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -7278,17 +7278,6 @@ static const char chaz_Integers_literal64_code[] =
CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( } );
-static const char chaz_Integers_u64_to_double_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( unsigned %s int_num = 0; )
- CHAZ_QUOTE( double float_num; )
- CHAZ_QUOTE( float_num = (double)int_num; )
- CHAZ_QUOTE( printf("%%f\n", float_num); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
void
chaz_Integers_run(void) {
char *output;
@@ -7558,28 +7547,6 @@ chaz_Integers_run(void) {
}
}
- /* Create macro for converting uint64_t to double. */
- if (has_64) {
- /*
- * Determine whether unsigned 64-bit integers can be converted to
- * double. Older MSVC versions don't support this conversion.
- */
- sprintf(code_buf, chaz_Integers_u64_to_double_code, i64_t_type);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- chaz_ConfWriter_add_def("U64_TO_DOUBLE(num)", "((double)(num))");
- free(output);
- }
- else {
- chaz_ConfWriter_add_def(
- "U64_TO_DOUBLE(num)",
- "((num) & UINT64_C(0x8000000000000000) ? "
- "(double)(int64_t)((num) & UINT64_C(0x7FFFFFFFFFFFFFFF)) + "
- "9223372036854775808.0 : "
- "(double)(int64_t)(num))");
- }
- }
-
chaz_ConfWriter_end_module();
/* Integer typedefs. */
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/runtime/core/Clownfish/TestHarness/TestUtils.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/TestHarness/TestUtils.c b/runtime/core/Clownfish/TestHarness/TestUtils.c
index 38301d3..db94ebf 100644
--- a/runtime/core/Clownfish/TestHarness/TestUtils.c
+++ b/runtime/core/Clownfish/TestHarness/TestUtils.c
@@ -65,7 +65,7 @@ TestUtils_random_f64s(double *buf, size_t count) {
double *f64s = buf ? buf : (double*)CALLOCATE(count, sizeof(double));
for (size_t i = 0; i < count; i++) {
uint64_t num = TestUtils_random_u64();
- f64s[i] = CHY_U64_TO_DOUBLE(num) / (double)UINT64_MAX;
+ f64s[i] = (double)num / (double)UINT64_MAX;
}
return f64s;
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/2b8147d3/runtime/test/Clownfish/Test/Util/TestMemory.c
----------------------------------------------------------------------
diff --git a/runtime/test/Clownfish/Test/Util/TestMemory.c b/runtime/test/Clownfish/Test/Util/TestMemory.c
index 8151c72..1083233 100644
--- a/runtime/test/Clownfish/Test/Util/TestMemory.c
+++ b/runtime/test/Clownfish/Test/Util/TestMemory.c
@@ -48,8 +48,7 @@ test_oversize__growth_rate(TestBatchRunner *runner) {
}
if (size > 0) {
growth_count += 1;
- double growth_rate = CHY_U64_TO_DOUBLE(next_size) /
- CHY_U64_TO_DOUBLE(size);
+ double growth_rate = (double)next_size / (double)size;
double sum = growth_rate + (growth_count - 1) * average_growth_rate;
average_growth_rate = sum / growth_count;
if (average_growth_rate < 1.1) {
@@ -70,7 +69,7 @@ test_oversize__growth_rate(TestBatchRunner *runner) {
for (size_t minimum = 1; minimum < 8; minimum++) {
uint64_t next_size = Memory_oversize(minimum, sizeof(void*));
- double growth_rate = CHY_U64_TO_DOUBLE(next_size) / (double)minimum;
+ double growth_rate = (double)next_size / (double)minimum;
TEST_TRUE(runner, growth_rate > 1.2,
"Growth rate is higher for smaller arrays (%u, %.3f)",
(unsigned)minimum, growth_rate);
[10/11] lucy-clownfish git commit: Update build instructions
Posted by nw...@apache.org.
Update build instructions
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/931b4909
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/931b4909
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/931b4909
Branch: refs/heads/master
Commit: 931b4909bb624d90371c0b1d552314dbe18a322e
Parents: 1612e7a
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 22:33:09 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 18:13:34 2017 +0100
----------------------------------------------------------------------
compiler/c/INSTALL.md | 57 ++++++++++++++++++++++++-------------
runtime/c/INSTALL.md | 71 ++++++++++++++++++++++++++++++++--------------
2 files changed, 87 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/931b4909/compiler/c/INSTALL.md
----------------------------------------------------------------------
diff --git a/compiler/c/INSTALL.md b/compiler/c/INSTALL.md
index 17ba47a..1774a45 100644
--- a/compiler/c/INSTALL.md
+++ b/compiler/c/INSTALL.md
@@ -8,41 +8,58 @@ Building under UNIX and derivatives or Cygwin
$ make
$ make test
+Use the installation script of the Clownfish runtime to install.
+
Building under Windows
----------------------
-You need MSVC or gcc as C compiler and nmake or mingw32-make as make utility.
+You need MSVC or gcc as C compiler and nmake, mingw32-make, or standard
+GNU make as make utility.
-When using cmd.exe configure with:
+Configure under cmd.exe:
- $ configure.bat
+ configure.bat
-When using the MSYS shell configure with:
+Configure under a POSIX shell like MSYS:
- $ ./configure
+ ./configure
+
+Build with nmake:
-When building with nmake run:
+ nmake
+ nmake test
- $ nmake
- $ nmake test
+Build with standard GNU make:
-When building with mingw32-make run:
+ make
+ make test
- $ mingw32-make
- $ mingw32-make test
+Build with mingw32-make:
+
+ mingw32-make
+ mingw32-make test
Configuration
-------------
- ./configure [ options ] [ -- cflags ]
+ [ environment ] ./configure [ options ] [ -- cflags ]
+
+### Options
+
+- `--enable-coverage`
+
+ Enable code coverage. Create HTML pages with coverage data using
+ lcov by running "make coverage".
+
+- `--with-system-cmark`
+
+ The Clownfish compiler is built with a bundled version of libcmark
+ by default. Use this option if you want to link against the system
+ libcmark.
+
+### Environment variables
-Options include
+- `CC`
- --enable-coverage
- Enable code coverage. Create HTML pages with coverage data using
- lcov by running "make coverage".
+ The C compiler.
- --with-system-cmark
- The Clownfish compiler is built with a bundled version of libcmark
- by default. Use this option if you want to link against the system
- libcmark.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/931b4909/runtime/c/INSTALL.md
----------------------------------------------------------------------
diff --git a/runtime/c/INSTALL.md b/runtime/c/INSTALL.md
index 5566b50..21aee4b 100644
--- a/runtime/c/INSTALL.md
+++ b/runtime/c/INSTALL.md
@@ -4,43 +4,72 @@ Build instructions for the Clownfish C library
Building under UNIX and derivatives or Cygwin
---------------------------------------------
- $ ./configure
- $ make
- $ make test
+ ./configure
+ make
+ make test
+ ./install.sh --prefix [ install prefix ]
Building under Windows
----------------------
-You need MSVC or gcc as C compiler and nmake or mingw32-make as make utility.
+You need MSVC or gcc as C compiler and nmake, mingw32-make, or standard
+GNU make as make utility.
-When using cmd.exe configure with:
+Configure under cmd.exe:
- $ configure.bat
+ configure.bat
-When using the MSYS shell configure with:
+Configure under a POSIX shell like MSYS:
- $ ./configure
+ ./configure
-When building with nmake run:
+Build with nmake:
- $ nmake
- $ nmake test
+ nmake
+ nmake test
-When building with mingw32-make run:
+Build with standard GNU make:
- $ mingw32-make
- $ mingw32-make test
+ make
+ make test
+
+Build with mingw32-make:
+
+ mingw32-make
+ mingw32-make test
+
+Install under cmd.exe:
+
+ install.bat --prefix [ install prefix ]
+
+Install under a POSIX shell like MSYS:
+
+ ./install.sh --prefix [ install prefix ]
Configuration
-------------
- ./configure [ options ] [ -- cflags ]
+ [ environment ] ./configure [ options ] [ -- cflags ]
+
+### Options
+
+- `--enable-coverage`
+
+ Enable code coverage. Create HTML pages with coverage data using
+ lcov by running "make coverage".
+
+- `--disable-threads`
+
+ Disable thread support.
+
+### Environment variables
+
+- `CC`
+
+ The C compiler.
-Options include
+- `TARGET_CC`
- --enable-coverage
- Enable code coverage. Create HTML pages with coverage data using
- lcov by running "make coverage".
- --disable-threads
- Disable thread support.
+ The target compiler when cross-compiling. `CC` can be set in addition
+ to specify the host compiler.
[09/11] lucy-clownfish git commit: Add cross-compilation support to
configure script
Posted by nw...@apache.org.
Add cross-compilation support to configure script
If the environment variable TARGET_CC is set, configure uses the value
as target compiler for cross-compiling. For example:
TARGET_CC=x86_64-w64-mingw32-gcc ./configure
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/1612e7a4
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/1612e7a4
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/1612e7a4
Branch: refs/heads/master
Commit: 1612e7a48aae57a02ebcff89abb4bf0a706705d3
Parents: ae56843
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 22:22:11 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 18:13:34 2017 +0100
----------------------------------------------------------------------
runtime/c/configure | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1612e7a4/runtime/c/configure
----------------------------------------------------------------------
diff --git a/runtime/c/configure b/runtime/c/configure
index 9557e66..40b79b6 100755
--- a/runtime/c/configure
+++ b/runtime/c/configure
@@ -15,8 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-(cd ../../compiler/c && ./configure "$@") || exit
-echo
+if [ ! -e ../../compiler/c/Makefile ]; then
+ (cd ../../compiler/c && TARGET_CC= ./configure "$@") || exit
+ echo
+fi
echo Configuring Clownfish runtime...
@@ -41,12 +43,17 @@ if [ -z "$CC" ]; then
fi
fi
-echo "Using C compiler '$CC'"
+if [ -z "$TARGET_CC" ]; then
+ echo "Using C compiler '$CC'"
+ TARGET_CC="$CC"
+else
+ echo "Using target compiler '$TARGET_CC' and host compiler '$CC'"
+fi
command="$CC ../common/charmonizer.c -o charmonizer"
echo $command
$command || exit
echo Running charmonizer
-./charmonizer --cc="$CC" --host=c --enable-c --enable-makefile "$@"
+./charmonizer --cc="$TARGET_CC" --host=c --enable-c --enable-makefile "$@"
[04/11] lucy-clownfish git commit: Adjust Charmonizer code for API
changes and regenerate
Posted by nw...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cadebb91/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 64bf01f..c010f5e 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -268,6 +268,12 @@ chaz_CC_capture_output(const char *source, size_t *output_len);
int
chaz_CC_has_macro(const char *macro);
+/** Return true if preprocessor expression matches predicate. Predicate has
+ * the form "<op> value", e.g. ">= 0x1500".
+ */
+int
+chaz_CC_test_macro(const char *expression, const char *predicate);
+
/** Initialize the compiler environment.
*/
void
@@ -334,16 +340,13 @@ const char*
chaz_CC_obj_ext(void);
int
-chaz_CC_gcc_version_num(void);
-
-const char*
-chaz_CC_gcc_version(void);
+chaz_CC_is_gcc(void);
int
-chaz_CC_msvc_version_num(void);
+chaz_CC_is_msvc(void);
int
-chaz_CC_sun_c_version_num(void);
+chaz_CC_is_sun_c(void);
int
chaz_CC_is_cygwin(void);
@@ -351,6 +354,15 @@ chaz_CC_is_cygwin(void);
int
chaz_CC_is_mingw(void);
+int
+chaz_CC_test_gcc_version(const char *predicate);
+
+int
+chaz_CC_test_msvc_version(const char *predicate);
+
+int
+chaz_CC_test_sun_c_version(const char *predicate);
+
const char*
chaz_CC_link_command(void);
@@ -630,6 +642,14 @@ int
chaz_HeadCheck_contains_member(const char *struct_name, const char *member,
const char *includes);
+/*
+ * Return the size of the type or 0 if can't be determined. Only checks for
+ * sizes 1, 2, 4, 8. If hint != 0, try this size first to speed up the
+ * detection.
+ */
+int
+chaz_HeadCheck_size_of_type(const char *type, const char *includes, int hint);
+
#endif /* H_CHAZ_HEAD_CHECK */
@@ -1095,23 +1115,6 @@ chaz_Probe_init(struct chaz_CLI *cli);
void
chaz_Probe_clean_up(void);
-/* Return an integer version of the GCC version number which is
- * (10000 * __GNU_C__ + 100 * __GNUC_MINOR__ + __GNUC_PATCHLEVEL__).
- */
-int
-chaz_Probe_gcc_version_num(void);
-
-/* If the compiler is GCC (or claims compatibility), return an X.Y.Z string
- * version of the GCC version; otherwise, return NULL.
- */
-const char*
-chaz_Probe_gcc_version(void);
-
-/* Return the integer version of MSVC defined by _MSC_VER
- */
-int
-chaz_Probe_msvc_version_num(void);
-
#endif /* Include guard. */
@@ -1919,8 +1922,16 @@ chaz_CFlags_hide_symbols(chaz_CFlags *flags) {
}
}
else if (flags->style == CHAZ_CFLAGS_STYLE_SUN_C) {
- if (chaz_CC_sun_c_version_num() >= 0x550) {
- /* Sun Studio 8. */
+ static int checked = 0;
+ static int version_ge_550;
+
+ if (!checked) {
+ /* Requires Sun Studio 8. */
+ version_ge_550 = chaz_CC_test_sun_c_version(">= 0x550");
+ checked = 1;
+ }
+
+ if (version_ge_550) {
chaz_CFlags_append(flags, "-xldscope=hidden");
}
}
@@ -2463,11 +2474,6 @@ chaz_CLI_parse(chaz_CLI *self, int argc, const char *argv[]) {
static void
chaz_CC_detect_binary_format(const char *filename);
-/** Return the numeric value of a macro or 0 if it isn't defined.
- */
-static int
-chaz_CC_eval_macro(const char *macro);
-
/* Detect macros which may help to identify some compilers.
*/
static void
@@ -2498,12 +2504,10 @@ static struct {
char gcc_version_str[30];
int binary_format;
int cflags_style;
- int intval___GNUC__;
- int intval___GNUC_MINOR__;
- int intval___GNUC_PATCHLEVEL__;
- int intval__MSC_VER;
- int intval___clang__;
- int intval___SUNPRO_C;
+ int is_gcc;
+ int is_msvc;
+ int is_clang;
+ int is_sun_c;
int is_cygwin;
int is_mingw;
chaz_CFlags *extra_cflags;
@@ -2511,7 +2515,7 @@ static struct {
} chaz_CC = {
NULL, NULL, NULL,
"", "", "", "", "", "",
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
NULL, NULL
};
@@ -2546,6 +2550,9 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
}
compile_succeeded = chaz_CC_compile_exe(CHAZ_CC_TRY_SOURCE_PATH,
CHAZ_CC_TRY_BASENAME, code);
+ if (compile_succeeded) {
+ strcpy(chaz_CC.obj_ext, ".obj");
+ }
}
/* Try POSIX argument style. */
@@ -2556,6 +2563,9 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
}
compile_succeeded = chaz_CC_compile_exe(CHAZ_CC_TRY_SOURCE_PATH,
CHAZ_CC_TRY_BASENAME, code);
+ if (compile_succeeded) {
+ strcpy(chaz_CC.obj_ext, ".o");
+ }
}
if (!compile_succeeded) {
@@ -2566,13 +2576,13 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
chaz_CC_detect_known_compilers();
- if (chaz_CC.intval___GNUC__) {
+ if (chaz_CC_is_gcc()) {
chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_GNU;
}
- else if (chaz_CC.intval__MSC_VER) {
+ else if (chaz_CC_is_msvc()) {
chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_MSVC;
}
- else if (chaz_CC.intval___SUNPRO_C) {
+ else if (chaz_CC_is_sun_c()) {
chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_SUN_C;
}
else {
@@ -2606,7 +2616,7 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
}
strcpy(chaz_CC.exe_ext, ".exe");
strcpy(chaz_CC.shared_lib_ext, ".dll");
- if (chaz_CC.intval___GNUC__) {
+ if (chaz_CC_is_gcc()) {
strcpy(chaz_CC.static_lib_ext, ".a");
strcpy(chaz_CC.import_lib_ext, ".dll.a");
strcpy(chaz_CC.obj_ext, ".o");
@@ -2680,43 +2690,40 @@ chaz_CC_detect_binary_format(const char *filename) {
free(output);
}
-static const char chaz_CC_eval_macro_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( #ifndef %s )
- CHAZ_QUOTE( #error "nope" )
- CHAZ_QUOTE( #endif )
- CHAZ_QUOTE( printf("%%d", %s); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
-static int
-chaz_CC_eval_macro(const char *macro) {
- size_t size = sizeof(chaz_CC_eval_macro_code)
- + (strlen(macro) * 2)
+int
+chaz_CC_has_macro(const char *macro) {
+ static const char template[] =
+ CHAZ_QUOTE( #ifdef %s )
+ CHAZ_QUOTE( int i; )
+ CHAZ_QUOTE( #else )
+ CHAZ_QUOTE( #error "nope" )
+ CHAZ_QUOTE( #endif );
+ size_t size = sizeof(template)
+ + strlen(macro)
+ 20;
char *code = (char*)malloc(size);
int retval = 0;
- char *output;
- size_t len;
- sprintf(code, chaz_CC_eval_macro_code, macro, macro);
- output = chaz_CC_capture_output(code, &len);
- if (output) {
- retval = atoi(output);
- free(output);
- }
+ sprintf(code, template, macro);
+ retval = chaz_CC_test_compile(code);
free(code);
return retval;
}
int
-chaz_CC_has_macro(const char *macro) {
- size_t size = sizeof(chaz_CC_eval_macro_code)
- + (strlen(macro) * 2)
+chaz_CC_test_macro(const char *expression, const char *predicate) {
+ static const char template[] =
+ CHAZ_QUOTE( #if (%s) %s )
+ CHAZ_QUOTE( int i; )
+ CHAZ_QUOTE( #else )
+ CHAZ_QUOTE( #error "nope" )
+ CHAZ_QUOTE( #endif );
+ size_t size = sizeof(template)
+ + strlen(expression)
+ + strlen(predicate)
+ 20;
char *code = (char*)malloc(size);
int retval = 0;
- sprintf(code, chaz_CC_eval_macro_code, macro, macro);
+ sprintf(code, template, expression, predicate);
retval = chaz_CC_test_compile(code);
free(code);
return retval;
@@ -2724,19 +2731,10 @@ chaz_CC_has_macro(const char *macro) {
static void
chaz_CC_detect_known_compilers(void) {
- chaz_CC.intval___GNUC__ = chaz_CC_eval_macro("__GNUC__");
- if (chaz_CC.intval___GNUC__) {
- chaz_CC.intval___GNUC_MINOR__
- = chaz_CC_eval_macro("__GNUC_MINOR__");
- chaz_CC.intval___GNUC_PATCHLEVEL__
- = chaz_CC_eval_macro("__GNUC_PATCHLEVEL__");
- sprintf(chaz_CC.gcc_version_str, "%d.%d.%d", chaz_CC.intval___GNUC__,
- chaz_CC.intval___GNUC_MINOR__,
- chaz_CC.intval___GNUC_PATCHLEVEL__);
- }
- chaz_CC.intval__MSC_VER = chaz_CC_eval_macro("_MSC_VER");
- chaz_CC.intval___clang__ = chaz_CC_eval_macro("__clang__");
- chaz_CC.intval___SUNPRO_C = chaz_CC_eval_macro("__SUNPRO_C");
+ chaz_CC.is_gcc = chaz_CC_has_macro("__GNUC__");
+ chaz_CC.is_msvc = chaz_CC_has_macro("_MSC_VER");
+ chaz_CC.is_clang = chaz_CC_has_macro("__clang__");
+ chaz_CC.is_sun_c = chaz_CC_has_macro("__SUNPRO_C");
}
void
@@ -2782,7 +2780,7 @@ chaz_CC_compile_exe(const char *source_path, const char *exe_name,
system(command);
}
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
/* Zap MSVC junk. */
size_t junk_buf_size = strlen(exe_file) + 4;
char *junk = (char*)malloc(junk_buf_size);
@@ -2970,25 +2968,18 @@ chaz_CC_obj_ext(void) {
}
int
-chaz_CC_gcc_version_num(void) {
- return 10000 * chaz_CC.intval___GNUC__
- + 100 * chaz_CC.intval___GNUC_MINOR__
- + chaz_CC.intval___GNUC_PATCHLEVEL__;
-}
-
-const char*
-chaz_CC_gcc_version(void) {
- return chaz_CC.intval___GNUC__ ? chaz_CC.gcc_version_str : NULL;
+chaz_CC_is_gcc(void) {
+ return chaz_CC.is_gcc;
}
int
-chaz_CC_msvc_version_num(void) {
- return chaz_CC.intval__MSC_VER;
+chaz_CC_is_msvc(void) {
+ return chaz_CC.is_msvc;
}
int
-chaz_CC_sun_c_version_num(void) {
- return chaz_CC.intval___SUNPRO_C;
+chaz_CC_is_sun_c(void) {
+ return chaz_CC.is_sun_c;
}
int
@@ -3001,9 +2992,26 @@ chaz_CC_is_mingw(void) {
return chaz_CC.is_mingw;
}
+int
+chaz_CC_test_gcc_version(const char *predicate) {
+ static const char version[] =
+ "10000 * __GNUC__ + 100 * __GNUC_MINOR__ + __GNUC_PATCHLEVEL__";
+ return chaz_CC_test_macro(version, predicate);
+}
+
+int
+chaz_CC_test_msvc_version(const char *predicate) {
+ return chaz_CC_test_macro("_MSC_VER", predicate);
+}
+
+int
+chaz_CC_test_sun_c_version(const char *predicate) {
+ return chaz_CC_test_macro("__SUNPRO_C", predicate);
+}
+
const char*
chaz_CC_link_command() {
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
return "link";
}
else {
@@ -3013,7 +3021,7 @@ chaz_CC_link_command() {
char*
chaz_CC_format_archiver_command(const char *target, const char *objects) {
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
/* TODO: Write `objects` to a temporary file in order to avoid
* exceeding line length limits. */
char *out = chaz_Util_join("", "/OUT:", target, NULL);
@@ -3029,7 +3037,7 @@ chaz_CC_format_archiver_command(const char *target, const char *objects) {
char*
chaz_CC_format_ranlib_command(const char *target) {
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
return NULL;
}
return chaz_Util_join(" ", "ranlib", target, NULL);
@@ -3039,7 +3047,7 @@ char*
chaz_CC_shared_lib_filename(const char *dir, const char *basename,
const char *version) {
/* Cygwin uses a "cyg" prefix for shared libraries. */
- const char *prefix = chaz_CC_msvc_version_num()
+ const char *prefix = chaz_CC_is_msvc()
? ""
: chaz_CC_is_cygwin() ? "cyg" : "lib";
return chaz_CC_build_lib_filename(dir, prefix, basename, version,
@@ -3049,7 +3057,7 @@ chaz_CC_shared_lib_filename(const char *dir, const char *basename,
char*
chaz_CC_import_lib_filename(const char *dir, const char *basename,
const char *version) {
- const char *prefix = chaz_CC_msvc_version_num() ? "" : "lib";
+ const char *prefix = chaz_CC_is_msvc() ? "" : "lib";
return chaz_CC_build_lib_filename(dir, prefix, basename, version,
chaz_CC.import_lib_ext);
}
@@ -3104,7 +3112,7 @@ chaz_CC_build_lib_filename(const char *dir, const char *prefix,
char*
chaz_CC_static_lib_filename(const char *dir, const char *basename) {
- const char *prefix = chaz_CC_msvc_version_num() ? "" : "lib";
+ const char *prefix = chaz_CC_is_msvc() ? "" : "lib";
if (dir == NULL || strcmp(dir, ".") == 0) {
return chaz_Util_join("", prefix, basename, chaz_CC.static_lib_ext,
@@ -4384,18 +4392,13 @@ chaz_HeadCheck_check_many_headers(const char **header_names) {
int
chaz_HeadCheck_defines_symbol(const char *symbol, const char *includes) {
- /*
- * Casting function pointers to object pointers like 'char*' is a C
- * extension, so for a bullet-proof check, a separate test for functions
- * might be necessary.
- */
static const char defines_code[] =
CHAZ_QUOTE( %s )
CHAZ_QUOTE( int main() { )
CHAZ_QUOTE( #ifdef %s )
CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( #else )
- CHAZ_QUOTE( return *(char*)&%s; )
+ CHAZ_QUOTE( return (int)&%s; )
CHAZ_QUOTE( #endif )
CHAZ_QUOTE( } );
long needed = sizeof(defines_code)
@@ -4430,6 +4433,44 @@ chaz_HeadCheck_contains_member(const char *struct_name, const char *member,
return retval;
}
+int
+chaz_HeadCheck_size_of_type(const char *type, const char *includes, int hint) {
+ static const char sizeof_code[] =
+ CHAZ_QUOTE( #include <stddef.h> )
+ CHAZ_QUOTE( %s )
+ CHAZ_QUOTE( int a[sizeof(%s)==%d?1:-1]; );
+ size_t needed = sizeof(sizeof_code)
+ + strlen(type)
+ + strlen(includes)
+ + 10;
+ char *buf = (char*)malloc(needed);
+ static const int sizes[] = { 4, 8, 2, 1 };
+ int retval = 0;
+ int i;
+
+ for (i = -1; i < (int)(sizeof(sizes) / sizeof(sizes[0])); i++) {
+ int size;
+
+ if (i < 0) {
+ if (hint != 0) { size = hint; }
+ else { continue; }
+ }
+ else {
+ if (sizes[i] != hint) { size = sizes[i]; }
+ else { continue; }
+ }
+
+ sprintf(buf, sizeof_code, includes, type, size);
+ if (chaz_CC_test_compile(buf)) {
+ retval = size;
+ break;
+ }
+ }
+
+ free(buf);
+ return retval;
+}
+
static int
chaz_HeadCheck_compare_headers(const void *vptr_a, const void *vptr_b) {
chaz_CHeader *const *const a = (chaz_CHeader*const*)vptr_a;
@@ -4995,7 +5036,7 @@ S_chaz_MakeFile_finish_shared_lib(chaz_MakeFile *self,
free(filename);
}
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
/* Remove export file. */
char *filename
= chaz_CC_export_filename(binary->target_dir, binary->basename,
@@ -5162,7 +5203,7 @@ chaz_MakeFile_write(chaz_MakeFile *self) {
S_chaz_MakeRule_write(self->distclean, out);
/* Suffix rule for .c files. */
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
fprintf(out, ".c.obj :\n");
fprintf(out, "\t$(CC) /nologo $(CFLAGS) /c $< /Fo$@\n\n");
}
@@ -5179,7 +5220,7 @@ S_chaz_MakeFile_write_binary_rules(chaz_MakeFile *self,
chaz_MakeBinary *binary, FILE *out) {
const char *cflags;
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
chaz_CFlags_append(binary->compile_flags, "/nologo");
chaz_CFlags_append(binary->link_flags, "/nologo");
}
@@ -6450,21 +6491,6 @@ chaz_Probe_clean_up(void) {
if (chaz_Util_verbosity) { printf("Cleanup complete.\n"); }
}
-int
-chaz_Probe_gcc_version_num(void) {
- return chaz_CC_gcc_version_num();
-}
-
-const char*
-chaz_Probe_gcc_version(void) {
- return chaz_CC_gcc_version_num() ? chaz_CC_gcc_version() : NULL;
-}
-
-int
-chaz_Probe_msvc_version_num(void) {
- return chaz_CC_msvc_version_num();
-}
-
/***************************************************************************/
#line 17 "src/Charmonizer/Probe/AtomicOps.c"
@@ -6827,34 +6853,30 @@ chaz_Floats_run(void) {
const char*
chaz_Floats_math_library(void) {
+ /*
+ * The cast to a specific function pointer type is required because
+ * C++ overloads sqrt.
+ */
static const char sqrt_code[] =
CHAZ_QUOTE( #include <math.h> )
- CHAZ_QUOTE( #include <stdio.h> )
CHAZ_QUOTE( typedef double (*sqrt_t)(double); )
- CHAZ_QUOTE( int main(void) { )
- CHAZ_QUOTE( printf("%p\n", (sqrt_t)sqrt); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( int main() { return (int)(sqrt_t)sqrt; } );
chaz_CFlags *temp_cflags = chaz_CC_get_temp_cflags();
- char *output = NULL;
- size_t output_len;
+ int success;
- output = chaz_CC_capture_output(sqrt_code, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_link(sqrt_code)) {
/* Linking against libm not needed. */
- free(output);
return NULL;
}
chaz_CFlags_add_external_lib(temp_cflags, "m");
- output = chaz_CC_capture_output(sqrt_code, &output_len);
+ success = chaz_CC_test_link(sqrt_code);
chaz_CFlags_clear(temp_cflags);
- if (output == NULL) {
+ if (!success) {
chaz_Util_die("Don't know how to use math library.");
}
- free(output);
return "m";
}
@@ -6871,63 +6893,13 @@ chaz_Floats_math_library(void) {
#include <stdio.h>
#include <stdlib.h>
-/* Probe for ISO func macro. */
-static int
-chaz_FuncMacro_probe_iso() {
- static const char iso_func_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%s", __func__); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
- size_t output_len;
- char *output;
- int success = false;
-
- output = chaz_CC_capture_output(iso_func_code, &output_len);
- if (output != NULL && strncmp(output, "main", 4) == 0) {
- success = true;
- }
- free(output);
-
- return success;
-}
-
-static int
-chaz_FuncMacro_probe_gnu() {
- /* Code for verifying GNU func macro. */
- static const char gnu_func_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%s", __FUNCTION__); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
- size_t output_len;
- char *output;
- int success = false;
-
- output = chaz_CC_capture_output(gnu_func_code, &output_len);
- if (output != NULL && strncmp(output, "main", 4) == 0) {
- success = true;
- }
- free(output);
-
- return success;
-}
-
/* Attempt to verify inline keyword. */
-static char*
-chaz_FuncMacro_try_inline(const char *keyword, size_t *output_len) {
- static const char inline_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( static %s int foo() { return 1; } )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%%d", foo()); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+static int
+chaz_FuncMacro_try_inline(const char *keyword) {
+ static const char inline_code[] = "static %s int f() { return 1; }";
char code[sizeof(inline_code) + 30];
sprintf(code, inline_code, keyword);
- return chaz_CC_capture_output(code, output_len);
+ return chaz_CC_test_compile(code);
}
static void
@@ -6943,12 +6915,9 @@ chaz_FuncMacro_probe_inline(void) {
for (i = 0; i < num_inline_options; i++) {
const char *inline_option = inline_options[i];
- size_t output_len;
- char *output = chaz_FuncMacro_try_inline(inline_option, &output_len);
- if (output != NULL) {
+ if (chaz_FuncMacro_try_inline(inline_option)) {
has_inline = true;
chaz_ConfWriter_add_def("INLINE", inline_option);
- free(output);
break;
}
}
@@ -6966,11 +6935,11 @@ chaz_FuncMacro_run(void) {
chaz_ConfWriter_start_module("FuncMacro");
/* Check for func macros. */
- if (chaz_FuncMacro_probe_iso()) {
+ if (chaz_CC_test_compile("const char *f() { return __func__; }")) {
has_funcmac = true;
has_iso_funcmac = true;
}
- if (chaz_FuncMacro_probe_gnu()) {
+ if (chaz_CC_test_compile("const char *f() { return __FUNCTION__; }")) {
has_funcmac = true;
has_gnuc_funcmac = true;
}
@@ -7239,44 +7208,12 @@ chaz_Headers_probe_win(void) {
static int
chaz_Integers_machine_is_big_endian(void);
-static const char chaz_Integers_sizes_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main () { )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(char)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(short)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(int)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(long)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(void*)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(size_t)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
static const char chaz_Integers_stdint_type_code[] =
CHAZ_QUOTE( #include <stdint.h> )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
-static const char chaz_Integers_type64_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( %s i; );
static const char chaz_Integers_literal64_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( #define big 9000000000000000000%s )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( int truncated = (int)big; )
- CHAZ_QUOTE( printf("%%d\n", truncated); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( int f() { return (int)9000000000000000000%s; } );
void
chaz_Integers_run(void) {
@@ -7321,51 +7258,31 @@ chaz_Integers_run(void) {
}
/* Record sizeof() for several common integer types. */
- output = chaz_CC_capture_output(chaz_Integers_sizes_code, &output_len);
- if (output != NULL) {
- char *ptr = output;
- char *end_ptr = output;
-
- sizeof_char = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_short = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_int = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_long = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_ptr = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_size_t = strtol(ptr, &end_ptr, 10);
-
- free(output);
- }
+ sizeof_char = chaz_HeadCheck_size_of_type("char", "", 1);
+ sizeof_short = chaz_HeadCheck_size_of_type("short", "", 2);
+ sizeof_int = chaz_HeadCheck_size_of_type("int", "", 4);
+ sizeof_long = chaz_HeadCheck_size_of_type("long", "", 4);
+ sizeof_ptr = chaz_HeadCheck_size_of_type("void*", "", 4);
+ sizeof_size_t = chaz_HeadCheck_size_of_type("size_t",
+ "#include <stddef.h>", 4);
/* Determine whether long longs are available. */
- sprintf(code_buf, chaz_Integers_type64_code, "long long");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile("long long l;")) {
has_long_long = true;
- sizeof_long_long = strtol(output, NULL, 10);
- free(output);
+ sizeof_long_long = chaz_HeadCheck_size_of_type("long long", "", 8);
}
/* Determine whether the __int64 type is available. */
- sprintf(code_buf, chaz_Integers_type64_code, "__int64");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile("__int64 i;")) {
has___int64 = true;
- sizeof___int64 = strtol(output, NULL, 10);
- free(output);
+ sizeof___int64 = chaz_HeadCheck_size_of_type("__int64", "", 8);
}
/* Determine whether the intptr_t type is available (it's optional in
* C99). */
sprintf(code_buf, chaz_Integers_stdint_type_code, "intptr_t");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
has_intptr_t = true;
- free(output);
}
/* Figure out which integer types are available. */
@@ -7409,34 +7326,26 @@ chaz_Integers_run(void) {
}
else if (has_64) {
sprintf(code_buf, chaz_Integers_literal64_code, "LL");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(i64_t_postfix, "LL");
- free(output);
}
else {
sprintf(code_buf, chaz_Integers_literal64_code, "i64");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(i64_t_postfix, "i64");
- free(output);
}
else {
chaz_Util_die("64-bit types, but no literal syntax found");
}
}
sprintf(code_buf, chaz_Integers_literal64_code, "ULL");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(u64_t_postfix, "ULL");
- free(output);
}
else {
sprintf(code_buf, chaz_Integers_literal64_code, "Ui64");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(u64_t_postfix, "Ui64");
- free(output);
}
else {
chaz_Util_die("64-bit types, but no literal syntax found");
@@ -7444,47 +7353,6 @@ chaz_Integers_run(void) {
}
}
- /* Probe for 64-bit printf format string modifier. */
- if (has_64) {
- int i;
- const char *options[] = {
- "ll",
- "l",
- "L",
- "q", /* Some *BSDs */
- "I64", /* Microsoft */
- NULL,
- };
-
- /* Buffer to hold the code, and its start and end. */
- static const char format_64_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%%%su", 18446744073709551615%s); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
- for (i = 0; options[i] != NULL; i++) {
- /* Try to print 2**64-1, and see if we get it back intact. */
- int success;
- sprintf(code_buf, format_64_code, options[i], u64_t_postfix);
- output = chaz_CC_capture_output(code_buf, &output_len);
- success = output != NULL
- && strcmp(output, "18446744073709551615") == 0;
- free(output);
-
- if (success) {
- break;
- }
- }
-
- if (options[i] == NULL) {
- chaz_Util_die("64-bit types, but no printf modifier found");
- }
-
- strcpy(printf_modifier_64, options[i]);
- }
-
/* Write out some conditional defines. */
if (has_inttypes) {
chaz_ConfWriter_add_def("HAS_INTTYPES_H", NULL);
@@ -7774,7 +7642,48 @@ chaz_Integers_run(void) {
chaz_ConfWriter_add_sys_include("inttypes.h");
}
- {
+ /* Probe for 64-bit printf format string modifier. */
+ if (!has_inttypes && has_64) {
+ int i;
+ const char *options[] = {
+ "ll",
+ "l",
+ "L",
+ "q", /* Some *BSDs */
+ "I64", /* Microsoft */
+ NULL,
+ };
+
+ /* Buffer to hold the code, and its start and end. */
+ static const char format_64_code[] =
+ CHAZ_QUOTE( #include <stdio.h> )
+ CHAZ_QUOTE( int main() { )
+ CHAZ_QUOTE( printf("%%%su", 18446744073709551615%s); )
+ CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( } );
+
+ for (i = 0; options[i] != NULL; i++) {
+ /* Try to print 2**64-1, and see if we get it back intact. */
+ int success;
+ sprintf(code_buf, format_64_code, options[i], u64_t_postfix);
+ output = chaz_CC_capture_output(code_buf, &output_len);
+ success = output != NULL
+ && strcmp(output, "18446744073709551615") == 0;
+ free(output);
+
+ if (success) {
+ break;
+ }
+ }
+
+ if (options[i] == NULL) {
+ chaz_Util_die("64-bit types, but no printf modifier found");
+ }
+
+ strcpy(printf_modifier_64, options[i]);
+ }
+
+ if (!has_inttypes || !has_intptr_t) {
/* We support only the following subset of inttypes.h
* PRId32
* PRIi32
@@ -7811,10 +7720,9 @@ chaz_Integers_run(void) {
int c = ptr[0];
if (has_32) {
- sprintf(scratch, "\"%s%c\"", printf_modifier_32, c);
-
+ macro_name_32[3] = c;
if (!has_inttypes) {
- macro_name_32[3] = c;
+ sprintf(scratch, "\"%s%c\"", printf_modifier_32, c);
chaz_ConfWriter_add_global_def(macro_name_32, scratch);
if (!has_64) {
macro_name_max[3] = c;
@@ -7824,21 +7732,22 @@ chaz_Integers_run(void) {
}
if (!has_intptr_t && sizeof_ptr == 4) {
macro_name_ptr[3] = c;
- chaz_ConfWriter_add_global_def(macro_name_ptr, scratch);
+ chaz_ConfWriter_add_global_def(macro_name_ptr,
+ macro_name_32);
}
}
if (has_64) {
- sprintf(scratch, "\"%s%c\"", printf_modifier_64, c);
-
+ macro_name_64[3] = c;
if (!has_inttypes) {
- macro_name_64[3] = c;
+ sprintf(scratch, "\"%s%c\"", printf_modifier_64, c);
chaz_ConfWriter_add_global_def(macro_name_64, scratch);
macro_name_max[3] = c;
chaz_ConfWriter_add_global_def(macro_name_max, scratch);
}
if (!has_intptr_t && sizeof_ptr == 8) {
macro_name_ptr[3] = c;
- chaz_ConfWriter_add_global_def(macro_name_ptr, scratch);
+ chaz_ConfWriter_add_global_def(macro_name_ptr,
+ macro_name_64);
}
}
}
@@ -7962,12 +7871,7 @@ static int
chaz_LargeFiles_probe_off64(void) {
static const char off64_code[] =
CHAZ_QUOTE( %s )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( int a[sizeof(%s)==8?1:-1]; );
char code_buf[sizeof(off64_code) + 100];
int i;
int success = false;
@@ -7981,8 +7885,6 @@ chaz_LargeFiles_probe_off64(void) {
for (i = 0; i < num_off64_options; i++) {
const char *candidate = off64_options[i];
- char *output;
- size_t output_len;
int has_sys_types_h = chaz_HeadCheck_check_header("sys/types.h");
const char *sys_types_include = has_sys_types_h
? "#include <sys/types.h>"
@@ -7990,15 +7892,10 @@ chaz_LargeFiles_probe_off64(void) {
/* Execute the probe. */
sprintf(code_buf, off64_code, sys_types_include, candidate);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- long sizeof_candidate = strtol(output, NULL, 10);
- free(output);
- if (sizeof_candidate == 8) {
- strcpy(chaz_LargeFiles.off64_type, candidate);
- success = true;
- break;
- }
+ if (chaz_CC_test_compile(code_buf)) {
+ strcpy(chaz_LargeFiles.off64_type, candidate);
+ success = true;
+ break;
}
}
return success;
@@ -8009,20 +7906,13 @@ chaz_LargeFiles_try_stdio64(chaz_LargeFiles_stdio64_combo *combo) {
static const char stdio64_code[] =
CHAZ_QUOTE( %s )
CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( %s pos; )
- CHAZ_QUOTE( FILE *f; )
- CHAZ_QUOTE( f = %s("_charm_stdio64", "w"); )
- CHAZ_QUOTE( if (f == NULL) return -1; )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( pos = %s(stdout); )
- CHAZ_QUOTE( %s(stdout, 0, SEEK_SET); )
- CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( int a[sizeof(%s)==8?1:-1]; )
+ CHAZ_QUOTE( void f() { )
+ CHAZ_QUOTE( FILE *f = %s("_charm_stdio64", "w"); )
+ CHAZ_QUOTE( %s pos = %s(f); )
+ CHAZ_QUOTE( %s(f, 0, SEEK_SET); )
CHAZ_QUOTE( } );
- char *output = NULL;
- size_t output_len;
char code_buf[sizeof(stdio64_code) + 200];
- int success = false;
/* Prepare the source code. */
sprintf(code_buf, stdio64_code, combo->includes,
@@ -8031,20 +7921,7 @@ chaz_LargeFiles_try_stdio64(chaz_LargeFiles_stdio64_combo *combo) {
combo->fseek_command);
/* Verify compilation and that the offset type has 8 bytes. */
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- long size = strtol(output, NULL, 10);
- if (size == 8) {
- success = true;
- }
- free(output);
- }
-
- if (!chaz_Util_remove_and_verify("_charm_stdio64")) {
- chaz_Util_die("Failed to remove '_charm_stdio64'");
- }
-
- return success;
+ return chaz_CC_test_compile(code_buf);
}
static void
@@ -8075,35 +7952,13 @@ chaz_LargeFiles_probe_stdio64(void) {
static int
chaz_LargeFiles_probe_lseek(chaz_LargeFiles_unbuff_combo *combo) {
static const char lseek_code[] =
- CHAZ_QUOTE( %s )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( int fd; )
- CHAZ_QUOTE( fd = open("_charm_lseek", O_WRONLY | O_CREAT, 0666); )
- CHAZ_QUOTE( if (fd == -1) { return -1; } )
- CHAZ_QUOTE( %s(fd, 0, SEEK_SET); )
- CHAZ_QUOTE( printf("%%d", 1); )
- CHAZ_QUOTE( if (close(fd)) { return -1; } )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( %s )
+ CHAZ_QUOTE( void f() { %s(0, 0, SEEK_SET); } );
char code_buf[sizeof(lseek_code) + 100];
- char *output = NULL;
- size_t output_len;
- int success = false;
/* Verify compilation. */
sprintf(code_buf, lseek_code, combo->includes, combo->lseek_command);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- success = true;
- free(output);
- }
-
- if (!chaz_Util_remove_and_verify("_charm_lseek")) {
- chaz_Util_die("Failed to remove '_charm_lseek'");
- }
-
- return success;
+ return chaz_CC_test_compile(code_buf);
}
static int
@@ -8112,28 +7967,15 @@ chaz_LargeFiles_probe_pread64(chaz_LargeFiles_unbuff_combo *combo) {
* fine as long as it compiles. */
static const char pread64_code[] =
CHAZ_QUOTE( %s )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( int fd = 20; )
+ CHAZ_QUOTE( void f() { )
CHAZ_QUOTE( char buf[1]; )
- CHAZ_QUOTE( printf("1"); )
- CHAZ_QUOTE( %s(fd, buf, 1, 1); )
- CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( %s(0, buf, 1, 1); )
CHAZ_QUOTE( } );
char code_buf[sizeof(pread64_code) + 100];
- char *output = NULL;
- size_t output_len;
- int success = false;
/* Verify compilation. */
sprintf(code_buf, pread64_code, combo->includes, combo->pread64_command);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- success = true;
- free(output);
- }
-
- return success;
+ return chaz_CC_test_compile(code_buf);
}
static void
@@ -8141,7 +7983,7 @@ chaz_LargeFiles_probe_unbuff(void) {
static chaz_LargeFiles_unbuff_combo unbuff_combos[] = {
{ "#include <unistd.h>\n#include <fcntl.h>\n", "lseek64", "pread64" },
{ "#include <unistd.h>\n#include <fcntl.h>\n", "lseek", "pread" },
- { "#include <io.h>\n#include <fcntl.h>\n", "_lseeki64", "NO_PREAD64" },
+ { "#include <io.h>\n#include <stdio.h>\n", "_lseeki64", "NO_PREAD64" },
{ NULL, NULL, NULL }
};
int i;
@@ -8219,7 +8061,7 @@ chaz_Memory_probe_alloca(void) {
/* Under GCC, alloca is a builtin that works without including the
* correct header, generating only a warning. To avoid misdetection,
* disable the alloca builtin temporarily. */
- if (chaz_CC_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
chaz_CFlags_append(temp_cflags, "-fno-builtin-alloca");
}
@@ -8312,6 +8154,7 @@ chaz_RegularExpressions_run(void) {
#line 17 "src/Charmonizer/Probe/Strings.c"
/* #include "Charmonizer/Core/Compiler.h" */
/* #include "Charmonizer/Core/ConfWriter.h" */
+/* #include "Charmonizer/Core/HeaderChecker.h" */
/* #include "Charmonizer/Probe/Strings.h" */
#include <stdlib.h>
@@ -8342,23 +8185,6 @@ chaz_Strings_probe_c99_snprintf(void) {
CHAZ_QUOTE( printf("%d", result); )
CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( } );
- static const char detect__scprintf_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( int result; )
- CHAZ_QUOTE( result = _scprintf("%s", "12345"); )
- CHAZ_QUOTE( printf("%d", result); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
- static const char detect__snprintf_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( char buf[6]; )
- CHAZ_QUOTE( int result; )
- CHAZ_QUOTE( result = _snprintf(buf, 6, "%s", "12345"); )
- CHAZ_QUOTE( printf("%d", result); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
char *output = NULL;
size_t output_len;
@@ -8377,15 +8203,11 @@ chaz_Strings_probe_c99_snprintf(void) {
/* Test for _scprintf and _snprintf found in the MSVCRT.
*/
- output = chaz_CC_capture_output(detect__scprintf_code, &output_len);
- if (output != NULL) {
+ if (chaz_HeadCheck_defines_symbol("_scprintf", "#include <stdio.h>")) {
chaz_ConfWriter_add_def("HAS__SCPRINTF", NULL);
- free(output);
}
- output = chaz_CC_capture_output(detect__snprintf_code, &output_len);
- if (output != NULL) {
+ if (chaz_HeadCheck_defines_symbol("_snprintf", "#include <stdio.h>")) {
chaz_ConfWriter_add_def("HAS__SNPRINTF", NULL);
- free(output);
}
}
@@ -8438,7 +8260,7 @@ chaz_SymbolVisibility_run(void) {
if (chaz_CC_test_compile(code_buf)) {
can_control_visibility = true;
chaz_ConfWriter_add_def("EXPORT", export_win);
- if (chaz_CC_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
/*
* Under MinGW, symbols with dllimport storage class aren't
* constant. If a global variable is initialized to such a
@@ -8518,48 +8340,35 @@ chaz_UnusedVars_run(void) {
/* Code for verifying ISO-style variadic macros. */
static const char chaz_VariadicMacros_iso_code[] =
CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( #define ISO_TEST(fmt, ...) \\ )
- " printf(fmt, __VA_ARGS__) \n"
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( ISO_TEST("%d %d", 1, 1); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ "#define ISO_TEST(fmt, ...) printf(fmt, __VA_ARGS__)\n"
+ CHAZ_QUOTE( void f() { ISO_TEST("%d %d", 1, 1); } );
/* Code for verifying GNU-style variadic macros. */
static const char chaz_VariadicMacros_gnuc_code[] =
CHAZ_QUOTE( #include <stdio.h> )
CHAZ_QUOTE( #define GNU_TEST(fmt, args...) printf(fmt, ##args) )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( GNU_TEST("%d %d", 1, 1); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( void f() { GNU_TEST("%d %d", 1, 1); } );
void
chaz_VariadicMacros_run(void) {
- char *output;
- size_t output_len;
int has_varmacros = false;
chaz_ConfWriter_start_module("VariadicMacros");
/* Test for ISO-style variadic macros. */
- output = chaz_CC_capture_output(chaz_VariadicMacros_iso_code, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(chaz_VariadicMacros_iso_code)) {
has_varmacros = true;
chaz_ConfWriter_add_def("HAS_VARIADIC_MACROS", NULL);
chaz_ConfWriter_add_def("HAS_ISO_VARIADIC_MACROS", NULL);
- free(output);
}
/* Test for GNU-style variadic macros. */
- output = chaz_CC_capture_output(chaz_VariadicMacros_gnuc_code, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(chaz_VariadicMacros_gnuc_code)) {
if (has_varmacros == false) {
has_varmacros = true;
chaz_ConfWriter_add_def("HAS_VARIADIC_MACROS", NULL);
}
chaz_ConfWriter_add_def("HAS_GNUC_VARIADIC_MACROS", NULL);
- free(output);
}
chaz_ConfWriter_end_module();
@@ -8757,7 +8566,7 @@ static void
S_add_compiler_flags(struct chaz_CLI *cli) {
chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags();
- if (chaz_Probe_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
if (!chaz_CC_is_mingw()) {
/* When using the MSVCRT, -pedantic complains about %I64 format
* specifiers.
@@ -8779,8 +8588,8 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
chaz_CFlags_append(extra_cflags, "-ffloat-store");
}
}
- else if (chaz_Probe_msvc_version_num()) {
- if (chaz_Probe_msvc_version_num() < 1800) {
+ else if (chaz_CC_is_msvc()) {
+ if (chaz_CC_test_msvc_version("< 1800")) {
/* Compile as C++ under MSVC11 and below. */
chaz_CFlags_append(extra_cflags, "/TP");
}
@@ -8789,11 +8598,6 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
/* Thwart stupid warnings. */
chaz_CFlags_append(extra_cflags, "/D_CRT_SECURE_NO_WARNINGS");
chaz_CFlags_append(extra_cflags, "/D_SCL_SECURE_NO_WARNINGS");
-
- if (chaz_Probe_msvc_version_num() < 1300) {
- /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */
- chaz_CFlags_append(extra_cflags, "/Dfor=\"if(0);else for\"");
- }
}
chaz_CFlags_hide_symbols(extra_cflags);
@@ -8969,7 +8773,7 @@ cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
* library.
*/
compile_flags = chaz_MakeBinary_get_compile_flags(self->lib);
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
/* Python uses /MT. */
chaz_CFlags_append(compile_flags, "/MT");
}
@@ -9023,7 +8827,7 @@ cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
* library.
*/
compile_flags = chaz_MakeBinary_get_compile_flags(self->test_lib);
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
/* Python uses /MT. */
chaz_CFlags_append(compile_flags, "/MT");
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cadebb91/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index 12be6db..a98c031 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -186,7 +186,7 @@ static void
S_add_compiler_flags(struct chaz_CLI *cli) {
chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags();
- if (chaz_Probe_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
if (!chaz_CC_is_mingw()) {
/* When using the MSVCRT, -pedantic complains about %I64 format
* specifiers.
@@ -208,8 +208,8 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
chaz_CFlags_append(extra_cflags, "-ffloat-store");
}
}
- else if (chaz_Probe_msvc_version_num()) {
- if (chaz_Probe_msvc_version_num() < 1800) {
+ else if (chaz_CC_is_msvc()) {
+ if (chaz_CC_test_msvc_version("< 1800")) {
/* Compile as C++ under MSVC11 and below. */
chaz_CFlags_append(extra_cflags, "/TP");
}
@@ -218,11 +218,6 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
/* Thwart stupid warnings. */
chaz_CFlags_append(extra_cflags, "/D_CRT_SECURE_NO_WARNINGS");
chaz_CFlags_append(extra_cflags, "/D_SCL_SECURE_NO_WARNINGS");
-
- if (chaz_Probe_msvc_version_num() < 1300) {
- /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */
- chaz_CFlags_append(extra_cflags, "/Dfor=\"if(0);else for\"");
- }
}
chaz_CFlags_hide_symbols(extra_cflags);
@@ -398,7 +393,7 @@ cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
* library.
*/
compile_flags = chaz_MakeBinary_get_compile_flags(self->lib);
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
/* Python uses /MT. */
chaz_CFlags_append(compile_flags, "/MT");
}
@@ -452,7 +447,7 @@ cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
* library.
*/
compile_flags = chaz_MakeBinary_get_compile_flags(self->test_lib);
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
/* Python uses /MT. */
chaz_CFlags_append(compile_flags, "/MT");
}
[08/11] lucy-clownfish git commit: Update charmonizer code
Posted by nw...@apache.org.
Update charmonizer code
- CC is now set automatically.
- Simplify runtime valgrind target.
- Remove unused variables.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/c9514ada
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/c9514ada
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/c9514ada
Branch: refs/heads/master
Commit: c9514ada66321ba8f285a9de920a92224a3b15cb
Parents: 931b490
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 23:36:14 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 18:13:34 2017 +0100
----------------------------------------------------------------------
compiler/common/charmonizer.c | 15 +++++++-------
compiler/common/charmonizer.main | 2 --
runtime/common/charmonizer.c | 37 +++++++++++------------------------
runtime/common/charmonizer.main | 24 ++++-------------------
4 files changed, 22 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c9514ada/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index 08afcf3..d45c84a 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -4923,7 +4923,6 @@ chaz_MakeFile_add_exe(chaz_MakeFile *self, const char *dir,
void
S_chaz_MakeFile_finish_exe(chaz_MakeFile *self, chaz_MakeBinary *binary) {
- const char *link = chaz_CC_link_command();
const char *link_flags_string;
char *command;
@@ -4938,8 +4937,8 @@ S_chaz_MakeFile_finish_exe(chaz_MakeFile *self, chaz_MakeBinary *binary) {
/* Objects in dollar var must come before flags since flags may
* contain libraries.
*/
- command = chaz_Util_join(" ", link, binary->dollar_var, link_flags_string,
- NULL);
+ command = chaz_Util_join(" ", "$(LINK)", binary->dollar_var,
+ link_flags_string, NULL);
chaz_MakeRule_add_command(binary->rule, command);
free(command);
}
@@ -4975,7 +4974,6 @@ chaz_MakeFile_add_shared_lib(chaz_MakeFile *self, const char *dir,
void
S_chaz_MakeFile_finish_shared_lib(chaz_MakeFile *self,
chaz_MakeBinary *binary) {
- const char *link = chaz_CC_link_command();
const char *link_flags_string;
int binfmt = chaz_CC_binary_format();
char *no_v_name
@@ -5000,8 +4998,8 @@ S_chaz_MakeFile_finish_shared_lib(chaz_MakeFile *self,
chaz_CFlags_set_link_output(binary->link_flags, "$@");
link_flags_string = chaz_CFlags_get_string(binary->link_flags);
- command = chaz_Util_join(" ", link, binary->dollar_var, link_flags_string,
- NULL);
+ command = chaz_Util_join(" ", "$(LINK)", binary->dollar_var,
+ link_flags_string, NULL);
chaz_MakeRule_add_command(binary->rule, command);
free(command);
@@ -5185,6 +5183,9 @@ chaz_MakeFile_write(chaz_MakeFile *self) {
fprintf(out, "SHELL = cmd\n");
}
+ fprintf(out, "CC = %s\n", chaz_CC_get_cc());
+ fprintf(out, "LINK = %s\n", chaz_CC_link_command());
+
for (i = 0; self->vars[i]; i++) {
chaz_MakeVar *var = self->vars[i];
fprintf(out, "%s = %s\n", var->name, var->value);
@@ -8549,8 +8550,6 @@ S_write_makefile(struct chaz_CLI *cli) {
/* C compiler */
- chaz_MakeFile_add_var(makefile, "CC", chaz_CC_get_cc());
-
makefile_cflags = chaz_CC_new_cflags();
chaz_CFlags_enable_optimization(makefile_cflags);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c9514ada/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main
index 7165cf0..47ad302 100644
--- a/compiler/common/charmonizer.main
+++ b/compiler/common/charmonizer.main
@@ -169,8 +169,6 @@ S_write_makefile(struct chaz_CLI *cli) {
/* C compiler */
- chaz_MakeFile_add_var(makefile, "CC", chaz_CC_get_cc());
-
makefile_cflags = chaz_CC_new_cflags();
chaz_CFlags_enable_optimization(makefile_cflags);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c9514ada/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index c9eceb2..e989f0a 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -4923,7 +4923,6 @@ chaz_MakeFile_add_exe(chaz_MakeFile *self, const char *dir,
void
S_chaz_MakeFile_finish_exe(chaz_MakeFile *self, chaz_MakeBinary *binary) {
- const char *link = chaz_CC_link_command();
const char *link_flags_string;
char *command;
@@ -4938,8 +4937,8 @@ S_chaz_MakeFile_finish_exe(chaz_MakeFile *self, chaz_MakeBinary *binary) {
/* Objects in dollar var must come before flags since flags may
* contain libraries.
*/
- command = chaz_Util_join(" ", link, binary->dollar_var, link_flags_string,
- NULL);
+ command = chaz_Util_join(" ", "$(LINK)", binary->dollar_var,
+ link_flags_string, NULL);
chaz_MakeRule_add_command(binary->rule, command);
free(command);
}
@@ -4975,7 +4974,6 @@ chaz_MakeFile_add_shared_lib(chaz_MakeFile *self, const char *dir,
void
S_chaz_MakeFile_finish_shared_lib(chaz_MakeFile *self,
chaz_MakeBinary *binary) {
- const char *link = chaz_CC_link_command();
const char *link_flags_string;
int binfmt = chaz_CC_binary_format();
char *no_v_name
@@ -5000,8 +4998,8 @@ S_chaz_MakeFile_finish_shared_lib(chaz_MakeFile *self,
chaz_CFlags_set_link_output(binary->link_flags, "$@");
link_flags_string = chaz_CFlags_get_string(binary->link_flags);
- command = chaz_Util_join(" ", link, binary->dollar_var, link_flags_string,
- NULL);
+ command = chaz_Util_join(" ", "$(LINK)", binary->dollar_var,
+ link_flags_string, NULL);
chaz_MakeRule_add_command(binary->rule, command);
free(command);
@@ -5185,6 +5183,9 @@ chaz_MakeFile_write(chaz_MakeFile *self) {
fprintf(out, "SHELL = cmd\n");
}
+ fprintf(out, "CC = %s\n", chaz_CC_get_cc());
+ fprintf(out, "LINK = %s\n", chaz_CC_link_command());
+
for (i = 0; self->vars[i]; i++) {
chaz_MakeVar *var = self->vars[i];
fprintf(out, "%s = %s\n", var->name, var->value);
@@ -8690,14 +8691,12 @@ cfish_MakeFile_destroy(cfish_MakeFile *self) {
static void
cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
- const char *dir_sep = chaz_OS_dir_sep();
- const char *host = chaz_CLI_strval(self->cli, "host");
+ const char *host = chaz_CLI_strval(self->cli, "host");
const char *lib_objs = NULL;
const char *test_lib_objs = NULL;
chaz_MakeVar *var;
- chaz_MakeRule *rule;
chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags();
chaz_CFlags *makefile_cflags;
@@ -8712,8 +8711,6 @@ cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
/* C compiler */
- chaz_MakeFile_add_var(self->makefile, "CC", chaz_CC_get_cc());
-
makefile_cflags = chaz_CC_new_cflags();
chaz_CFlags_enable_optimization(makefile_cflags);
@@ -8962,23 +8959,11 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
chaz_MakeRule_add_command(rule, "$(TEST_CFISH_EXE)");
if (chaz_OS_shell_type() == CHAZ_OS_POSIX) {
- const char *valgrind_command;
-
rule = chaz_MakeFile_add_rule(self->makefile, "valgrind",
"$(TEST_CFISH_EXE)");
- if (chaz_CC_binary_format() == CHAZ_CC_BINFMT_ELF) {
- valgrind_command = "LD_LIBRARY_PATH=. CLOWNFISH_VALGRIND=1"
- " valgrind"
- " --leak-check=full"
- " $(TEST_CFISH_EXE)";
- }
- else {
- valgrind_command = "CLOWNFISH_VALGRIND=1"
- " valgrind"
- " --leak-check=full"
- " $(TEST_CFISH_EXE)";
- }
- chaz_MakeRule_add_command(rule, valgrind_command);
+ chaz_MakeRule_add_command(rule,
+ "valgrind --leak-check=full"
+ " $(TEST_CFISH_EXE)");
}
if (chaz_CLI_defined(self->cli, "enable-coverage")) {
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c9514ada/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index e8a21fd..22b8f01 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -310,14 +310,12 @@ cfish_MakeFile_destroy(cfish_MakeFile *self) {
static void
cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
- const char *dir_sep = chaz_OS_dir_sep();
- const char *host = chaz_CLI_strval(self->cli, "host");
+ const char *host = chaz_CLI_strval(self->cli, "host");
const char *lib_objs = NULL;
const char *test_lib_objs = NULL;
chaz_MakeVar *var;
- chaz_MakeRule *rule;
chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags();
chaz_CFlags *makefile_cflags;
@@ -332,8 +330,6 @@ cfish_MakeFile_write(cfish_MakeFile *self, chaz_CFlags *extra_link_flags) {
/* C compiler */
- chaz_MakeFile_add_var(self->makefile, "CC", chaz_CC_get_cc());
-
makefile_cflags = chaz_CC_new_cflags();
chaz_CFlags_enable_optimization(makefile_cflags);
@@ -582,23 +578,11 @@ cfish_MakeFile_write_c_test_rules(cfish_MakeFile *self) {
chaz_MakeRule_add_command(rule, "$(TEST_CFISH_EXE)");
if (chaz_OS_shell_type() == CHAZ_OS_POSIX) {
- const char *valgrind_command;
-
rule = chaz_MakeFile_add_rule(self->makefile, "valgrind",
"$(TEST_CFISH_EXE)");
- if (chaz_CC_binary_format() == CHAZ_CC_BINFMT_ELF) {
- valgrind_command = "LD_LIBRARY_PATH=. CLOWNFISH_VALGRIND=1"
- " valgrind"
- " --leak-check=full"
- " $(TEST_CFISH_EXE)";
- }
- else {
- valgrind_command = "CLOWNFISH_VALGRIND=1"
- " valgrind"
- " --leak-check=full"
- " $(TEST_CFISH_EXE)";
- }
- chaz_MakeRule_add_command(rule, valgrind_command);
+ chaz_MakeRule_add_command(rule,
+ "valgrind --leak-check=full"
+ " $(TEST_CFISH_EXE)");
}
if (chaz_CLI_defined(self->cli, "enable-coverage")) {
[03/11] lucy-clownfish git commit: Remove CFISH endian macros
Posted by nw...@apache.org.
Remove CFISH endian macros
Lucy's NumberUtils.cfh doesn't need them anymore.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/15e683bf
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/15e683bf
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/15e683bf
Branch: refs/heads/master
Commit: 15e683bfcaaeb29a75451e5f06377971910f260d
Parents: 2b8147d
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 14:55:02 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 15:10:54 2017 +0100
----------------------------------------------------------------------
compiler/src/CFCBindCore.c | 8 --------
1 file changed, 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/15e683bf/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index 0bca5e6..5920550 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -576,14 +576,6 @@ static char*
S_charmony_feature_defines() {
char *defines = CFCUtil_strdup("");
-#ifdef CHY_LITTLE_END
- // Needed by NumberUtils.cfh.
- defines = CFCUtil_cat(defines, "#define CFISH_LITTLE_END\n", NULL);
-#endif
-#ifdef CHY_BIG_END
- // Needed by NumberUtils.cfh.
- defines = CFCUtil_cat(defines, "#define CFISH_BIG_END\n", NULL);
-#endif
#ifdef CHY_HAS_FUNC_MACRO
// Needed by Err.cfh.
defines = CFCUtil_cat(defines, "#define CFISH_HAS_FUNC_MACRO\n", NULL);
[07/11] lucy-clownfish git commit: Add --charmonic option to cfc
Posted by nw...@apache.org.
Add --charmonic option to cfc
With --charmonic, cfc makes cfish_platform.h include charmony.h and
use its CHY_* macros for platform-specific settings. This is needed
when cross-compiling.
Otherwise, the CHY_* values from the CFC configuration are used.
This breaks cross compilation but allows to build Clownfish projects
without Charmonizer.
Run cfc with --charmonic when building the runtime.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/ae56843f
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/ae56843f
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/ae56843f
Branch: refs/heads/master
Commit: ae56843f1f0907e4376aa380df646b79d04d210b
Parents: cadebb9
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 22:15:05 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 18:13:34 2017 +0100
----------------------------------------------------------------------
compiler/c/cfc.c | 7 +-
compiler/go/cfc/cfc.go | 3 +-
compiler/perl/lib/Clownfish/CFC.xs | 2 +-
compiler/python/src/cfc/_cfc.c | 2 +-
compiler/ruby/ext/Clownfish/CFC.c | 3 +-
compiler/src/CFCBindCore.c | 271 +++++++++++++++-----------------
compiler/src/CFCBindCore.h | 6 +-
runtime/common/charmonizer.c | 5 +-
runtime/common/charmonizer.main | 5 +-
9 files changed, 148 insertions(+), 156 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/compiler/c/cfc.c
----------------------------------------------------------------------
diff --git a/compiler/c/cfc.c b/compiler/c/cfc.c
index d329708..21bd989 100644
--- a/compiler/c/cfc.c
+++ b/compiler/c/cfc.c
@@ -45,6 +45,7 @@ struct CFCArgs {
char **parcels;
char *header_filename;
char *footer_filename;
+ int charmonic;
};
typedef struct CFCArgs CFCArgs;
@@ -109,6 +110,10 @@ S_parse_arguments(int argc, char **argv, CFCArgs *args) {
for (i = 1; i < argc; i++) {
char *arg = argv[i];
+ if (strcmp(arg, "--charmonic") == 0) {
+ args->charmonic = 1;
+ continue;
+ }
if (S_parse_string_argument(arg, "--dest", &args->dest)) {
continue;
}
@@ -238,7 +243,7 @@ main(int argc, char **argv) {
footer = CFCUtil_strdup("");
}
- core_binding = CFCBindCore_new(hierarchy, header, footer);
+ core_binding = CFCBindCore_new(hierarchy, header, footer, args.charmonic);
CFCBindCore_write_all_modified(core_binding, 0);
c_binding = CFCC_new(hierarchy, header, footer);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/compiler/go/cfc/cfc.go
----------------------------------------------------------------------
diff --git a/compiler/go/cfc/cfc.go b/compiler/go/cfc/cfc.go
index d24f957..2ea823e 100644
--- a/compiler/go/cfc/cfc.go
+++ b/compiler/go/cfc/cfc.go
@@ -146,7 +146,8 @@ func NewBindCore(hierarchy *Hierarchy, header string, footer string) *BindCore {
defer C.free(unsafe.Pointer(headerCString))
defer C.free(unsafe.Pointer(footerCString))
obj := &BindCore{
- C.CFCBindCore_new(hierarchy.ref, headerCString, footerCString),
+ C.CFCBindCore_new(hierarchy.ref, headerCString, footerCString,
+ 0),
}
runtime.SetFinalizer(obj, (*BindCore).finalize)
return obj
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs b/compiler/perl/lib/Clownfish/CFC.xs
index 8caa0b7..c5ee7dd 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -1871,7 +1871,7 @@ _new(hierarchy, header, footer)
const char *header;
const char *footer;
CODE:
- CFCBindCore *self = CFCBindCore_new(hierarchy, header, footer);
+ CFCBindCore *self = CFCBindCore_new(hierarchy, header, footer, 0);
RETVAL = S_cfcbase_to_perlref(self);
CFCBase_decref((CFCBase*)self);
OUTPUT: RETVAL
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/compiler/python/src/cfc/_cfc.c
----------------------------------------------------------------------
diff --git a/compiler/python/src/cfc/_cfc.c b/compiler/python/src/cfc/_cfc.c
index e7e8f3f..30968b3 100644
--- a/compiler/python/src/cfc/_cfc.c
+++ b/compiler/python/src/cfc/_cfc.c
@@ -306,7 +306,7 @@ S_CFCBindCore_new(PyTypeObject *type, PyObject *args,
&footer);
if (!result) { return NULL; }
CFCHierarchy *hierarchy = S_to_Hierarchy(hierarchy_wrapped);
- CFCBindCore *obj = CFCBindCore_new(hierarchy, header, footer);
+ CFCBindCore *obj = CFCBindCore_new(hierarchy, header, footer, 0);
return S_wrap_cfcbase(BindCore_pytype, obj);
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/compiler/ruby/ext/Clownfish/CFC.c
----------------------------------------------------------------------
diff --git a/compiler/ruby/ext/Clownfish/CFC.c b/compiler/ruby/ext/Clownfish/CFC.c
index 3ade99e..85d803e 100644
--- a/compiler/ruby/ext/Clownfish/CFC.c
+++ b/compiler/ruby/ext/Clownfish/CFC.c
@@ -44,7 +44,8 @@ S_CFC_Binding_Core_Init(VALUE self_rb, VALUE params) {
Data_Get_Struct(hierarchy, CFCHierarchy, hierarchy_obj);
Data_Get_Struct(self_rb, CFCBindCore, self);
- self = CFCBindCore_new(hierarchy_obj, StringValuePtr(header), StringValuePtr(footer));
+ self = CFCBindCore_new(hierarchy_obj, StringValuePtr(header),
+ StringValuePtr(footer), 0);
DATA_PTR(self_rb) = self;
return self_rb;
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index 5920550..4bd943e 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -40,6 +40,7 @@ struct CFCBindCore {
CFCHierarchy *hierarchy;
char *c_header;
char *c_footer;
+ int charmonic;
};
/* Write the "parcel.h" header file, which contains common symbols needed by
@@ -59,21 +60,6 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel);
static void
S_write_platform_h(CFCBindCore *self);
-static char*
-S_charmony_feature_defines();
-
-static char*
-S_charmony_string_defines();
-
-static char*
-S_charmony_stdbool_defines();
-
-static char*
-S_charmony_stdint_defines();
-
-static char*
-S_charmony_alloca_defines();
-
static void
S_write_host_data_json(CFCBindCore *self, CFCParcel *parcel,
const char *dest_dir, const char *host_lang);
@@ -86,20 +72,21 @@ static const CFCMeta CFCBINDCORE_META = {
CFCBindCore*
CFCBindCore_new(CFCHierarchy *hierarchy, const char *header,
- const char *footer) {
+ const char *footer, int charmonic) {
CFCBindCore *self = (CFCBindCore*)CFCBase_allocate(&CFCBINDCORE_META);
- return CFCBindCore_init(self, hierarchy, header, footer);
+ return CFCBindCore_init(self, hierarchy, header, footer, charmonic);
}
CFCBindCore*
CFCBindCore_init(CFCBindCore *self, CFCHierarchy *hierarchy,
- const char *header, const char *footer) {
+ const char *header, const char *footer, int charmonic) {
CFCUTIL_NULL_CHECK(hierarchy);
CFCUTIL_NULL_CHECK(header);
CFCUTIL_NULL_CHECK(footer);
self->hierarchy = (CFCHierarchy*)CFCBase_incref((CFCBase*)hierarchy);
self->c_header = CFCUtil_make_c_comment(header);
self->c_footer = CFCUtil_make_c_comment(footer);
+ self->charmonic = charmonic;
return self;
}
@@ -519,11 +506,126 @@ S_write_parcel_c(CFCBindCore *self, CFCParcel *parcel) {
*/
static void
S_write_platform_h(CFCBindCore *self) {
- char *feature_defs = S_charmony_feature_defines();
- char *string_defs = S_charmony_string_defines();
- char *stdbool_defs = S_charmony_stdbool_defines();
- char *stdint_defs = S_charmony_stdint_defines();
- char *alloca_defs = S_charmony_alloca_defines();
+ const char *content;
+
+ if (self->charmonic) {
+ content =
+ "#include \"charmony.h\"\n"
+ "\n"
+ "#ifdef CHY_HAS_FUNC_MACRO\n"
+ " #define CFISH_HAS_FUNC_MACRO\n"
+ "#endif\n"
+ "#ifdef CHY_HAS_VARIADIC_MACROS\n"
+ " #define CFISH_HAS_VARIADIC_MACROS\n"
+ "#endif\n"
+ "#ifdef CHY_HAS_ISO_VARIADIC_MACROS\n"
+ " #define CFISH_HAS_ISO_VARIADIC_MACROS\n"
+ "#endif\n"
+ "#ifdef CHY_HAS_GNUC_VARIADIC_MACROS\n"
+ " #define CFISH_HAS_GNUC_VARIADIC_MACROS\n"
+ "#endif\n"
+ "\n"
+ "#define CFISH_INLINE CHY_INLINE\n"
+ "#define CFISH_EXPORT CHY_EXPORT\n"
+ "#define CFISH_IMPORT CHY_IMPORT\n"
+ "#define CFISH_FUNC_MACRO CHY_FUNC_MACRO\n"
+ "\n"
+ "#ifdef CHY_HAS_STDBOOL_H\n"
+ " #include <stdbool.h>\n"
+ "#else\n"
+ " #if (!defined(__cplusplus) && !defined(CFISH_HAS_STDBOOL))\n"
+ " typedef int bool;\n"
+ " #ifndef true\n"
+ " #define true 1\n"
+ " #endif\n"
+ " #ifndef false\n"
+ " #define false 0\n"
+ " #endif\n"
+ " #endif\n"
+ "#endif\n"
+ "\n"
+ "#ifdef CHY_HAS_STDINT_H\n"
+ " #include <stdint.h>\n"
+ "#else\n"
+ " #ifndef CFISH_HAS_STDINT\n"
+ " typedef CHY_INT8_T int8_t;\n"
+ " typedef CHY_UINT8_T uint8_t;\n"
+ " typedef CHY_INT16_T int16_t;\n"
+ " typedef CHY_UINT16_T uint16_t;\n"
+ " typedef CHY_INT32_T int32_t;\n"
+ " typedef CHY_UINT32_T uint32_t;\n"
+ " typedef CHY_INT64_T int64_t;\n"
+ " typedef CHY_UINT64_T uint64_t;\n"
+ " #endif\n"
+ "#endif\n"
+ "\n"
+ "#if defined(CHY_ALLOCA_IN_STDLIB_H)\n"
+ " #include <stdlib.h>\n"
+ "#elif defined(CHY_HAS_ALLOCA_H)\n"
+ " #include <alloca.h>\n"
+ "#elif defined(CHY_HAS_MALLOC_H)\n"
+ " #include <malloc.h>\n"
+ "#endif\n"
+ "#define cfish_alloca chy_alloca\n";
+ }
+ else {
+ // Use the same values CFC was compiled with.
+ content =
+#ifdef CHY_HAS_FUNC_MACRO
+ "#define CFISH_HAS_FUNC_MACRO\n"
+#endif
+#ifdef CHY_HAS_VARIADIC_MACROS
+ "#define CFISH_HAS_VARIADIC_MACROS\n"
+#endif
+#ifdef CHY_HAS_ISO_VARIADIC_MACROS
+ "#define CFISH_HAS_ISO_VARIADIC_MACROS\n"
+#endif
+#ifdef CHY_HAS_GNUC_VARIADIC_MACROS
+ "#define CFISH_HAS_GNUC_VARIADIC_MACROS\n"
+#endif
+ "#define CFISH_INLINE " XSTRING(CHY_INLINE) "\n"
+ "#define CFISH_EXPORT " XSTRING(CHY_EXPORT) "\n"
+ "#define CFISH_IMPORT " XSTRING(CHY_IMPORT) "\n"
+ "#define CFISH_FUNC_MACRO " XSTRING(CHY_FUNC_MACRO) "\n"
+ "\n"
+#ifdef CHY_HAS_STDBOOL_H
+ "#include <stdbool.h>\n"
+#else
+ "#if (!defined(__cplusplus) && !defined(CFISH_HAS_STDBOOL))\n"
+ " typedef int bool;\n"
+ " #ifndef true\n"
+ " #define true 1\n"
+ " #endif\n"
+ " #ifndef false\n"
+ " #define false 0\n"
+ " #endif\n"
+ "#endif\n"
+#endif
+ "\n"
+#ifdef CHY_HAS_STDINT_H
+ "#include <stdint.h>\n"
+#else
+ "#ifndef CFISH_HAS_STDINT\n"
+ " typedef " XSTRING(CHY_INT8_T) " int8_t;\n"
+ " typedef " XSTRING(CHY_UINT8_T) " uint8_t;\n"
+ " typedef " XSTRING(CHY_INT16_T) " int16_t;\n"
+ " typedef " XSTRING(CHY_UINT16_T) " uint16_t;\n"
+ " typedef " XSTRING(CHY_INT32_T) " int32_t;\n"
+ " typedef " XSTRING(CHY_UINT32_T) " uint32_t;\n"
+ " typedef " XSTRING(CHY_INT64_T) " int64_t;\n"
+ " typedef " XSTRING(CHY_UINT64_T) " uint64_t;\n"
+ "#endif\n"
+#endif
+ "\n"
+#if defined(CHY_ALLOCA_IN_STDLIB_H)
+ "#include <stdlib.h>\n"
+#elif defined(CHY_HAS_ALLOCA_H)
+ "#include <alloca.h>\n"
+#elif defined(CHY_HAS_MALLOC_H)
+ "#include <malloc.h>\n"
+#endif
+ "#define cfish_alloca " XSTRING(chy_alloca) "\n";
+ }
const char pattern[] =
"%s"
@@ -536,12 +638,6 @@ S_write_platform_h(CFCBindCore *self) {
"#endif\n"
"\n"
"%s"
- "%s"
- "\n"
- "%s"
- "%s"
- "\n"
- "%s"
"\n"
"#ifdef __cplusplus\n"
"}\n"
@@ -552,9 +648,7 @@ S_write_platform_h(CFCBindCore *self) {
"%s"
"\n";
char *file_content
- = CFCUtil_sprintf(pattern, self->c_header, feature_defs, string_defs,
- stdbool_defs, stdint_defs, alloca_defs,
- self->c_footer);
+ = CFCUtil_sprintf(pattern, self->c_header, content, self->c_footer);
// Unlink then write file.
const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy);
@@ -563,119 +657,6 @@ S_write_platform_h(CFCBindCore *self) {
remove(filepath);
CFCUtil_write_file(filepath, file_content, strlen(file_content));
FREEMEM(filepath);
-
- FREEMEM(feature_defs);
- FREEMEM(string_defs);
- FREEMEM(stdbool_defs);
- FREEMEM(stdint_defs);
- FREEMEM(alloca_defs);
- FREEMEM(file_content);
-}
-
-static char*
-S_charmony_feature_defines() {
- char *defines = CFCUtil_strdup("");
-
-#ifdef CHY_HAS_FUNC_MACRO
- // Needed by Err.cfh.
- defines = CFCUtil_cat(defines, "#define CFISH_HAS_FUNC_MACRO\n", NULL);
-#endif
-#ifdef CHY_HAS_VARIADIC_MACROS
- // Needed by Err.cfh.
- defines = CFCUtil_cat(defines, "#define CFISH_HAS_VARIADIC_MACROS\n",
- NULL);
-#endif
-#ifdef CHY_HAS_ISO_VARIADIC_MACROS
- // Needed by Err.cfh.
- defines = CFCUtil_cat(defines, "#define CFISH_HAS_ISO_VARIADIC_MACROS\n",
- NULL);
-#endif
-#ifdef CHY_HAS_GNUC_VARIADIC_MACROS
- // Needed by Err.cfh.
- defines = CFCUtil_cat(defines, "#define CFISH_HAS_GNUC_VARIADIC_MACROS\n",
- NULL);
-#endif
-
- return defines;
-}
-
-static char*
-S_charmony_string_defines() {
- const char *pattern =
- "#define CFISH_INLINE %s\n"
- "#define CFISH_EXPORT %s\n"
- "#define CFISH_IMPORT %s\n"
- "#define CFISH_FUNC_MACRO %s\n";
- char *defines
- = CFCUtil_sprintf(pattern,
- XSTRING(CHY_INLINE),
- XSTRING(CHY_EXPORT),
- XSTRING(CHY_IMPORT),
- XSTRING(CHY_FUNC_MACRO));
-
- return defines;
-}
-
-static char*
-S_charmony_stdbool_defines() {
-#ifdef CHY_HAS_STDBOOL_H
- const char *defines = "#include <stdbool.h>\n";
-#else
- const char *defines =
- "#if (!defined(__cplusplus) && !defined(CFISH_HAS_STDBOOL))\n"
- " typedef int bool;\n"
- " #ifndef true\n"
- " #define true 1\n"
- " #endif\n"
- " #ifndef false\n"
- " #define false 0\n"
- " #endif\n"
- "#endif\n";
-#endif
-
- return CFCUtil_strdup(defines);
-}
-
-static char*
-S_charmony_stdint_defines() {
-#ifdef CHY_HAS_STDINT_H
- return CFCUtil_strdup("#include <stdint.h>\n");
-#else
- const char *pattern =
- "#ifndef CFISH_HAS_STDINT\n"
- " typedef %s int8_t;\n"
- " typedef %s uint8_t;\n"
- " typedef %s int16_t;\n"
- " typedef %s uint16_t;\n"
- " typedef %s int32_t;\n"
- " typedef %s uint32_t;\n"
- " typedef %s int64_t;\n"
- " typedef %s uint64_t;\n"
- "#endif\n";
- return CFCUtil_sprintf(pattern,
- XSTRING(CHY_INT8_T), XSTRING(CHY_UINT8_T),
- XSTRING(CHY_INT16_T), XSTRING(CHY_UINT16_T),
- XSTRING(CHY_INT32_T), XSTRING(CHY_UINT32_T),
- XSTRING(CHY_INT64_T), XSTRING(CHY_UINT64_T));
-#endif
-}
-
-static char*
-S_charmony_alloca_defines() {
- char *defines = CFCUtil_strdup("");
-
-#if defined(CHY_HAS_ALLOCA_H)
- defines = CFCUtil_cat(defines, "#include <alloca.h>\n", NULL);
-#elif defined(CHY_HAS_MALLOC_H)
- defines = CFCUtil_cat(defines, "#include <malloc.h>\n", NULL);
-#elif defined(CHY_ALLOCA_IN_STDLIB_H)
- defines = CFCUtil_cat(defines, "#include <stdlib.h>\n", NULL);
-#endif
-
- defines = CFCUtil_cat(defines, "#define cfish_alloca ",
- XSTRING(chy_alloca), "\n", NULL);
-
- return defines;
}
void
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/compiler/src/CFCBindCore.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.h b/compiler/src/CFCBindCore.h
index aa40bb2..ff81594 100644
--- a/compiler/src/CFCBindCore.h
+++ b/compiler/src/CFCBindCore.h
@@ -38,14 +38,16 @@ struct CFCHierarchy;
* typically, an "autogenerated file" warning.
* @param footer Text to be appended to the end of each generated C file --
* typically copyright information.
+ * @param charmonic If true, make cfish_platform.h include charmony.h.
+ * Otherwise, use the same config CFC was compiled with.
*/
CFCBindCore*
CFCBindCore_new(struct CFCHierarchy *hierarchy, const char *header,
- const char *footer);
+ const char *footer, int charmonic);
CFCBindCore*
CFCBindCore_init(CFCBindCore *self, struct CFCHierarchy *hierarchy,
- const char *header, const char *footer);
+ const char *header, const char *footer, int charmonic);
void
CFCBindCore_destroy(CFCBindCore *self);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index c010f5e..c9eceb2 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -8509,6 +8509,7 @@ int main(int argc, const char **argv) {
chaz_Floats_run();
chaz_LargeFiles_run();
chaz_Memory_run();
+ chaz_SymbolVisibility_run();
chaz_VariadicMacros_run();
/* Local definitions. */
@@ -8910,8 +8911,8 @@ cfish_MakeFile_write_c_cfc_rules(cfish_MakeFile *self) {
rule = chaz_MakeFile_add_rule(self->makefile, self->autogen_target,
cfc_exe);
chaz_MakeRule_add_prereq(rule, "$(CLOWNFISH_HEADERS)");
- cfc_command = chaz_Util_join("", cfc_exe, " --source=", self->core_dir,
- " --source=", self->test_dir,
+ cfc_command = chaz_Util_join("", cfc_exe, " --charmonic --source=",
+ self->core_dir, " --source=", self->test_dir,
" --dest=autogen --header=cfc_header", NULL);
chaz_MakeRule_add_command(rule, cfc_command);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ae56843f/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index a98c031..e8a21fd 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -129,6 +129,7 @@ int main(int argc, const char **argv) {
chaz_Floats_run();
chaz_LargeFiles_run();
chaz_Memory_run();
+ chaz_SymbolVisibility_run();
chaz_VariadicMacros_run();
/* Local definitions. */
@@ -530,8 +531,8 @@ cfish_MakeFile_write_c_cfc_rules(cfish_MakeFile *self) {
rule = chaz_MakeFile_add_rule(self->makefile, self->autogen_target,
cfc_exe);
chaz_MakeRule_add_prereq(rule, "$(CLOWNFISH_HEADERS)");
- cfc_command = chaz_Util_join("", cfc_exe, " --source=", self->core_dir,
- " --source=", self->test_dir,
+ cfc_command = chaz_Util_join("", cfc_exe, " --charmonic --source=",
+ self->core_dir, " --source=", self->test_dir,
" --dest=autogen --header=cfc_header", NULL);
chaz_MakeRule_add_command(rule, cfc_command);
[05/11] lucy-clownfish git commit: Adjust Charmonizer code for API
changes and regenerate
Posted by nw...@apache.org.
Adjust Charmonizer code for API changes and regenerate
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/cadebb91
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/cadebb91
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/cadebb91
Branch: refs/heads/master
Commit: cadebb9166f4be14499125b7f0558f6fd36d3682
Parents: 15e683b
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Feb 3 19:56:23 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 18:13:28 2017 +0100
----------------------------------------------------------------------
compiler/common/charmonizer.c | 726 ++++++++++++---------------------
compiler/common/charmonizer.main | 11 +-
runtime/common/charmonizer.c | 730 +++++++++++++---------------------
runtime/common/charmonizer.main | 15 +-
4 files changed, 540 insertions(+), 942 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cadebb91/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index 895f63a..08afcf3 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -268,6 +268,12 @@ chaz_CC_capture_output(const char *source, size_t *output_len);
int
chaz_CC_has_macro(const char *macro);
+/** Return true if preprocessor expression matches predicate. Predicate has
+ * the form "<op> value", e.g. ">= 0x1500".
+ */
+int
+chaz_CC_test_macro(const char *expression, const char *predicate);
+
/** Initialize the compiler environment.
*/
void
@@ -334,16 +340,13 @@ const char*
chaz_CC_obj_ext(void);
int
-chaz_CC_gcc_version_num(void);
-
-const char*
-chaz_CC_gcc_version(void);
+chaz_CC_is_gcc(void);
int
-chaz_CC_msvc_version_num(void);
+chaz_CC_is_msvc(void);
int
-chaz_CC_sun_c_version_num(void);
+chaz_CC_is_sun_c(void);
int
chaz_CC_is_cygwin(void);
@@ -351,6 +354,15 @@ chaz_CC_is_cygwin(void);
int
chaz_CC_is_mingw(void);
+int
+chaz_CC_test_gcc_version(const char *predicate);
+
+int
+chaz_CC_test_msvc_version(const char *predicate);
+
+int
+chaz_CC_test_sun_c_version(const char *predicate);
+
const char*
chaz_CC_link_command(void);
@@ -630,6 +642,14 @@ int
chaz_HeadCheck_contains_member(const char *struct_name, const char *member,
const char *includes);
+/*
+ * Return the size of the type or 0 if can't be determined. Only checks for
+ * sizes 1, 2, 4, 8. If hint != 0, try this size first to speed up the
+ * detection.
+ */
+int
+chaz_HeadCheck_size_of_type(const char *type, const char *includes, int hint);
+
#endif /* H_CHAZ_HEAD_CHECK */
@@ -1095,23 +1115,6 @@ chaz_Probe_init(struct chaz_CLI *cli);
void
chaz_Probe_clean_up(void);
-/* Return an integer version of the GCC version number which is
- * (10000 * __GNU_C__ + 100 * __GNUC_MINOR__ + __GNUC_PATCHLEVEL__).
- */
-int
-chaz_Probe_gcc_version_num(void);
-
-/* If the compiler is GCC (or claims compatibility), return an X.Y.Z string
- * version of the GCC version; otherwise, return NULL.
- */
-const char*
-chaz_Probe_gcc_version(void);
-
-/* Return the integer version of MSVC defined by _MSC_VER
- */
-int
-chaz_Probe_msvc_version_num(void);
-
#endif /* Include guard. */
@@ -1919,8 +1922,16 @@ chaz_CFlags_hide_symbols(chaz_CFlags *flags) {
}
}
else if (flags->style == CHAZ_CFLAGS_STYLE_SUN_C) {
- if (chaz_CC_sun_c_version_num() >= 0x550) {
- /* Sun Studio 8. */
+ static int checked = 0;
+ static int version_ge_550;
+
+ if (!checked) {
+ /* Requires Sun Studio 8. */
+ version_ge_550 = chaz_CC_test_sun_c_version(">= 0x550");
+ checked = 1;
+ }
+
+ if (version_ge_550) {
chaz_CFlags_append(flags, "-xldscope=hidden");
}
}
@@ -2463,11 +2474,6 @@ chaz_CLI_parse(chaz_CLI *self, int argc, const char *argv[]) {
static void
chaz_CC_detect_binary_format(const char *filename);
-/** Return the numeric value of a macro or 0 if it isn't defined.
- */
-static int
-chaz_CC_eval_macro(const char *macro);
-
/* Detect macros which may help to identify some compilers.
*/
static void
@@ -2498,12 +2504,10 @@ static struct {
char gcc_version_str[30];
int binary_format;
int cflags_style;
- int intval___GNUC__;
- int intval___GNUC_MINOR__;
- int intval___GNUC_PATCHLEVEL__;
- int intval__MSC_VER;
- int intval___clang__;
- int intval___SUNPRO_C;
+ int is_gcc;
+ int is_msvc;
+ int is_clang;
+ int is_sun_c;
int is_cygwin;
int is_mingw;
chaz_CFlags *extra_cflags;
@@ -2511,7 +2515,7 @@ static struct {
} chaz_CC = {
NULL, NULL, NULL,
"", "", "", "", "", "",
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
NULL, NULL
};
@@ -2546,6 +2550,9 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
}
compile_succeeded = chaz_CC_compile_exe(CHAZ_CC_TRY_SOURCE_PATH,
CHAZ_CC_TRY_BASENAME, code);
+ if (compile_succeeded) {
+ strcpy(chaz_CC.obj_ext, ".obj");
+ }
}
/* Try POSIX argument style. */
@@ -2556,6 +2563,9 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
}
compile_succeeded = chaz_CC_compile_exe(CHAZ_CC_TRY_SOURCE_PATH,
CHAZ_CC_TRY_BASENAME, code);
+ if (compile_succeeded) {
+ strcpy(chaz_CC.obj_ext, ".o");
+ }
}
if (!compile_succeeded) {
@@ -2566,13 +2576,13 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
chaz_CC_detect_known_compilers();
- if (chaz_CC.intval___GNUC__) {
+ if (chaz_CC_is_gcc()) {
chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_GNU;
}
- else if (chaz_CC.intval__MSC_VER) {
+ else if (chaz_CC_is_msvc()) {
chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_MSVC;
}
- else if (chaz_CC.intval___SUNPRO_C) {
+ else if (chaz_CC_is_sun_c()) {
chaz_CC.cflags_style = CHAZ_CFLAGS_STYLE_SUN_C;
}
else {
@@ -2606,7 +2616,7 @@ chaz_CC_init(const char *compiler_command, const char *compiler_flags) {
}
strcpy(chaz_CC.exe_ext, ".exe");
strcpy(chaz_CC.shared_lib_ext, ".dll");
- if (chaz_CC.intval___GNUC__) {
+ if (chaz_CC_is_gcc()) {
strcpy(chaz_CC.static_lib_ext, ".a");
strcpy(chaz_CC.import_lib_ext, ".dll.a");
strcpy(chaz_CC.obj_ext, ".o");
@@ -2680,43 +2690,40 @@ chaz_CC_detect_binary_format(const char *filename) {
free(output);
}
-static const char chaz_CC_eval_macro_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( #ifndef %s )
- CHAZ_QUOTE( #error "nope" )
- CHAZ_QUOTE( #endif )
- CHAZ_QUOTE( printf("%%d", %s); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
-static int
-chaz_CC_eval_macro(const char *macro) {
- size_t size = sizeof(chaz_CC_eval_macro_code)
- + (strlen(macro) * 2)
+int
+chaz_CC_has_macro(const char *macro) {
+ static const char template[] =
+ CHAZ_QUOTE( #ifdef %s )
+ CHAZ_QUOTE( int i; )
+ CHAZ_QUOTE( #else )
+ CHAZ_QUOTE( #error "nope" )
+ CHAZ_QUOTE( #endif );
+ size_t size = sizeof(template)
+ + strlen(macro)
+ 20;
char *code = (char*)malloc(size);
int retval = 0;
- char *output;
- size_t len;
- sprintf(code, chaz_CC_eval_macro_code, macro, macro);
- output = chaz_CC_capture_output(code, &len);
- if (output) {
- retval = atoi(output);
- free(output);
- }
+ sprintf(code, template, macro);
+ retval = chaz_CC_test_compile(code);
free(code);
return retval;
}
int
-chaz_CC_has_macro(const char *macro) {
- size_t size = sizeof(chaz_CC_eval_macro_code)
- + (strlen(macro) * 2)
+chaz_CC_test_macro(const char *expression, const char *predicate) {
+ static const char template[] =
+ CHAZ_QUOTE( #if (%s) %s )
+ CHAZ_QUOTE( int i; )
+ CHAZ_QUOTE( #else )
+ CHAZ_QUOTE( #error "nope" )
+ CHAZ_QUOTE( #endif );
+ size_t size = sizeof(template)
+ + strlen(expression)
+ + strlen(predicate)
+ 20;
char *code = (char*)malloc(size);
int retval = 0;
- sprintf(code, chaz_CC_eval_macro_code, macro, macro);
+ sprintf(code, template, expression, predicate);
retval = chaz_CC_test_compile(code);
free(code);
return retval;
@@ -2724,19 +2731,10 @@ chaz_CC_has_macro(const char *macro) {
static void
chaz_CC_detect_known_compilers(void) {
- chaz_CC.intval___GNUC__ = chaz_CC_eval_macro("__GNUC__");
- if (chaz_CC.intval___GNUC__) {
- chaz_CC.intval___GNUC_MINOR__
- = chaz_CC_eval_macro("__GNUC_MINOR__");
- chaz_CC.intval___GNUC_PATCHLEVEL__
- = chaz_CC_eval_macro("__GNUC_PATCHLEVEL__");
- sprintf(chaz_CC.gcc_version_str, "%d.%d.%d", chaz_CC.intval___GNUC__,
- chaz_CC.intval___GNUC_MINOR__,
- chaz_CC.intval___GNUC_PATCHLEVEL__);
- }
- chaz_CC.intval__MSC_VER = chaz_CC_eval_macro("_MSC_VER");
- chaz_CC.intval___clang__ = chaz_CC_eval_macro("__clang__");
- chaz_CC.intval___SUNPRO_C = chaz_CC_eval_macro("__SUNPRO_C");
+ chaz_CC.is_gcc = chaz_CC_has_macro("__GNUC__");
+ chaz_CC.is_msvc = chaz_CC_has_macro("_MSC_VER");
+ chaz_CC.is_clang = chaz_CC_has_macro("__clang__");
+ chaz_CC.is_sun_c = chaz_CC_has_macro("__SUNPRO_C");
}
void
@@ -2782,7 +2780,7 @@ chaz_CC_compile_exe(const char *source_path, const char *exe_name,
system(command);
}
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
/* Zap MSVC junk. */
size_t junk_buf_size = strlen(exe_file) + 4;
char *junk = (char*)malloc(junk_buf_size);
@@ -2970,25 +2968,18 @@ chaz_CC_obj_ext(void) {
}
int
-chaz_CC_gcc_version_num(void) {
- return 10000 * chaz_CC.intval___GNUC__
- + 100 * chaz_CC.intval___GNUC_MINOR__
- + chaz_CC.intval___GNUC_PATCHLEVEL__;
-}
-
-const char*
-chaz_CC_gcc_version(void) {
- return chaz_CC.intval___GNUC__ ? chaz_CC.gcc_version_str : NULL;
+chaz_CC_is_gcc(void) {
+ return chaz_CC.is_gcc;
}
int
-chaz_CC_msvc_version_num(void) {
- return chaz_CC.intval__MSC_VER;
+chaz_CC_is_msvc(void) {
+ return chaz_CC.is_msvc;
}
int
-chaz_CC_sun_c_version_num(void) {
- return chaz_CC.intval___SUNPRO_C;
+chaz_CC_is_sun_c(void) {
+ return chaz_CC.is_sun_c;
}
int
@@ -3001,9 +2992,26 @@ chaz_CC_is_mingw(void) {
return chaz_CC.is_mingw;
}
+int
+chaz_CC_test_gcc_version(const char *predicate) {
+ static const char version[] =
+ "10000 * __GNUC__ + 100 * __GNUC_MINOR__ + __GNUC_PATCHLEVEL__";
+ return chaz_CC_test_macro(version, predicate);
+}
+
+int
+chaz_CC_test_msvc_version(const char *predicate) {
+ return chaz_CC_test_macro("_MSC_VER", predicate);
+}
+
+int
+chaz_CC_test_sun_c_version(const char *predicate) {
+ return chaz_CC_test_macro("__SUNPRO_C", predicate);
+}
+
const char*
chaz_CC_link_command() {
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
return "link";
}
else {
@@ -3013,7 +3021,7 @@ chaz_CC_link_command() {
char*
chaz_CC_format_archiver_command(const char *target, const char *objects) {
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
/* TODO: Write `objects` to a temporary file in order to avoid
* exceeding line length limits. */
char *out = chaz_Util_join("", "/OUT:", target, NULL);
@@ -3029,7 +3037,7 @@ chaz_CC_format_archiver_command(const char *target, const char *objects) {
char*
chaz_CC_format_ranlib_command(const char *target) {
- if (chaz_CC.intval__MSC_VER) {
+ if (chaz_CC_is_msvc()) {
return NULL;
}
return chaz_Util_join(" ", "ranlib", target, NULL);
@@ -3039,7 +3047,7 @@ char*
chaz_CC_shared_lib_filename(const char *dir, const char *basename,
const char *version) {
/* Cygwin uses a "cyg" prefix for shared libraries. */
- const char *prefix = chaz_CC_msvc_version_num()
+ const char *prefix = chaz_CC_is_msvc()
? ""
: chaz_CC_is_cygwin() ? "cyg" : "lib";
return chaz_CC_build_lib_filename(dir, prefix, basename, version,
@@ -3049,7 +3057,7 @@ chaz_CC_shared_lib_filename(const char *dir, const char *basename,
char*
chaz_CC_import_lib_filename(const char *dir, const char *basename,
const char *version) {
- const char *prefix = chaz_CC_msvc_version_num() ? "" : "lib";
+ const char *prefix = chaz_CC_is_msvc() ? "" : "lib";
return chaz_CC_build_lib_filename(dir, prefix, basename, version,
chaz_CC.import_lib_ext);
}
@@ -3104,7 +3112,7 @@ chaz_CC_build_lib_filename(const char *dir, const char *prefix,
char*
chaz_CC_static_lib_filename(const char *dir, const char *basename) {
- const char *prefix = chaz_CC_msvc_version_num() ? "" : "lib";
+ const char *prefix = chaz_CC_is_msvc() ? "" : "lib";
if (dir == NULL || strcmp(dir, ".") == 0) {
return chaz_Util_join("", prefix, basename, chaz_CC.static_lib_ext,
@@ -4384,18 +4392,13 @@ chaz_HeadCheck_check_many_headers(const char **header_names) {
int
chaz_HeadCheck_defines_symbol(const char *symbol, const char *includes) {
- /*
- * Casting function pointers to object pointers like 'char*' is a C
- * extension, so for a bullet-proof check, a separate test for functions
- * might be necessary.
- */
static const char defines_code[] =
CHAZ_QUOTE( %s )
CHAZ_QUOTE( int main() { )
CHAZ_QUOTE( #ifdef %s )
CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( #else )
- CHAZ_QUOTE( return *(char*)&%s; )
+ CHAZ_QUOTE( return (int)&%s; )
CHAZ_QUOTE( #endif )
CHAZ_QUOTE( } );
long needed = sizeof(defines_code)
@@ -4430,6 +4433,44 @@ chaz_HeadCheck_contains_member(const char *struct_name, const char *member,
return retval;
}
+int
+chaz_HeadCheck_size_of_type(const char *type, const char *includes, int hint) {
+ static const char sizeof_code[] =
+ CHAZ_QUOTE( #include <stddef.h> )
+ CHAZ_QUOTE( %s )
+ CHAZ_QUOTE( int a[sizeof(%s)==%d?1:-1]; );
+ size_t needed = sizeof(sizeof_code)
+ + strlen(type)
+ + strlen(includes)
+ + 10;
+ char *buf = (char*)malloc(needed);
+ static const int sizes[] = { 4, 8, 2, 1 };
+ int retval = 0;
+ int i;
+
+ for (i = -1; i < (int)(sizeof(sizes) / sizeof(sizes[0])); i++) {
+ int size;
+
+ if (i < 0) {
+ if (hint != 0) { size = hint; }
+ else { continue; }
+ }
+ else {
+ if (sizes[i] != hint) { size = sizes[i]; }
+ else { continue; }
+ }
+
+ sprintf(buf, sizeof_code, includes, type, size);
+ if (chaz_CC_test_compile(buf)) {
+ retval = size;
+ break;
+ }
+ }
+
+ free(buf);
+ return retval;
+}
+
static int
chaz_HeadCheck_compare_headers(const void *vptr_a, const void *vptr_b) {
chaz_CHeader *const *const a = (chaz_CHeader*const*)vptr_a;
@@ -4995,7 +5036,7 @@ S_chaz_MakeFile_finish_shared_lib(chaz_MakeFile *self,
free(filename);
}
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
/* Remove export file. */
char *filename
= chaz_CC_export_filename(binary->target_dir, binary->basename,
@@ -5162,7 +5203,7 @@ chaz_MakeFile_write(chaz_MakeFile *self) {
S_chaz_MakeRule_write(self->distclean, out);
/* Suffix rule for .c files. */
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
fprintf(out, ".c.obj :\n");
fprintf(out, "\t$(CC) /nologo $(CFLAGS) /c $< /Fo$@\n\n");
}
@@ -5179,7 +5220,7 @@ S_chaz_MakeFile_write_binary_rules(chaz_MakeFile *self,
chaz_MakeBinary *binary, FILE *out) {
const char *cflags;
- if (chaz_CC_msvc_version_num()) {
+ if (chaz_CC_is_msvc()) {
chaz_CFlags_append(binary->compile_flags, "/nologo");
chaz_CFlags_append(binary->link_flags, "/nologo");
}
@@ -6450,21 +6491,6 @@ chaz_Probe_clean_up(void) {
if (chaz_Util_verbosity) { printf("Cleanup complete.\n"); }
}
-int
-chaz_Probe_gcc_version_num(void) {
- return chaz_CC_gcc_version_num();
-}
-
-const char*
-chaz_Probe_gcc_version(void) {
- return chaz_CC_gcc_version_num() ? chaz_CC_gcc_version() : NULL;
-}
-
-int
-chaz_Probe_msvc_version_num(void) {
- return chaz_CC_msvc_version_num();
-}
-
/***************************************************************************/
#line 17 "src/Charmonizer/Probe/AtomicOps.c"
@@ -6827,34 +6853,30 @@ chaz_Floats_run(void) {
const char*
chaz_Floats_math_library(void) {
+ /*
+ * The cast to a specific function pointer type is required because
+ * C++ overloads sqrt.
+ */
static const char sqrt_code[] =
CHAZ_QUOTE( #include <math.h> )
- CHAZ_QUOTE( #include <stdio.h> )
CHAZ_QUOTE( typedef double (*sqrt_t)(double); )
- CHAZ_QUOTE( int main(void) { )
- CHAZ_QUOTE( printf("%p\n", (sqrt_t)sqrt); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( int main() { return (int)(sqrt_t)sqrt; } );
chaz_CFlags *temp_cflags = chaz_CC_get_temp_cflags();
- char *output = NULL;
- size_t output_len;
+ int success;
- output = chaz_CC_capture_output(sqrt_code, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_link(sqrt_code)) {
/* Linking against libm not needed. */
- free(output);
return NULL;
}
chaz_CFlags_add_external_lib(temp_cflags, "m");
- output = chaz_CC_capture_output(sqrt_code, &output_len);
+ success = chaz_CC_test_link(sqrt_code);
chaz_CFlags_clear(temp_cflags);
- if (output == NULL) {
+ if (!success) {
chaz_Util_die("Don't know how to use math library.");
}
- free(output);
return "m";
}
@@ -6871,63 +6893,13 @@ chaz_Floats_math_library(void) {
#include <stdio.h>
#include <stdlib.h>
-/* Probe for ISO func macro. */
-static int
-chaz_FuncMacro_probe_iso() {
- static const char iso_func_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%s", __func__); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
- size_t output_len;
- char *output;
- int success = false;
-
- output = chaz_CC_capture_output(iso_func_code, &output_len);
- if (output != NULL && strncmp(output, "main", 4) == 0) {
- success = true;
- }
- free(output);
-
- return success;
-}
-
-static int
-chaz_FuncMacro_probe_gnu() {
- /* Code for verifying GNU func macro. */
- static const char gnu_func_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%s", __FUNCTION__); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
- size_t output_len;
- char *output;
- int success = false;
-
- output = chaz_CC_capture_output(gnu_func_code, &output_len);
- if (output != NULL && strncmp(output, "main", 4) == 0) {
- success = true;
- }
- free(output);
-
- return success;
-}
-
/* Attempt to verify inline keyword. */
-static char*
-chaz_FuncMacro_try_inline(const char *keyword, size_t *output_len) {
- static const char inline_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( static %s int foo() { return 1; } )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%%d", foo()); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+static int
+chaz_FuncMacro_try_inline(const char *keyword) {
+ static const char inline_code[] = "static %s int f() { return 1; }";
char code[sizeof(inline_code) + 30];
sprintf(code, inline_code, keyword);
- return chaz_CC_capture_output(code, output_len);
+ return chaz_CC_test_compile(code);
}
static void
@@ -6943,12 +6915,9 @@ chaz_FuncMacro_probe_inline(void) {
for (i = 0; i < num_inline_options; i++) {
const char *inline_option = inline_options[i];
- size_t output_len;
- char *output = chaz_FuncMacro_try_inline(inline_option, &output_len);
- if (output != NULL) {
+ if (chaz_FuncMacro_try_inline(inline_option)) {
has_inline = true;
chaz_ConfWriter_add_def("INLINE", inline_option);
- free(output);
break;
}
}
@@ -6966,11 +6935,11 @@ chaz_FuncMacro_run(void) {
chaz_ConfWriter_start_module("FuncMacro");
/* Check for func macros. */
- if (chaz_FuncMacro_probe_iso()) {
+ if (chaz_CC_test_compile("const char *f() { return __func__; }")) {
has_funcmac = true;
has_iso_funcmac = true;
}
- if (chaz_FuncMacro_probe_gnu()) {
+ if (chaz_CC_test_compile("const char *f() { return __FUNCTION__; }")) {
has_funcmac = true;
has_gnuc_funcmac = true;
}
@@ -7239,44 +7208,12 @@ chaz_Headers_probe_win(void) {
static int
chaz_Integers_machine_is_big_endian(void);
-static const char chaz_Integers_sizes_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main () { )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(char)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(short)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(int)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(long)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(void*)); )
- CHAZ_QUOTE( printf("%d ", (int)sizeof(size_t)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
static const char chaz_Integers_stdint_type_code[] =
CHAZ_QUOTE( #include <stdint.h> )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
-static const char chaz_Integers_type64_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( %s i; );
static const char chaz_Integers_literal64_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( #define big 9000000000000000000%s )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( int truncated = (int)big; )
- CHAZ_QUOTE( printf("%%d\n", truncated); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( int f() { return (int)9000000000000000000%s; } );
void
chaz_Integers_run(void) {
@@ -7321,51 +7258,31 @@ chaz_Integers_run(void) {
}
/* Record sizeof() for several common integer types. */
- output = chaz_CC_capture_output(chaz_Integers_sizes_code, &output_len);
- if (output != NULL) {
- char *ptr = output;
- char *end_ptr = output;
-
- sizeof_char = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_short = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_int = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_long = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_ptr = strtol(ptr, &end_ptr, 10);
- ptr = end_ptr;
- sizeof_size_t = strtol(ptr, &end_ptr, 10);
-
- free(output);
- }
+ sizeof_char = chaz_HeadCheck_size_of_type("char", "", 1);
+ sizeof_short = chaz_HeadCheck_size_of_type("short", "", 2);
+ sizeof_int = chaz_HeadCheck_size_of_type("int", "", 4);
+ sizeof_long = chaz_HeadCheck_size_of_type("long", "", 4);
+ sizeof_ptr = chaz_HeadCheck_size_of_type("void*", "", 4);
+ sizeof_size_t = chaz_HeadCheck_size_of_type("size_t",
+ "#include <stddef.h>", 4);
/* Determine whether long longs are available. */
- sprintf(code_buf, chaz_Integers_type64_code, "long long");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile("long long l;")) {
has_long_long = true;
- sizeof_long_long = strtol(output, NULL, 10);
- free(output);
+ sizeof_long_long = chaz_HeadCheck_size_of_type("long long", "", 8);
}
/* Determine whether the __int64 type is available. */
- sprintf(code_buf, chaz_Integers_type64_code, "__int64");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile("__int64 i;")) {
has___int64 = true;
- sizeof___int64 = strtol(output, NULL, 10);
- free(output);
+ sizeof___int64 = chaz_HeadCheck_size_of_type("__int64", "", 8);
}
/* Determine whether the intptr_t type is available (it's optional in
* C99). */
sprintf(code_buf, chaz_Integers_stdint_type_code, "intptr_t");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
has_intptr_t = true;
- free(output);
}
/* Figure out which integer types are available. */
@@ -7409,34 +7326,26 @@ chaz_Integers_run(void) {
}
else if (has_64) {
sprintf(code_buf, chaz_Integers_literal64_code, "LL");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(i64_t_postfix, "LL");
- free(output);
}
else {
sprintf(code_buf, chaz_Integers_literal64_code, "i64");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(i64_t_postfix, "i64");
- free(output);
}
else {
chaz_Util_die("64-bit types, but no literal syntax found");
}
}
sprintf(code_buf, chaz_Integers_literal64_code, "ULL");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(u64_t_postfix, "ULL");
- free(output);
}
else {
sprintf(code_buf, chaz_Integers_literal64_code, "Ui64");
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(code_buf)) {
strcpy(u64_t_postfix, "Ui64");
- free(output);
}
else {
chaz_Util_die("64-bit types, but no literal syntax found");
@@ -7444,47 +7353,6 @@ chaz_Integers_run(void) {
}
}
- /* Probe for 64-bit printf format string modifier. */
- if (has_64) {
- int i;
- const char *options[] = {
- "ll",
- "l",
- "L",
- "q", /* Some *BSDs */
- "I64", /* Microsoft */
- NULL,
- };
-
- /* Buffer to hold the code, and its start and end. */
- static const char format_64_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( printf("%%%su", 18446744073709551615%s); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
-
- for (i = 0; options[i] != NULL; i++) {
- /* Try to print 2**64-1, and see if we get it back intact. */
- int success;
- sprintf(code_buf, format_64_code, options[i], u64_t_postfix);
- output = chaz_CC_capture_output(code_buf, &output_len);
- success = output != NULL
- && strcmp(output, "18446744073709551615") == 0;
- free(output);
-
- if (success) {
- break;
- }
- }
-
- if (options[i] == NULL) {
- chaz_Util_die("64-bit types, but no printf modifier found");
- }
-
- strcpy(printf_modifier_64, options[i]);
- }
-
/* Write out some conditional defines. */
if (has_inttypes) {
chaz_ConfWriter_add_def("HAS_INTTYPES_H", NULL);
@@ -7774,7 +7642,48 @@ chaz_Integers_run(void) {
chaz_ConfWriter_add_sys_include("inttypes.h");
}
- {
+ /* Probe for 64-bit printf format string modifier. */
+ if (!has_inttypes && has_64) {
+ int i;
+ const char *options[] = {
+ "ll",
+ "l",
+ "L",
+ "q", /* Some *BSDs */
+ "I64", /* Microsoft */
+ NULL,
+ };
+
+ /* Buffer to hold the code, and its start and end. */
+ static const char format_64_code[] =
+ CHAZ_QUOTE( #include <stdio.h> )
+ CHAZ_QUOTE( int main() { )
+ CHAZ_QUOTE( printf("%%%su", 18446744073709551615%s); )
+ CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( } );
+
+ for (i = 0; options[i] != NULL; i++) {
+ /* Try to print 2**64-1, and see if we get it back intact. */
+ int success;
+ sprintf(code_buf, format_64_code, options[i], u64_t_postfix);
+ output = chaz_CC_capture_output(code_buf, &output_len);
+ success = output != NULL
+ && strcmp(output, "18446744073709551615") == 0;
+ free(output);
+
+ if (success) {
+ break;
+ }
+ }
+
+ if (options[i] == NULL) {
+ chaz_Util_die("64-bit types, but no printf modifier found");
+ }
+
+ strcpy(printf_modifier_64, options[i]);
+ }
+
+ if (!has_inttypes || !has_intptr_t) {
/* We support only the following subset of inttypes.h
* PRId32
* PRIi32
@@ -7811,10 +7720,9 @@ chaz_Integers_run(void) {
int c = ptr[0];
if (has_32) {
- sprintf(scratch, "\"%s%c\"", printf_modifier_32, c);
-
+ macro_name_32[3] = c;
if (!has_inttypes) {
- macro_name_32[3] = c;
+ sprintf(scratch, "\"%s%c\"", printf_modifier_32, c);
chaz_ConfWriter_add_global_def(macro_name_32, scratch);
if (!has_64) {
macro_name_max[3] = c;
@@ -7824,21 +7732,22 @@ chaz_Integers_run(void) {
}
if (!has_intptr_t && sizeof_ptr == 4) {
macro_name_ptr[3] = c;
- chaz_ConfWriter_add_global_def(macro_name_ptr, scratch);
+ chaz_ConfWriter_add_global_def(macro_name_ptr,
+ macro_name_32);
}
}
if (has_64) {
- sprintf(scratch, "\"%s%c\"", printf_modifier_64, c);
-
+ macro_name_64[3] = c;
if (!has_inttypes) {
- macro_name_64[3] = c;
+ sprintf(scratch, "\"%s%c\"", printf_modifier_64, c);
chaz_ConfWriter_add_global_def(macro_name_64, scratch);
macro_name_max[3] = c;
chaz_ConfWriter_add_global_def(macro_name_max, scratch);
}
if (!has_intptr_t && sizeof_ptr == 8) {
macro_name_ptr[3] = c;
- chaz_ConfWriter_add_global_def(macro_name_ptr, scratch);
+ chaz_ConfWriter_add_global_def(macro_name_ptr,
+ macro_name_64);
}
}
}
@@ -7962,12 +7871,7 @@ static int
chaz_LargeFiles_probe_off64(void) {
static const char off64_code[] =
CHAZ_QUOTE( %s )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() )
- CHAZ_QUOTE( { )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( int a[sizeof(%s)==8?1:-1]; );
char code_buf[sizeof(off64_code) + 100];
int i;
int success = false;
@@ -7981,8 +7885,6 @@ chaz_LargeFiles_probe_off64(void) {
for (i = 0; i < num_off64_options; i++) {
const char *candidate = off64_options[i];
- char *output;
- size_t output_len;
int has_sys_types_h = chaz_HeadCheck_check_header("sys/types.h");
const char *sys_types_include = has_sys_types_h
? "#include <sys/types.h>"
@@ -7990,15 +7892,10 @@ chaz_LargeFiles_probe_off64(void) {
/* Execute the probe. */
sprintf(code_buf, off64_code, sys_types_include, candidate);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- long sizeof_candidate = strtol(output, NULL, 10);
- free(output);
- if (sizeof_candidate == 8) {
- strcpy(chaz_LargeFiles.off64_type, candidate);
- success = true;
- break;
- }
+ if (chaz_CC_test_compile(code_buf)) {
+ strcpy(chaz_LargeFiles.off64_type, candidate);
+ success = true;
+ break;
}
}
return success;
@@ -8009,20 +7906,13 @@ chaz_LargeFiles_try_stdio64(chaz_LargeFiles_stdio64_combo *combo) {
static const char stdio64_code[] =
CHAZ_QUOTE( %s )
CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( %s pos; )
- CHAZ_QUOTE( FILE *f; )
- CHAZ_QUOTE( f = %s("_charm_stdio64", "w"); )
- CHAZ_QUOTE( if (f == NULL) return -1; )
- CHAZ_QUOTE( printf("%%d", (int)sizeof(%s)); )
- CHAZ_QUOTE( pos = %s(stdout); )
- CHAZ_QUOTE( %s(stdout, 0, SEEK_SET); )
- CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( int a[sizeof(%s)==8?1:-1]; )
+ CHAZ_QUOTE( void f() { )
+ CHAZ_QUOTE( FILE *f = %s("_charm_stdio64", "w"); )
+ CHAZ_QUOTE( %s pos = %s(f); )
+ CHAZ_QUOTE( %s(f, 0, SEEK_SET); )
CHAZ_QUOTE( } );
- char *output = NULL;
- size_t output_len;
char code_buf[sizeof(stdio64_code) + 200];
- int success = false;
/* Prepare the source code. */
sprintf(code_buf, stdio64_code, combo->includes,
@@ -8031,20 +7921,7 @@ chaz_LargeFiles_try_stdio64(chaz_LargeFiles_stdio64_combo *combo) {
combo->fseek_command);
/* Verify compilation and that the offset type has 8 bytes. */
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- long size = strtol(output, NULL, 10);
- if (size == 8) {
- success = true;
- }
- free(output);
- }
-
- if (!chaz_Util_remove_and_verify("_charm_stdio64")) {
- chaz_Util_die("Failed to remove '_charm_stdio64'");
- }
-
- return success;
+ return chaz_CC_test_compile(code_buf);
}
static void
@@ -8075,35 +7952,13 @@ chaz_LargeFiles_probe_stdio64(void) {
static int
chaz_LargeFiles_probe_lseek(chaz_LargeFiles_unbuff_combo *combo) {
static const char lseek_code[] =
- CHAZ_QUOTE( %s )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( int fd; )
- CHAZ_QUOTE( fd = open("_charm_lseek", O_WRONLY | O_CREAT, 0666); )
- CHAZ_QUOTE( if (fd == -1) { return -1; } )
- CHAZ_QUOTE( %s(fd, 0, SEEK_SET); )
- CHAZ_QUOTE( printf("%%d", 1); )
- CHAZ_QUOTE( if (close(fd)) { return -1; } )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( %s )
+ CHAZ_QUOTE( void f() { %s(0, 0, SEEK_SET); } );
char code_buf[sizeof(lseek_code) + 100];
- char *output = NULL;
- size_t output_len;
- int success = false;
/* Verify compilation. */
sprintf(code_buf, lseek_code, combo->includes, combo->lseek_command);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- success = true;
- free(output);
- }
-
- if (!chaz_Util_remove_and_verify("_charm_lseek")) {
- chaz_Util_die("Failed to remove '_charm_lseek'");
- }
-
- return success;
+ return chaz_CC_test_compile(code_buf);
}
static int
@@ -8112,28 +7967,15 @@ chaz_LargeFiles_probe_pread64(chaz_LargeFiles_unbuff_combo *combo) {
* fine as long as it compiles. */
static const char pread64_code[] =
CHAZ_QUOTE( %s )
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( int fd = 20; )
+ CHAZ_QUOTE( void f() { )
CHAZ_QUOTE( char buf[1]; )
- CHAZ_QUOTE( printf("1"); )
- CHAZ_QUOTE( %s(fd, buf, 1, 1); )
- CHAZ_QUOTE( return 0; )
+ CHAZ_QUOTE( %s(0, buf, 1, 1); )
CHAZ_QUOTE( } );
char code_buf[sizeof(pread64_code) + 100];
- char *output = NULL;
- size_t output_len;
- int success = false;
/* Verify compilation. */
sprintf(code_buf, pread64_code, combo->includes, combo->pread64_command);
- output = chaz_CC_capture_output(code_buf, &output_len);
- if (output != NULL) {
- success = true;
- free(output);
- }
-
- return success;
+ return chaz_CC_test_compile(code_buf);
}
static void
@@ -8141,7 +7983,7 @@ chaz_LargeFiles_probe_unbuff(void) {
static chaz_LargeFiles_unbuff_combo unbuff_combos[] = {
{ "#include <unistd.h>\n#include <fcntl.h>\n", "lseek64", "pread64" },
{ "#include <unistd.h>\n#include <fcntl.h>\n", "lseek", "pread" },
- { "#include <io.h>\n#include <fcntl.h>\n", "_lseeki64", "NO_PREAD64" },
+ { "#include <io.h>\n#include <stdio.h>\n", "_lseeki64", "NO_PREAD64" },
{ NULL, NULL, NULL }
};
int i;
@@ -8219,7 +8061,7 @@ chaz_Memory_probe_alloca(void) {
/* Under GCC, alloca is a builtin that works without including the
* correct header, generating only a warning. To avoid misdetection,
* disable the alloca builtin temporarily. */
- if (chaz_CC_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
chaz_CFlags_append(temp_cflags, "-fno-builtin-alloca");
}
@@ -8312,6 +8154,7 @@ chaz_RegularExpressions_run(void) {
#line 17 "src/Charmonizer/Probe/Strings.c"
/* #include "Charmonizer/Core/Compiler.h" */
/* #include "Charmonizer/Core/ConfWriter.h" */
+/* #include "Charmonizer/Core/HeaderChecker.h" */
/* #include "Charmonizer/Probe/Strings.h" */
#include <stdlib.h>
@@ -8342,23 +8185,6 @@ chaz_Strings_probe_c99_snprintf(void) {
CHAZ_QUOTE( printf("%d", result); )
CHAZ_QUOTE( return 0; )
CHAZ_QUOTE( } );
- static const char detect__scprintf_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( int result; )
- CHAZ_QUOTE( result = _scprintf("%s", "12345"); )
- CHAZ_QUOTE( printf("%d", result); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
- static const char detect__snprintf_code[] =
- CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( char buf[6]; )
- CHAZ_QUOTE( int result; )
- CHAZ_QUOTE( result = _snprintf(buf, 6, "%s", "12345"); )
- CHAZ_QUOTE( printf("%d", result); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
char *output = NULL;
size_t output_len;
@@ -8377,15 +8203,11 @@ chaz_Strings_probe_c99_snprintf(void) {
/* Test for _scprintf and _snprintf found in the MSVCRT.
*/
- output = chaz_CC_capture_output(detect__scprintf_code, &output_len);
- if (output != NULL) {
+ if (chaz_HeadCheck_defines_symbol("_scprintf", "#include <stdio.h>")) {
chaz_ConfWriter_add_def("HAS__SCPRINTF", NULL);
- free(output);
}
- output = chaz_CC_capture_output(detect__snprintf_code, &output_len);
- if (output != NULL) {
+ if (chaz_HeadCheck_defines_symbol("_snprintf", "#include <stdio.h>")) {
chaz_ConfWriter_add_def("HAS__SNPRINTF", NULL);
- free(output);
}
}
@@ -8438,7 +8260,7 @@ chaz_SymbolVisibility_run(void) {
if (chaz_CC_test_compile(code_buf)) {
can_control_visibility = true;
chaz_ConfWriter_add_def("EXPORT", export_win);
- if (chaz_CC_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
/*
* Under MinGW, symbols with dllimport storage class aren't
* constant. If a global variable is initialized to such a
@@ -8518,48 +8340,35 @@ chaz_UnusedVars_run(void) {
/* Code for verifying ISO-style variadic macros. */
static const char chaz_VariadicMacros_iso_code[] =
CHAZ_QUOTE( #include <stdio.h> )
- CHAZ_QUOTE( #define ISO_TEST(fmt, ...) \\ )
- " printf(fmt, __VA_ARGS__) \n"
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( ISO_TEST("%d %d", 1, 1); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ "#define ISO_TEST(fmt, ...) printf(fmt, __VA_ARGS__)\n"
+ CHAZ_QUOTE( void f() { ISO_TEST("%d %d", 1, 1); } );
/* Code for verifying GNU-style variadic macros. */
static const char chaz_VariadicMacros_gnuc_code[] =
CHAZ_QUOTE( #include <stdio.h> )
CHAZ_QUOTE( #define GNU_TEST(fmt, args...) printf(fmt, ##args) )
- CHAZ_QUOTE( int main() { )
- CHAZ_QUOTE( GNU_TEST("%d %d", 1, 1); )
- CHAZ_QUOTE( return 0; )
- CHAZ_QUOTE( } );
+ CHAZ_QUOTE( void f() { GNU_TEST("%d %d", 1, 1); } );
void
chaz_VariadicMacros_run(void) {
- char *output;
- size_t output_len;
int has_varmacros = false;
chaz_ConfWriter_start_module("VariadicMacros");
/* Test for ISO-style variadic macros. */
- output = chaz_CC_capture_output(chaz_VariadicMacros_iso_code, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(chaz_VariadicMacros_iso_code)) {
has_varmacros = true;
chaz_ConfWriter_add_def("HAS_VARIADIC_MACROS", NULL);
chaz_ConfWriter_add_def("HAS_ISO_VARIADIC_MACROS", NULL);
- free(output);
}
/* Test for GNU-style variadic macros. */
- output = chaz_CC_capture_output(chaz_VariadicMacros_gnuc_code, &output_len);
- if (output != NULL) {
+ if (chaz_CC_test_compile(chaz_VariadicMacros_gnuc_code)) {
if (has_varmacros == false) {
has_varmacros = true;
chaz_ConfWriter_add_def("HAS_VARIADIC_MACROS", NULL);
}
chaz_ConfWriter_add_def("HAS_GNUC_VARIADIC_MACROS", NULL);
- free(output);
}
chaz_ConfWriter_end_module();
@@ -8669,7 +8478,7 @@ static void
S_add_compiler_flags(struct chaz_CLI *cli) {
chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags();
- if (chaz_Probe_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
chaz_CFlags_append(extra_cflags,
"-pedantic -Wall -Wextra -Wno-variadic-macros"
" -Wno-overlength-strings");
@@ -8680,8 +8489,8 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
/* Tell GCC explicitly to run with maximum options. */
chaz_CFlags_append(extra_cflags, "-std=gnu99 -D_GNU_SOURCE");
}
- else if (chaz_Probe_msvc_version_num()) {
- if (chaz_Probe_msvc_version_num() < 1800) {
+ else if (chaz_CC_is_msvc()) {
+ if (chaz_CC_test_msvc_version("< 1800")) {
/* Compile as C++ under MSVC11 and below. */
chaz_CFlags_append(extra_cflags, "/TP");
}
@@ -8694,11 +8503,6 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
/* Thwart stupid warnings. */
chaz_CFlags_append(extra_cflags,
"/D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /wd4996");
-
- if (chaz_Probe_msvc_version_num() < 1300) {
- /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */
- chaz_CFlags_append(extra_cflags, "/Dfor=\"if(0);else for\"");
- }
}
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/cadebb91/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main
index 348b7cf..7165cf0 100644
--- a/compiler/common/charmonizer.main
+++ b/compiler/common/charmonizer.main
@@ -98,7 +98,7 @@ static void
S_add_compiler_flags(struct chaz_CLI *cli) {
chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags();
- if (chaz_Probe_gcc_version_num()) {
+ if (chaz_CC_is_gcc()) {
chaz_CFlags_append(extra_cflags,
"-pedantic -Wall -Wextra -Wno-variadic-macros"
" -Wno-overlength-strings");
@@ -109,8 +109,8 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
/* Tell GCC explicitly to run with maximum options. */
chaz_CFlags_append(extra_cflags, "-std=gnu99 -D_GNU_SOURCE");
}
- else if (chaz_Probe_msvc_version_num()) {
- if (chaz_Probe_msvc_version_num() < 1800) {
+ else if (chaz_CC_is_msvc()) {
+ if (chaz_CC_test_msvc_version("< 1800")) {
/* Compile as C++ under MSVC11 and below. */
chaz_CFlags_append(extra_cflags, "/TP");
}
@@ -123,11 +123,6 @@ S_add_compiler_flags(struct chaz_CLI *cli) {
/* Thwart stupid warnings. */
chaz_CFlags_append(extra_cflags,
"/D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /wd4996");
-
- if (chaz_Probe_msvc_version_num() < 1300) {
- /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */
- chaz_CFlags_append(extra_cflags, "/Dfor=\"if(0);else for\"");
- }
}
}
[06/11] lucy-clownfish git commit: Test ARM cross compilation under
Travis
Posted by nw...@apache.org.
Test ARM cross compilation under Travis
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/e65b995f
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/e65b995f
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/e65b995f
Branch: refs/heads/master
Commit: e65b995fc48020af2675d05271c547b31a434d7a
Parents: c9514ad
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Feb 4 00:46:27 2017 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Feb 4 18:13:34 2017 +0100
----------------------------------------------------------------------
.travis.yml | 6 ++++++
devel/bin/travis-test.sh | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e65b995f/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 7bd87b7..3c150d5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -21,6 +21,12 @@ script: devel/bin/travis-test.sh
matrix:
include:
- env: CLOWNFISH_HOST=c
+ - env: CLOWNFISH_HOST=c TARGET_CC=arm-linux-gnueabihf-gcc
+ addons:
+ apt:
+ packages:
+ - gcc-arm-linux-gnueabihf
+ - libc6-dev-armhf-cross
- env: CLOWNFISH_HOST=go
- env: CLOWNFISH_HOST=perl PERL_VERSION=5.20-extras
- env: CLOWNFISH_HOST=perl PERL_VERSION=5.18-extras
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/e65b995f/devel/bin/travis-test.sh
----------------------------------------------------------------------
diff --git a/devel/bin/travis-test.sh b/devel/bin/travis-test.sh
index a41c7e6..f96f779 100755
--- a/devel/bin/travis-test.sh
+++ b/devel/bin/travis-test.sh
@@ -27,7 +27,11 @@ test_c() {
make -j test
cd ../../runtime/c
./configure
- make -j test
+ if [ -z "$TARGET_CC" ]; then
+ make -j test
+ else
+ make -j
+ fi
}
test_perl() {