diff --git a/thread/gx_pthread.h b/thread/gx_pthread.h index 60b9df97d6..36a8449cfa 100644 --- a/thread/gx_pthread.h +++ b/thread/gx_pthread.h @@ -86,13 +86,16 @@ typedef int pthread_attr_t; typedef cond_t pthread_cond_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; - 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); } @@ -135,17 +138,20 @@ static inline int pthread_mutex_trylock(pthread_mutex_t *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); } -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); } -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); } diff --git a/thread/psp_pthread.h b/thread/psp_pthread.h index 329dd65a5a..0d881fb67f 100644 --- a/thread/psp_pthread.h +++ b/thread/psp_pthread.h @@ -33,7 +33,7 @@ typedef int pthread_attr_t; typedef SceUID pthread_cond_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]; 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); } -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); - *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.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); } -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); @@ -105,19 +108,22 @@ static inline int pthread_mutex_trylock(pthread_mutex_t *mutex) 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); 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 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 return 1; diff --git a/tools/retroarch-joyconfig.c b/tools/retroarch-joyconfig.c index 350958271f..3adc698cf2 100644 --- a/tools/retroarch-joyconfig.c +++ b/tools/retroarch-joyconfig.c @@ -27,8 +27,10 @@ #include #include "../compat/posix_string.h" -// 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. +/* 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. + */ struct settings g_settings; struct global g_extern; 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; 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) initial = 0; - // Certain joypads (such as XBox360 controller on Linux) has a default negative axis for shoulder triggers, - // which makes configuration very awkward. - // If default negative, we can't trigger on the negative axis, and similar with defaulted positive axes. + /* Certain joypads (such as XBox360 controller on Linux) + * has a default negative axis for shoulder triggers, + * which makes configuration very awkward. + * + * If default negative, we can't trigger on the negative axis, + * and similar with defaulted positive axes. + */ if (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; - // To avoid pegging CPU. - // Ideally use an event-based joypad scheme, - // but it adds far more complexity, so, meh. + /* To avoid pegging CPU. + * Ideally use an event-based joypad scheme, + * but it adds far more complexity, so, meh. + */ rarch_sleep(10); 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); char key[64]; 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); 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_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 (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; } - // 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) continue; 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) { 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]; 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]; 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); @@ -298,7 +313,9 @@ static void get_binds(config_file_t *conf, config_file_t *auto_conf, int player, char key[64]; 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); @@ -394,7 +411,8 @@ static void parse_input(int argc, char *argv[]) } 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); } break; diff --git a/wii/mem2_manager.c b/wii/mem2_manager.c index 26dc80a26c..cf78908589 100644 --- a/wii/mem2_manager.c +++ b/wii/mem2_manager.c @@ -73,15 +73,20 @@ bool gx_init_mem2(void) u32 level; _CPU_ISR_Disable(level); - // BIG NOTE: MEM2 on the Wii is 64MB, but a portion of that is reserved for - // IOS. libogc by default defines the "safe" area for MEM2 to go from - // 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. - // 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. + /* BIG NOTE: MEM2 on the Wii is 64MB, but a portion + * of that is reserved for IOS. + * + * libogc by default defines the "safe" area for MEM2 + * to go from 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. + * 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; 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 *ptr; - - if(size == 0) - return NULL; - - ptr = __lwp_heap_allocate(&gx_mem2_heap, size); - - if (ptr == NULL) - return NULL; - - return ptr; + if(size != 0) + return __lwp_heap_allocate(&gx_mem2_heap, size); + return NULL; } void *_mem2_malloc(u32 size) @@ -114,10 +111,8 @@ void *_mem2_malloc(u32 size) void _mem2_free(void *ptr) { - if(!ptr) - return; - - __lwp_heap_free(&gx_mem2_heap, ptr); + if(ptr) + __lwp_heap_free(&gx_mem2_heap, ptr); } 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) { void *n; - // ptr from mem2 + /* ptr from mem2 */ if (((u32) p & 0x10000000) != 0) { n = _mem2_realloc(p, size);