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;
struct rarch_dsp_plug *new_plugs = NULL;
dylib_t lib = dylib_load(list->elems[i].data);
dspfilter_get_implementation_t cb;
if (!lib)
continue;
dspfilter_get_implementation_t cb = (dspfilter_get_implementation_t)
dylib_proc(lib, "dspfilter_get_implementation");
cb = (dspfilter_get_implementation_t)dylib_proc(lib, "dspfilter_get_implementation");
if (!cb)
{
dylib_close(lib);

View File

@ -58,9 +58,11 @@ static void alsa_worker_thread(void *data)
while (!alsa->thread_dead)
{
size_t avail;
size_t fifo_size;
slock_lock(alsa->fifo_lock);
size_t avail = fifo_read_avail(alsa->buffer);
size_t fifo_size = min(alsa->period_size, avail);
avail = fifo_read_avail(alsa->buffer);
fifo_size = min(alsa->period_size, avail);
fifo_read(alsa->buffer, buf, fifo_size);
scond_signal(alsa->cond);
slock_unlock(alsa->fifo_lock);
@ -149,15 +151,11 @@ static void *alsa_thread_init(const char *device,
unsigned rate, unsigned latency)
{
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_sw_params_t *sw_params = NULL;
const char *alsa_dev = "default";
if (device)
alsa_dev = device;
const char *alsa_dev = device ? device : "default";
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_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_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)
{
size_t avail;
size_t write_amt;
slock_lock(alsa->fifo_lock);
size_t avail = fifo_write_avail(alsa->buffer);
size_t write_amt = min(avail, size);
avail = fifo_write_avail(alsa->buffer);
write_amt = min(avail, size);
fifo_write(alsa->buffer, buf, write_amt);
slock_unlock(alsa->fifo_lock);
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;
while (written < size && !alsa->thread_dead)
{
size_t avail;
slock_lock(alsa->fifo_lock);
size_t avail = fifo_write_avail(alsa->buffer);
avail = fifo_write_avail(alsa->buffer);
if (avail == 0)
{
@ -316,11 +320,12 @@ static bool alsa_thread_start(void *data)
static size_t alsa_thread_write_avail(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
size_t val;
if (alsa->thread_dead)
return 0;
slock_lock(alsa->fifo_lock);
size_t val = fifo_write_avail(alsa->buffer);
val = fifo_write_avail(alsa->buffer);
slock_unlock(alsa->fifo_lock);
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));
settings_t *settings = config_get_ptr();
const char *oss_device = device ? device : DEFAULT_OSS_DEV;
if (fd == NULL)
return NULL;
const char *oss_device = DEFAULT_OSS_DEV;
if (device != NULL)
oss_device = device;
if ((*fd = open(oss_device, O_WRONLY)) < 0)
{
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)
{
(void)s;
pa_t *pa = (pa_t*)data;
(void)s;
pa->success = success;
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.format = AUDIO_S16SYS;
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.userdata = sdl;

View File

@ -97,11 +97,11 @@ static void resampler_CC_process(void *re_, struct resampler_data *data)
".set push\n"
".set noreorder\n"
"mtv %2, s700 \n" // 700 = data->ratio = b
// "vsat0.s s700, s700 \n"
"vrcp.s s701, s700 \n" // 701 = 1.0 / b
"vadd.s s702, s700, s700 \n" // 702 = 2 * b
"vmul.s s703, s700, s710 \n" // 703 = b * pi
"mtv %2, s700 \n" /* 700 = data->ratio = b */
/* "vsat0.s s700, s700 \n" */
"vrcp.s s701, s700 \n" /* 701 = 1.0 / b */
"vadd.s s702, s700, s700 \n" /* 702 = 2 * b */
"vmul.s s703, s700, s710 \n" /* 703 = b * pi */
"mfv %0, s701 \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"
"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 c610, c600, c700[Z,Z,Z,Z] \n" /* *2*b */
"vmul.q c600, c600, c700[W,W,W,W] \n" /* *b*pi */
"vsin.q c610, 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
const float *phase_table = resamp->phase_table + phase * taps;
#endif
__m128 sum;
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 }
*/
__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_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,
line3, line3b, line4, line4b, line5;
asm volatile (
__asm__ volatile (
" srwi %[width], %[width], 2 \n"
" srwi %[height], %[height], 2 \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_RenderSetViewport(vid->renderer, &r);
// breaks int scaling
// SDL_RenderSetLogicalSize(vid->renderer, vid->vp.width, vid->vp.height);
/* breaks int scaling */
/* SDL_RenderSetLogicalSize(vid->renderer, vid->vp.width, vid->vp.height); */
}
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);
}
// void *sdl_input = NULL;
if (!video->fullscreen)
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++ = EGL_CONTEXT_MINOR_VERSION_KHR;
*attr++ = g_minor;
// Technically, we don't have core/compat until 3.2.
// Version 3.1 is either compat or not depending on GL_ARB_compatibility.
/* Technically, we don't have core/compat until 3.2.
* Version 3.1 is either compat or not depending on GL_ARB_compatibility. */
if (version >= 3002)
{
*attr++ = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
@ -554,7 +554,7 @@ static EGLint *egl_fill_attribs(EGLint *attr)
#endif
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;
#ifdef EGL_KHR_create_context
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)
{
(void)data;
#if 0
//void *wl = input_wayland.init();
//*input = wl ? &input_wayland : NULL;
//*input_data = wl;
#endif
*input = NULL;
*input_data = NULL;
}
@ -754,7 +756,7 @@ uint32_t format,
int fd,
uint32_t size)
{
// TODO
/* TODO */
}
static void keyboard_handle_enter(void* data,
@ -763,7 +765,7 @@ uint32_t serial,
struct wl_surface* surface,
struct wl_array* keys)
{
// TODO
/* TODO */
}
static void keyboard_handle_leave(void* data,
@ -771,7 +773,7 @@ struct wl_keyboard* keyboard,
uint32_t serial,
struct wl_surface* surface)
{
// TODO
/* TODO */
}
static void keyboard_handle_key(void* data,
@ -781,7 +783,7 @@ uint32_t time,
uint32_t key,
uint32_t state)
{
// TODO
/* TODO */
}
static void keyboard_handle_modifiers(void* data,
@ -792,7 +794,7 @@ uint32_t modsLatched,
uint32_t modsLocked,
uint32_t group)
{
// TODO
/* TODO */
}
static const struct wl_keyboard_listener keyboard_listener = {
@ -810,7 +812,7 @@ struct wl_surface* surface,
wl_fixed_t sx,
wl_fixed_t sy)
{
// TODO
/* TODO */
}
static void pointer_handle_leave(void* data,
@ -818,7 +820,7 @@ struct wl_pointer* pointer,
uint32_t serial,
struct wl_surface* surface)
{
// TODO
/* TODO */
}
static void pointer_handle_motion(void* data,
@ -827,7 +829,7 @@ uint32_t time,
wl_fixed_t sx,
wl_fixed_t sy)
{
// TODO
/* TODO */
}
static void pointer_handle_button(void* data,
@ -837,7 +839,7 @@ uint32_t time,
uint32_t button,
uint32_t state)
{
// TODO
/* TODO */
}
static void pointer_handle_axis(void* data,
@ -846,7 +848,7 @@ uint32_t time,
uint32_t axis,
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));
// Touchpads report in absolute coords.
/* Touchpads report in absolute coords. */
if (cb == udev_handle_touchpad &&
(ioctl(fd, EVIOCGABS(ABS_X), &device->state.touchpad.info_x) < 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[VTIME] = 0;
// Be careful about recovering the terminal ...
/* Be careful about recovering the terminal ... */
if (ioctl(0, KDGKBMODE, &oldkbmd) < 0)
return;
if (tcsetattr(0, TCSAFLUSH, &newterm) < 0)
@ -695,7 +695,7 @@ static void disable_terminal_input(void)
sa.sa_flags = SA_RESTART | SA_RESETHAND;
sigemptyset(&sa.sa_mask);
// Trap some fatal signals.
/* Trap some fatal signals. */
sigaction(SIGABRT, &sa, NULL);
sigaction(SIGBUS, &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)
#if defined(__i386__) || defined(__i486__) || defined(__i686__)
asm volatile ("rdtsc" : "=A" (time_ticks));
__asm__ volatile ("rdtsc" : "=A" (time_ticks));
#elif defined(__x86_64__)
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);
#endif
#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__)
time_ticks = __mftb();
#elif defined(PSP)
@ -286,7 +286,7 @@ static void x86_cpuid(int func, int flags[4])
#endif
#if defined(__GNUC__)
asm volatile (
__asm__ volatile (
"mov %%" REG_b ", %%" REG_S "\n"
"cpuid\n"
"xchg %%" REG_b ", %%" REG_S "\n"
@ -305,7 +305,7 @@ static uint64_t xgetbv_x86(uint32_t idx)
{
#if defined(__GNUC__)
uint32_t eax, edx;
asm volatile (
__asm__ volatile (
/* Older GCC versions (Apple's GCC for example) do
* not understand xgetbv instruction.
* 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 y = 0x03000000;
int r;
asm volatile(
__asm__ volatile(
"fmrx %0, fpscr \n\t" /* r0 = FPSCR */
"and %0, %0, %1 \n\t" /* r0 = r0 & 0x04086060 */
"orr %0, %0, %2 \n\t" /* r0 = r0 | 0x03000000 */