diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 121b676f53..82895bc00c 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -146,9 +146,12 @@ static void compute_audio_buffer_statistics(void) { unsigned i, low_water_size, high_water_size, avg, stddev; float avg_filled, deviation; - uint64_t accum = 0, accum_var = 0; - unsigned low_water_count = 0, high_water_count = 0; - unsigned samples = min(audio_driver_data.buffer_free_samples_count, + uint64_t accum = 0; + uint64_t accum_var = 0; + unsigned low_water_count = 0; + unsigned high_water_count = 0; + unsigned samples = MIN( + audio_driver_data.buffer_free_samples_count, AUDIO_BUFFER_FREE_SAMPLES_COUNT); if (samples < 3) diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index 17ca7d93a4..19bf000b41 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -227,7 +227,8 @@ static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) while (size) { - size_t avail_write = min(alsa->buf_size - alsa->buffer_ptr, size); + size_t avail_write = MIN(alsa->buf_size - alsa->buffer_ptr, size); + if (avail_write) { memcpy(alsa->buffer[alsa->buffer_index] + diff --git a/audio/drivers/alsathread.c b/audio/drivers/alsathread.c index 9947cf980d..1984083c12 100644 --- a/audio/drivers/alsathread.c +++ b/audio/drivers/alsathread.c @@ -66,7 +66,7 @@ static void alsa_worker_thread(void *data) snd_pcm_sframes_t frames; slock_lock(alsa->fifo_lock); avail = fifo_read_avail(alsa->buffer); - fifo_size = min(alsa->period_size, avail); + fifo_size = MIN(alsa->period_size, avail); fifo_read(alsa->buffer, buf, fifo_size); scond_signal(alsa->cond); slock_unlock(alsa->fifo_lock); @@ -252,11 +252,14 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size) { size_t avail; size_t write_amt; + slock_lock(alsa->fifo_lock); - avail = fifo_write_avail(alsa->buffer); - 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; } else @@ -278,7 +281,7 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size) } else { - size_t write_amt = min(size - written, avail); + size_t write_amt = MIN(size - written, avail); fifo_write(alsa->buffer, (const char*)buf + written, write_amt); slock_unlock(alsa->fifo_lock); written += write_amt; diff --git a/audio/drivers/openal.c b/audio/drivers/openal.c index 0571affb5b..b410176057 100644 --- a/audio/drivers/openal.c +++ b/audio/drivers/openal.c @@ -162,7 +162,7 @@ static bool al_get_buffer(al_t *al, ALuint *buffer) static size_t al_fill_internal_buf(al_t *al, const void *buf, size_t size) { - size_t read_size = min(BUFSIZE - al->tmpbuf_ptr, size); + size_t read_size = MIN(BUFSIZE - al->tmpbuf_ptr, size); memcpy(al->tmpbuf + al->tmpbuf_ptr, buf, read_size); al->tmpbuf_ptr += read_size; return read_size; diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index 4838537ab5..5ae527bcbd 100644 --- a/audio/drivers/pulse.c +++ b/audio/drivers/pulse.c @@ -238,9 +238,7 @@ static ssize_t pulse_write(void *data, const void *buf_, size_t size) pa_threaded_mainloop_lock(pa->mainloop); while (size) { - size_t writable = pa_stream_writable_size(pa->stream); - - writable = min(size, writable); + size_t writable = MIN(size, pa_stream_writable_size(pa->stream)); if (writable) { diff --git a/audio/drivers/xaudio.cpp b/audio/drivers/xaudio.cpp index 6eb977f5ab..fde377a103 100644 --- a/audio/drivers/xaudio.cpp +++ b/audio/drivers/xaudio.cpp @@ -194,7 +194,7 @@ static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_) while (bytes) { - unsigned need = min(bytes, handle->bufsize - handle->bufptr); + unsigned need = MIN(bytes, handle->bufsize - handle->bufptr); memcpy(handle->buf + handle->write_buffer * handle->bufsize + handle->bufptr, buffer, need); diff --git a/audio/drivers_resampler/cc_resampler.c b/audio/drivers_resampler/cc_resampler.c index e13b57d4c2..02ee695b8f 100644 --- a/audio/drivers_resampler/cc_resampler.c +++ b/audio/drivers_resampler/cc_resampler.c @@ -271,7 +271,7 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data) audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in; audio_frame_float_t *inp_max = (audio_frame_float_t*)(inp + data->input_frames); audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out; - float b = min(data->ratio, 1.00); /* cutoff frequency. */ + float b = MIN(data->ratio, 1.00); /* cutoff frequency. */ float ratio = 1.0 / data->ratio; __m128 vec_previous = _mm_loadu_ps((float*)&re->buffer[0]); __m128 vec_current = _mm_loadu_ps((float*)&re->buffer[2]); @@ -446,7 +446,7 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data) audio_frame_float_t *inp_max = (audio_frame_float_t*) (inp + data->input_frames); audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out; - float b = min(data->ratio, 1.00); /* cutoff frequency. */ + float b = MIN(data->ratio, 1.00); /* cutoff frequency. */ float ratio = 1.0 / data->ratio; while (inp != inp_max) diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index 7cdcead8f0..dfa5167ebf 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -210,9 +210,9 @@ static bool init_device(void *data) } /* VIDIOC_S_FMT may change width, height and pitch. */ - v4l->width = fmt.fmt.pix.width; + v4l->width = fmt.fmt.pix.width; v4l->height = fmt.fmt.pix.height; - v4l->pitch = max(fmt.fmt.pix.bytesperline, v4l->width * 2); + v4l->pitch = MAX(fmt.fmt.pix.bytesperline, v4l->width * 2); /* Sanity check to see if our assumptions are met. * It is possible to support whatever the device gives us, diff --git a/command_event.c b/command_event.c index f11926ed74..c6a6454bdb 100644 --- a/command_event.c +++ b/command_event.c @@ -309,8 +309,8 @@ static void event_set_volume(float gain) settings_t *settings = config_get_ptr(); settings->audio.volume += gain; - settings->audio.volume = max(settings->audio.volume, -80.0f); - settings->audio.volume = min(settings->audio.volume, 12.0f); + settings->audio.volume = MAX(settings->audio.volume, -80.0f); + settings->audio.volume = MIN(settings->audio.volume, 12.0f); snprintf(msg, sizeof(msg), "Volume: %.1f dB", settings->audio.volume); runloop_msg_queue_push(msg, 1, 180, true); diff --git a/configuration.c b/configuration.c index 302c700341..5f75be3b67 100644 --- a/configuration.c +++ b/configuration.c @@ -1368,8 +1368,8 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, settings, video.black_frame_insertion, "video_black_frame_insertion"); CONFIG_GET_INT_BASE(conf, settings, video.swap_interval, "video_swap_interval"); - settings->video.swap_interval = max(settings->video.swap_interval, 1); - settings->video.swap_interval = min(settings->video.swap_interval, 4); + settings->video.swap_interval = MAX(settings->video.swap_interval, 1); + settings->video.swap_interval = MIN(settings->video.swap_interval, 4); CONFIG_GET_BOOL_BASE(conf, settings, video.threaded, "video_threaded"); CONFIG_GET_BOOL_BASE(conf, settings, video.shared_context, "video_shared_context"); #ifdef GEKKO diff --git a/gfx/common/drm_common.c b/gfx/common/drm_common.c index e5b6f9b51a..e10ff8bc3d 100644 --- a/gfx/common/drm_common.c +++ b/gfx/common/drm_common.c @@ -65,7 +65,7 @@ bool drm_get_connector(int fd) unsigned i; unsigned monitor_index = 0; settings_t *settings = config_get_ptr(); - unsigned monitor = max(settings->video.monitor_index, 1); + unsigned monitor = MAX(settings->video.monitor_index, 1); /* Enumerate all connectors. */ diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index 3ce537025c..4aef61abd5 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -54,7 +54,7 @@ bool gl_load_luts(const struct video_shader *shader, GLuint *textures_lut) { unsigned i; - unsigned num_luts = min(shader->luts, GFX_MAX_TEXTURES); + unsigned num_luts = MIN(shader->luts, GFX_MAX_TEXTURES); if (!shader->luts) return true; diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 9f1861fd0f..0180959a07 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -286,10 +286,10 @@ unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y, for (i = 0; i < num_screens; i++) { int area; - int max_lx = max(x, info[i].x_org); - int min_rx = min(x + w, info[i].x_org + info[i].width); - int max_ty = max(y, info[i].y_org); - int min_by = min(y + h, info[i].y_org + info[i].height); + int max_lx = MAX(x, info[i].x_org); + int min_rx = MIN(x + w, info[i].x_org + info[i].width); + int max_ty = MAX(y, info[i].y_org); + int min_by = MIN(y + h, info[i].y_org + info[i].height); int len_x = min_rx - max_lx; int len_y = min_by - max_ty; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 3d228a2f57..59614529ac 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2810,7 +2810,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo video_shader_driver_ctl(SHADER_CTL_GET_PREV_TEXTURES, &texture_info); minimum = texture_info.id; - gl->textures = max(minimum + 1, gl->textures); + gl->textures = MAX(minimum + 1, gl->textures); } if (!video_shader_driver_ctl(SHADER_CTL_INFO, &shader_info)) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 18522ca950..96979892db 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -321,9 +321,9 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, if (fbWidth > max_width) fbWidth = max_width; - gx_mode.viTVMode = VI_TVMODE(tvmode, modetype); - gx_mode.fbWidth = fbWidth; - gx_mode.efbHeight = min(lines, 480); + gx_mode.viTVMode = VI_TVMODE(tvmode, modetype); + gx_mode.fbWidth = fbWidth; + gx_mode.efbHeight = MIN(lines, 480); if (modetype == VI_NON_INTERLACE && lines > max_height / 2) gx_mode.xfbHeight = max_height / 2; @@ -332,8 +332,8 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, else gx_mode.xfbHeight = lines; - gx_mode.viWidth = viWidth; - gx_mode.viHeight = gx_mode.xfbHeight * viHeightMultiplier; + gx_mode.viWidth = viWidth; + gx_mode.viHeight = gx_mode.xfbHeight * viHeightMultiplier; gx_used_system_xOrigin = gx_system_xOrigin; if(gx_used_system_xOrigin > 0) @@ -1459,8 +1459,8 @@ static bool gx_frame(void *data, const void *frame, while (((g_vsync || gx->menu_texture_enable)) && !g_draw_done) OSSleepThread(g_video_cond); - width = min(g_tex.width, width); - height = min(g_tex.height, height); + width = MIN(g_tex.width, width); + height = MIN(g_tex.height, height); if (width != gx_old_width || height != gx_old_height) { diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index c9c5ef8e4f..3f74d8dc62 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -37,7 +37,7 @@ #define UV_LEFT 2 #define UV_RIGHT 3 -// pixel shader +/* pixel shader */ const unsigned int g_xps_PS[] = { 0x102a1100, 0x000000b4, 0x0000003c, 0x00000000, 0x00000024, 0x00000000, @@ -52,7 +52,7 @@ const unsigned int g_xps_PS[] = 0xc80f8000, 0x00000000, 0xe2010100, 0x00000000, 0x00000000, 0x00000000 }; -// vertex shader +/* vertex shader */ const unsigned int g_xvs_VS[] = { 0x102a1101, 0x0000009c, 0x00000078, 0x00000000, 0x00000024, 0x00000000, diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 736459bf9f..6bfcb93213 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -196,7 +196,7 @@ static int gl_get_message_width(void *data, const char *msg, { unsigned i; int delta_x = 0; - unsigned msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); + unsigned msg_len = MIN(msg_len_full, MAX_MSG_LEN_CHUNK); gl_raster_t *font = (gl_raster_t*)data; if (!font) @@ -225,7 +225,7 @@ static int gl_get_message_width(void *data, const char *msg, msg_len_full -= msg_len; msg += msg_len; - msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); + msg_len = MIN(msg_len_full, MAX_MSG_LEN_CHUNK); } return delta_x * scale; @@ -267,7 +267,7 @@ static void gl_raster_font_render_line( if (!gl) return; - msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); + msg_len = MIN(msg_len_full, MAX_MSG_LEN_CHUNK); x = roundf(pos_x * gl->vp.width); y = roundf(pos_y * gl->vp.height); @@ -334,7 +334,7 @@ static void gl_raster_font_render_line( msg_len_full -= msg_len; msg += msg_len; - msg_len = min(msg_len_full, MAX_MSG_LEN_CHUNK); + msg_len = MIN(msg_len_full, MAX_MSG_LEN_CHUNK); } } diff --git a/gfx/drivers_font_renderer/coretext.c b/gfx/drivers_font_renderer/coretext.c index 4f1ad85577..41f723fe61 100644 --- a/gfx/drivers_font_renderer/coretext.c +++ b/gfx/drivers_font_renderer/coretext.c @@ -122,26 +122,26 @@ static bool font_renderer_create_atlas(CTFontRef face, ct_font_renderer_t *handl if (!glyph) continue; - origin_x = ceil(bounds[i].origin.x); - origin_y = ceil(bounds[i].origin.y); + origin_x = ceil(bounds[i].origin.x); + origin_y = ceil(bounds[i].origin.y); glyph->draw_offset_x = 0; glyph->draw_offset_y = -ascent; - glyph->width = ceil(bounds[i].size.width); - glyph->height = ceil(bounds[i].size.height); - glyph->advance_x = ceil(advances[i].width); - glyph->advance_y = ceil(advances[i].height); + glyph->width = ceil(bounds[i].size.width); + glyph->height = ceil(bounds[i].size.height); + glyph->advance_x = ceil(advances[i].width); + glyph->advance_y = ceil(advances[i].height); - max_width = max(max_width, (origin_x + glyph->width)); - max_height = max(max_height, (origin_y + glyph->height)); + max_width = MAX(max_width, (origin_x + glyph->width)); + max_height = MAX(max_height, (origin_y + glyph->height)); } - max_height = max(max_height, ceil(ascent+descent)); + max_height = MAX(max_height, ceil(ascent+descent)); - handle->atlas.width = max_width * CT_ATLAS_COLS; - handle->atlas.height = max_height * CT_ATLAS_ROWS; + handle->atlas.width = max_width * CT_ATLAS_COLS; + handle->atlas.height = max_height * CT_ATLAS_ROWS; - handle->atlas.buffer = (uint8_t*) + handle->atlas.buffer = (uint8_t*) calloc(handle->atlas.width * handle->atlas.height, 1); if (!handle->atlas.buffer) diff --git a/gfx/drivers_font_renderer/freetype.c b/gfx/drivers_font_renderer/freetype.c index eee511a161..bbf5a9e8d4 100644 --- a/gfx/drivers_font_renderer/freetype.c +++ b/gfx/drivers_font_renderer/freetype.c @@ -115,8 +115,8 @@ static bool font_renderer_create_atlas(ft_font_renderer_t *handle) if (buffer[i]) memcpy(buffer[i], slot->bitmap.buffer, slot->bitmap.rows * pitches[i]); - max_width = max(max_width, (unsigned)slot->bitmap.width); - max_height = max(max_height, (unsigned)slot->bitmap.rows); + max_width = MAX(max_width, (unsigned)slot->bitmap.width); + max_height = MAX(max_height, (unsigned)slot->bitmap.rows); } handle->atlas.width = max_width * FT_ATLAS_COLS; diff --git a/gfx/drivers_font_renderer/stb.c b/gfx/drivers_font_renderer/stb.c index e650456920..07c4589f53 100644 --- a/gfx/drivers_font_renderer/stb.c +++ b/gfx/drivers_font_renderer/stb.c @@ -111,8 +111,8 @@ static bool font_renderer_stb_create_atlas(stb_font_renderer_t *self, /* Limit growth to 2048x2048 unless we already reached that */ if (width < 2048 || height < 2048) { - new_width = min(new_width, 2048); - new_height = min(new_height, 2048); + new_width = MIN(new_width, 2048); + new_height = MIN(new_height, 2048); } return font_renderer_stb_create_atlas(self, font_data, font_size, diff --git a/gfx/drivers_shader/glslang_util.cpp b/gfx/drivers_shader/glslang_util.cpp index 2e48826ebc..f2d12308de 100644 --- a/gfx/drivers_shader/glslang_util.cpp +++ b/gfx/drivers_shader/glslang_util.cpp @@ -28,15 +28,18 @@ using namespace std; bool read_file(const char *path, vector *output) { - char *buf = nullptr; - ssize_t len = 0; + char *buf = nullptr; + ssize_t len = 0; + struct string_list *list = NULL; + if (retro_read_file(path, (void**)&buf, &len) < 0) { RARCH_ERR("Failed to open shader file: \"%s\".\n", path); return false; } - struct string_list *list = string_split(buf, "\n"); + list = string_split(buf, "\n"); + if (!list) { free(buf); @@ -61,11 +64,11 @@ bool read_file(const char *path, vector *output) string build_stage_source(const vector &lines, const char *stage) { ostringstream str; + bool active = true; // Version header. str << lines.front(); str << '\n'; - bool active = true; for (auto itr = begin(lines) + 1; itr != end(lines); ++itr) { @@ -92,8 +95,9 @@ string build_stage_source(const vector &lines, const char *stage) bool glslang_compile_shader(const char *shader_path, glslang_output *output) { - RARCH_LOG("Compiling shader \"%s\".\n", shader_path); vector lines; + + RARCH_LOG("Compiling shader \"%s\".\n", shader_path); if (!read_file(shader_path, &lines)) return false; diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index 2f2506c901..d6b78165f9 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -1050,7 +1050,7 @@ static unsigned gl_cg_get_prev_textures(void *data) for (i = 1; i <= cg_data->shader->passes; i++) for (j = 0; j < PREV_TEXTURES; j++) if (cg_data->prg[i].prev[j].tex) - max_prev = max(j + 1, max_prev); + max_prev = MAX(j + 1, max_prev); return max_prev; } diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 38097ab7e7..91a7d90d3d 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -1383,7 +1383,7 @@ static unsigned gl_glsl_get_prev_textures(void *data) for (i = 1; i <= glsl->shader->passes; i++) for (j = 0; j < PREV_TEXTURES; j++) if (glsl->gl_uniforms[i].prev[j].texture >= 0) - max_prev = max(j + 1, max_prev); + max_prev = MAX(j + 1, max_prev); return max_prev; } diff --git a/gfx/video_common.c b/gfx/video_common.c index b6521a2524..23059d7c7e 100644 --- a/gfx/video_common.c +++ b/gfx/video_common.c @@ -40,9 +40,9 @@ bool gfx_coord_array_add(gfx_coord_array_t *ca, const gfx_coords_t *coords, unsigned count) { size_t base_size, offset; - bool success = false; + bool success = false; - count = min(count, coords->vertices); + count = MIN(count, coords->vertices); if (ca->coords.vertices + count >= ca->allocated) { diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 14e858834f..d20b10d03f 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -453,7 +453,7 @@ static void init_video_filter(enum retro_pixel_format colfmt) pow2_x = next_pow2(width); pow2_y = next_pow2(height); - maxsize = max(pow2_x, pow2_y); + maxsize = MAX(pow2_x, pow2_y); video_driver_state.filter.scale = maxsize / RARCH_SCALE_BASE; video_driver_state.filter.out_rgb32 = rarch_softfilter_get_output_format( video_driver_state.filter.filter) == RETRO_PIXEL_FORMAT_XRGB8888; @@ -673,9 +673,9 @@ static bool init_video(void) goto error; } - max_dim = max(geom->max_width, geom->max_height); + max_dim = MAX(geom->max_width, geom->max_height); scale = next_pow2(max_dim) / RARCH_SCALE_BASE; - scale = max(scale, 1); + scale = MAX(scale, 1); if (video_driver_state.filter.filter) scale = video_driver_state.filter.scale; @@ -994,10 +994,8 @@ bool video_monitor_fps_statistics(double *refresh_rate, { unsigned i; retro_time_t accum = 0, avg, accum_var = 0; - unsigned samples = 0; settings_t *settings = config_get_ptr(); - - samples = min(MEASURE_FRAME_TIME_SAMPLES_COUNT, + unsigned samples = MIN(MEASURE_FRAME_TIME_SAMPLES_COUNT, video_driver_state.frame_time_samples_count); if (settings->video.threaded || (samples < 2)) @@ -1347,7 +1345,7 @@ static void video_viewport_set_square_pixel(unsigned width, unsigned height) if (width == 0 || height == 0) return; - len = min(width, height); + len = MIN(width, height); highest = 1; for (i = 1; i < len; i++) @@ -1853,10 +1851,10 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, if (keep_aspect) { /* X/Y scale must be same. */ - unsigned max_scale = min(width / base_width, + unsigned max_scale = MIN(width / base_width, height / base_height); - padding_x = width - base_width * max_scale; - padding_y = height - base_height * max_scale; + padding_x = width - base_width * max_scale; + padding_y = height - base_height * max_scale; } else { diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 49da8f220f..14aca9fbe4 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -626,7 +626,8 @@ bool video_shader_read_conf_cgp(config_file_t *conf, struct video_shader *shader if (!config_get_int(conf, "feedback_pass", &shader->feedback_pass)) shader->feedback_pass = -1; - shader->passes = min(shaders, GFX_MAX_SHADERS); + shader->passes = MIN(shaders, GFX_MAX_SHADERS); + for (i = 0; i < shader->passes; i++) { if (!video_shader_parse_pass(conf, &shader->pass[i], i)) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 9638883216..b83da30e97 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -529,7 +529,7 @@ static INLINE int android_input_poll_event_type_motion( else { float x, y; - int pointer_max = min(AMotionEvent_getPointerCount(event), MAX_TOUCH); + int pointer_max = MIN(AMotionEvent_getPointerCount(event), MAX_TOUCH); for (motion_ptr = 0; motion_ptr < pointer_max; motion_ptr++) { @@ -542,7 +542,7 @@ static INLINE int android_input_poll_event_type_motion( &android_data->pointer[motion_ptr].full_x, &android_data->pointer[motion_ptr].full_y); - android_data->pointer_count = max( + android_data->pointer_count = MAX( android_data->pointer_count, motion_ptr + 1); } diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index 7d9ab833bb..93b673e4ed 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -68,14 +68,12 @@ #define M_PI 3.14159265358979323846264338327 #endif -#ifndef __cplusplus -#ifndef max -#define max(a, b) ((a) > (b) ? (a) : (b)) +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif -#ifndef min -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) diff --git a/menu/cbs/menu_cbs_down.c b/menu/cbs/menu_cbs_down.c index 28a3c08928..d6a9317c92 100644 --- a/menu/cbs/menu_cbs_down.c +++ b/menu/cbs/menu_cbs_down.c @@ -30,7 +30,7 @@ static int action_bind_down_generic(unsigned type, const char *label) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) return -1; - scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; + scroll_speed = (MAX(scroll_accel, 2) - 2) / 4 + 1; if (menu_entries_get_size() <= 0) return 0; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 6bfc3995c2..938be29dc9 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -44,7 +44,7 @@ static int generic_shader_action_parameter_left( if (shader) { param->current -= param->step; - param->current = min(max(param->minimum, param->current), param->maximum); + param->current = MIN(MAX(param->minimum, param->current), param->maximum); } return 0; } @@ -110,8 +110,8 @@ static int action_left_scroll(unsigned type, const char *label, if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) return false; - scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; - fast_scroll_speed = 4 + 4 * scroll_speed; + scroll_speed = (MAX(scroll_accel, 2) - 2) / 4 + 1; + fast_scroll_speed = 4 + 4 * scroll_speed; if (selection > fast_scroll_speed) { diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 209a8176d5..a3d59fa92c 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -47,7 +47,7 @@ static int generic_shader_action_parameter_right( return menu_cbs_exit(); param->current += param->step; - param->current = min(max(param->minimum, param->current), param->maximum); + param->current = MIN(MAX(param->minimum, param->current), param->maximum); if (ui_companion_is_on_foreground()) ui_companion_driver_notify_refresh(); @@ -130,7 +130,7 @@ static int action_right_scroll(unsigned type, const char *label, if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) return false; - scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; + scroll_speed = (MAX(scroll_accel, 2) - 2) / 4 + 1; fast_scroll_speed = 4 + 4 * scroll_speed; if (selection + fast_scroll_speed < (menu_entries_get_size())) diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index 38783fc43e..505f12cb46 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -125,7 +125,7 @@ static int action_start_shader_action_parameter(unsigned type, const char *label param = &shader_info.data->parameters [type - MENU_SETTINGS_SHADER_PARAMETER_0]; param->current = param->initial; - param->current = min(max(param->minimum, param->current), param->maximum); + param->current = MIN(MAX(param->minimum, param->current), param->maximum); #endif @@ -146,7 +146,7 @@ static int action_start_shader_action_preset_parameter(unsigned type, const char param = &shader->parameters[type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0]; param->current = param->initial; - param->current = min(max(param->minimum, param->current), param->maximum); + param->current = MIN(MAX(param->minimum, param->current), param->maximum); #endif return 0; diff --git a/menu/cbs/menu_cbs_up.c b/menu/cbs/menu_cbs_up.c index 7c6a2c21f9..f9f84168d4 100644 --- a/menu/cbs/menu_cbs_up.c +++ b/menu/cbs/menu_cbs_up.c @@ -25,12 +25,12 @@ static int action_bind_up_generic(unsigned type, const char *label) { - size_t scroll_accel = 0; + size_t scroll_accel = 0; unsigned scroll_speed = 0; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) return -1; - scroll_speed = (max(scroll_accel, 2) - 2) / 4 + 1; + scroll_speed = (MAX(scroll_accel, 2) - 2) / 4 + 1; if (menu_entries_get_size() <= 0) return 0; diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 90d95ad8bc..801c358beb 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -348,7 +348,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) * * We need to fix this entire mess, mouse controls * should not rely on a hack like this in order to work. */ - selection = max(min(selection, (menu_entries_get_size() - 1)), 0); + selection = MAX(MIN(selection, (menu_entries_get_size() - 1)), 0); menu_entry_get(&entry, 0, selection, NULL, false); ret = menu_entry_action(&entry, selection, (enum menu_action)action); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 849e060e58..9bffa54cbc 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -363,8 +363,8 @@ static void rgui_render_messagebox(const char *message) } line_width = msglen * FONT_WIDTH_STRIDE - 1 + 6 + 10; - width = max(width, line_width); - glyphs_width = max(glyphs_width, msglen); + width = MAX(width, line_width); + glyphs_width = MAX(glyphs_width, msglen); } height = FONT_HEIGHT_STRIDE * list->size + 6 + 10; diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 336318cb29..d83138a02d 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -662,7 +662,7 @@ static bool zarch_zui_gamepad_input(zui_t *zui, if (*list_first > (int)cutoff_point) *list_first = cutoff_point; - *list_first = min(max(*list_first, 0), cutoff_point - skip); + *list_first = MIN(MAX(*list_first, 0), cutoff_point - skip); } return false; } @@ -752,7 +752,7 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, zui->load_dlist_first = 0; } - cwd_offset = min(strlen(zui->load_cwd), 60); + cwd_offset = MIN(strlen(zui->load_cwd), 60); zarch_zui_draw_text(zui, ZUI_FG_NORMAL, 15, tabbed->tabline_size + 5 + 41, @@ -977,7 +977,7 @@ static int zarch_zui_render_pick_core(zui_t *zui) zui->pick_first += zui->mouse.wheel; - zui->pick_first = min(max(zui->pick_first, 0), zui->pick_supported - 5); + zui->pick_first = MIN(MAX(zui->pick_first, 0), zui->pick_supported - 5); for (i = zui->pick_first; i < zui->pick_supported; ++i) { diff --git a/menu/menu_input.c b/menu/menu_input.c index c129b9356d..6a498d002b 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -1313,7 +1313,7 @@ unsigned menu_input_frame_retropad(retro_input_t input, menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &new_scroll_accel); - new_scroll_accel = min(new_scroll_accel + 1, 64); + new_scroll_accel = MIN(new_scroll_accel + 1, 64); } initial_held = false; diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 0d9518c8b9..d03f1b8d08 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -1162,7 +1162,7 @@ static void ffmpeg_audio_resample(ffmpeg_t *handle, if (!handle->audio.resample_out) return; - handle->audio.fixed_conv_frames = max(handle->audio.resample_out_frames, + handle->audio.fixed_conv_frames = MAX(handle->audio.resample_out_frames, handle->audio.float_conv_frames); handle->audio.fixed_conv = (int16_t*)av_realloc(handle->audio.fixed_conv, handle->audio.fixed_conv_frames * handle->params.channels * sizeof(int16_t)); diff --git a/retroarch.c b/retroarch.c index 9fd8db30a0..e688b19991 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1038,7 +1038,7 @@ static void rarch_init_savefile_paths(void) global->subsystem); /* We'll handle this error gracefully later. */ - unsigned num_content = min(info ? info->num_roms : 0, + unsigned num_content = MIN(info ? info->num_roms : 0, global->subsystem_fullpaths ? global->subsystem_fullpaths->size : 0);