gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] Removal of DFA_ENABLE #ifdefs


From: Teun Burgers
Subject: [gnugo-devel] Removal of DFA_ENABLE #ifdefs
Date: Thu, 08 Nov 2001 23:12:02 +0100

This patch removes the DFA_ENABLE #ifdefs.
Note that this does not make the DFA the default:
it only means that the DFA code is always compiled.
It does not obsolete the --enable-dfa option

This has 2 benefits:
- reduces risk of DFA code getting out of sync
- Switching to DFA only requires rebuilding
  the DFA .c and .o files, libpatterns.a and
  a relink of gnugo

Teun
Index: engine/interface.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v
retrieving revision 1.9
diff -u -r1.9 interface.c
--- engine/interface.c  2001/10/09 23:05:14     1.9
+++ engine/interface.c  2001/11/08 22:04:37
@@ -39,9 +39,7 @@
  * once only.
  */
 
-#if DFA_ENABLED
 extern void dfa_match_init(void);
-#endif
 
 void
 init_gnugo(float memory)
@@ -49,9 +47,7 @@
   reading_cache_init(memory * 1024 * 1024);
   clear_board();
 
-#if DFA_ENABLED
   dfa_match_init();
-#endif
 }
 
 
Index: engine/matchpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v
retrieving revision 1.13
diff -u -r1.13 matchpat.c
--- engine/matchpat.c   2001/10/26 07:21:11     1.13
+++ engine/matchpat.c   2001/11/08 22:04:40
@@ -57,9 +57,7 @@
   for (; pattern->patn; ++pattern) {
     pattern->hits = 0;
     pattern->reading_nodes = 0;
-#if DFA_ENABLED
     pattern->dfa_hits = 0;
-#endif
   }
 }
 #endif
@@ -74,12 +72,8 @@
     if (pattern->hits > 0) {
       *total_hits += pattern->hits;
       *total_nodes += pattern->reading_nodes;
-#if DFA_ENABLED 
       *total_dfa_hits += pattern->dfa_hits;
       fprintf(stderr, "%6d ", pattern->dfa_hits);
-#else
-      *total_dfa_hits = 0;
-#endif
       fprintf(stderr, "%6d %9d %8.1f %s\n", 
              pattern->hits,
              pattern->reading_nodes,
@@ -635,7 +629,6 @@
 /* DFA matcher:                                                           */
 /**************************************************************************/
 
-#if DFA_ENABLED
 /* If DFA_SORT, all matched patterns are sorted and checked 
  * in the same order as the standard scheme */
 #define DFA_SORT 1
@@ -993,10 +986,7 @@
 }
 
 
-#endif /* DFA_ENABLED */
 
-
-
 /**************************************************************************/
 /* Main functions:                                                        */
 /**************************************************************************/
@@ -1061,13 +1051,11 @@
   }
 
   /* select pattern matching strategy */
-#if DFA_ENABLED > 0
   if (pdb->pdfa != NULL)
     { 
       loop = dfa_matchpat_loop;
       prepare = dfa_prepare_for_match;
     }
-#endif
 
   /* select strategy */
   switch(color)
Index: patterns/mkpat.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v
retrieving revision 1.26
diff -u -r1.26 mkpat.c
--- patterns/mkpat.c    2001/11/06 16:36:51     1.26
+++ patterns/mkpat.c    2001/11/08 22:04:48
@@ -70,9 +70,7 @@
 #include "patterns.h"
 #include "gg-getopt.h"
 
-#if DFA_ENABLED
 #include "dfa.h"
-#endif
 
 #define PATTERNS    0
 #define CONNECTIONS 1
@@ -308,11 +306,9 @@
 int choose_best_anchor = 0;  /* -m */
 
 int fullboard = 0;   /* Whether this is a database of fullboard patterns. */
-#if DFA_ENABLED
 int dfa_generate = 0; /* if 1 a dfa is created. */
 int dfa_c_output = 0; /* if 1 the dfa is saved as a c file */
 dfa_t dfa;
-#endif
 
 
 /**************************
@@ -387,7 +383,6 @@
   pattern[patno].maxj = maxj - cj;
 }
 
-#if DFA_ENABLED
 
 /*
  * Here we build the dfa.
@@ -423,8 +418,6 @@
 }
 
 
-#endif
-
 /* For good performance, we want to reject patterns as quickly as
  * possible. For each pattern, this combines 16 positions around
  * the anchor stone into a 32-bit mask and value. In the matcher,
@@ -1366,9 +1359,7 @@
     fprintf(outfile, ",%d", p->anchored_at_X);
 #if PROFILE_PATTERNS
     fprintf(outfile, ",0,0");
-#if DFA_ENABLED
     fprintf(outfile, ",0");
-#endif /* DFA_ENABLED */
 #endif
 
     fprintf(outfile, "},\n");
@@ -1387,9 +1378,7 @@
   fprintf(outfile, ",0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0,NULL,NULL,0");
 #if PROFILE_PATTERNS
   fprintf(outfile, ",0,0");
-#if DFA_ENABLED
     fprintf(outfile, ",0");
-#endif /* DFA_ENABLED */
 #endif
   fprintf(outfile, "}\n};\n");
 }
@@ -1407,12 +1396,10 @@
   fprintf(outfile, "struct pattern_db %s_db = {\n", name);
   fprintf(outfile, "  -1,\n");
   fprintf(outfile, "  %s\n", name);
-#if DFA_ENABLED
   if (dfa_c_output)
     fprintf(outfile, " ,& dfa_%s\n", name); /* pointer to the wired dfa */
   else
     fprintf(outfile, " , NULL\n"); /* pointer to a possible dfa */
-#endif
   fprintf(outfile, "};\n");
 }
 
@@ -1430,11 +1417,7 @@
   
   {
     /* parse command-line args */
-#if DFA_ENABLED
     while ((i = gg_getopt(argc, argv, "i:o:V:vcbXfmtD")) != EOF) {
-#else
-    while ((i = gg_getopt(argc, argv, "i:o:vcbXfm")) != EOF) {
-#endif
       switch(i) {
       case 'v': verbose = 1; break;
       case 'c': pattern_type = CONNECTIONS; break;
@@ -1444,13 +1427,11 @@
       case 'm': choose_best_anchor = 1; break;
       case 'i': input_file_name = gg_optarg; break;
       case 'o': output_file_name = gg_optarg; break;
-#if DFA_ENABLED
       case 'D':
        dfa_generate = 1; dfa_c_output = 1; 
        break;
       case 'V': dfa_verbose = strtol(gg_optarg, NULL, 10); break;
 
-#endif
       default:
        fprintf(stderr, "Invalid argument ignored\n");
       }
@@ -1480,12 +1461,10 @@
   }
 
 
-#if DFA_ENABLED
   if (dfa_generate) {
     dfa_init();
     new_dfa(&dfa, "mkpat's dfa");
   }
-#endif 
 
   if (gg_optind >= argc) {
     fputs(USAGE, stderr);
@@ -1613,10 +1592,8 @@
       if (state == 2 || state == 3) {
        finish_pattern(line);
        write_elements(output_FILE, argv[gg_optind]);
-#if DFA_ENABLED
        if (dfa_generate)
          write_to_dfa(patno);
-#endif
        state = 4;
       }
       else {
@@ -1693,7 +1670,6 @@
 
   write_patterns(output_FILE, argv[gg_optind]);
 
-#if DFA_ENABLED
   if (dfa_generate) {
     fprintf(stderr, "---------------------------\n");
     fprintf(stderr, "dfa for %s\n", argv[gg_optind]);
@@ -1710,7 +1686,6 @@
     kill_dfa(&dfa);
     dfa_end();
   }
-#endif
 
 
   write_pattern_db(output_FILE, argv[gg_optind]);
Index: patterns/patterns.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/patterns.h,v
retrieving revision 1.12
diff -u -r1.12 patterns.h
--- patterns/patterns.h 2001/10/26 07:21:11     1.12
+++ patterns/patterns.h 2001/11/08 22:04:50
@@ -30,11 +30,9 @@
 #ifndef __PATTERN_H__
 #define __PATTERN_H__
 
-#if DFA_ENABLED
 #ifndef _DFA_H_
 #include "dfa.h"
 #endif
-#endif
 
 /* local versions of absolute value, min and max */
 
@@ -240,9 +238,7 @@
   int anchored_at_X;    /* 3 if the pattern has 'X' at the anchor posn */
 #if PROFILE_PATTERNS
   int hits;
-#if DFA_ENABLED
   int dfa_hits;
-#endif
   int reading_nodes;
 #endif
 };
@@ -250,9 +246,7 @@
 struct pattern_db {
   int  fixed_for_size;
   struct pattern *patterns;
-#if DFA_ENABLED
   struct dfa *pdfa;
-#endif
 };
 
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]