You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2006/11/05 01:12:50 UTC

svn commit: r471304 - /lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm

Author: marvin
Date: Sat Nov  4 16:12:50 2006
New Revision: 471304

URL: http://svn.apache.org/viewvc?view=rev&rev=471304
Log:
Switch to probing strategy for determining suffixes for 64-bit literals.
Rework detection of 64-bit types slightly.

Modified:
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm?view=diff&rev=471304&r1=471303&r2=471304
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm Sat Nov  4 16:12:50 2006
@@ -8,6 +8,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+static char *code_buf = NULL;
+static size_t code_buf_len = 0;
+
 /* Determine endian-ness of this machine.
  */
 static chaz_bool_t
@@ -28,22 +31,23 @@
     }
 METAQUOTE;
 
-static char long_long_code[] = METAQUOTE
+static char type64_code[] = METAQUOTE
     #include "_charm.h"
     int main() 
     {
         Charm_Setup;
-        printf("%d", (int)sizeof(long long));
+        printf("%%d", (int)sizeof(%s));
         return 0;
     }
 METAQUOTE;
 
-static char __int64_code[] = METAQUOTE
+static char literal64_code[] = METAQUOTE
     #include "_charm.h"
-    int main() 
+    #define big 9000000000000000000%s
+    int main()
     {
         Charm_Setup;
-        printf("%d", (int)sizeof(__int64));
+        printf("1\n");
         return 0;
     }
 METAQUOTE;
@@ -99,16 +103,18 @@
     }
 
     /* determine whether long longs are available */
-    output = capture_output(long_long_code, strlen(long_long_code),
-        &output_len);
+    code_buf_len = grow_buf(&code_buf, code_buf_len, 
+        sizeof(type64_code) + 200);
+    sprintf(code_buf, type64_code, "long long");
+    output = capture_output(code_buf, strlen(code_buf), &output_len);
     if (output != NULL) {
         has_long_long    = true;
         sizeof_long_long = strtol(output, NULL, 10);
     }
 
     /* determine whether the __int64 type is available */
-    output = capture_output(__int64_code, strlen(__int64_code),
-        &output_len);
+    sprintf(code_buf, type64_code, "__int64");
+    output = capture_output(code_buf, strlen(code_buf), &output_len);
     if (output != NULL) {
         has___int64 = true;
         sizeof___int64 = strtol(output, NULL, 10);
@@ -136,20 +142,48 @@
     if (sizeof_long == 8) {
         has_64 = true;
         strcpy(i64_t_type, "long");
-        strcpy(i64_t_postfix, "L");
-        strcpy(u64_t_postfix, "UL");
     }
     else if (sizeof_long_long == 8) {
         has_64 = true;
         strcpy(i64_t_type, "long long");
-        strcpy(i64_t_postfix, "LL");
-        strcpy(u64_t_postfix, "LLU");
     }
     else if (sizeof___int64 == 8) {
         has_64 = true;
         strcpy(i64_t_type, "__int64");
-        strcpy(i64_t_postfix, "i64");
-        strcpy(u64_t_postfix, "ui64");
+    }
+
+    /* probe for 64-bit literal syntax */
+    if (has_64 && sizeof_long == 8) {
+        strcpy(i64_t_postfix, "L");
+        strcpy(u64_t_postfix, "UL");
+    }
+    else if (has_64) {
+        sprintf(code_buf, literal64_code, "LL");
+        output = capture_output(code_buf, strlen(code_buf), &output_len);
+        if (output != NULL) {
+            strcpy(i64_t_postfix, "LL");
+        }
+        else {
+            sprintf(code_buf, literal64_code, "i64");
+            output = capture_output(code_buf, strlen(code_buf), &output_len);
+            if (output != NULL)
+                strcpy(i64_t_postfix, "i64");
+            else
+                die("64-bit types, but no literal syntax found");
+        }
+        sprintf(code_buf, literal64_code, "ULL");
+        output = capture_output(code_buf, strlen(code_buf), &output_len);
+        if (output != NULL) {
+            strcpy(u64_t_postfix, "ULL");
+        }
+        else {
+            sprintf(code_buf, literal64_code, "Ui64");
+            output = capture_output(code_buf, strlen(code_buf), &output_len);
+            if (output != NULL)
+                strcpy(u64_t_postfix, "Ui64");
+            else
+                die("64-bit types, but no literal syntax found");
+        }
     }
 
     /* write out some conditional defines */