mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-10 07:06:34 +00:00
Stratosphere: Launch Queue C style lib -> namespace
This commit is contained in:
parent
c8d1342ddf
commit
033cd8df24
2 changed files with 37 additions and 46 deletions
|
@ -2,45 +2,34 @@
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
static launch_item_t g_launch_queue[LAUNCH_QUEUE_SIZE];
|
namespace LaunchQueue {
|
||||||
|
static LaunchItem g_launch_queue[LAUNCH_QUEUE_SIZE];
|
||||||
|
|
||||||
int launch_queue_get_index(u64 TID) {
|
int get_index(u64 tid) {
|
||||||
for(unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
for(unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
||||||
if(g_launch_queue[i].tid == TID) {
|
if(g_launch_queue[i].tid == tid) {
|
||||||
return i;
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LAUNCH_QUEUE_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int get_free_index(u64 tid) {
|
||||||
|
for(unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
||||||
|
if(g_launch_queue[i].tid == tid || g_launch_queue[i].tid == 0x0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return LAUNCH_QUEUE_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool contains(u64 tid) {
|
||||||
|
return get_index(tid) != LAUNCH_QUEUE_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
for (unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
||||||
|
g_launch_queue[i].tid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return LAUNCH_QUEUE_FULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int launch_queue_get_free_index(u64 TID) {
|
|
||||||
for(unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
|
||||||
if(g_launch_queue[i].tid == TID || g_launch_queue[i].tid == 0x0) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return LAUNCH_QUEUE_FULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result launch_queue_add(launch_item_t *item) {
|
|
||||||
if(item->arg_size > LAUNCH_QUEUE_ARG_SIZE_MAX) {
|
|
||||||
return 0x209;
|
|
||||||
}
|
|
||||||
|
|
||||||
int idx = launch_queue_get_free_index(item->tid);
|
|
||||||
if(idx == LAUNCH_QUEUE_FULL)
|
|
||||||
return 0x409;
|
|
||||||
|
|
||||||
g_launch_queue[idx] = *item;
|
|
||||||
return 0x0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool launch_queue_contains(uint64_t TID) {
|
|
||||||
return launch_queue_get_index(TID) != LAUNCH_QUEUE_FULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void launch_queue_clear() {
|
|
||||||
for (unsigned int i = 0; i < LAUNCH_QUEUE_SIZE; i++) {
|
|
||||||
g_launch_queue[i].tid = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -6,14 +6,16 @@
|
||||||
|
|
||||||
#define LAUNCH_QUEUE_ARG_SIZE_MAX (0x8000)
|
#define LAUNCH_QUEUE_ARG_SIZE_MAX (0x8000)
|
||||||
|
|
||||||
typedef struct launch_item_t {
|
namespace LaunchQueue {
|
||||||
u64 tid;
|
struct LaunchItem {
|
||||||
u64 arg_size;
|
u64 tid;
|
||||||
char args[LAUNCH_QUEUE_ARG_SIZE_MAX];
|
u64 arg_size;
|
||||||
} launch_item_t;
|
char args[LAUNCH_QUEUE_ARG_SIZE_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
Result launch_queue_add(launch_item_t item);
|
Result add(LaunchItem *item);
|
||||||
int launch_queue_get_index(u64 TID);
|
int get_index(u64 tid);
|
||||||
int launch_queue_get_free_index(u64 TID = 0);
|
int get_free_index(u64 tid);
|
||||||
bool launch_queue_contains(u64 TID);
|
bool contains(u64 tid);
|
||||||
void launch_queue_clear();
|
void clear();
|
||||||
|
}
|
Loading…
Reference in a new issue