[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mountlist missing sys/sysmacros.h include

From: Pádraig Brady
Subject: Re: mountlist missing sys/sysmacros.h include
Date: Wed, 9 Mar 2016 11:18:46 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 08/03/16 02:18, Mike Frysinger wrote:
lib/mountlist.c assumes that sys/types.h includes sys/sysmacros.h
directly in order to provide makedev().  when it doesn't, things
fall apart like:
mountlist.c: In function 'read_file_system_list':
mountlist.c:532:26: warning: implicit declaration of function 'makedev' 
        me->me_dev = makedev (devmaj, devmin);
.../libgnulib.a(mountlist.o): In function `read_file_system_list':
.../mountlist.c:532: undefined reference to `makedev'
collect2: error: ld returned 1 exit status

configure output looks like:
checking sys/mkdev.h usability... no
checking sys/mkdev.h presence... no
checking for sys/mkdev.h... no
checking whether sys/types.h defines makedev... no
checking for sys/mkdev.h... (cached) no
checking sys/sysmacros.h usability... yes
checking sys/sysmacros.h presence... yes
checking for sys/sysmacros.h... yes

autoconf provides a AC_HEADER_MAJOR helper specifically for this:
        If sys/types.h does not define major, minor, and makedev, but
        sys/mkdev.h does, define MAJOR_IN_MKDEV; otherwise, if
        sys/sysmacros.h does, define MAJOR_IN_SYSMACROS.

lib/ptsname_r.c could probably do with a bit of cleanup in this area too.

This would be for BSD userspace on Linux kernel I suppose.
Yes I noted previously that if ever porting this part of read_file_system_list()
that it would be worth creating a makedev gnulib module
to wrap all these differences. The basis would be this from coreutils:

/* Since major is a function on SVR4, we can't use 'ifndef major'.  */
# include <sys/mkdev.h>
# define HAVE_MAJOR
# include <sys/sysmacros.h>
# define HAVE_MAJOR
#ifdef major                    /* Might be defined in sys/types.h.  */
# define HAVE_MAJOR

#ifndef HAVE_MAJOR
# define major(dev)  (((dev) >> 8) & 0xff)
# define minor(dev)  ((dev) & 0xff)
# define makedev(maj, min)  (((maj) << 8) | (min))

#if ! defined makedev && defined mkdev
# define makedev(maj, min)  mkdev (maj, min)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]