summaryrefslogtreecommitdiff
path: root/Kernel/API/Device.h
blob: 05cba987e465c14c081d4c796c88e244ba692085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Platform.h>
#include <sys/cdefs.h>
#include <sys/types.h>

__BEGIN_DECLS

ALWAYS_INLINE dev_t serenity_dev_makedev(unsigned major, unsigned minor)
{
    return (minor & 0xffu) | (major << 8u) | ((minor & ~0xffu) << 12u);
}

ALWAYS_INLINE unsigned int serenity_dev_major(dev_t dev)
{
    return (dev & 0xfff00u) >> 8u;
}

ALWAYS_INLINE unsigned int serenity_dev_minor(dev_t dev)
{
    return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u);
}

__END_DECLS