AutoDeleter: add delarations for common types and destructors

Change-Id: I74b75a54038d5af370696302f33b5c0abab4820c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3481
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
X512 2020-12-09 18:37:12 +09:00 committed by Adrien Destugues
parent 84b1893b73
commit 553f3f2309
6 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1 @@
#include <../private/shared/AutoDeleterDrivers.h>

View File

@ -0,0 +1 @@
#include <../private/shared/AutoDeleterOS.h>

View File

@ -0,0 +1 @@
#include <../private/shared/AutoDeleterPosix.h>

View File

@ -0,0 +1,43 @@
/*
* Copyright 2020, Haiku, Inc.
* 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>
#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
#include <vfs.h>
#include <fs/fd.h>
#endif
namespace BPrivate {
typedef CObjectDeleter<void, status_t, unload_driver_settings> DriverSettingsUnloader;
#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
typedef CObjectDeleter<struct vnode, void, vfs_put_vnode> VnodePutter;
typedef CObjectDeleter<file_descriptor, void, put_fd> DescriptorPutter;
#endif
}
using ::BPrivate::DriverSettingsUnloader;
#if defined(_KERNEL_MODE) && !defined(_BOOT_MODE)
using ::BPrivate::VnodePutter;
using ::BPrivate::DescriptorPutter;
#endif
#endif // _AUTO_DELETER_DRIVERS_H

View File

@ -0,0 +1,29 @@
/*
* Copyright 2020, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _AUTO_DELETER_OS_H
#define _AUTO_DELETER_OS_H
#include <AutoDeleter.h>
#include <OS.h>
namespace BPrivate {
typedef HandleDeleter<area_id, status_t, delete_area> AreaDeleter;
typedef HandleDeleter<sem_id, status_t, delete_sem> SemDeleter;
typedef HandleDeleter<port_id, status_t, delete_port> PortDeleter;
}
using ::BPrivate::AreaDeleter;
using ::BPrivate::SemDeleter;
using ::BPrivate::PortDeleter;
#endif // _AUTO_DELETER_OS_H

View File

@ -0,0 +1,31 @@
/*
* Copyright 2020, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _AUTO_DELETER_POSIX_H
#define _AUTO_DELETER_POSIX_H
#include <AutoDeleter.h>
#include <stdio.h>
#include <dirent.h>
#include <fs_attr.h>
namespace BPrivate {
typedef CObjectDeleter<FILE, int, fclose> FileCloser;
typedef CObjectDeleter<DIR, int, closedir> DirCloser;
typedef CObjectDeleter<DIR, int, fs_close_attr_dir> AttrDirCloser;
}
using ::BPrivate::FileCloser;
using ::BPrivate::DirCloser;
using ::BPrivate::AttrDirCloser;
#endif // _AUTO_DELETER_POSIX_H