mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
Add, document, and use MAX_WAIT_OBJECTS
This commit is contained in:
parent
33dad9b893
commit
21f69bfa57
@ -13,6 +13,9 @@
|
|||||||
/// Pseudo handle for the current thread.
|
/// Pseudo handle for the current thread.
|
||||||
#define CUR_THREAD_HANDLE 0xFFFF8000
|
#define CUR_THREAD_HANDLE 0xFFFF8000
|
||||||
|
|
||||||
|
/// Maximum number of objects that can be waited on by \ref svcWaitSynchronization (Horizon kernel limitation).
|
||||||
|
#define MAX_WAIT_OBJECTS 0x40
|
||||||
|
|
||||||
/// Memory type enumeration (lower 8 bits of \ref MemoryState)
|
/// Memory type enumeration (lower 8 bits of \ref MemoryState)
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MemType_Unmapped=0x00, ///< Unmapped memory.
|
MemType_Unmapped=0x00, ///< Unmapped memory.
|
||||||
@ -362,6 +365,7 @@ Result svcResetSignal(Handle handle);
|
|||||||
* @brief Waits on one or more synchronization objects, optionally with a timeout.
|
* @brief Waits on one or more synchronization objects, optionally with a timeout.
|
||||||
* @return Result code.
|
* @return Result code.
|
||||||
* @note Syscall number 0x18.
|
* @note Syscall number 0x18.
|
||||||
|
* @note \p handleCount must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
|
||||||
* @note Please use \ref waitMultiHandle instead. That function handles sporadical interrupts caused by usermode synchronization primitives.
|
* @note Please use \ref waitMultiHandle instead. That function handles sporadical interrupts caused by usermode synchronization primitives.
|
||||||
*/
|
*/
|
||||||
Result svcWaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout);
|
Result svcWaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout);
|
||||||
|
@ -58,7 +58,7 @@ Result waitNHandle(s32* idx_out, Handle* handles, size_t num_handles, u64 timeou
|
|||||||
* @brief Waits for an arbitrary number of waiters. This is a macro that uses var-args.
|
* @brief Waits for an arbitrary number of waiters. This is a macro that uses var-args.
|
||||||
* @param[out] idx_out The index of the signalled waiter.
|
* @param[out] idx_out The index of the signalled waiter.
|
||||||
* @param[in] timeout Timeout (in nanoseconds).
|
* @param[in] timeout Timeout (in nanoseconds).
|
||||||
* @note The number of waiters must be less than 64. This is a Horizon kernel limitation.
|
* @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
|
||||||
*/
|
*/
|
||||||
#define waitMulti(idx_out, timeout, ...) \
|
#define waitMulti(idx_out, timeout, ...) \
|
||||||
waitN((idx_out), (Waiter[]) { __VA_ARGS__ }, sizeof((Waiter[]) { __VA_ARGS__ }) / sizeof(Waiter), (timeout))
|
waitN((idx_out), (Waiter[]) { __VA_ARGS__ }, sizeof((Waiter[]) { __VA_ARGS__ }) / sizeof(Waiter), (timeout))
|
||||||
@ -67,7 +67,7 @@ Result waitNHandle(s32* idx_out, Handle* handles, size_t num_handles, u64 timeou
|
|||||||
* @brief Waits for an arbitrary number of handles. This is a macro that uses var-args.
|
* @brief Waits for an arbitrary number of handles. This is a macro that uses var-args.
|
||||||
* @param[out] idx_out The index of the signalled handle.
|
* @param[out] idx_out The index of the signalled handle.
|
||||||
* @param[in] timeout Timeout (in nanoseconds).
|
* @param[in] timeout Timeout (in nanoseconds).
|
||||||
* @note The number of handles must be less than 64. This is a Horizon kernel limitation.
|
* @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation.
|
||||||
*/
|
*/
|
||||||
#define waitMultiHandle(idx_out, timeout, ...) \
|
#define waitMultiHandle(idx_out, timeout, ...) \
|
||||||
waitNHandle((idx_out), (Handle[]) { __VA_ARGS__ }, sizeof((Handle[]) { __VA_ARGS__ }) / sizeof(Handle), (timeout))
|
waitNHandle((idx_out), (Handle[]) { __VA_ARGS__ }, sizeof((Handle[]) { __VA_ARGS__ }) / sizeof(Handle), (timeout))
|
||||||
|
@ -8,13 +8,11 @@
|
|||||||
#include "wait.h"
|
#include "wait.h"
|
||||||
#include "../internal.h"
|
#include "../internal.h"
|
||||||
|
|
||||||
#define MAX_WAIT 0x40
|
|
||||||
|
|
||||||
typedef Result (*WaitImplFunc)(s32* idx_out, void* objects, size_t num_objects, u64 timeout);
|
typedef Result (*WaitImplFunc)(s32* idx_out, void* objects, size_t num_objects, u64 timeout);
|
||||||
|
|
||||||
static Result waitImpl(s32* idx_out, Waiter* objects, size_t num_objects, u64 timeout)
|
static Result waitImpl(s32* idx_out, Waiter* objects, size_t num_objects, u64 timeout)
|
||||||
{
|
{
|
||||||
if (num_objects > MAX_WAIT)
|
if (num_objects > MAX_WAIT_OBJECTS)
|
||||||
return KERNELRESULT(OutOfRange); // same error returned by kernel
|
return KERNELRESULT(OutOfRange); // same error returned by kernel
|
||||||
|
|
||||||
Handle own_thread_handle = getThreadVars()->handle;
|
Handle own_thread_handle = getThreadVars()->handle;
|
||||||
|
Loading…
Reference in New Issue
Block a user