[Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.71,2.72
Fred L. Drake
python-dev@python.org
Mon, 14 Aug 2000 08:47:06 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv683/Python
Modified Files:
sysmodule.c
Log Message:
Add a byte_order value to the sys module. The value is "big" for
big-endian machines and "little" for little-endian machines.
Index: sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.71
retrieving revision 2.72
diff -C2 -r2.71 -r2.72
*** sysmodule.c 2000/07/24 16:06:23 2.71
--- sysmodule.c 2000/08/14 15:47:03 2.72
***************
*** 457,460 ****
--- 457,473 ----
v = list_builtin_module_names());
Py_XDECREF(v);
+ {
+ /* Assumes that longs are at least 2 bytes long.
+ Should be safe! */
+ unsigned long number = 1;
+
+ s = (char *) &number;
+ if (s[0] == 0)
+ PyDict_SetItemString(sysdict, "byte_order",
+ PyString_FromString("big"));
+ else
+ PyDict_SetItemString(sysdict, "byte_order",
+ PyString_FromString("little"));
+ }
#ifdef MS_COREDLL
PyDict_SetItemString(sysdict, "dllhandle",