lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r464366 - in /lucene/lucy/trunk/charmonizer: ./ src/ src/Charmonizer/
Date Mon, 16 Oct 2006 02:58:56 GMT
Author: marvin
Date: Sun Oct 15 19:58:55 2006
New Revision: 464366

URL: http://svn.apache.org/viewvc?view=rev&rev=464366
Log:
Charmonizer probes now load "_charm.h" and invoke a macro called Charm_Setup.
chaz_init() and chaz_clean_up() added.  

Modified:
    lucene/lucy/trunk/charmonizer/charmonize.c
    lucene/lucy/trunk/charmonizer/src/Charmonizer.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer.harm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm
    lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm

Modified: lucene/lucy/trunk/charmonizer/charmonize.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/charmonize.c?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/charmonize.c (original)
+++ lucene/lucy/trunk/charmonizer/charmonize.c Sun Oct 15 19:58:55 2006
@@ -64,6 +64,7 @@
     if (fclose(config_fh))
         die("Error closing file '%s': %s", outpath, strerror(errno));
     free(outpath);
+    chaz_clean_up();
 
     return 0;
 }
@@ -84,6 +85,7 @@
     outpath  = extract_delim(infile_contents, infile_len, "charm_outpath");
     
     /* set up Charmonizer */
+    chaz_init();
     chaz_set_prefixes("LUCY_", "Lucy_", "lucy_", "lucy_");
     chaz_set_compiler(compiler);
     chaz_set_ccflags(ccflags);

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer.charm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer.charm Sun Oct 15 19:58:55 2006
@@ -6,6 +6,18 @@
 #include "Charmonizer.h"
 #include "Charmonizer/Core.h"
 
+void
+chaz_init()
+{
+    write_charm_h();
+}
+
+void
+chaz_clean_up()
+{
+    remove("_charm.h");
+}
+
 void 
 chaz_set_compiler(char* comp_cmd) 
 {

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer.harm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer.harm Sun Oct 15 19:58:55 2006
@@ -3,6 +3,18 @@
 
 #include <stddef.h>
 
+/* Set up the Charmonizer environment.  This should be called before anything
+ * else.
+ */
+void
+chaz_init();
+
+/* Clean up the Charmonizer environment -- deleting tempfiles, etc.  This
+ * should be called only after everything else finishes.
+ */
+void
+chaz_clean_up();
+
 /* Tell Charmonizer the name of the compiler it should use.
  */
 void

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.charm Sun Oct 15 19:58:55 2006
@@ -16,6 +16,29 @@
 static char *command_buf = NULL;
 static size_t command_buf_len = 0;
 
+static char charm_h_code[] = METAQUOTE
+    #ifndef CHARM_H
+    #define CHARM_H 1
+
+    #include <stdio.h>
+
+    #define Charm_Setup \
+        freopen("_charmonizer_target", "w", stdout)
+    
+    #endif
+METAQUOTE;
+
+void
+write_charm_h()
+{
+    FILE *fh = fopen("_charm.h", "w+");
+    if (fh == NULL)
+        die("Couldn't open '_charm.h': %s", strerror(errno));
+    fprintf(fh, "%s\n", charm_h_code);
+    if (fclose(fh))
+        die("Error when closing '_charm.h': %s", strerror(errno));
+}
+
 char*
 capture_output(char *source, size_t source_len, size_t *output_len) 
 {
@@ -57,7 +80,7 @@
      * yet be able to recover it later, so we're stuck seeing the
      * errors when something fails.
      */
-    sprintf(command_buf, "%s " TRY_SOURCE_PATH " -o " TRY_APP_PATH " %s", 
+    sprintf(command_buf, "%s " TRY_SOURCE_PATH " -o " TRY_APP_PATH " -I. %s", 
         compiler, ccflags);
     system(command_buf);
 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core.harm Sun Oct 15 19:58:55 2006
@@ -28,6 +28,11 @@
 extern char *chaz_Core_typedef_prefix;
 extern char *chaz_Core_function_prefix;
 
+/* Write the "_charm.h" file used by every probe.
+ */
+void
+chaz_Core_write_charm_h();
+
 /* Attempt to compile the supplied source code.  If successful, capture the 
  * output of the program and return a pointer to a newly allocated buffer.
  * If the compilation fails, return NULL.  The length of the captured 
@@ -90,6 +95,7 @@
 # define macro_prefix           chaz_Core_macro_prefix
 # define typedef_prefix         chaz_Core_typedef_prefix
 # define function_prefix        chaz_Core_function_prefix
+# define write_charm_h          chaz_Core_write_charm_h
 # define capture_output         chaz_Core_capture_output 
 # define slurp_file             chaz_Core_slurp_file 
 # define flength                chaz_Core_flength 

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/FuncMacro.charm Sun Oct 15 19:58:55 2006
@@ -7,18 +7,18 @@
 
 
 static char iso_func_code[] = METAQUOTE
-    #include <stdio.h>
+    #include "_charm.h" 
     int main() {
-        freopen("_charmonizer_target", "w", stdout);
+        Charm_Setup;
         printf("%s", __func__);
         return 0;
     }
 METAQUOTE;
 
 static char gnuc_func_code[] = METAQUOTE
-    #include <stdio.h>
+    #include "_charm.h" 
     int main() {
-        freopen("_charmonizer_target", "w", stdout);
+        Charm_Setup;
         printf("%s", __FUNCTION__);
         return 0;
     }

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm Sun Oct 15 19:58:55 2006
@@ -8,9 +8,9 @@
 
 static char sizes_code[] = 
     METAQUOTE
-        #include <stdio.h>
+        #include "_charm.h"
         int main () {
-            freopen("_charmonizer_target", "w", stdout);
+            Charm_Setup;
             printf("%d %d %d %d %d",
                 (int)sizeof(char),
                 (int)sizeof(short),
@@ -24,11 +24,11 @@
 
 static char inttypes_code[] = 
     METAQUOTE
-        #include <stdio.h>
+        #include "_charm.h"
         #include <inttypes.h>
         int main()
         {
-            freopen("_charmonizer_target", "w", stdout);
+            Charm_Setup;
             printf("We have inttypes.h\n");
             return 0;
         }
@@ -36,10 +36,10 @@
 
 static char long_long_code[] = 
     METAQUOTE
-        #include <stdio.h>
+        #include "_charm.h"
         int main() 
         {
-            freopen("_charmonizer_target", "w", stdout);
+            Charm_Setup;
             long long foo = 4;
             printf("%d", (int)sizeof(long long));
             return 0;

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/LargeFiles.charm Sun Oct 15 19:58:55 2006
@@ -7,11 +7,11 @@
 #include <stdio.h>
 
 static char ftello_code[] = METAQUOTE
-    #include <stdio.h>
+    #include "_charm.h"
     #include <sys/types.h>
     int main() {
         off_t foo;
-        freopen("_charmonizer_target", "w", stdout);
+        Charm_Setup;
         printf("%d", (int)sizeof(off_t));
         foo = ftello(stdout);
         fseeko(stdout, 0, SEEK_SET);
@@ -20,10 +20,10 @@
 METAQUOTE;
 
 static char ftello64_code[] = METAQUOTE
-    #include <stdio.h>
+    #include "_charm.h"
     int main() {
         off64_t foo;
-        freopen("_charmonizer_target", "w", stdout);
+        Charm_Setup;
         printf("%d", (int)sizeof(off64_t));
         foo = ftello64(stdout);
         fseeko64(stdout, 0, SEEK_SET);
@@ -32,9 +32,9 @@
 METAQUOTE;
 
 static char sizeof_long_code[] = METAQUOTE
-    #include <stdio.h>
+    #include "_charm.h"
     int main() {
-        freopen("_charmonizer_target", "w", stdout);
+        Charm_Setup;
         printf("%d\n", (int)sizeof(long));
         return 0;
     }

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm?view=diff&rev=464366&r1=464365&r2=464366
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/VariadicMacros.charm Sun Oct 15 19:58:55
2006
@@ -7,22 +7,22 @@
 
 
 static char iso_code[] = METAQUOTE
-    #include <stdio.h>
+    #include "_charm.h"
     #define ISO_TEST(fmt, ...) \
         printf(fmt, __VA_ARGS__)
     int main() {
-        freopen("_charmonizer_target", "w", stdout);
+        Charm_Setup;
         ISO_TEST("%d %d", 1, 1);
         return 0;
     }
 METAQUOTE;
 
 static char gnuc_code[] = METAQUOTE
-    #include <stdio.h>
+    #include "_charm.h"
     #define GNU_TEST(fmt, args...) \
         printf(fmt, ##args)
     int main() {
-        freopen("_charmonizer_target", "w", stdout);
+        Charm_Setup;
         GNU_TEST("%d %d", 1, 1);
         return 0;
     }



Mime
View raw message