Bug 31133

Summary: libpciaccess v0.12.0 build error on Solaris 10 x86
Product: xorg Reporter: Rajesh <rmandalemula>
Component: Lib/pciaccessAssignee: Alan Coopersmith <alan.coopersmith>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: All   
OS: Solaris   
Whiteboard:
i915 platform: i915 features:

Description Rajesh 2010-10-26 08:15:03 UTC
[I am building using Sun Studio cc v12.1]

While building libpciaccess v0.12.0 on Solaris 10 x86, I get the below error:

<<<<>>>>
"scanpci.c", line 38: cannot find include file: <err.h>
"scanpci.c", line 216: warning: implicit function declaration: err
cc: acomp failed for scanpci.c
<<<<>>>>

The below patch to src/scanpci.c fixes the issue:

<<<<>>>
--- libpciaccess-0.12.0/src/scanpci.c~ 2009-02-13 05:17:58
+++ libpciaccess-0.12.0/src/scanpci.c  2010-10-26 20:41:43
@@ -24,7 +24,19 @@

 #include <stdlib.h>
 #include <stdio.h>
-#include <err.h>
+#ifdef sun
+# include <errno.h>
+# define err(exitcode, format, args...) \
+   errx(exitcode, format ": %s", ## args, strerror(errno))
+# define errx(exitcode, format, args...) \
+   { warnx(format, ## args); exit(exitcode); }
+# define warn(format, args...) \
+   warnx(format ": %s", ## args, strerror(errno))
+# define warnx(format, args...) \
+   fprintf(stderr, format "\n", ## args)
+#else
+# include <err.h>
+#endif
 #include <unistd.h>
<<<<>>>

Thanks.  Rajesh
Comment 1 Alan Coopersmith 2010-10-26 08:27:17 UTC
#ifdef sun is incorrect since Solaris 11 & OpenSolaris have those
functions (which is why I didn't notice this).

It needs to be a configure.ac check for the err() functions/err.h header.
Comment 2 Jeremy Huddleston Sequoia 2011-10-09 03:54:14 UTC
commit b9c5ce8083be53ea017bd15a63b173b4476fff23
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Sun Oct 9 03:53:05 2011 -0700

    scanpci: Build fix for systems without <err.h>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=31133
    
    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>

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.