1553f3f23SX512 /* 2*a748b72eSX512 * Copyright 2020, Haiku, Inc. All rights reserved. 3553f3f23SX512 * Distributed under the terms of the MIT License. 4553f3f23SX512 */ 5553f3f23SX512 #ifndef _AUTO_DELETER_DRIVERS_H 6553f3f23SX512 #define _AUTO_DELETER_DRIVERS_H 7553f3f23SX512 8553f3f23SX512 9553f3f23SX512 #include <AutoDeleter.h> 10553f3f23SX512 #include <driver_settings.h> 11*a748b72eSX512 12553f3f23SX512 #if defined(_KERNEL_MODE) && !defined(_BOOT_MODE) 13553f3f23SX512 #include <vfs.h> 14553f3f23SX512 #include <fs/fd.h> 15*a748b72eSX512 #include <vm/VMAddressSpace.h> 16*a748b72eSX512 #include <device_manager.h> 17553f3f23SX512 #endif 18553f3f23SX512 19553f3f23SX512 20553f3f23SX512 namespace BPrivate { 21553f3f23SX512 22553f3f23SX512 23*a748b72eSX512 typedef CObjectDeleter<void, status_t, unload_driver_settings> 24*a748b72eSX512 DriverSettingsUnloader; 25553f3f23SX512 26553f3f23SX512 #if defined(_KERNEL_MODE) && !defined(_BOOT_MODE) 27553f3f23SX512 28553f3f23SX512 typedef CObjectDeleter<struct vnode, void, vfs_put_vnode> VnodePutter; 29553f3f23SX512 typedef CObjectDeleter<file_descriptor, void, put_fd> DescriptorPutter; 30*a748b72eSX512 typedef MethodDeleter<VMAddressSpace, void, &VMAddressSpace::Put> 31*a748b72eSX512 VMAddressSpacePutter; 32*a748b72eSX512 33*a748b72eSX512 #if __GNUC__ >= 4 34*a748b72eSX512 35*a748b72eSX512 template <device_manager_info **deviceManager> 36*a748b72eSX512 using DeviceNodePutter = MethodObjectDeleter<device_node, device_manager_info, 37*a748b72eSX512 deviceManager, void, &device_manager_info::put_node>; 38*a748b72eSX512 39*a748b72eSX512 #else 40*a748b72eSX512 41*a748b72eSX512 template <device_manager_info **deviceManager> 42*a748b72eSX512 struct DeviceNodePutter : MethodObjectDeleter<device_node, device_manager_info, 43*a748b72eSX512 deviceManager, void, &device_manager_info::put_node> 44*a748b72eSX512 { 45*a748b72eSX512 typedef MethodObjectDeleter<device_node, device_manager_info, 46*a748b72eSX512 deviceManager, void, &device_manager_info::put_node> Base; 47*a748b72eSX512 48*a748b72eSX512 DeviceNodePutter() : Base() {} 49*a748b72eSX512 DeviceNodePutter(device_node* object) : Base(object) {} 50*a748b72eSX512 }; 51*a748b72eSX512 52*a748b72eSX512 #endif 53553f3f23SX512 54553f3f23SX512 #endif 55553f3f23SX512 56553f3f23SX512 57553f3f23SX512 } 58553f3f23SX512 59553f3f23SX512 60553f3f23SX512 using ::BPrivate::DriverSettingsUnloader; 61553f3f23SX512 62553f3f23SX512 #if defined(_KERNEL_MODE) && !defined(_BOOT_MODE) 63553f3f23SX512 64553f3f23SX512 using ::BPrivate::VnodePutter; 65553f3f23SX512 using ::BPrivate::DescriptorPutter; 66*a748b72eSX512 using ::BPrivate::VMAddressSpacePutter; 67*a748b72eSX512 using ::BPrivate::DeviceNodePutter; 68553f3f23SX512 69553f3f23SX512 #endif 70553f3f23SX512 71553f3f23SX512 72553f3f23SX512 #endif // _AUTO_DELETER_DRIVERS_H 73