From ac979619e614e02f9063768ea6af6994069c488c Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Mon, 1 Mar 2010 13:32:07 -0800 Subject: [PATCH] record the C++ compiler version in the VM, and expose it with a vm-compiler word --- core/alien/strings/strings.factor | 5 +++-- core/system/system.factor | 2 ++ vm/factor.cpp | 1 + vm/master.hpp | 13 +++++++++++++ vm/objects.hpp | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/alien/strings/strings.factor b/core/alien/strings/strings.factor index 0ad4f6c85a..435ceb2a96 100644 --- a/core/alien/strings/strings.factor +++ b/core/alien/strings/strings.factor @@ -66,6 +66,7 @@ M: string string>symbol string>symbol* ; M: sequence string>symbol [ string>symbol* ] map ; [ - 8 special-object utf8 alien>string string>cpu \ cpu set-global - 9 special-object utf8 alien>string string>os \ os set-global + 8 special-object utf8 alien>string string>cpu \ cpu set-global + 9 special-object utf8 alien>string string>os \ os set-global + 67 special-object utf8 alien>string \ vm-compiler set-global ] "alien.strings" add-startup-hook diff --git a/core/system/system.factor b/core/system/system.factor index 715564c64d..765861c62f 100644 --- a/core/system/system.factor +++ b/core/system/system.factor @@ -24,6 +24,8 @@ UNION: unix bsd solaris linux haiku ; : os ( -- class ) \ os get-global ; foldable +: vm-compiler ( -- string ) \ vm-compiler get-global ; foldable + cpu ( str -- class ) diff --git a/vm/factor.cpp b/vm/factor.cpp index fb14336ae4..4433095173 100755 --- a/vm/factor.cpp +++ b/vm/factor.cpp @@ -136,6 +136,7 @@ void factor_vm::init_factor(vm_parameters *p) special_objects[OBJ_EXECUTABLE] = allot_alien(false_object,(cell)p->executable_path); special_objects[OBJ_ARGS] = false_object; special_objects[OBJ_EMBEDDED] = false_object; + special_objects[OBJ_VM_COMPILER] = allot_alien(false_object,(cell)FACTOR_COMPILER_VERSION); /* We can GC now */ gc_off = false; diff --git a/vm/master.hpp b/vm/master.hpp index 70736c1bd9..9ba4ebd64b 100755 --- a/vm/master.hpp +++ b/vm/master.hpp @@ -29,6 +29,19 @@ #include #include +/* Record compiler version */ +#if defined(__clang__) + #define FACTOR_COMPILER_VERSION "Clang (GCC " __VERSION__ ")" +#elif defined(__INTEL_COMPILER) + #define FACTOR_COMPILER_VERSION "Intel C Compiler " #__INTEL_COMPILER +#elif defined(__GNUC__) + #define FACTOR_COMPILER_VERSION "GCC " __VERSION__ +#elif defined(_MSC_FULL_VER) + #define FACTOR_COMPILER_VERSION "Microsoft Visual C++ " #_MSC_FULL_VER +#else + #define FACTOR_COMPILER_VERSION "unknown" +#endif + /* Detect target CPU type */ #if defined(__arm__) #define FACTOR_ARM diff --git a/vm/objects.hpp b/vm/objects.hpp index fdc5758a8d..2d777ac516 100644 --- a/vm/objects.hpp +++ b/vm/objects.hpp @@ -95,6 +95,8 @@ enum special_object { OBJ_THREADS = 64, OBJ_RUN_QUEUE = 65, OBJ_SLEEP_QUEUE = 66, + + OBJ_VM_COMPILER = 67, /* version string of the compiler we were built with */ }; /* save-image-and-exit discards special objects that are filled in on startup