Some C89 strict fixes

This commit is contained in:
Alcaro 2015-06-26 17:03:05 +02:00
parent 9bc06346b5
commit 1bbd54f597
12 changed files with 58 additions and 55 deletions

View File

@ -175,12 +175,12 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
const struct dspfilter_implementation *impl = NULL; const struct dspfilter_implementation *impl = NULL;
struct rarch_dsp_plug *new_plugs = NULL; struct rarch_dsp_plug *new_plugs = NULL;
dylib_t lib = dylib_load(list->elems[i].data); dylib_t lib = dylib_load(list->elems[i].data);
dspfilter_get_implementation_t cb;
if (!lib) if (!lib)
continue; continue;
dspfilter_get_implementation_t cb = (dspfilter_get_implementation_t) cb = (dspfilter_get_implementation_t)dylib_proc(lib, "dspfilter_get_implementation");
dylib_proc(lib, "dspfilter_get_implementation");
if (!cb) if (!cb)
{ {
dylib_close(lib); dylib_close(lib);

View File

@ -58,9 +58,11 @@ static void alsa_worker_thread(void *data)
while (!alsa->thread_dead) while (!alsa->thread_dead)
{ {
size_t avail;
size_t fifo_size;
slock_lock(alsa->fifo_lock); slock_lock(alsa->fifo_lock);
size_t avail = fifo_read_avail(alsa->buffer); avail = fifo_read_avail(alsa->buffer);
size_t fifo_size = min(alsa->period_size, avail); fifo_size = min(alsa->period_size, avail);
fifo_read(alsa->buffer, buf, fifo_size); fifo_read(alsa->buffer, buf, fifo_size);
scond_signal(alsa->cond); scond_signal(alsa->cond);
slock_unlock(alsa->fifo_lock); slock_unlock(alsa->fifo_lock);
@ -149,15 +151,11 @@ static void *alsa_thread_init(const char *device,
unsigned rate, unsigned latency) unsigned rate, unsigned latency)
{ {
alsa_thread_t *alsa = (alsa_thread_t*)calloc(1, sizeof(alsa_thread_t)); alsa_thread_t *alsa = (alsa_thread_t*)calloc(1, sizeof(alsa_thread_t));
if (!alsa)
return NULL;
snd_pcm_hw_params_t *params = NULL; snd_pcm_hw_params_t *params = NULL;
snd_pcm_sw_params_t *sw_params = NULL; snd_pcm_sw_params_t *sw_params = NULL;
const char *alsa_dev = "default"; const char *alsa_dev = device ? device : "default";
if (device)
alsa_dev = device;
unsigned latency_usec = latency * 1000 / 2; unsigned latency_usec = latency * 1000 / 2;
@ -166,6 +164,9 @@ static void *alsa_thread_init(const char *device,
snd_pcm_uframes_t buffer_size; snd_pcm_uframes_t buffer_size;
snd_pcm_format_t format; snd_pcm_format_t format;
if (!alsa)
return NULL;
TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, 0)); TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, 0));
TRY_ALSA(snd_pcm_hw_params_malloc(&params)); TRY_ALSA(snd_pcm_hw_params_malloc(&params));
@ -246,9 +247,11 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size)
if (alsa->nonblock) if (alsa->nonblock)
{ {
size_t avail;
size_t write_amt;
slock_lock(alsa->fifo_lock); slock_lock(alsa->fifo_lock);
size_t avail = fifo_write_avail(alsa->buffer); avail = fifo_write_avail(alsa->buffer);
size_t write_amt = min(avail, size); write_amt = min(avail, size);
fifo_write(alsa->buffer, buf, write_amt); fifo_write(alsa->buffer, buf, write_amt);
slock_unlock(alsa->fifo_lock); slock_unlock(alsa->fifo_lock);
return write_amt; return write_amt;
@ -258,8 +261,9 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size)
size_t written = 0; size_t written = 0;
while (written < size && !alsa->thread_dead) while (written < size && !alsa->thread_dead)
{ {
size_t avail;
slock_lock(alsa->fifo_lock); slock_lock(alsa->fifo_lock);
size_t avail = fifo_write_avail(alsa->buffer); avail = fifo_write_avail(alsa->buffer);
if (avail == 0) if (avail == 0)
{ {
@ -316,11 +320,12 @@ static bool alsa_thread_start(void *data)
static size_t alsa_thread_write_avail(void *data) static size_t alsa_thread_write_avail(void *data)
{ {
alsa_thread_t *alsa = (alsa_thread_t*)data; alsa_thread_t *alsa = (alsa_thread_t*)data;
size_t val;
if (alsa->thread_dead) if (alsa->thread_dead)
return 0; return 0;
slock_lock(alsa->fifo_lock); slock_lock(alsa->fifo_lock);
size_t val = fifo_write_avail(alsa->buffer); val = fifo_write_avail(alsa->buffer);
slock_unlock(alsa->fifo_lock); slock_unlock(alsa->fifo_lock);
return val; return val;
} }

View File

@ -47,14 +47,11 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency)
int *fd = (int*)calloc(1, sizeof(int)); int *fd = (int*)calloc(1, sizeof(int));
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
const char *oss_device = device ? device : DEFAULT_OSS_DEV;
if (fd == NULL) if (fd == NULL)
return NULL; return NULL;
const char *oss_device = DEFAULT_OSS_DEV;
if (device != NULL)
oss_device = device;
if ((*fd = open(oss_device, O_WRONLY)) < 0) if ((*fd = open(oss_device, O_WRONLY)) < 0)
{ {
free(fd); free(fd);

View File

@ -62,8 +62,8 @@ static void pulse_free(void *data)
static void stream_success_cb(pa_stream *s, int success, void *data) static void stream_success_cb(pa_stream *s, int success, void *data)
{ {
(void)s;
pa_t *pa = (pa_t*)data; pa_t *pa = (pa_t*)data;
(void)s;
pa->success = success; pa->success = success;
pa_threaded_mainloop_signal(pa->mainloop, 0); pa_threaded_mainloop_signal(pa->mainloop, 0);
} }

View File

@ -95,7 +95,7 @@ static void *sdl_audio_init(const char *device,
spec.freq = rate; spec.freq = rate;
spec.format = AUDIO_S16SYS; spec.format = AUDIO_S16SYS;
spec.channels = 2; spec.channels = 2;
spec.samples = frames; // This is in audio frames, not samples ... :( spec.samples = frames; /* This is in audio frames, not samples ... :( */
spec.callback = sdl_audio_cb; spec.callback = sdl_audio_cb;
spec.userdata = sdl; spec.userdata = sdl;

View File

@ -97,11 +97,11 @@ static void resampler_CC_process(void *re_, struct resampler_data *data)
".set push\n" ".set push\n"
".set noreorder\n" ".set noreorder\n"
"mtv %2, s700 \n" // 700 = data->ratio = b "mtv %2, s700 \n" /* 700 = data->ratio = b */
// "vsat0.s s700, s700 \n" /* "vsat0.s s700, s700 \n" */
"vrcp.s s701, s700 \n" // 701 = 1.0 / b "vrcp.s s701, s700 \n" /* 701 = 1.0 / b */
"vadd.s s702, s700, s700 \n" // 702 = 2 * b "vadd.s s702, s700, s700 \n" /* 702 = 2 * b */
"vmul.s s703, s700, s710 \n" // 703 = b * pi "vmul.s s703, s700, s710 \n" /* 703 = b * pi */
"mfv %0, s701 \n" "mfv %0, s701 \n"
"mfv %1, s730 \n" "mfv %1, s730 \n"
@ -128,8 +128,8 @@ static void resampler_CC_process(void *re_, struct resampler_data *data)
"vadd.q c600, c730[-X,Y,-X,Y], c730[1/2,1/2,-1/2,-1/2]\n" "vadd.q c600, c730[-X,Y,-X,Y], c730[1/2,1/2,-1/2,-1/2]\n"
"vmul.q c610, c600, c700[Z,Z,Z,Z] \n" //*2*b "vmul.q c610, c600, c700[Z,Z,Z,Z] \n" /* *2*b */
"vmul.q c600, c600, c700[W,W,W,W] \n" //*b*pi "vmul.q c600, c600, c700[W,W,W,W] \n" /* *b*pi */
"vsin.q c610, c610 \n" "vsin.q c610, c610 \n"
"vadd.q c600, c600, c610 \n" "vadd.q c600, c600, c610 \n"

View File

@ -351,6 +351,7 @@ static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
#else #else
const float *phase_table = resamp->phase_table + phase * taps; const float *phase_table = resamp->phase_table + phase * taps;
#endif #endif
__m128 sum;
for (i = 0; i < taps; i += 4) for (i = 0; i < taps; i += 4)
{ {
@ -373,7 +374,7 @@ static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
* sum_r = { r3, r2, r1, r0 } * sum_r = { r3, r2, r1, r0 }
*/ */
__m128 sum = _mm_add_ps(_mm_shuffle_ps(sum_l, sum_r, sum = _mm_add_ps(_mm_shuffle_ps(sum_l, sum_r,
_MM_SHUFFLE(1, 0, 1, 0)), _MM_SHUFFLE(1, 0, 1, 0)),
_mm_shuffle_ps(sum_l, sum_r, _MM_SHUFFLE(3, 2, 3, 2))); _mm_shuffle_ps(sum_l, sum_r, _MM_SHUFFLE(3, 2, 3, 2)));

View File

@ -663,7 +663,7 @@ static void update_texture_asm(const uint32_t *src, const uint32_t *dst,
register uint32_t tmp0, tmp1, tmp2, tmp3, line2, line2b, register uint32_t tmp0, tmp1, tmp2, tmp3, line2, line2b,
line3, line3b, line4, line4b, line5; line3, line3b, line4, line4b, line5;
asm volatile ( __asm__ volatile (
" srwi %[width], %[width], 2 \n" " srwi %[width], %[width], 2 \n"
" srwi %[height], %[height], 2 \n" " srwi %[height], %[height], 2 \n"
" subi %[tmp3], %[dst], 4 \n" " subi %[tmp3], %[dst], 4 \n"

View File

@ -254,8 +254,8 @@ static void sdl_refresh_renderer(sdl2_video_t *vid)
SDL_Rect r = { vid->vp.x, vid->vp.y, (int)vid->vp.width, (int)vid->vp.height }; SDL_Rect r = { vid->vp.x, vid->vp.y, (int)vid->vp.width, (int)vid->vp.height };
SDL_RenderSetViewport(vid->renderer, &r); SDL_RenderSetViewport(vid->renderer, &r);
// breaks int scaling /* breaks int scaling */
// SDL_RenderSetLogicalSize(vid->renderer, vid->vp.width, vid->vp.height); /* SDL_RenderSetLogicalSize(vid->renderer, vid->vp.width, vid->vp.height); */
} }
static void sdl_refresh_viewport(sdl2_video_t *vid) static void sdl_refresh_viewport(sdl2_video_t *vid)
@ -407,8 +407,6 @@ static void *sdl2_gfx_init(const video_info_t *video, const input_driver_t **inp
mode.refresh_rate); mode.refresh_rate);
} }
// void *sdl_input = NULL;
if (!video->fullscreen) if (!video->fullscreen)
RARCH_LOG("[SDL]: Creating window @ %ux%u\n", video->width, video->height); RARCH_LOG("[SDL]: Creating window @ %ux%u\n", video->width, video->height);

View File

@ -534,8 +534,8 @@ static EGLint *egl_fill_attribs(EGLint *attr)
*attr++ = g_major; *attr++ = g_major;
*attr++ = EGL_CONTEXT_MINOR_VERSION_KHR; *attr++ = EGL_CONTEXT_MINOR_VERSION_KHR;
*attr++ = g_minor; *attr++ = g_minor;
// Technically, we don't have core/compat until 3.2. /* Technically, we don't have core/compat until 3.2.
// Version 3.1 is either compat or not depending on GL_ARB_compatibility. * Version 3.1 is either compat or not depending on GL_ARB_compatibility. */
if (version >= 3002) if (version >= 3002)
{ {
*attr++ = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR; *attr++ = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
@ -554,7 +554,7 @@ static EGLint *egl_fill_attribs(EGLint *attr)
#endif #endif
case GFX_CTX_OPENGL_ES_API: case GFX_CTX_OPENGL_ES_API:
*attr++ = EGL_CONTEXT_CLIENT_VERSION; // Same as EGL_CONTEXT_MAJOR_VERSION *attr++ = EGL_CONTEXT_CLIENT_VERSION; /* Same as EGL_CONTEXT_MAJOR_VERSION */
*attr++ = g_major ? (EGLint)g_major : 2; *attr++ = g_major ? (EGLint)g_major : 2;
#ifdef EGL_KHR_create_context #ifdef EGL_KHR_create_context
if (g_minor > 0) if (g_minor > 0)
@ -666,9 +666,11 @@ static void gfx_ctx_wl_input_driver(void *data,
const input_driver_t **input, void **input_data) const input_driver_t **input, void **input_data)
{ {
(void)data; (void)data;
#if 0
//void *wl = input_wayland.init(); //void *wl = input_wayland.init();
//*input = wl ? &input_wayland : NULL; //*input = wl ? &input_wayland : NULL;
//*input_data = wl; //*input_data = wl;
#endif
*input = NULL; *input = NULL;
*input_data = NULL; *input_data = NULL;
} }
@ -754,7 +756,7 @@ uint32_t format,
int fd, int fd,
uint32_t size) uint32_t size)
{ {
// TODO /* TODO */
} }
static void keyboard_handle_enter(void* data, static void keyboard_handle_enter(void* data,
@ -763,7 +765,7 @@ uint32_t serial,
struct wl_surface* surface, struct wl_surface* surface,
struct wl_array* keys) struct wl_array* keys)
{ {
// TODO /* TODO */
} }
static void keyboard_handle_leave(void* data, static void keyboard_handle_leave(void* data,
@ -771,7 +773,7 @@ struct wl_keyboard* keyboard,
uint32_t serial, uint32_t serial,
struct wl_surface* surface) struct wl_surface* surface)
{ {
// TODO /* TODO */
} }
static void keyboard_handle_key(void* data, static void keyboard_handle_key(void* data,
@ -781,7 +783,7 @@ uint32_t time,
uint32_t key, uint32_t key,
uint32_t state) uint32_t state)
{ {
// TODO /* TODO */
} }
static void keyboard_handle_modifiers(void* data, static void keyboard_handle_modifiers(void* data,
@ -792,7 +794,7 @@ uint32_t modsLatched,
uint32_t modsLocked, uint32_t modsLocked,
uint32_t group) uint32_t group)
{ {
// TODO /* TODO */
} }
static const struct wl_keyboard_listener keyboard_listener = { static const struct wl_keyboard_listener keyboard_listener = {
@ -810,7 +812,7 @@ struct wl_surface* surface,
wl_fixed_t sx, wl_fixed_t sx,
wl_fixed_t sy) wl_fixed_t sy)
{ {
// TODO /* TODO */
} }
static void pointer_handle_leave(void* data, static void pointer_handle_leave(void* data,
@ -818,7 +820,7 @@ struct wl_pointer* pointer,
uint32_t serial, uint32_t serial,
struct wl_surface* surface) struct wl_surface* surface)
{ {
// TODO /* TODO */
} }
static void pointer_handle_motion(void* data, static void pointer_handle_motion(void* data,
@ -827,7 +829,7 @@ uint32_t time,
wl_fixed_t sx, wl_fixed_t sx,
wl_fixed_t sy) wl_fixed_t sy)
{ {
// TODO /* TODO */
} }
static void pointer_handle_button(void* data, static void pointer_handle_button(void* data,
@ -837,7 +839,7 @@ uint32_t time,
uint32_t button, uint32_t button,
uint32_t state) uint32_t state)
{ {
// TODO /* TODO */
} }
static void pointer_handle_axis(void* data, static void pointer_handle_axis(void* data,
@ -846,7 +848,7 @@ uint32_t time,
uint32_t axis, uint32_t axis,
wl_fixed_t value) wl_fixed_t value)
{ {
// TODO /* TODO */
} }

View File

@ -299,7 +299,7 @@ static bool add_device(udev_input_t *udev,
strlcpy(device->devnode, devnode, sizeof(device->devnode)); strlcpy(device->devnode, devnode, sizeof(device->devnode));
// Touchpads report in absolute coords. /* Touchpads report in absolute coords. */
if (cb == udev_handle_touchpad && if (cb == udev_handle_touchpad &&
(ioctl(fd, EVIOCGABS(ABS_X), &device->state.touchpad.info_x) < 0 || (ioctl(fd, EVIOCGABS(ABS_X), &device->state.touchpad.info_x) < 0 ||
ioctl(fd, EVIOCGABS(ABS_Y), &device->state.touchpad.info_y) < 0)) ioctl(fd, EVIOCGABS(ABS_Y), &device->state.touchpad.info_y) < 0))
@ -680,7 +680,7 @@ static void disable_terminal_input(void)
newterm.c_cc[VMIN] = 0; newterm.c_cc[VMIN] = 0;
newterm.c_cc[VTIME] = 0; newterm.c_cc[VTIME] = 0;
// Be careful about recovering the terminal ... /* Be careful about recovering the terminal ... */
if (ioctl(0, KDGKBMODE, &oldkbmd) < 0) if (ioctl(0, KDGKBMODE, &oldkbmd) < 0)
return; return;
if (tcsetattr(0, TCSAFLUSH, &newterm) < 0) if (tcsetattr(0, TCSAFLUSH, &newterm) < 0)
@ -695,7 +695,7 @@ static void disable_terminal_input(void)
sa.sa_flags = SA_RESTART | SA_RESETHAND; sa.sa_flags = SA_RESTART | SA_RESETHAND;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
// Trap some fatal signals. /* Trap some fatal signals. */
sigaction(SIGABRT, &sa, NULL); sigaction(SIGABRT, &sa, NULL);
sigaction(SIGBUS, &sa, NULL); sigaction(SIGBUS, &sa, NULL);
sigaction(SIGFPE, &sa, NULL); sigaction(SIGFPE, &sa, NULL);

View File

@ -182,15 +182,15 @@ retro_perf_tick_t rarch_get_perf_counter(void)
#elif defined(__GNUC__) && !defined(RARCH_CONSOLE) #elif defined(__GNUC__) && !defined(RARCH_CONSOLE)
#if defined(__i386__) || defined(__i486__) || defined(__i686__) #if defined(__i386__) || defined(__i486__) || defined(__i686__)
asm volatile ("rdtsc" : "=A" (time_ticks)); __asm__ volatile ("rdtsc" : "=A" (time_ticks));
#elif defined(__x86_64__) #elif defined(__x86_64__)
unsigned a, d; unsigned a, d;
asm volatile ("rdtsc" : "=a" (a), "=d" (d)); __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
time_ticks = (retro_perf_tick_t)a | ((retro_perf_tick_t)d << 32); time_ticks = (retro_perf_tick_t)a | ((retro_perf_tick_t)d << 32);
#endif #endif
#elif defined(__ARM_ARCH_6__) #elif defined(__ARM_ARCH_6__)
asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(time_ticks) ); __asm__ volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(time_ticks) );
#elif defined(__CELLOS_LV2__) || defined(GEKKO) || defined(_XBOX360) || defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__) #elif defined(__CELLOS_LV2__) || defined(GEKKO) || defined(_XBOX360) || defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__)
time_ticks = __mftb(); time_ticks = __mftb();
#elif defined(PSP) #elif defined(PSP)
@ -286,7 +286,7 @@ static void x86_cpuid(int func, int flags[4])
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__)
asm volatile ( __asm__ volatile (
"mov %%" REG_b ", %%" REG_S "\n" "mov %%" REG_b ", %%" REG_S "\n"
"cpuid\n" "cpuid\n"
"xchg %%" REG_b ", %%" REG_S "\n" "xchg %%" REG_b ", %%" REG_S "\n"
@ -305,7 +305,7 @@ static uint64_t xgetbv_x86(uint32_t idx)
{ {
#if defined(__GNUC__) #if defined(__GNUC__)
uint32_t eax, edx; uint32_t eax, edx;
asm volatile ( __asm__ volatile (
/* Older GCC versions (Apple's GCC for example) do /* Older GCC versions (Apple's GCC for example) do
* not understand xgetbv instruction. * not understand xgetbv instruction.
* Stamp out the machine code directly. * Stamp out the machine code directly.
@ -331,7 +331,7 @@ static void arm_enable_runfast_mode(void)
static const unsigned x = 0x04086060; static const unsigned x = 0x04086060;
static const unsigned y = 0x03000000; static const unsigned y = 0x03000000;
int r; int r;
asm volatile( __asm__ volatile(
"fmrx %0, fpscr \n\t" /* r0 = FPSCR */ "fmrx %0, fpscr \n\t" /* r0 = FPSCR */
"and %0, %0, %1 \n\t" /* r0 = r0 & 0x04086060 */ "and %0, %0, %1 \n\t" /* r0 = r0 & 0x04086060 */
"orr %0, %0, %2 \n\t" /* r0 = r0 | 0x03000000 */ "orr %0, %0, %2 \n\t" /* r0 = r0 | 0x03000000 */