Nugget
Loading...
Searching...
No Matches
ucontext.h
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2025 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
29// This file provides an ersatz for the ucontext.h API, which is otherwise not available on PSX.
30// It defines the necessary structures and function prototypes to allow for context switching,
31// similar to what ucontext.h provides in POSIX systems. It's not strictly compliant with the POSIX standard,
32// but it provides a minimal implementation suitable for coroutine management in a PSX environment.
33
34#include <stdint.h>
35
36struct stack_t {
37 void *ss_sp;
38 unsigned ss_size;
39};
40
41struct mcontext_t {
43};
44
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55int getcontext(struct ucontext_t *ucp);
56int setcontext(const struct ucontext_t *ucp);
57int makecontext(struct ucontext_t *ucp, void (*func)(void *), void *arg);
58int swapcontext(struct ucontext_t *oucp, const struct ucontext_t *ucp);
59
60#ifdef __cplusplus
61}
62#endif
Definition ucontext.h:41
uint32_t reserved[16]
Definition ucontext.h:42
Definition ucontext.h:36
unsigned ss_size
Definition ucontext.h:38
void * ss_sp
Definition ucontext.h:37
Definition ucontext.h:45
struct ucontext_t * uc_link
Definition ucontext.h:47
struct mcontext_t uc_mcontext
Definition ucontext.h:46
struct stack_t uc_stack
Definition ucontext.h:48
void uint32_t(classId, spec)
int makecontext(struct ucontext_t *ucp, void(*func)(void *), void *arg)
int setcontext(const struct ucontext_t *ucp)
int swapcontext(struct ucontext_t *oucp, const struct ucontext_t *ucp)
int getcontext(struct ucontext_t *ucp)