예제 #1
0
        // SDK location: /user/pspthreadman.h:676
        // SDK declaration: int sceKernelPollEventFlag(int evid, u32 bits, u32 wait, u32 *outBits);
        public int sceKernelPollEventFlag(int evid, int bits, int wait, int outBits)
        {
            KEvent ev = _kernel.GetHandle <KEvent>(evid);

            if (ev == null)
            {
                return(-1);
            }

            // We may already be set
            if (ev.Matches(( uint )bits, ( KWaitType )wait) == true)
            {
                if (outBits != 0)
                {
                    unsafe
                    {
                        uint *poutBits = ( uint * )_memorySystem.Translate(( uint )outBits);
                        *     poutBits = ev.Value;
                    }
                }

                ev.Clear((uint)bits, (KWaitType)wait);
                return(0);
            }

            // What is the proper return here when we haven't matched?
            return(-1);
        }
예제 #2
0
        // SDK location: /user/pspthreadman.h:700
        // SDK declaration: int sceKernelWaitEventFlagCB(int evid, u32 bits, u32 wait, u32 *outBits, SceUInt *timeout);
        public int sceKernelWaitEventFlagCB(int evid, int bits, int wait, int outBits, int timeout)
        {
            // SAME AS ABOVE!

            KEvent ev = _kernel.GetHandle <KEvent>(evid);

            if (ev == null)
            {
                return(-1);
            }

            // TODO: event timeouts
            Debug.Assert(timeout == 0);

            // We may already be set
            if (ev.Matches(( uint )bits, ( KWaitType )wait) == true)
            {
                if (outBits != 0)
                {
                    unsafe
                    {
                        uint *poutBits = ( uint * )_memorySystem.Translate(( uint )outBits);
                        *     poutBits = ev.Value;
                    }
                }

                ev.Clear(( uint )bits, ( KWaitType )wait);
                return(0);
            }
            else
            {
                // No match - wait us
                KThread thread = _kernel.ActiveThread;
                Debug.Assert(thread != null);
                thread.Wait(ev, ( KWaitType )wait, ( uint )bits, ( uint )outBits, ( uint )timeout, true);

                return(0);
            }
        }