C89_BUILD fixes

This commit is contained in:
twinaphex 2015-06-29 21:39:00 +02:00
parent de6494f6d9
commit 018c685b09
11 changed files with 83 additions and 89 deletions

View File

@ -295,11 +295,14 @@ ifeq ($(HAVE_JACK),1)
DEFINES += $(JACK_CFLAGS) DEFINES += $(JACK_CFLAGS)
endif endif
ifneq ($(C89_BUILD), 1)
# PulseAudio is not a C89-compliant API.
ifeq ($(HAVE_PULSE), 1) ifeq ($(HAVE_PULSE), 1)
OBJ += audio/drivers/pulse.o OBJ += audio/drivers/pulse.o
LIBS += $(PULSE_LIBS) LIBS += $(PULSE_LIBS)
DEFINES += $(PULSE_CFLAGS) DEFINES += $(PULSE_CFLAGS)
endif endif
endif
ifeq ($(HAVE_OSS_LIB), 1) ifeq ($(HAVE_OSS_LIB), 1)
LIBS += -lossaudio LIBS += -lossaudio

View File

@ -96,9 +96,11 @@ static bool create_filter_graph(rarch_dsp_filter_t *dsp, float sample_rate)
for (i = 0; i < filters; i++) for (i = 0; i < filters; i++)
{ {
struct config_file_userdata userdata; struct config_file_userdata userdata;
struct dspfilter_info info;
char key[64] = {0}; char key[64] = {0};
char name[64] = {0}; char name[64] = {0};
struct dspfilter_info info = { sample_rate };
info.input_rate = sample_rate;
snprintf(key, sizeof(key), "filter%u", i); snprintf(key, sizeof(key), "filter%u", i);

View File

@ -66,7 +66,7 @@ void audio_convert_float_to_s16_C(int16_t *out,
for (i = 0; i < samples; i++) for (i = 0; i < samples; i++)
{ {
int32_t val = (int32_t)(in[i] * 0x8000); int32_t val = (int32_t)(in[i] * 0x8000);
out[i] = (val > 0x7FFF) ? 0x7FFF : out[i] = (val > 0x7FFF) ? 0x7FFF :
(val < -0x8000 ? -0x8000 : (int16_t)val); (val < -0x8000 ? -0x8000 : (int16_t)val);
} }
} }
@ -93,19 +93,14 @@ void audio_convert_s16_to_float_SSE2(float *out,
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8) for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{ {
__m128i input = _mm_loadu_si128((const __m128i *)in); __m128i input = _mm_loadu_si128((const __m128i *)in);
__m128i regs[2] = { __m128i regs_l = _mm_unpacklo_epi16(_mm_setzero_si128(), input);
_mm_unpacklo_epi16(_mm_setzero_si128(), input), __m128i regs_r = _mm_unpackhi_epi16(_mm_setzero_si128(), input);
_mm_unpackhi_epi16(_mm_setzero_si128(), input), __m128 output_l = _mm_mul_ps(_mm_cvtepi32_ps(regs_l), factor);
}; __m128 output_r = _mm_mul_ps(_mm_cvtepi32_ps(regs_r), factor);
__m128 output[2] = { _mm_storeu_ps(out + 0, output_l);
_mm_mul_ps(_mm_cvtepi32_ps(regs[0]), factor), _mm_storeu_ps(out + 4, output_r);
_mm_mul_ps(_mm_cvtepi32_ps(regs[1]), factor),
};
_mm_storeu_ps(out + 0, output[0]);
_mm_storeu_ps(out + 4, output[1]);
} }
audio_convert_s16_to_float_C(out, in, samples - i, gain); audio_convert_s16_to_float_C(out, in, samples - i, gain);
@ -130,12 +125,13 @@ void audio_convert_float_to_s16_SSE2(int16_t *out,
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8) for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{ {
__m128 input[2] = { _mm_loadu_ps(in + 0), _mm_loadu_ps(in + 4) }; __m128 input_l = _mm_loadu_ps(in + 0);
__m128 res[2] = { _mm_mul_ps(input[0], factor), __m128 input_r = _mm_loadu_ps(in + 4);
_mm_mul_ps(input[1], factor) }; __m128 res_l = _mm_mul_ps(input_l, factor);
__m128 res_r = _mm_mul_ps(input_r, factor);
__m128i ints[2] = { _mm_cvtps_epi32(res[0]), _mm_cvtps_epi32(res[1]) }; __m128i ints_l = _mm_cvtps_epi32(res_l);
__m128i packed = _mm_packs_epi32(ints[0], ints[1]); __m128i ints_r = _mm_cvtps_epi32(res_r);
__m128i packed = _mm_packs_epi32(ints_l, ints_r);
_mm_storeu_si128((__m128i *)out, packed); _mm_storeu_si128((__m128i *)out, packed);
} }
@ -170,10 +166,10 @@ void audio_convert_s16_to_float_altivec(float *out,
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8) for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{ {
vector signed short input = vec_ld(0, in); vector signed short input = vec_ld(0, in);
vector signed int hi = vec_unpackh(input); vector signed int hi = vec_unpackh(input);
vector signed int lo = vec_unpackl(input); vector signed int lo = vec_unpackl(input);
vector float out_hi = vec_madd(vec_ctf(hi, 15), gain_vec, zero_vec); vector float out_hi = vec_madd(vec_ctf(hi, 15), gain_vec, zero_vec);
vector float out_lo = vec_madd(vec_ctf(lo, 15), gain_vec, zero_vec); vector float out_lo = vec_madd(vec_ctf(lo, 15), gain_vec, zero_vec);
vec_st(out_hi, 0, out); vec_st(out_hi, 0, out);
vec_st(out_lo, 16, out); vec_st(out_lo, 16, out);
@ -207,8 +203,8 @@ void audio_convert_float_to_s16_altivec(int16_t *out,
size_t i; size_t i;
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8) for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{ {
vector float input0 = vec_ld( 0, in); vector float input0 = vec_ld( 0, in);
vector float input1 = vec_ld(16, in); vector float input1 = vec_ld(16, in);
vector signed int result0 = vec_cts(input0, 15); vector signed int result0 = vec_cts(input0, 15);
vector signed int result1 = vec_cts(input1, 15); vector signed int result1 = vec_cts(input1, 15);
vec_st(vec_packs(result0, result1), 0, out); vec_st(vec_packs(result0, result1), 0, out);

View File

@ -150,7 +150,7 @@ static bool al_get_buffer(al_t *al, ALuint *buffer)
if (al->nonblock) if (al->nonblock)
return false; return false;
// Must sleep as there is no proper blocking method. :( /* Must sleep as there is no proper blocking method. */
rarch_sleep(1); rarch_sleep(1);
} }
} }

View File

@ -119,6 +119,8 @@ void fill_pathname_abbreviate_special(char *out_path,
{ {
#if !defined(RARCH_CONSOLE) #if !defined(RARCH_CONSOLE)
unsigned i; unsigned i;
const char *candidates[3];
const char *notations[3];
char application_dir[PATH_MAX_LENGTH] = {0}; char application_dir[PATH_MAX_LENGTH] = {0};
const char *home = getenv("HOME"); const char *home = getenv("HOME");
@ -128,8 +130,13 @@ void fill_pathname_abbreviate_special(char *out_path,
* new location inside home would break otherwise. */ * new location inside home would break otherwise. */
/* ugly hack - use application_dir pointer before filling it in. C89 reasons */ /* ugly hack - use application_dir pointer before filling it in. C89 reasons */
const char *candidates[3] = { application_dir, home, NULL }; candidates[0] = application_dir;
const char *notations[3] = { ":", "~", NULL }; candidates[1] = home;
candidates[2] = NULL;
notations [0] = ":";
notations [1] = "~";
notations [2] = NULL;
fill_pathname_application_path(application_dir, sizeof(application_dir)); fill_pathname_application_path(application_dir, sizeof(application_dir));
path_basedir(application_dir); path_basedir(application_dir);
@ -199,11 +206,12 @@ void fill_pathname_application_path(char *buf, size_t size)
} }
#else #else
{ {
pid_t pid;
static const char *exts[] = { "exe", "file", "path/a.out" }; static const char *exts[] = { "exe", "file", "path/a.out" };
char link_path[PATH_MAX_LENGTH] = {0}; char link_path[PATH_MAX_LENGTH] = {0};
*buf = '\0'; *buf = '\0';
pid_t pid = getpid(); pid = getpid();
/* Linux, BSD and Solaris paths. Not standardized. */ /* Linux, BSD and Solaris paths. Not standardized. */
for (i = 0; i < ARRAY_SIZE(exts); i++) for (i = 0; i < ARRAY_SIZE(exts); i++)

View File

@ -116,28 +116,14 @@ static PyObject *py_read_input(PyObject *self, PyObject *args)
static PyObject *py_read_analog(PyObject *self, PyObject *args) static PyObject *py_read_analog(PyObject *self, PyObject *args)
{ {
unsigned user, index, id; unsigned user, index, id, i;
int16_t res = 0; int16_t res = 0;
driver_t *driver = driver_get_ptr(); driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
const struct retro_keybind *py_binds[MAX_USERS] = { const struct retro_keybind *py_binds[MAX_USERS];
settings->input.binds[0],
settings->input.binds[1], for (i = 0; i < MAX_USERS; i++)
settings->input.binds[2], py_binds[i] = settings->input.binds[i];
settings->input.binds[3],
settings->input.binds[4],
settings->input.binds[5],
settings->input.binds[6],
settings->input.binds[7],
settings->input.binds[8],
settings->input.binds[9],
settings->input.binds[10],
settings->input.binds[11],
settings->input.binds[12],
settings->input.binds[13],
settings->input.binds[14],
settings->input.binds[15],
};
(void)self; (void)self;

View File

@ -286,7 +286,8 @@ void fill_pathname_slash(char *path, size_t size)
/* Try to preserve slash type. */ /* Try to preserve slash type. */
if (last_slash && (last_slash != (path + path_len - 1))) if (last_slash && (last_slash != (path + path_len - 1)))
{ {
char join_str[2] = {*last_slash}; char join_str[2];
strlcpy(join_str, last_slash, sizeof(join_str));
rarch_assert(strlcat(path, join_str, size) < size); rarch_assert(strlcat(path, join_str, size) < size);
} }
else if (!last_slash) else if (!last_slash)

View File

@ -151,7 +151,7 @@ struct argument
{ {
struct rmsgpack_dom_value value; struct rmsgpack_dom_value value;
struct invocation invocation; struct invocation invocation;
}; } a;
}; };
static void argument_free(struct argument *arg) static void argument_free(struct argument *arg)
@ -160,12 +160,12 @@ static void argument_free(struct argument *arg)
if (arg->type != AT_FUNCTION) if (arg->type != AT_FUNCTION)
{ {
rmsgpack_dom_value_free(&arg->value); rmsgpack_dom_value_free(&arg->a.value);
return; return;
} }
for (i = 0; i < arg->invocation.argc; i++) for (i = 0; i < arg->a.invocation.argc; i++)
argument_free(&arg->invocation.argv[i]); argument_free(&arg->a.invocation.argv[i]);
} }
struct query struct query
@ -219,12 +219,12 @@ static struct rmsgpack_dom_value equals(struct rmsgpack_dom_value input,
res.val.bool_ = 0; res.val.bool_ = 0;
else else
{ {
if (input.type == RDT_UINT && arg.value.type == RDT_INT) if (input.type == RDT_UINT && arg.a.value.type == RDT_INT)
{ {
arg.value.type = RDT_UINT; arg.a.value.type = RDT_UINT;
arg.value.val.uint_ = arg.value.val.int_; arg.a.value.val.uint_ = arg.a.value.val.int_;
} }
res.val.bool_ = (rmsgpack_dom_value_cmp(&input, &arg.value) == 0); res.val.bool_ = (rmsgpack_dom_value_cmp(&input, &arg.a.value) == 0);
} }
} }
return res; return res;
@ -246,9 +246,9 @@ static struct rmsgpack_dom_value operator_or(struct rmsgpack_dom_value input,
res = equals(input, 1, &argv[i]); res = equals(input, 1, &argv[i]);
else else
{ {
res = is_true(argv[i].invocation.func(input, res = is_true(argv[i].a.invocation.func(input,
argv[i].invocation.argc, argv[i].a.invocation.argc,
argv[i].invocation.argv argv[i].a.invocation.argv
), 0, NULL); ), 0, NULL);
} }
@ -276,16 +276,16 @@ static struct rmsgpack_dom_value between(struct rmsgpack_dom_value input,
return res; return res;
if (argv[0].type != AT_VALUE || argv[1].type != AT_VALUE) if (argv[0].type != AT_VALUE || argv[1].type != AT_VALUE)
return res; return res;
if (argv[0].value.type != RDT_INT || argv[1].value.type != RDT_INT) if (argv[0].a.value.type != RDT_INT || argv[1].a.value.type != RDT_INT)
return res; return res;
switch (input.type) switch (input.type)
{ {
case RDT_INT: case RDT_INT:
res.val.bool_ = ((input.val.int_ >= argv[0].value.val.int_) && (input.val.int_ <= argv[1].value.val.int_)); res.val.bool_ = ((input.val.int_ >= argv[0].a.value.val.int_) && (input.val.int_ <= argv[1].a.value.val.int_));
break; break;
case RDT_UINT: case RDT_UINT:
res.val.bool_ = (((unsigned)input.val.int_ >= argv[0].value.val.uint_) && (input.val.int_ <= argv[1].value.val.int_)); res.val.bool_ = (((unsigned)input.val.int_ >= argv[0].a.value.val.uint_) && (input.val.int_ <= argv[1].a.value.val.int_));
break; break;
default: default:
return res; return res;
@ -311,9 +311,9 @@ static struct rmsgpack_dom_value operator_and(struct rmsgpack_dom_value input,
else else
{ {
res = is_true( res = is_true(
argv[i].invocation.func(input, argv[i].a.invocation.func(input,
argv[i].invocation.argc, argv[i].a.invocation.argc,
argv[i].invocation.argv argv[i].a.invocation.argv
), ),
0, NULL); 0, NULL);
} }
@ -338,12 +338,12 @@ static struct rmsgpack_dom_value q_glob(struct rmsgpack_dom_value input,
if (argc != 1) if (argc != 1)
return res; return res;
if (argv[0].type != AT_VALUE || argv[0].value.type != RDT_STRING) if (argv[0].type != AT_VALUE || argv[0].a.value.type != RDT_STRING)
return res; return res;
if (input.type != RDT_STRING) if (input.type != RDT_STRING)
return res; return res;
res.val.bool_ = rl_fnmatch( res.val.bool_ = rl_fnmatch(
argv[0].value.val.string.buff, argv[0].a.value.val.string.buff,
input.val.string.buff, input.val.string.buff,
0 0
) == 0; ) == 0;
@ -381,7 +381,7 @@ static struct rmsgpack_dom_value all_map(struct rmsgpack_dom_value input,
res.val.bool_ = 0; res.val.bool_ = 0;
goto clean; goto clean;
} }
value = rmsgpack_dom_value_map_value(&input, &arg.value); value = rmsgpack_dom_value_map_value(&input, &arg.a.value);
if (!value) /* All missing fields are nil */ if (!value) /* All missing fields are nil */
value = &nil_value; value = &nil_value;
arg = argv[i + 1]; arg = argv[i + 1];
@ -389,10 +389,10 @@ static struct rmsgpack_dom_value all_map(struct rmsgpack_dom_value input,
res = equals(*value, 1, &arg); res = equals(*value, 1, &arg);
else else
{ {
res = is_true(arg.invocation.func( res = is_true(arg.a.invocation.func(
*value, *value,
arg.invocation.argc, arg.a.invocation.argc,
arg.invocation.argv arg.a.invocation.argv
), 0, NULL); ), 0, NULL);
value = NULL; value = NULL;
} }
@ -767,25 +767,25 @@ static struct buffer parse_table(struct buffer buff,
if (!*error) if (!*error)
{ {
args[argi].value.type = RDT_STRING; args[argi].a.value.type = RDT_STRING;
args[argi].value.val.string.len = ident_len; args[argi].a.value.val.string.len = ident_len;
args[argi].value.val.string.buff = (char*)calloc( args[argi].a.value.val.string.buff = (char*)calloc(
ident_len + 1, ident_len + 1,
sizeof(char) sizeof(char)
); );
if (!args[argi].value.val.string.buff) if (!args[argi].a.value.val.string.buff)
goto clean; goto clean;
strncpy( strncpy(
args[argi].value.val.string.buff, args[argi].a.value.val.string.buff,
ident_name, ident_name,
ident_len ident_len
); );
} }
} }
else else
buff = parse_string(buff, &args[argi].value, error); buff = parse_string(buff, &args[argi].a.value, error);
if (*error) if (*error)
goto clean; goto clean;
@ -864,17 +864,17 @@ static struct buffer parse_argument(struct buffer buff,
) )
{ {
arg->type = AT_FUNCTION; arg->type = AT_FUNCTION;
buff = parse_method_call(buff, &arg->invocation, error); buff = parse_method_call(buff, &arg->a.invocation, error);
} }
else if (peek(buff, "{")) else if (peek(buff, "{"))
{ {
arg->type = AT_FUNCTION; arg->type = AT_FUNCTION;
buff = parse_table(buff, &arg->invocation, error); buff = parse_table(buff, &arg->a.invocation, error);
} }
else else
{ {
arg->type = AT_VALUE; arg->type = AT_VALUE;
buff = parse_value(buff, &arg->value, error); buff = parse_value(buff, &arg->a.value, error);
} }
return buff; return buff;
} }

View File

@ -90,7 +90,6 @@ static INLINE void gl_menu_frame_background(
0.0f, 0.0f, 0.0f, alpha, 0.0f, 0.0f, 0.0f, alpha,
}; };
coords.vertices = 4; coords.vertices = 4;
coords.vertex = vertex; coords.vertex = vertex;
coords.tex_coord = tex_coord; coords.tex_coord = tex_coord;

View File

@ -227,7 +227,7 @@ size_t state_manager_raw_compress(const void *src, const void *dst, size_t len,
while (num16s) while (num16s)
{ {
size_t i; size_t i, changed;
size_t skip = find_change(old16, new16); size_t skip = find_change(old16, new16);
if (skip >= num16s) if (skip >= num16s)
@ -253,7 +253,7 @@ size_t state_manager_raw_compress(const void *src, const void *dst, size_t len,
continue; continue;
} }
size_t changed = find_same(old16, new16); changed = find_same(old16, new16);
if (changed > UINT16_MAX) if (changed > UINT16_MAX)
changed = UINT16_MAX; changed = UINT16_MAX;

View File

@ -290,15 +290,14 @@ bool take_screenshot(void)
{ {
unsigned old_width, old_height; unsigned old_width, old_height;
size_t old_pitch; size_t old_pitch;
void *frame_data;
const void* old_data = NULL; const void* old_data = NULL;
video_driver_cached_frame_get(&old_data, &old_width, &old_height, video_driver_cached_frame_get(&old_data, &old_width, &old_height,
&old_pitch); &old_pitch);
void* frame_data = video_driver_read_frame_raw( frame_data = video_driver_read_frame_raw(
&old_width, &old_width, &old_height, &old_pitch);
&old_height,
&old_pitch);
video_driver_cached_frame_set(old_data, old_width, old_height, video_driver_cached_frame_set(old_data, old_width, old_height,
old_pitch); old_pitch);