Turn while (true) into for (;;) for easier MSVC backwards compatibility

This commit is contained in:
twinaphex 2020-02-01 04:15:22 +01:00
parent ff6d79b2cc
commit 64c515bac4
14 changed files with 96 additions and 104 deletions

View File

@ -182,7 +182,7 @@ bool d3d12_init_base(d3d12_video_t* d3d12)
d3d12->gpu_list = string_list_new();
while (true)
for (;;)
{
char str[128];
union string_list_elem_attr attr = {0};

View File

@ -1008,7 +1008,7 @@ static void *d3d10_gfx_init(const video_info_t* video,
d3d10_gpu_list = string_list_new();
while (true)
for (;;)
{
DXGI_ADAPTER_DESC desc = {0};
union string_list_elem_attr attr = {0};

View File

@ -1079,7 +1079,7 @@ static void *d3d11_gfx_init(const video_info_t* video,
d3d11_gpu_list = string_list_new();
while (true)
for (;;)
{
DXGI_ADAPTER_DESC desc = {0};
char str[128];

View File

@ -145,7 +145,7 @@ static INLINE int pthread_cond_wait(pthread_cond_t *cond,
static INLINE int pthread_cond_timedwait(pthread_cond_t *cond,
pthread_mutex_t *mutex, const struct timespec *abstime)
{
while (true)
for (;;)
{
struct timespec now = {0};
/* Missing clock_gettime*/

View File

@ -104,7 +104,7 @@ static void tpool_worker(void *arg)
tpool_work_t *work = NULL;
tpool_t *tp = (tpool_t*)arg;
while (true)
for (;;)
{
slock_lock(tp->work_mutex);
/* Keep running until told to stop. */
@ -252,7 +252,8 @@ void tpool_wait(tpool_t *tp)
return;
slock_lock(tp->work_mutex);
while (true)
for (;;)
{
/* working_cond is dual use. It signals when we're not stopping but the
* working_cnt is 0 indicating there isn't any work processing. If we
@ -262,5 +263,6 @@ void tpool_wait(tpool_t *tp)
else
break;
}
slock_unlock(tp->work_mutex);
}

View File

@ -166,12 +166,11 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
char **values_buf = NULL;
/* Determine number of options */
while (true)
for (;;)
{
if (option_defs_us[num_options].key)
num_options++;
else
if (!option_defs_us[num_options].key)
break;
num_options++;
}
/* Allocate arrays */
@ -198,20 +197,18 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
size_t num_values = 0;
/* Determine number of values */
while (true)
for (;;)
{
if (values[num_values].value)
{
/* Check if this is the default value */
if (default_value)
if (strcmp(values[num_values].value, default_value) == 0)
default_index = num_values;
buf_len += strlen(values[num_values].value);
num_values++;
}
else
if (!values[num_values].value)
break;
/* Check if this is the default value */
if (default_value)
if (strcmp(values[num_values].value, default_value) == 0)
default_index = num_values;
buf_len += strlen(values[num_values].value);
num_values++;
}
/* Build values string */

View File

@ -187,12 +187,11 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
* but we'll allocate space for all of them. The difference
* in resource usage is negligible, and this allows us to
* keep the code 'cleaner' */
while (true)
for (;;)
{
if (option_defs_us[num_options].key)
num_options++;
else
if (!option_defs_us[num_options].key)
break;
num_options++;
}
/* Allocate arrays */
@ -224,20 +223,18 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
size_t num_values = 0;
/* Determine number of values */
while (true)
for (;;)
{
if (values[num_values].value)
{
/* Check if this is the default value */
if (default_value)
if (strcmp(values[num_values].value, default_value) == 0)
default_index = num_values;
buf_len += strlen(values[num_values].value);
num_values++;
}
else
if (!values[num_values].value)
break;
/* Check if this is the default value */
if (default_value)
if (strcmp(values[num_values].value, default_value) == 0)
default_index = num_values;
buf_len += strlen(values[num_values].value);
num_values++;
}
/* Build values string */

View File

@ -166,12 +166,11 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
char **values_buf = NULL;
/* Determine number of options */
while (true)
for (;;)
{
if (option_defs_us[num_options].key)
num_options++;
else
if (!option_defs_us[num_options].key)
break;
num_options++;
}
/* Allocate arrays */
@ -198,20 +197,18 @@ static INLINE void libretro_set_core_options(retro_environment_t environ_cb)
size_t num_values = 0;
/* Determine number of values */
while (true)
for (;;)
{
if (values[num_values].value)
{
/* Check if this is the default value */
if (default_value)
if (strcmp(values[num_values].value, default_value) == 0)
default_index = num_values;
buf_len += strlen(values[num_values].value);
num_values++;
}
else
if (!values[num_values].value)
break;
/* Check if this is the default value */
if (default_value)
if (strcmp(values[num_values].value, default_value) == 0)
default_index = num_values;
buf_len += strlen(values[num_values].value);
num_values++;
}
/* Build values string */

View File

@ -6476,7 +6476,7 @@ static int xmb_pointer_up(void *userdata,
* to reach the bottom of the screen - i.e. we just
* want an index offset to subtract from the current
* selection... */
while (true)
for (;;)
{
float top = xmb_item_y(xmb, bottom_idx, selection) + xmb->margins_screen_top;

View File

@ -1704,7 +1704,8 @@ bool menu_animation_ticker_smooth(menu_animation_ctx_ticker_smooth_t *ticker)
/* Determine number of characters to copy */
text_width = ticker->field_width - (3 * period_width);
while (true)
for (;;)
{
current_width += src_char_widths[num_chars];

View File

@ -1328,7 +1328,8 @@ static bool netplay_get_cmd(netplay_t *netplay,
/* It wants future frames, make sure we don't capture or send intermediate ones */
START(netplay->self_ptr);
frame_count = netplay->self_frame_count;
while (true)
for (;;)
{
if (!dframe->used)
{

View File

@ -4415,7 +4415,8 @@ static void handle_translation_cb(
/* Parse JSON body for the image and sound data */
body_copy = strdup(data->data);
while (true)
for (;;)
{
curr = (char)*(body_copy+i);
if (curr == '\0')
@ -8191,12 +8192,11 @@ static bool core_option_manager_parse_option(
option->info = strdup(option_def->info);
/* Get number of values */
while (true)
for (;;)
{
if (!string_is_empty(values[num_vals].value))
num_vals++;
else
if (string_is_empty(values[num_vals].value))
break;
num_vals++;
}
if (num_vals < 1)
@ -8605,12 +8605,11 @@ static struct retro_core_option_definition *core_option_manager_get_definitions(
return NULL;
/* Determine number of options */
while (true)
for (;;)
{
if (!string_is_empty(option_defs_us[num_options].key))
num_options++;
else
if (string_is_empty(option_defs_us[num_options].key))
break;
num_options++;
}
if (num_options < 1)
@ -8647,24 +8646,22 @@ static struct retro_core_option_definition *core_option_manager_get_definitions(
{
size_t index = 0;
while (true)
for (;;)
{
const char *local_key = option_defs_local[index].key;
if (!string_is_empty(local_key))
{
if (string_is_equal(key, local_key))
{
local_desc = option_defs_local[index].desc;
local_info = option_defs_local[index].info;
local_values = option_defs_local[index].values;
break;
}
else
index++;
}
else
if (string_is_empty(local_key))
break;
if (string_is_equal(key, local_key))
{
local_desc = option_defs_local[index].desc;
local_info = option_defs_local[index].info;
local_values = option_defs_local[index].values;
break;
}
index++;
}
}
@ -8674,12 +8671,11 @@ static struct retro_core_option_definition *core_option_manager_get_definitions(
/* Determine number of values
* (always taken from us english defs) */
while (true)
for (;;)
{
if (!string_is_empty(option_defs_us[i].values[num_values].value))
num_values++;
else
if (string_is_empty(option_defs_us[i].values[num_values].value))
break;
num_values++;
}
/* Copy values */
@ -8696,22 +8692,20 @@ static struct retro_core_option_definition *core_option_manager_get_definitions(
{
size_t value_index = 0;
while (true)
for (;;)
{
const char *local_value = local_values[value_index].value;
if (!string_is_empty(local_value))
{
if (string_is_equal(value, local_value))
{
local_label = local_values[value_index].label;
break;
}
else
value_index++;
}
else
if (string_is_empty(local_value))
break;
if (string_is_equal(value, local_value))
{
local_label = local_values[value_index].label;
break;
}
value_index++;
}
}
@ -9098,9 +9092,7 @@ static bool dynamic_verify_hw_context(enum retro_hw_context_type type,
case RETRO_HW_CONTEXT_OPENGL_CORE:
if (!string_is_equal(video_ident, "gl") &&
!string_is_equal(video_ident, "glcore"))
{
return false;
}
break;
case RETRO_HW_CONTEXT_DIRECT3D:
if (!(string_is_equal(video_ident, "d3d11") && major == 11))
@ -9175,7 +9167,8 @@ static size_t mmap_add_bits_down(size_t n)
n |= n >> 8;
n |= n >> 16;
/* double shift to avoid warnings on 32bit (it's dead code, but compilers suck) */
/* double shift to avoid warnings on 32bit (it's dead code,
* but compilers suck) */
if (sizeof(size_t) > 4)
n |= n >> 16 >> 16;

View File

@ -306,7 +306,8 @@ static void ups_target_write(struct ups_data *data, uint8_t n)
static uint64_t ups_decode(struct ups_data *data)
{
uint64_t offset = 0, shift = 1;
while (true)
for (;;)
{
uint8_t x = ups_patch_read(data);
offset += (x & 0x7f) * shift;
@ -384,7 +385,8 @@ static enum patch_error ups_apply_patch(
unsigned length = (unsigned)ups_decode(&data);
while (length--)
ups_target_write(&data, ups_source_read(&data));
while (true)
for (;;)
{
uint8_t patch_xor = ups_patch_read(&data);
ups_target_write(&data, patch_xor ^ ups_source_read(&data));

View File

@ -325,18 +325,20 @@ void App::Load(Platform::String^ entryPoint)
// This method is called after the window becomes active.
void App::Run()
{
bool x = false;
if (!m_initialized)
{
RARCH_WARN("Initialization failed, so not running\n");
return;
}
bool x = false;
while (true)
for (;;)
{
int ret;
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
int ret = runloop_iterate();
ret = runloop_iterate();
task_queue_check();