Cleanups
This commit is contained in:
parent
958c4cb5e0
commit
11866d42f8
|
@ -86,13 +86,16 @@ typedef int pthread_attr_t;
|
||||||
typedef cond_t pthread_cond_t;
|
typedef cond_t pthread_cond_t;
|
||||||
typedef cond_t pthread_condattr_t;
|
typedef cond_t pthread_condattr_t;
|
||||||
|
|
||||||
static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
|
static inline int pthread_create(pthread_t *thread,
|
||||||
|
const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
|
||||||
{
|
{
|
||||||
*thread = 0;
|
*thread = 0;
|
||||||
return OSCreateThread(thread, start_routine, 0 /* unused */, arg, 0, STACKSIZE, 64, 0 /* unused */);
|
return OSCreateThread(thread, start_routine, 0 /* unused */, arg,
|
||||||
|
0, STACKSIZE, 64, 0 /* unused */);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
|
static inline int pthread_mutex_init(pthread_mutex_t *mutex,
|
||||||
|
const pthread_mutexattr_t *attr)
|
||||||
{
|
{
|
||||||
return OSInitMutex(mutex);
|
return OSInitMutex(mutex);
|
||||||
}
|
}
|
||||||
|
@ -135,17 +138,20 @@ static inline int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||||
return OSTryLockMutex(*mutex);
|
return OSTryLockMutex(*mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
static inline int pthread_cond_wait(pthread_cond_t *cond,
|
||||||
|
pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
return OSWaitCond(*cond, *mutex);
|
return OSWaitCond(*cond, *mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
|
static inline int pthread_cond_timedwait(pthread_cond_t *cond,
|
||||||
|
pthread_mutex_t *mutex, const struct timespec *abstime)
|
||||||
{
|
{
|
||||||
return LWP_CondTimedWait(*cond, *mutex, abstime);
|
return LWP_CondTimedWait(*cond, *mutex, abstime);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
|
static inline int pthread_cond_init(pthread_cond_t *cond,
|
||||||
|
const pthread_condattr_t *attr)
|
||||||
{
|
{
|
||||||
return OSInitCond(cond);
|
return OSInitCond(cond);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ typedef int pthread_attr_t;
|
||||||
typedef SceUID pthread_cond_t;
|
typedef SceUID pthread_cond_t;
|
||||||
typedef SceUID pthread_condattr_t;
|
typedef SceUID pthread_condattr_t;
|
||||||
|
|
||||||
// use pointer values to create unique names for threads/mutexes
|
/* Use pointer values to create unique names for threads/mutexes */
|
||||||
char name_buffer[256];
|
char name_buffer[256];
|
||||||
|
|
||||||
typedef void* (*sthreadEntry)(void *argp);
|
typedef void* (*sthreadEntry)(void *argp);
|
||||||
|
@ -52,11 +52,13 @@ static int psp_thread_wrap(SceSize args, void *argp)
|
||||||
return (int)sthread_args->start_routine(sthread_args->arg);
|
return (int)sthread_args->start_routine(sthread_args->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
|
static inline int pthread_create(pthread_t *thread,
|
||||||
|
const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
|
||||||
{
|
{
|
||||||
sprintf(name_buffer, "0x%08X", (uint32_t) thread);
|
sprintf(name_buffer, "0x%08X", (uint32_t) thread);
|
||||||
|
|
||||||
*thread = sceKernelCreateThread(name_buffer,psp_thread_wrap, 0x20, STACKSIZE, 0, NULL);
|
*thread = sceKernelCreateThread(name_buffer,
|
||||||
|
psp_thread_wrap, 0x20, STACKSIZE, 0, NULL);
|
||||||
|
|
||||||
sthread_args_struct sthread_args;
|
sthread_args_struct sthread_args;
|
||||||
sthread_args.arg = arg;
|
sthread_args.arg = arg;
|
||||||
|
@ -65,7 +67,8 @@ static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
return sceKernelStartThread(*thread, sizeof(sthread_args), &sthread_args);
|
return sceKernelStartThread(*thread, sizeof(sthread_args), &sthread_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
|
static inline int pthread_mutex_init(pthread_mutex_t *mutex,
|
||||||
|
const pthread_mutexattr_t *attr)
|
||||||
{
|
{
|
||||||
sprintf(name_buffer, "0x%08X", (uint32_t) mutex);
|
sprintf(name_buffer, "0x%08X", (uint32_t) mutex);
|
||||||
|
|
||||||
|
@ -105,19 +108,22 @@ static inline int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
static inline int pthread_cond_wait(pthread_cond_t *cond,
|
||||||
|
pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
sceKernelDelayThread(10000);
|
sceKernelDelayThread(10000);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
|
static inline int pthread_cond_timedwait(pthread_cond_t *cond,
|
||||||
|
pthread_mutex_t *mutex, const struct timespec *abstime)
|
||||||
{
|
{
|
||||||
//FIXME: stub
|
//FIXME: stub
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
|
static inline int pthread_cond_init(pthread_cond_t *cond,
|
||||||
|
const pthread_condattr_t *attr)
|
||||||
{
|
{
|
||||||
//FIXME: stub
|
//FIXME: stub
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -27,8 +27,10 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "../compat/posix_string.h"
|
#include "../compat/posix_string.h"
|
||||||
|
|
||||||
// Need to be present for build to work, but it's not *really* used.
|
/* Need to be present for build to work, but it's not *really* used.
|
||||||
// Better than having to build special versions of lots of objects with special #ifdefs.
|
* Better than having to build special versions of lots of objects
|
||||||
|
* with special #ifdefs.
|
||||||
|
*/
|
||||||
struct settings g_settings;
|
struct settings g_settings;
|
||||||
struct global g_extern;
|
struct global g_extern;
|
||||||
driver_t driver;
|
driver_t driver;
|
||||||
|
@ -100,7 +102,8 @@ static void poll_joypad(const rarch_joypad_driver_t *driver,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, int joypad)
|
static void get_binds(config_file_t *conf, config_file_t *auto_conf,
|
||||||
|
int player, int joypad)
|
||||||
{
|
{
|
||||||
int i, timeout_cnt;
|
int i, timeout_cnt;
|
||||||
const rarch_joypad_driver_t *driver = input_joypad_init_driver(g_driver);
|
const rarch_joypad_driver_t *driver = input_joypad_init_driver(g_driver);
|
||||||
|
@ -146,9 +149,13 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
if (abs(initial) < 20000)
|
if (abs(initial) < 20000)
|
||||||
initial = 0;
|
initial = 0;
|
||||||
|
|
||||||
// Certain joypads (such as XBox360 controller on Linux) has a default negative axis for shoulder triggers,
|
/* Certain joypads (such as XBox360 controller on Linux)
|
||||||
// which makes configuration very awkward.
|
* has a default negative axis for shoulder triggers,
|
||||||
// If default negative, we can't trigger on the negative axis, and similar with defaulted positive axes.
|
* which makes configuration very awkward.
|
||||||
|
*
|
||||||
|
* If default negative, we can't trigger on the negative axis,
|
||||||
|
* and similar with defaulted positive axes.
|
||||||
|
*/
|
||||||
|
|
||||||
if (initial)
|
if (initial)
|
||||||
fprintf(stderr, "Axis %d is defaulted to %s axis value of %d.\n", i, initial > 0 ? "positive" : "negative", initial);
|
fprintf(stderr, "Axis %d is defaulted to %s axis value of %d.\n", i, initial > 0 ? "positive" : "negative", initial);
|
||||||
|
@ -183,9 +190,10 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
{
|
{
|
||||||
old_poll = new_poll;
|
old_poll = new_poll;
|
||||||
|
|
||||||
// To avoid pegging CPU.
|
/* To avoid pegging CPU.
|
||||||
// Ideally use an event-based joypad scheme,
|
* Ideally use an event-based joypad scheme,
|
||||||
// but it adds far more complexity, so, meh.
|
* but it adds far more complexity, so, meh.
|
||||||
|
*/
|
||||||
rarch_sleep(10);
|
rarch_sleep(10);
|
||||||
|
|
||||||
if (timeout_ticks)
|
if (timeout_ticks)
|
||||||
|
@ -206,7 +214,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
fprintf(stderr, "\tJoybutton pressed: %d\n", j);
|
fprintf(stderr, "\tJoybutton pressed: %d\n", j);
|
||||||
char key[64];
|
char key[64];
|
||||||
snprintf(key, sizeof(key), "%s_%s_btn",
|
snprintf(key, sizeof(key), "%s_%s_btn",
|
||||||
input_config_get_prefix(player_index, input_config_bind_map[i].meta), input_config_bind_map[i].base);
|
input_config_get_prefix(player_index,
|
||||||
|
input_config_bind_map[i].meta),
|
||||||
|
input_config_bind_map[i].base);
|
||||||
config_set_int(conf, key, j);
|
config_set_int(conf, key, j);
|
||||||
|
|
||||||
if (auto_conf)
|
if (auto_conf)
|
||||||
|
@ -230,7 +240,8 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
bool require_negative = initial_axes[j] > 0;
|
bool require_negative = initial_axes[j] > 0;
|
||||||
bool require_positive = initial_axes[j] < 0;
|
bool require_positive = initial_axes[j] < 0;
|
||||||
|
|
||||||
// Block the axis config until we're sure axes have returned to their neutral state.
|
/* Block the axis config until we're sure
|
||||||
|
* axes have returned to their neutral state. */
|
||||||
if (same_axis)
|
if (same_axis)
|
||||||
{
|
{
|
||||||
if (abs(value) < 10000 ||
|
if (abs(value) < 10000 ||
|
||||||
|
@ -239,7 +250,8 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
block_axis = false;
|
block_axis = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If axes are in their neutral state, we can't allow it.
|
/* If axes are in their neutral state,
|
||||||
|
* we can't allow it. */
|
||||||
if (require_negative && value >= 0)
|
if (require_negative && value >= 0)
|
||||||
continue;
|
continue;
|
||||||
if (require_positive && value <= 0)
|
if (require_positive && value <= 0)
|
||||||
|
@ -251,7 +263,8 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
if (abs(value) > 20000)
|
if (abs(value) > 20000)
|
||||||
{
|
{
|
||||||
last_axis = j;
|
last_axis = j;
|
||||||
fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n", j, value);
|
fprintf(stderr, "\tJoyaxis moved: Axis %d, Value %d\n",
|
||||||
|
j, value);
|
||||||
|
|
||||||
char buf[8];
|
char buf[8];
|
||||||
snprintf(buf, sizeof(buf),
|
snprintf(buf, sizeof(buf),
|
||||||
|
@ -259,7 +272,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
|
|
||||||
char key[64];
|
char key[64];
|
||||||
snprintf(key, sizeof(key), "%s_%s_axis",
|
snprintf(key, sizeof(key), "%s_%s_axis",
|
||||||
input_config_get_prefix(player_index, input_config_bind_map[i].meta), input_config_bind_map[i].base);
|
input_config_get_prefix(player_index,
|
||||||
|
input_config_bind_map[i].meta),
|
||||||
|
input_config_bind_map[i].base);
|
||||||
|
|
||||||
config_set_string(conf, key, buf);
|
config_set_string(conf, key, buf);
|
||||||
|
|
||||||
|
@ -298,7 +313,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player,
|
||||||
|
|
||||||
char key[64];
|
char key[64];
|
||||||
snprintf(key, sizeof(key), "%s_%s_btn",
|
snprintf(key, sizeof(key), "%s_%s_btn",
|
||||||
input_config_get_prefix(player_index, input_config_bind_map[i].meta), input_config_bind_map[i].base);
|
input_config_get_prefix(player_index,
|
||||||
|
input_config_bind_map[i].meta),
|
||||||
|
input_config_bind_map[i].base);
|
||||||
|
|
||||||
config_set_string(conf, key, buf);
|
config_set_string(conf, key, buf);
|
||||||
|
|
||||||
|
@ -394,7 +411,8 @@ static void parse_input(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
else if (g_player > MAX_PLAYERS)
|
else if (g_player > MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Player number must be from 1 to %d.\n", MAX_PLAYERS);
|
fprintf(stderr, "Player number must be from 1 to %d.\n",
|
||||||
|
MAX_PLAYERS);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -73,15 +73,20 @@ bool gx_init_mem2(void)
|
||||||
u32 level;
|
u32 level;
|
||||||
_CPU_ISR_Disable(level);
|
_CPU_ISR_Disable(level);
|
||||||
|
|
||||||
// BIG NOTE: MEM2 on the Wii is 64MB, but a portion of that is reserved for
|
/* BIG NOTE: MEM2 on the Wii is 64MB, but a portion
|
||||||
// IOS. libogc by default defines the "safe" area for MEM2 to go from
|
* of that is reserved for IOS.
|
||||||
// 0x90002000 to 0x933E0000. However, from my testing, I've found I need to
|
*
|
||||||
// reserve about 256KB for stuff like network and USB to work correctly.
|
* libogc by default defines the "safe" area for MEM2
|
||||||
// However, other sources says these functions need at least 0xE0000 bytes,
|
* to go from 0x90002000 to 0x933E0000.
|
||||||
// 7/8 of a megabyte, of reserved memory to do this. My initial testing
|
*
|
||||||
// shows that we can work with only 128KB, but we use 256KB becuse testing
|
* However, from my testing, I've found I need to
|
||||||
// has shown some stuff being iffy with only 128KB, mainly wiimote stuff.
|
* reserve about 256KB for stuff like network and USB to work correctly.
|
||||||
// If some stuff mysteriously stops working, try fiddling with this size.
|
* However, other sources says these functions need at least 0xE0000 bytes,
|
||||||
|
* 7/8 of a megabyte, of reserved memory to do this. My initial testing
|
||||||
|
* shows that we can work with only 128KB, but we use 256KB becuse testing
|
||||||
|
* has shown some stuff being iffy with only 128KB, mainly Wiimote stuff.
|
||||||
|
* If some stuff mysteriously stops working, try fiddling with this size.
|
||||||
|
*/
|
||||||
u32 size = SYS_GetArena2Size() - 1024 * 256;
|
u32 size = SYS_GetArena2Size() - 1024 * 256;
|
||||||
|
|
||||||
void *heap_ptr = (void *) ROUNDUP32(((u32) SYS_GetArena2Hi() - size));
|
void *heap_ptr = (void *) ROUNDUP32(((u32) SYS_GetArena2Hi() - size));
|
||||||
|
@ -94,17 +99,9 @@ bool gx_init_mem2(void)
|
||||||
|
|
||||||
void *_mem2_memalign(u8 align, u32 size)
|
void *_mem2_memalign(u8 align, u32 size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
if(size != 0)
|
||||||
|
return __lwp_heap_allocate(&gx_mem2_heap, size);
|
||||||
if(size == 0)
|
return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ptr = __lwp_heap_allocate(&gx_mem2_heap, size);
|
|
||||||
|
|
||||||
if (ptr == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *_mem2_malloc(u32 size)
|
void *_mem2_malloc(u32 size)
|
||||||
|
@ -114,10 +111,8 @@ void *_mem2_malloc(u32 size)
|
||||||
|
|
||||||
void _mem2_free(void *ptr)
|
void _mem2_free(void *ptr)
|
||||||
{
|
{
|
||||||
if(!ptr)
|
if(ptr)
|
||||||
return;
|
__lwp_heap_free(&gx_mem2_heap, ptr);
|
||||||
|
|
||||||
__lwp_heap_free(&gx_mem2_heap, ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *_mem2_realloc(void *ptr, u32 newsize)
|
void *_mem2_realloc(void *ptr, u32 newsize)
|
||||||
|
@ -246,7 +241,7 @@ __attribute__ ((used)) void __wrap_free(void *p)
|
||||||
__attribute__ ((used)) void *__wrap_realloc(void *p, size_t size)
|
__attribute__ ((used)) void *__wrap_realloc(void *p, size_t size)
|
||||||
{
|
{
|
||||||
void *n;
|
void *n;
|
||||||
// ptr from mem2
|
/* ptr from mem2 */
|
||||||
if (((u32) p & 0x10000000) != 0)
|
if (((u32) p & 0x10000000) != 0)
|
||||||
{
|
{
|
||||||
n = _mem2_realloc(p, size);
|
n = _mem2_realloc(p, size);
|
||||||
|
|
Loading…
Reference in New Issue