From ddebf19a2a59a942247a1c090fd1d7ad837703c4 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Tue, 5 Apr 2011 00:53:17 +0000 Subject: [PATCH] * include/cygwin/types.h: Move #include to end of header so that it gets the dev_t typedef. * include/sys/sysmacros.h (gnu_dev_major, gnu_dev_minor, gnu_dev_makedev): Prototype and define as inline functions. (major, minor, makedev): Redefine in terms of gnu_dev_*. --- winsup/cygwin/ChangeLog | 8 +++++++ winsup/cygwin/include/cygwin/types.h | 4 +++- winsup/cygwin/include/sys/sysmacros.h | 30 +++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6ee98389d..18c74553b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2011-04-04 Yaakov Selkowitz + + * include/cygwin/types.h: Move #include to + end of header so that it gets the dev_t typedef. + * include/sys/sysmacros.h (gnu_dev_major, gnu_dev_minor, + gnu_dev_makedev): Prototype and define as inline functions. + (major, minor, makedev): Redefine in terms of gnu_dev_*. + 2011-04-04 Yaakov Selkowitz * include/cygwin/types.h: Move multiple inclusion guards to diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h index c049fa371..cbb4b4492 100644 --- a/winsup/cygwin/include/cygwin/types.h +++ b/winsup/cygwin/include/cygwin/types.h @@ -17,7 +17,6 @@ extern "C" { #endif -#include #include #include @@ -219,6 +218,9 @@ typedef class pthread_rwlockattr *pthread_rwlockattr_t; typedef class semaphore *sem_t; #endif /* __INSIDE_CYGWIN__ */ +/* this header needs the dev_t typedef */ +#include + #ifdef __cplusplus } #endif diff --git a/winsup/cygwin/include/sys/sysmacros.h b/winsup/cygwin/include/sys/sysmacros.h index 82bc6c1e3..78f2db2d5 100644 --- a/winsup/cygwin/include/sys/sysmacros.h +++ b/winsup/cygwin/include/sys/sysmacros.h @@ -1,6 +1,6 @@ /* sys/sysmacros.h - Copyright 1998, 2001, 2010 Red Hat, Inc. + Copyright 1998, 2001, 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -11,8 +11,30 @@ details. */ #ifndef _SYS_SYSMACROS_H #define _SYS_SYSMACROS_H -#define major(dev) ((int)(((dev) >> 16) & 0xffff)) -#define minor(dev) ((int)((dev) & 0xffff)) -#define makedev(major, minor) (((major) << 16) | ((minor) & 0xffff)) +_ELIDABLE_INLINE int gnu_dev_major(dev_t); +_ELIDABLE_INLINE int gnu_dev_minor(dev_t); +_ELIDABLE_INLINE dev_t gnu_dev_makedev(int, int); + +_ELIDABLE_INLINE int +gnu_dev_major(dev_t dev) +{ + return (int)(((dev) >> 16) & 0xffff); +} + +_ELIDABLE_INLINE int +gnu_dev_minor(dev_t dev) +{ + return (int)((dev) & 0xffff); +} + +_ELIDABLE_INLINE dev_t +gnu_dev_makedev(int maj, int min) +{ + return (((maj) << 16) | ((min) & 0xffff)); +} + +#define major(dev) gnu_dev_major(dev) +#define minor(dev) gnu_dev_minor(dev) +#define makedev(maj, min) gnu_dev_makedev(maj, min) #endif /* _SYS_SYSMACROS_H */