Bug 12533 - Endianness and bit swapping in Mac OS X
Summary: Endianness and bit swapping in Mac OS X
Status: RESOLVED WONTFIX
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/pciaccess (show other bugs)
Version: 7.2 (2007.02)
Hardware: PowerPC Mac OS X (All)
: medium normal
Assignee: Jeremy Huddleston Sequoia
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
: 14631 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-23 13:11 UTC by Peter Dyballa
Modified: 2008-11-10 10:22 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch to endianness and bit swapping failure in Mac OS X (573 bytes, patch)
2007-09-23 13:15 UTC, Peter Dyballa
no flags Details | Splinter Review

Description Peter Dyballa 2007-09-23 13:11:56 UTC
When compiling on Mac OS X 10.4.10 (Tiger) with GCC 4 I get:

	common_interface.c:62:24: error: sys/endian.h: No such file or directory
	common_interface.c: In function 'pci_device_cfg_read_u16':
	common_interface.c:473: warning: implicit declaration of function 'le16toh'
	common_interface.c:473: warning: nested extern declaration of 'le16toh'
	common_interface.c: In function 'pci_device_cfg_read_u32':
	common_interface.c:489: warning: implicit declaration of function 'le32toh'
	common_interface.c:489: warning: nested extern declaration of 'le32toh'
	common_interface.c: In function 'pci_device_cfg_write_u16':
	common_interface.c:555: warning: implicit declaration of function 'htole16'
	common_interface.c:555: warning: nested extern declaration of 'htole16'
	common_interface.c: In function 'pci_device_cfg_write_u32':
	common_interface.c:572: warning: implicit declaration of function 'htole32'
	common_interface.c:572: warning: nested extern declaration of 'htole32'
	make[2]: *** [common_interface.lo] Error 1
	make[1]: *** [all-recursive] Error 1
	make: *** [all] Error 2
	***** make failed on lib/libpciaccess

There are two reasons:
  1. wrong C header file included
  2. missing macros to convert between host and little or big endian integer formats

A little patch can correct (although I cannot test whether the library actually works: no PCI on board).


--- lib/libpciaccess/src/common_interface.c-orig	2007-09-22 10:35:52.000000000 +0200
+++ lib/libpciaccess/src/common_interface.c	2007-09-23 20:28:13.000000000 +0200
@@ -57,8 +57,14 @@
 #define	LETOH_32(x)	(x)
 #define	HTOLE_32(x)	(x)
 
-#else
+#elif defined(__APPLE__) /* Mac OS X */
+#include <machine/endian.h>
+#define	LETOH_16(x)	OSSwapLittleToHostInt16(x)
+#define	HTOLE_16(x)	OSSwapHostToLittleInt16(x)
+#define	LETOH_32(x)	OSSwapLittleToHostInt32(x)
+#define	HTOLE_32(x)	OSSwapHostToLittleInt32(x)
 
+#else
 #include <sys/endian.h>
 
 #define LETOH_16(x)	le16toh(x)
Comment 1 Peter Dyballa 2007-09-23 13:15:48 UTC
Created attachment 11703 [details] [review]
Patch to endianness and bit swapping failure in Mac OS X

Done with diff (version 2.8.1) -au orig new – is this correct?
Comment 2 Jeremy Huddleston Sequoia 2008-11-08 14:59:13 UTC
Why, exactly, do you want libpciaccess on Mac OSX?
Comment 3 Jeremy Huddleston Sequoia 2008-11-08 15:08:50 UTC
*** Bug 14631 has been marked as a duplicate of this bug. ***
Comment 4 Peter Dyballa 2008-11-10 02:42:59 UTC
It's not me who wants it, the X server seems to need it:

checking for PCIACCESS... configure: error: Package requirements (pciaccess >= 0.8.0) were not met:

No package 'pciaccess' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables PCIACCESS_CFLAGS
and PCIACCESS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
Comment 5 Jeremy Huddleston Sequoia 2008-11-10 09:11:59 UTC
What are you configuring and what are your command line arguments?
Comment 6 Peter Dyballa 2008-11-10 09:55:20 UTC
I'm using the build.sh script which configures this way:

./configure --enable-maintainer-mode --prefix=/usr/X11R7.1 --libdir=/usr/X11R7.1/lib --enable-builddocs --enable-quartz --enable-xorg --with-xcb=yes --enable-xprint --enable-xgl --enable-xglx --enable-xegl --enable-xorgcfg 
Comment 7 Jeremy Huddleston Sequoia 2008-11-10 10:22:28 UTC
Yeah, that's why.  Your configure options are trying to build the xorg ddx which isn't for OSX.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.