1996-08-02 05:27:50 +00:00
|
|
|
/* Definitions of macros to access `dev_t' values.
|
2007-03-17 17:04:28 +00:00
|
|
|
Copyright (C) 1996, 1997, 1999, 2003, 2004, 2007
|
|
|
|
Free Software Foundation, Inc.
|
1996-12-10 03:08:06 +00:00
|
|
|
This file is part of the GNU C Library.
|
1996-08-02 05:27:50 +00:00
|
|
|
|
1996-12-10 03:08:06 +00:00
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1996-08-02 05:27:50 +00:00
|
|
|
|
1996-12-10 03:08:06 +00:00
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1996-08-02 05:27:50 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
1996-08-02 05:27:50 +00:00
|
|
|
|
|
|
|
#ifndef _SYS_SYSMACROS_H
|
|
|
|
#define _SYS_SYSMACROS_H 1
|
|
|
|
|
2003-09-24 05:05:38 +00:00
|
|
|
#include <features.h>
|
|
|
|
|
|
|
|
/* If the compiler does not know long long it is out of luck. We are
|
|
|
|
not going to hack weird hacks to support the dev_t representation
|
|
|
|
they need. */
|
|
|
|
#ifdef __GLIBC_HAVE_LONG_LONG
|
2003-09-29 22:23:14 +00:00
|
|
|
__extension__
|
2007-03-17 17:04:28 +00:00
|
|
|
__extern_inline unsigned int gnu_dev_major (unsigned long long int __dev)
|
2003-09-24 21:13:55 +00:00
|
|
|
__THROW;
|
2003-09-29 22:23:14 +00:00
|
|
|
__extension__
|
2007-03-17 17:04:28 +00:00
|
|
|
__extern_inline unsigned int gnu_dev_minor (unsigned long long int __dev)
|
2003-09-24 21:13:55 +00:00
|
|
|
__THROW;
|
2003-09-29 22:23:14 +00:00
|
|
|
__extension__
|
2007-03-17 17:04:28 +00:00
|
|
|
__extern_inline unsigned long long int gnu_dev_makedev (unsigned int __major,
|
2003-09-29 22:23:14 +00:00
|
|
|
unsigned int __minor)
|
2003-09-24 21:13:55 +00:00
|
|
|
__THROW;
|
2003-09-24 05:05:38 +00:00
|
|
|
|
|
|
|
# if defined __GNUC__ && __GNUC__ >= 2
|
2007-03-17 17:04:28 +00:00
|
|
|
__extension__ __extern_inline unsigned int
|
2004-09-07 22:33:37 +00:00
|
|
|
__NTH (gnu_dev_major (unsigned long long int __dev))
|
2003-09-24 05:05:38 +00:00
|
|
|
{
|
|
|
|
return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
|
|
|
|
}
|
|
|
|
|
2007-03-17 17:04:28 +00:00
|
|
|
__extension__ __extern_inline unsigned int
|
2004-09-07 22:33:37 +00:00
|
|
|
__NTH (gnu_dev_minor (unsigned long long int __dev))
|
2003-09-24 05:05:38 +00:00
|
|
|
{
|
|
|
|
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
|
|
|
|
}
|
|
|
|
|
2007-03-17 17:04:28 +00:00
|
|
|
__extension__ __extern_inline unsigned long long int
|
2004-09-07 22:33:37 +00:00
|
|
|
__NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor))
|
2003-09-24 05:05:38 +00:00
|
|
|
{
|
|
|
|
return ((__minor & 0xff) | ((__major & 0xfff) << 8)
|
|
|
|
| (((unsigned long long int) (__minor & ~0xff)) << 12)
|
|
|
|
| (((unsigned long long int) (__major & ~0xfff)) << 32));
|
|
|
|
}
|
1999-06-16 14:31:04 +00:00
|
|
|
# endif
|
2003-09-24 05:05:38 +00:00
|
|
|
|
|
|
|
|
2003-09-24 21:13:55 +00:00
|
|
|
/* Access the functions with their traditional names. */
|
|
|
|
# define major(dev) gnu_dev_major (dev)
|
|
|
|
# define minor(dev) gnu_dev_minor (dev)
|
|
|
|
# define makedev(maj, min) gnu_dev_makedev (maj, min)
|
1997-08-27 20:26:10 +00:00
|
|
|
#endif
|
1996-08-02 05:27:50 +00:00
|
|
|
|
1999-01-21 14:52:39 +00:00
|
|
|
#endif /* sys/sysmacros.h */
|