lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [6/14] git commit: refs/heads/master - Detect and expose the GCC version number.
Date Wed, 02 Jan 2013 20:38:08 GMT
Detect and expose the GCC version number.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/65da4881
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/65da4881
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/65da4881

Branch: refs/heads/master
Commit: 65da4881704529a6373a71509cfc3c5243f0abb5
Parents: 95e4351
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Wed Nov 28 19:56:34 2012 -0800
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Wed Jan 2 12:10:11 2013 -0800

----------------------------------------------------------------------
 charmonizer/src/Charmonizer/Core/Compiler.c |   28 ++++++++++++++++++++-
 charmonizer/src/Charmonizer/Core/Compiler.h |    6 ++++
 charmonizer/src/Charmonizer/Probe.c         |   10 ++++++++
 charmonizer/src/Charmonizer/Probe.h         |   12 +++++++++
 4 files changed, 54 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/65da4881/charmonizer/src/Charmonizer/Core/Compiler.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Compiler.c b/charmonizer/src/Charmonizer/Core/Compiler.c
index 0364686..d0bd093 100644
--- a/charmonizer/src/Charmonizer/Core/Compiler.c
+++ b/charmonizer/src/Charmonizer/Core/Compiler.c
@@ -42,14 +42,17 @@ static struct {
     char      exe_flag[10];
     char      no_link_flag[10];
     char      error_flag[10];
+    char      gcc_version_str[30];
     int       intval___GNUC__;
+    int       intval___GNUC_MINOR__;
+    int       intval___GNUC_PATCHLEVEL__;
     int       intval__MSC_VER;
     int       intval___clang__;
     int       warnings_as_errors;
 } chaz_CC = {
     NULL, NULL, NULL, NULL,
-    "", "", "", "", "",
-    0, 0, 0, 0
+    "", "", "", "", "", "",
+    0, 0, 0, 0, 0, 0
 };
 
 void
@@ -147,6 +150,15 @@ chaz_CC_detect_macro(const char *macro) {
 static void
 chaz_CC_detect_known_compilers(void) {
     chaz_CC.intval___GNUC__  = chaz_CC_detect_macro("__GNUC__");
+    if (chaz_CC.intval___GNUC__) {
+        chaz_CC.intval___GNUC_MINOR__
+            = chaz_CC_detect_macro("__GNUC_MINOR__");
+        chaz_CC.intval___GNUC_PATCHLEVEL__
+            = chaz_CC_detect_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_detect_macro("_MSC_VER");
     chaz_CC.intval___clang__ = chaz_CC_detect_macro("__clang__");
 }
@@ -307,3 +319,15 @@ chaz_CC_capture_output(const char *source, size_t *output_len) {
     return captured_output;
 }
 
+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;
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/65da4881/charmonizer/src/Charmonizer/Core/Compiler.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Core/Compiler.h b/charmonizer/src/Charmonizer/Core/Compiler.h
index ce41cb7..49aa897 100644
--- a/charmonizer/src/Charmonizer/Core/Compiler.h
+++ b/charmonizer/src/Charmonizer/Core/Compiler.h
@@ -68,6 +68,12 @@ chaz_CC_clean_up(void);
 void
 chaz_CC_set_warnings_as_errors(const int flag);
 
+int
+chaz_CC_gcc_version_num();
+
+const char*
+chaz_CC_gcc_version();
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/lucy/blob/65da4881/charmonizer/src/Charmonizer/Probe.c
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe.c b/charmonizer/src/Charmonizer/Probe.c
index dc99875..3005e5d 100644
--- a/charmonizer/src/Charmonizer/Probe.c
+++ b/charmonizer/src/Charmonizer/Probe.c
@@ -151,3 +151,13 @@ 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;
+}
+

http://git-wip-us.apache.org/repos/asf/lucy/blob/65da4881/charmonizer/src/Charmonizer/Probe.h
----------------------------------------------------------------------
diff --git a/charmonizer/src/Charmonizer/Probe.h b/charmonizer/src/Charmonizer/Probe.h
index 6214ba5..147d22c 100644
--- a/charmonizer/src/Charmonizer/Probe.h
+++ b/charmonizer/src/Charmonizer/Probe.h
@@ -75,6 +75,18 @@ chaz_Probe_init(struct chaz_CLIArgs *args);
 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);
+
 #ifdef __cplusplus
 }
 #endif


Mime
View raw message