Skip to content

Commit

Permalink
cond,libcxx,xglobals: Hard-wrap lines
Browse files Browse the repository at this point in the history
(cherry picked from commit ed8bd1b)
Signed-off-by: LIU Hao <[email protected]>
  • Loading branch information
lhmouse committed Nov 1, 2024
1 parent 6ab0e20 commit 41ee083
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
6 changes: 4 additions & 2 deletions mcfgthread/cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

static __MCF_NEVER_INLINE
int
do_unlock_and_wait(_MCF_cond* cond, _MCF_cond_unlock_callback* unlock_opt, intptr_t* unlocked, intptr_t lock_arg, const int64_t* timeout_opt)
do_unlock_and_wait(_MCF_cond* cond, _MCF_cond_unlock_callback* unlock_opt, intptr_t* unlocked,
intptr_t lock_arg, const int64_t* timeout_opt)
{
__MCF_winnt_timeout nt_timeout;
__MCF_initialize_winnt_timeout_v3(&nt_timeout, timeout_opt);
Expand Down Expand Up @@ -70,7 +71,8 @@ do_unlock_and_wait(_MCF_cond* cond, _MCF_cond_unlock_callback* unlock_opt, intpt

__MCF_DLLEXPORT
int
_MCF_cond_wait(_MCF_cond* cond, _MCF_cond_unlock_callback* unlock_opt, _MCF_cond_relock_callback* relock_opt, intptr_t lock_arg, const int64_t* timeout_opt)
_MCF_cond_wait(_MCF_cond* cond, _MCF_cond_unlock_callback* unlock_opt, _MCF_cond_relock_callback* relock_opt,
intptr_t lock_arg, const int64_t* timeout_opt)
{
__MCF_SEH_DEFINE_TERMINATE_FILTER;
intptr_t unlocked;
Expand Down
3 changes: 2 additions & 1 deletion mcfgthread/cond.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ _MCF_cond_init(_MCF_cond* __cond) __MCF_noexcept;
* wakeup, or -1 if the wait operation has timed out. */
__MCF_COND_IMPORT
int
_MCF_cond_wait(_MCF_cond* __cond, _MCF_cond_unlock_callback* __unlock_opt, _MCF_cond_relock_callback* __relock_opt, intptr_t __lock_arg, const int64_t* __timeout_opt) __MCF_noexcept;
_MCF_cond_wait(_MCF_cond* __cond, _MCF_cond_unlock_callback* __unlock_opt, _MCF_cond_relock_callback* __relock_opt,
intptr_t __lock_arg, const int64_t* __timeout_opt) __MCF_noexcept;

/* Wakes up some or all threads that have been put to sleep on this condition
* variable.
Expand Down
6 changes: 4 additions & 2 deletions mcfgthread/libcxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ __MCF_libcxx_condvar_wait(__libcpp_condvar_t* __cond, __libcpp_mutex_t* __mtx) _
* `pthread_cond_timedwait()`. */
__MCF_LIBCXX_INLINE
int
__MCF_libcxx_condvar_timedwait(__libcpp_condvar_t* __cond, __libcpp_mutex_t* __mtx, const __libcpp_timespec_t* __abs_time) __MCF_noexcept;
__MCF_libcxx_condvar_timedwait(__libcpp_condvar_t* __cond, __libcpp_mutex_t* __mtx,
const __libcpp_timespec_t* __abs_time) __MCF_noexcept;

#ifndef __MCF_LIBCXX_NO_ALIASES
# define __libcpp_condvar_timedwait __MCF_libcxx_condvar_timedwait
Expand Down Expand Up @@ -500,7 +501,8 @@ __MCF_libcxx_condvar_wait(__libcpp_condvar_t* __cond, __libcpp_mutex_t* __mtx) _

__MCF_LIBCXX_INLINE
int
__MCF_libcxx_condvar_timedwait(__libcpp_condvar_t* __cond, __libcpp_mutex_t* __mtx, const __libcpp_timespec_t* __abs_time) __MCF_noexcept
__MCF_libcxx_condvar_timedwait(__libcpp_condvar_t* __cond, __libcpp_mutex_t* __mtx,
const __libcpp_timespec_t* __abs_time) __MCF_noexcept
{
int64_t __timeout = __MCF_gthr_timeout_from_timespec(__abs_time);
int __err = __MCF_gthr_cond_mutex_wait(__cond, __mtx, &__timeout);
Expand Down
18 changes: 13 additions & 5 deletions mcfgthread/xglobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,9 @@ __MCF_is_process_shutting_down(void)

/* Create a named section of memory.
* https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-zwcreatesection */
NTSYSAPI NTSTATUS NTAPI NtCreateSection(HANDLE* OutHandle, ACCESS_MASK DesiredAccess, OBJECT_ATTRIBUTES* Attributes, LARGE_INTEGER* MaximumSize, ULONG Protection, ULONG Allocation, HANDLE File);
NTSYSAPI NTSTATUS NTAPI NtCreateSection(HANDLE* OutHandle, ACCESS_MASK DesiredAccess,
OBJECT_ATTRIBUTES* Attributes, LARGE_INTEGER* MaximumSize,
ULONG Protection, ULONG Allocation, HANDLE File);

__MCF_ALWAYS_INLINE
HANDLE
Expand All @@ -572,7 +574,9 @@ __MCF_create_named_section(OBJECT_ATTRIBUTES* Attributes, LONGLONG MaximumSize)

/* Creates another handle to an object.
* https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-zwduplicateobject */
NTSYSAPI NTSTATUS NTAPI NtDuplicateObject(HANDLE SourceProcess, HANDLE SourceHandle, HANDLE TargetProcess, HANDLE* TargetHandle, ACCESS_MASK DesiredAccess, ULONG HandleAttributes, ULONG Options);
NTSYSAPI NTSTATUS NTAPI NtDuplicateObject(HANDLE SourceProcess, HANDLE SourceHandle, HANDLE TargetProcess,
HANDLE* TargetHandle, ACCESS_MASK DesiredAccess,
ULONG HandleAttributes, ULONG Options);

__MCF_ALWAYS_INLINE
HANDLE
Expand All @@ -598,15 +602,18 @@ __MCF_close_handle(HANDLE Handle)

/* Maps a named section of memory into the virtual address space.
* https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-zwmapviewofsection */
NTSYSAPI NTSTATUS NTAPI NtMapViewOfSection(HANDLE Section, HANDLE Process, PVOID* BaseAddress, ULONG_PTR ZeroBits, SIZE_T CommitSize, LARGE_INTEGER* Offset, SIZE_T* ViewSize, UINT SectionInherit, ULONG Allocation, ULONG Protection);
NTSYSAPI NTSTATUS NTAPI NtMapViewOfSection(HANDLE Section, HANDLE Process, PVOID* BaseAddress, ULONG_PTR ZeroBits,
SIZE_T CommitSize, LARGE_INTEGER* Offset, SIZE_T* ViewSize,
UINT SectionInherit, ULONG Allocation, ULONG Protection);

__MCF_ALWAYS_INLINE
void
__MCF_map_view_of_section(HANDLE Section, void** BaseAddress, size_t* ViewSize, bool Inheritable)
{
HANDLE process = GetCurrentProcess();
UINT inherit = Inheritable ? 1U : 2U; /* ViewShare : ViewUnmap */
NTSTATUS status = NtMapViewOfSection(Section, process, BaseAddress, 0, 0, __MCF_nullptr, (SIZE_T*) ViewSize, inherit, 0, PAGE_READWRITE);
NTSTATUS status = NtMapViewOfSection(Section, process, BaseAddress, 0, 0, __MCF_nullptr,
(SIZE_T*) ViewSize, inherit, 0, PAGE_READWRITE);
__MCF_ASSERT(NT_SUCCESS(status));
}

Expand Down Expand Up @@ -680,7 +687,8 @@ __MCF_keyed_event_signal(const void* Key, const __MCF_winnt_timeout* Timeout)
/* Sends a hard-error LPC message to CSRSS.EXE. This function is useful in a DLL
* entry-point function or a TLS callback, where it is not safe to make a call
* to `MessageBox()`. */
NTSYSAPI NTSTATUS NTAPI NtRaiseHardError(NTSTATUS Status, ULONG NumberOfParameters, ULONG UnicodeStringParameterMask, ULONG_PTR* Parameters, ULONG ResponseOption, ULONG* Response);
NTSYSAPI NTSTATUS NTAPI NtRaiseHardError(NTSTATUS Status, ULONG NumberOfParameters, ULONG UnicodeStringParameterMask,
ULONG_PTR* Parameters, ULONG ResponseOption, ULONG* Response);

__MCF_ALWAYS_INLINE
int
Expand Down

0 comments on commit 41ee083

Please sign in to comment.