2020-12-09 12:37:12 +03:00
|
|
|
/*
|
2021-05-26 16:23:38 +03:00
|
|
|
* Copyright 2020, Haiku, Inc. All rights reserved.
|
2020-12-09 12:37:12 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _AUTO_DELETER_DRIVERS_H
|
|
|
|
#define _AUTO_DELETER_DRIVERS_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <AutoDeleter.h>
|
|
|
|
#include <driver_settings.h>
|
2021-05-26 16:23:38 +03:00
|
|
|
|
2020-12-09 12:37:12 +03:00
|
|
|
#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
|
|
|
|
#include <vfs.h>
|
|
|
|
#include <fs/fd.h>
|
2021-05-26 16:23:38 +03:00
|
|
|
#include <vm/VMAddressSpace.h>
|
|
|
|
#include <device_manager.h>
|
2020-12-09 12:37:12 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
|
2021-05-26 16:23:38 +03:00
|
|
|
typedef CObjectDeleter<void, status_t, unload_driver_settings>
|
|
|
|
DriverSettingsUnloader;
|
2020-12-09 12:37:12 +03:00
|
|
|
|
|
|
|
#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
|
|
|
|
|
|
|
|
typedef CObjectDeleter<struct vnode, void, vfs_put_vnode> VnodePutter;
|
|
|
|
typedef CObjectDeleter<file_descriptor, void, put_fd> DescriptorPutter;
|
2021-05-26 16:23:38 +03:00
|
|
|
typedef MethodDeleter<VMAddressSpace, void, &VMAddressSpace::Put>
|
|
|
|
VMAddressSpacePutter;
|
|
|
|
|
|
|
|
#if __GNUC__ >= 4
|
|
|
|
|
|
|
|
template <device_manager_info **deviceManager>
|
|
|
|
using DeviceNodePutter = MethodObjectDeleter<device_node, device_manager_info,
|
|
|
|
deviceManager, void, &device_manager_info::put_node>;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
template <device_manager_info **deviceManager>
|
|
|
|
struct DeviceNodePutter : MethodObjectDeleter<device_node, device_manager_info,
|
|
|
|
deviceManager, void, &device_manager_info::put_node>
|
|
|
|
{
|
|
|
|
typedef MethodObjectDeleter<device_node, device_manager_info,
|
|
|
|
deviceManager, void, &device_manager_info::put_node> Base;
|
|
|
|
|
|
|
|
DeviceNodePutter() : Base() {}
|
|
|
|
DeviceNodePutter(device_node* object) : Base(object) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2020-12-09 12:37:12 +03:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using ::BPrivate::DriverSettingsUnloader;
|
|
|
|
|
|
|
|
#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
|
|
|
|
|
|
|
|
using ::BPrivate::VnodePutter;
|
|
|
|
using ::BPrivate::DescriptorPutter;
|
2021-05-26 16:23:38 +03:00
|
|
|
using ::BPrivate::VMAddressSpacePutter;
|
|
|
|
using ::BPrivate::DeviceNodePutter;
|
2020-12-09 12:37:12 +03:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _AUTO_DELETER_DRIVERS_H
|