lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r464787 - in /lucene/lucy/trunk/charmonizer/src/Charmonizer: Integers.charm Integers.harm
Date Tue, 17 Oct 2006 03:57:04 GMT
Author: marvin
Date: Mon Oct 16 20:57:03 2006
New Revision: 464787

URL: http://svn.apache.org/viewvc?view=rev&rev=464787
Log:
Add BIG_ENDIAN and LITTLE_ENDIAN.

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

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=464787&r1=464786&r2=464787
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.charm Mon Oct 16 20:57:03 2006
@@ -6,6 +6,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+/* Determine endian-ness of this machine.
+ */
+static chaz_bool_t
+machine_is_big_endian();
+
 static char sizes_code[] = METAQUOTE
     #include "_charm.h"
     int main () {
@@ -63,6 +68,12 @@
 
     Start_Run(conf_fh, "Integers");
 
+    /* document endian-ness */
+    if (machine_is_big_endian())
+        fprintf(conf_fh, "#define %sBIG_ENDIAN\n", constant_prefix);
+    else 
+        fprintf(conf_fh, "#define %sLITTLE_ENDIAN\n", constant_prefix);
+
     /* Record sizeof() for several common integer types. */
     output = capture_output(sizes_code, strlen(sizes_code), &output_len);
     if (output != NULL) {
@@ -262,6 +273,13 @@
     }
     
     End_Run(conf_fh);
+}
+
+static chaz_bool_t
+machine_is_big_endian()
+{
+    long one = 1;
+    return !(*((char *)(&one)));
 }
 
 /**

Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.harm?view=diff&rev=464787&r1=464786&r2=464787
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Integers.harm Mon Oct 16 20:57:03 2006
@@ -1,6 +1,11 @@
 /* Charmonizer/Integers.h -- info about integer types and sizes.
  *
- * Defines the following symbols:
+ * One or the other of these will be defined.
+ * 
+ * BIG_ENDIAN
+ * LITTLE_ENDIAN
+ * 
+ * These will always be defined:
  * 
  * SIZEOF_CHAR
  * SIZEOF_SHORT



Mime
View raw message