-
-
Save fireyang/c15d6a7b56e2dfddb3a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Workaround for Unity game slowing in iPhone4 + 7.1 | |
//Write in main.mm | |
#include <pthread.h> | |
#include <dlfcn.h> | |
typedef int (*pthread_create_f)(pthread_t * __restrict, const pthread_attr_t * __restrict, void *(*)(void *), void * __restrict); | |
static pthread_create_f real_create = NULL; | |
extern "C" int pthread_create(pthread_t * __restrict thread, const pthread_attr_t * __restrict attr, void *(*start)(void *), void * __restrict arg) | |
{ | |
int rc; | |
if (!real_create) | |
real_create = (pthread_create_f)dlsym(RTLD_NEXT, "pthread_create"); | |
rc = (*real_create)(thread, attr, start, arg); | |
struct sched_param param; | |
int policy; | |
pthread_getschedparam(*thread, &policy, ¶m); | |
pthread_setschedparam(*thread, SCHED_FIFO, ¶m); | |
return rc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment