1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Add const attr to gnu_dev_{major,minor,makedev}

This commit is contained in:
Marek Polacek
2011-07-20 12:35:29 -04:00
committed by Ulrich Drepper
parent 3ff9459622
commit 295e904fe6
3 changed files with 20 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2011-07-12 Marek Polacek <mpolacek@redhat.com>
* misc/sys/cdefs.h: Add support for const attribute.
* sysdeps/unix/sysv/linux/sys/sysmacros.h: Add __attribute_const__
to gnu_dev_{major,minor,makedev} functions.
2011-07-20 Marek Polacek <mpolacek@redhat.com> 2011-07-20 Marek Polacek <mpolacek@redhat.com>
* intl/dcigettext.c (get_output_charset): Add missing bracket. * intl/dcigettext.c (get_output_charset): Add missing bracket.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1992-2001, 2002, 2004, 2005, 2006, 2007, 2009 /* Copyright (C) 1992-2001, 2002, 2004, 2005, 2006, 2007, 2009, 2011
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@ -218,6 +218,13 @@
# define __attribute_pure__ /* Ignore */ # define __attribute_pure__ /* Ignore */
#endif #endif
/* This declaration tells the compiler that the value is constant. */
#if __GNUC_PREREQ (2,5)
# define __attribute_const__ __attribute__ ((__const__))
#else
# define __attribute_const__ /* Ignore */
#endif
/* At some point during the gcc 3.1 development the `used' attribute /* At some point during the gcc 3.1 development the `used' attribute
for functions was introduced. We don't want to use it unconditionally for functions was introduced. We don't want to use it unconditionally
(although this would be possible) since it generates warnings. */ (although this would be possible) since it generates warnings. */

View File

@ -31,29 +31,29 @@ __BEGIN_DECLS
__extension__ __extension__
extern unsigned int gnu_dev_major (unsigned long long int __dev) extern unsigned int gnu_dev_major (unsigned long long int __dev)
__THROW; __THROW __attribute_const__;
__extension__ __extension__
extern unsigned int gnu_dev_minor (unsigned long long int __dev) extern unsigned int gnu_dev_minor (unsigned long long int __dev)
__THROW; __THROW __attribute_const__;
__extension__ __extension__
extern unsigned long long int gnu_dev_makedev (unsigned int __major, extern unsigned long long int gnu_dev_makedev (unsigned int __major,
unsigned int __minor) unsigned int __minor)
__THROW; __THROW __attribute_const__;
# if defined __GNUC__ && __GNUC__ >= 2 && defined __USE_EXTERN_INLINES # if defined __GNUC__ && __GNUC__ >= 2 && defined __USE_EXTERN_INLINES
__extension__ __extern_inline unsigned int __extension__ __extern_inline __attribute_const__ unsigned int
__NTH (gnu_dev_major (unsigned long long int __dev)) __NTH (gnu_dev_major (unsigned long long int __dev))
{ {
return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
} }
__extension__ __extern_inline unsigned int __extension__ __extern_inline __attribute_const__ unsigned int
__NTH (gnu_dev_minor (unsigned long long int __dev)) __NTH (gnu_dev_minor (unsigned long long int __dev))
{ {
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
} }
__extension__ __extern_inline unsigned long long int __extension__ __extern_inline __attribute_const__ unsigned long long int
__NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor)) __NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor))
{ {
return ((__minor & 0xff) | ((__major & 0xfff) << 8) return ((__minor & 0xff) | ((__major & 0xfff) << 8)