You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by pq...@apache.org on 2009/01/04 03:06:53 UTC

svn commit: r731157 - /apr/apr/trunk/build/aprenv.py

Author: pquerna
Date: Sat Jan  3 18:06:53 2009
New Revision: 731157

URL: http://svn.apache.org/viewvc?rev=731157&view=rev
Log:
Add check for Big Endianess via python's struct module.

Modified:
    apr/apr/trunk/build/aprenv.py

Modified: apr/apr/trunk/build/aprenv.py
URL: http://svn.apache.org/viewvc/apr/apr/trunk/build/aprenv.py?rev=731157&r1=731156&r2=731157&view=diff
==============================================================================
--- apr/apr/trunk/build/aprenv.py (original)
+++ apr/apr/trunk/build/aprenv.py Sat Jan  3 18:06:53 2009
@@ -183,6 +183,18 @@
     context.Result(result[0])
     return result[0]
 
+  def Check_apr_big_endian(self, context):
+    context.Message("Checking for big endianess... ")
+    import struct
+    array = struct.pack('cccc', '\x01', '\x02', '\x03', '\x04')
+    i = struct.unpack('i', array)
+    if i == struct.unpack('>i', array):
+      context.Result('yes')
+      return 1
+    else:
+      context.Result('no')
+      return 0
+
   def critical_value(self, f, value, *args):
     rv = f(*args)
 
@@ -209,11 +221,13 @@
     conf = self.Configure(custom_tests = {
                             'Check_apr_atomic_builtins': self.Check_apr_atomic_builtins,
                             'Check_apr_largefile64': self.Check_apr_largefile64,
+                            'Check_apr_big_endian': self.Check_apr_big_endian,
                             },
                           config_h = 'include/arch/%s/apr_private.h' % (self['APR_PLATFORM']))
 
     # Do we have a working C Compiler?
     self.critical(conf.CheckCC)
+
     flag_headers = self.Split("""ByteOrder.h
     conio.h
     crypt.h
@@ -300,6 +314,10 @@
     sizeof_off_t = conf.CheckTypeSize('off_t', includes='#include <sys/types.h>')
     sizeof_size_t = conf.CheckTypeSize('size_t')
 
+    if conf.Check_apr_big_endian():
+      subst['@bigendian@'] = 1
+    else:
+      subst['@bigendian@'] = 0
     # Now we need to find what apr_int64_t (sizeof == 8) will be.
     # The first match is our preference.
     if sizeof_int == 8:



Re: svn commit: r731157 - /apr/apr/trunk/build/aprenv.py

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
pquerna@apache.org wrote:
> Author: pquerna
> Date: Sat Jan  3 18:06:53 2009
> New Revision: 731157
> 
> URL: http://svn.apache.org/viewvc?rev=731157&view=rev
> Log:
> Add check for Big Endianess via python's struct module.

You do realize you can't use python's config to determine the proper
mechanics of the cl environment?  Especially with cross compiles,
microcode emulators, word size etc.