ReactOS 0.4.16-dev-311-g9382aa2
device.h
Go to the documentation of this file.
1/* @(#)device.h 1.19 09/11/16 Copyright 1995-2007 J. Schilling */
2/*
3 * Generic header for users of major(), minor() and makedev()
4 *
5 * Copyright (c) 1995-2007 J. Schilling
6 */
7/*
8 * The contents of this file are subject to the terms of the
9 * Common Development and Distribution License, Version 1.0 only
10 * (the "License"). You may not use this file except in compliance
11 * with the License.
12 *
13 * See the file CDDL.Schily.txt in this distribution for details.
14 *
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file CDDL.Schily.txt from this distribution.
17 */
18
19#ifndef _SCHILY_DEVICE_H
20#define _SCHILY_DEVICE_H
21
22#ifndef _SCHILY_MCONFIG_H
23#include <schily/mconfig.h>
24#endif
25
26/*
27 * On generic SVR4, major is a function (defined in sys/mkdev.h).
28 * On Solaris it is defined ...
29 * As we cannot just test if major is #define'd, we have to
30 * define _FOUND_MAJOR_ instead.
31 *
32 * WARNING: Do never include <sys/sysmacros.h> in SVR4, it contains
33 * an old definition for major()/minor() defining 8 minorbits.
34 * Use <sys/mkdev.h> instead.
35 */
36#ifndef _SCHILY_TYPES_H
37#include <schily/types.h>
38#endif
39
40/*
41 * Some systems define major in <sys/types.h>.
42 * We are ready...
43 */
44#ifdef major
45# define _FOUND_MAJOR_
46#endif
47
48#ifdef MAJOR_IN_MKDEV
49# ifndef _INCL_SYS_MKDEV_H
50# include <sys/mkdev.h>
51# define _INCL_SYS_MKDEV_H
52# endif
53 /*
54 * Interix doesn't use makedev(); it uses mkdev()
55 */
56# if !defined(makedev) && defined(mkdev)
57# define makedev(a, b) mkdev((a), (b))
58# endif
59# define _FOUND_MAJOR_
60#endif
61
62#ifndef _FOUND_MAJOR_
63# ifdef MAJOR_IN_SYSMACROS
64# ifndef _INCL_SYS_SYSMACROS_H
65# include <sys/sysmacros.h>
66# define _INCL_SYS_SYSMACROS_H
67# endif
68# define _FOUND_MAJOR_
69# endif
70#endif
71
72/*
73 * If we are on HP/UX before HP/UX 8,
74 * major/minor are not in <sys/sysmacros.h>.
75 */
76#ifndef _FOUND_MAJOR_
77# if defined(hpux) || defined(__hpux__) || defined(__hpux)
78# ifndef _INCL_SYS_MKOD_H
79# include <sys/mknod.h>
80# define _INCL_SYS_MKOD_H
81# endif
82# define _FOUND_MAJOR_
83# endif
84#endif
85
86#ifndef _FOUND_MAJOR_
87# ifdef VMS
88# define major(dev) (((((long)dev) >> 8) & 0xFF))
89# define minor(dev) ((((long)dev) & 0xFF))
90# define makedev(majo, mino) (((majo) << 8) | (mino))
91# define _FOUND_MAJOR_
92# endif /* VMS */
93#endif /* _FOUND_MAJOR_ */
94
95#ifdef __cplusplus
96extern "C" {
97#endif
98
99/*
100 * For all other systems define major()/minor() here.
101 * XXX Check if this definition will be usefull for ms dos too.
102 */
103#ifndef _FOUND_MAJOR_
104# define major(dev) (((dev) >> 8) & 0xFF)
105# define minor(dev) ((dev) & 0xFF)
106# define makedev(majo, mino) (((majo) << 8) | (mino))
107#endif
108
109/*
110 * Don't pollute namespace...
111 */
112#undef _FOUND_MAJOR_
113
114#ifdef __XDEV__
115/*
116 * The following defines are currently only needed for 'star'.
117 * We make it conditional code to avoid to pollute the namespace.
118 */
119#define XDEV_T unsigned long
120
121extern int minorbits;
122extern XDEV_T minormask;
123extern XDEV_T _dev_mask[];
124
125#define dev_major(dev) (((XDEV_T)(dev)) >> minorbits)
126#define _dev_major(mbits, dev) (((XDEV_T)(dev)) >> (mbits))
127
128#define dev_minor(dev) (((XDEV_T)(dev)) & minormask)
129#define _dev_minor(mbits, dev) (((XDEV_T)(dev)) & _dev_mask[(mbits)])
130
131
132#define dev_make(majo, mino) ((((XDEV_T)(majo)) << minorbits) | \
133 ((XDEV_T)(mino)))
134#define _dev_make(mbits, majo, mino) ((((XDEV_T)(majo)) << (mbits) | \
135 ((XDEV_T)(mino)))
136
137extern void dev_init __PR((BOOL debug));
138#ifndef dev_major
139extern XDEV_T dev_major __PR((XDEV_T dev));
140extern XDEV_T _dev_major __PR((int mbits, XDEV_T dev));
141extern XDEV_T dev_minor __PR((XDEV_T dev));
142extern XDEV_T _dev_minor __PR((int mbits, XDEV_T dev));
143extern XDEV_T dev_make __PR((XDEV_T majo, XDEV_T mino));
144extern XDEV_T _dev_make __PR((int mbits, XDEV_T majo, XDEV_T mino));
145#endif
146
147#endif /* __XDEV__ */
148
149#ifdef __cplusplus
150}
151#endif
152
153#endif /* _SCHILY_DEVICE_H */
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debug(msg)
Definition: key_call.c:71
#define __PR(a)
Definition: prototyp.h:106