Put it in a separate header file so that it won't pollute everyone's pre-processor macro definition namespace with ntstatus.h. Note that winnt.h omits STATUS_ALERTED.
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com ---
Notes: This function is used in the subsequent patch. See its notes.
include/wine/async.h | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 include/wine/async.h
diff --git a/include/wine/async.h b/include/wine/async.h new file mode 100644 index 00000000000..1ef4ded4319 --- /dev/null +++ b/include/wine/async.h @@ -0,0 +1,46 @@ +/* + * Common helper definitions for Wine asynchronous I/O + * + * Copyright (C) 2022 Jinoh Kang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef __WINE_WINE_ASYNC_H +#define __WINE_WINE_ASYNC_H + +#include <windef.h> +#include <ntstatus.h> + +/* Tests whether the return status of an I/O request server call indicates that + * the ownership of async_fileio has been relinquished from the caller and + * transferred to the async completion routine. + */ +static inline BOOL is_completion_deferred( NTSTATUS status ) +{ + /* STATUS_ALERTED is a status code internally repurposed in wineserver + * to indicate that an APC_ASYNC_IO system APC has been queued to notify + * completion of the async. + * + * We could simply have translated STATUS_ALERTED to STATUS_PENDING in + * server side, obviating the need for this function; however, + * STATUS_ALERTED does not necessarily mean that the I/O request will be + * completed asynchronously (i.e. "async->pending" will be set). + * We explicitly differentiate these conditions to avoid confusion. + */ + return status == STATUS_PENDING || status == STATUS_ALERTED; +} + +#endif /* __WINE_WINE_ASYNC_H */