Bug 12533

Summary: Endianness and bit swapping in Mac OS X
Product: xorg Reporter: Peter Dyballa <Peter_Dyballa>
Component: Lib/pciaccessAssignee: Jeremy Huddleston Sequoia <jeremyhu>
Status: RESOLVED WONTFIX QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: 7.2 (2007.02)   
Hardware: PowerPC   
OS: Mac OS X (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
Patch to endianness and bit swapping failure in Mac OS X none

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.