[PATCH v2] configure.ac: use AC_HEADER_MAJOR to detect major()/minor()

Pekka Paalanen ppaalanen at gmail.com
Tue Dec 12 08:28:39 UTC 2017


On Mon, 11 Dec 2017 16:16:47 +0200
Pekka Paalanen <ppaalanen at gmail.com> wrote:

> On Wed, 31 May 2017 22:17:50 +0100
> Sergei Trofimovich <slyfox at gentoo.org> wrote:
> 
> > This change slightly updates c4d7f66c12853b9575366dd9f4a7960ec5694934
> > which added <sys/sysmacros.h> inclusion.
> > 
> > Autoconf has AC_HEADER_MAJOR to find out which header defines
> > reqiured macros:
> >     https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html
> > 
> > This change should increase portability across other libcs.
> > 
> > Bug: https://bugs.gentoo.org/610652
> > Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>
> > ---
> > Change since v1:
> > - rebased on top of current master
> > - dedented nested '#    include'
> >  configure.ac                       | 1 +
> >  libweston/launcher-direct.c        | 9 ++++++++-
> >  libweston/launcher-logind.c        | 9 ++++++++-
> >  libweston/launcher-weston-launch.c | 8 +++++++-
> >  libweston/weston-launch.c          | 9 ++++++++-
> >  5 files changed, 32 insertions(+), 4 deletions(-)  
> 
> Hi,
> 
> I'm on Gentoo with sys-libs/glibc-2.25-r9:2.2 and I am now getting a
> bunch of warnings like this:
> 
> /home/pq/git/weston/libweston/weston-launch.c: In function ‘handle_open’:
> /home/pq/git/weston/libweston/weston-launch.c:333:13: warning: In the GNU C Library, "major" is defined
>  by <sys/sysmacros.h>. For historical compatibility, it is
>  currently defined by <sys/types.h> as well, but we plan to
>  remove this soon. To use "major", include <sys/sysmacros.h>
>  directly. If you did not intend to use a system-defined macro
>  "major", you should undefine it after including <sys/types.h>.
>   if (major(s.st_rdev) != INPUT_MAJOR &&
> 
> 
> Reverting this patch makes the warnings go away.
> 
> What's the right fix here?
> 
> In config.h I have:
> 
> /* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
>    */
> /* #undef MAJOR_IN_MKDEV */
> 
> /* Define to 1 if `major', `minor', and `makedev' are declared in
>    <sysmacros.h>. */
> /* #undef MAJOR_IN_SYSMACROS */
> 
> I'm not sure what I needed to do get even that far, maybe wipe my
> out-of-tree build dir. Even then, I cannot find any evidence of
> configure actually running the tests. I always start a new build dir by
> running autogen.sh.

Hi,

there is an email thread of the problem from a slightly different point
of view:
https://lists.gnu.org/archive/html/autoconf/2016-09/msg00000.html

If we keep the code as is, the warning will not go away until glibc
actually drops the things from sys/types.h and distros ship it.
Apparently there is a workaround one could make with config.site:
https://lists.gnu.org/archive/html/autoconf/2016-09/msg00013.html

Or we could wait for a new autoconf release and require it, but the
discussion happened in 2016 and at least Gentoo does not have a
autoconf 2.70 yet. Or we could ship a fixed AC_HEADER_MAJOR.

Or we could just revert this patch until something in the above changes
or we have migrated to Meson.

Proposals?

The warnings are quite annoying. I would be for reverting the patch.


Thanks,
pq

> > 
> > diff --git a/configure.ac b/configure.ac
> > index db757f20..ff89c3a4 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -34,6 +34,7 @@ AC_CONFIG_MACRO_DIR([m4])
> >  
> >  AC_USE_SYSTEM_EXTENSIONS
> >  AC_SYS_LARGEFILE
> > +AC_HEADER_MAJOR
> >  
> >  AM_INIT_AUTOMAKE([1.11 parallel-tests foreign no-dist-gzip dist-xz color-tests subdir-objects])
> >  
> > diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
> > index a5d3ee53..b4ca609a 100644
> > --- a/libweston/launcher-direct.c
> > +++ b/libweston/launcher-direct.c
> > @@ -33,7 +33,6 @@
> >  #include <unistd.h>
> >  #include <signal.h>
> >  #include <sys/stat.h>
> > -#include <sys/sysmacros.h>
> >  #include <sys/ioctl.h>
> >  #include <linux/vt.h>
> >  #include <linux/kd.h>
> > @@ -47,6 +46,14 @@
> >  #define KDSKBMUTE	0x4B51
> >  #endif
> >  
> > +/* major()/minor() */
> > +#ifdef MAJOR_IN_MKDEV
> > +#include <sys/mkdev.h>
> > +#endif
> > +#ifdef MAJOR_IN_SYSMACROS
> > +#include <sys/sysmacros.h>
> > +#endif
> > +
> >  #ifdef BUILD_DRM_COMPOSITOR
> >  
> >  #include <xf86drm.h>
> > diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c
> > index f10a2831..3c23d000 100644
> > --- a/libweston/launcher-logind.c
> > +++ b/libweston/launcher-logind.c
> > @@ -35,7 +35,6 @@
> >  #include <stdlib.h>
> >  #include <string.h>
> >  #include <sys/stat.h>
> > -#include <sys/sysmacros.h>
> >  #include <systemd/sd-login.h>
> >  #include <unistd.h>
> >  
> > @@ -45,6 +44,14 @@
> >  
> >  #define DRM_MAJOR 226
> >  
> > +/* major()/minor() */
> > +#ifdef MAJOR_IN_MKDEV
> > +#include <sys/mkdev.h>
> > +#endif
> > +#ifdef MAJOR_IN_SYSMACROS
> > +#include <sys/sysmacros.h>
> > +#endif
> > +
> >  struct launcher_logind {
> >  	struct weston_launcher base;
> >  	struct weston_compositor *compositor;
> > diff --git a/libweston/launcher-weston-launch.c b/libweston/launcher-weston-launch.c
> > index 97da18c5..3d3b4d2f 100644
> > --- a/libweston/launcher-weston-launch.c
> > +++ b/libweston/launcher-weston-launch.c
> > @@ -34,7 +34,6 @@
> >  #include <errno.h>
> >  #include <signal.h>
> >  #include <sys/socket.h>
> > -#include <sys/sysmacros.h>
> >  #include <sys/types.h>
> >  #include <sys/stat.h>
> >  #include <sys/uio.h>
> > @@ -75,6 +74,13 @@ drmSetMaster(int drm_fd)
> >  
> >  #endif
> >  
> > +/* major()/minor() */
> > +#ifdef MAJOR_IN_MKDEV
> > +#include <sys/mkdev.h>
> > +#endif
> > +#ifdef MAJOR_IN_SYSMACROS
> > +#include <sys/sysmacros.h>
> > +#endif
> >  
> >  union cmsg_data { unsigned char b[4]; int fd; };
> >  
> > diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
> > index aa7e0711..a15f053e 100644
> > --- a/libweston/weston-launch.c
> > +++ b/libweston/weston-launch.c
> > @@ -42,7 +42,6 @@
> >  #include <sys/wait.h>
> >  #include <sys/socket.h>
> >  #include <sys/signalfd.h>
> > -#include <sys/sysmacros.h>
> >  #include <signal.h>
> >  #include <unistd.h>
> >  #include <fcntl.h>
> > @@ -93,6 +92,14 @@ drmSetMaster(int drm_fd)
> >  
> >  #endif
> >  
> > +/* major()/minor() */
> > +#ifdef MAJOR_IN_MKDEV
> > +#    include <sys/mkdev.h>
> > +#endif
> > +#ifdef MAJOR_IN_SYSMACROS
> > +#    include <sys/sysmacros.h>
> > +#endif
> > +
> >  struct weston_launch {
> >  	struct pam_conv pc;
> >  	pam_handle_t *ph;  
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20171212/7cfef614/attachment-0001.sig>


More information about the wayland-devel mailing list