Skip to content

Instantly share code, notes, and snippets.

@d3m3vilurr
Created June 9, 2016 14:57
Show Gist options
  • Save d3m3vilurr/571cfbab5cb7c097ede725d0ac51ce55 to your computer and use it in GitHub Desktop.
Save d3m3vilurr/571cfbab5cb7c097ede725d0ac51ce55 to your computer and use it in GitHub Desktop.
check_set_cpu_time_limit
#include <stdio.h>
#include <3ds.h>
const u64 SECOND = 1000 * 1000 * 1000;
u32 stack[0x400];
static void threadEntry (void* args) {
svcSleepThread(1 * SECOND);
svcExitThread();
}
int main() {
u8 isNew3DS;
u32 origCpuTimeLimit;
u32 ret;
Handle thread;
gfxInitDefault();
gfxSet3D(false);
consoleInit(GFX_BOTTOM, NULL);
printf("Check SetAppCpuTimeLimit\n\n");
aptOpenSession();
APT_CheckNew3DS(&isNew3DS);
printf("New 3DS: %s\n", isNew3DS ? "True" : "False");
printf("GetAppCpuTimeLimit: ");
ret = APT_GetAppCpuTimeLimit(&origCpuTimeLimit);
if (ret) {
printf("error(0x%lx)\n", ret);
} else {
printf("%lu\n", origCpuTimeLimit);
}
printf("SetAppCpuTimeLimit: ");
ret = APT_SetAppCpuTimeLimit(5);
if (ret) {
printf("error(0x%lx)\n", ret);
} else {
printf("ok\n");
}
aptCloseSession();
printf("CreateThread: ");
ret = svcCreateThread(&thread, (ThreadFunc)threadEntry, 0x0,
stack + 0x400, 0x3f, 1);
if (ret) {
printf("error(0x%lx)\n", ret);
} else {
printf("ok\n");
printf("Wait thread: ");
svcWaitSynchronization(thread, U64_MAX);
svcCloseHandle(thread);
printf("ok\n");
}
printf("\ndone!\n");
while (aptMainLoop()) {
hidScanInput();
ret = hidKeysDown();
if (ret) {
break;
}
}
gfxExit();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment