1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-03 00:38:44 +00:00

Style nits - turn macro names into upper-case - some while style nits

This commit is contained in:
twinaphex 2020-06-26 20:00:19 +02:00
parent fa50695b89
commit 1ae20ea17c
44 changed files with 221 additions and 201 deletions

View File

@ -606,13 +606,17 @@ void net_print_exp(const char *str)
sendto(wiiu_log_socket, str, strlen(str), 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
}
/* RFC 791 specifies that any IP host must be able to receive a datagram of 576 bytes.
* Since we're generally never logging more than a line or two's worth of data (~100 bytes)
/* RFC 791 specifies that any IP host must be able
* to receive a datagram of 576 bytes.
* Since we're generally never logging more than a
* line or two's worth of data (~100 bytes)
* this is a reasonable size for our use. */
#define DGRAM_SIZE 576
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
static ssize_t wiiu_log_write(struct _reent *r,
void *fd, const char *ptr, size_t len)
{
int remaining;
if (wiiu_log_socket < 0)
return len;
@ -621,13 +625,13 @@ static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_
wiiu_log_lock = 1;
int sent;
int remaining = len;
remaining = len;
while (remaining > 0)
{
int block = remaining < DGRAM_SIZE ? remaining : DGRAM_SIZE;
sent = sendto(wiiu_log_socket, ptr, block, 0, (struct sockaddr *)&broadcast, sizeof(broadcast));
int sent = sendto(wiiu_log_socket, ptr, block, 0,
(struct sockaddr *)&broadcast, sizeof(broadcast));
if (sent < 0)
break;

View File

@ -2666,7 +2666,9 @@ static void gl2_video_layout_layer_begin(const video_layout_render_info_t *info)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
static void gl2_video_layout_image(const video_layout_render_info_t *info, void *image_handle, void *alpha_handle)
static void gl2_video_layout_image(
const video_layout_render_info_t *info,
void *image_handle, void *alpha_handle)
{
/* TODO alpha_handle */
int i;

View File

@ -28,7 +28,7 @@
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define gl1_raster_font_emit(c, vx, vy) do { \
#define GL1_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
@ -38,14 +38,10 @@
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]; \
} while(0)
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define MAX_MSG_LEN_CHUNK 64
#ifdef VITA
static float *vertices3 = NULL;
#endif
typedef struct
{
@ -248,6 +244,10 @@ static int gl1_get_message_width(void *data, const char *msg,
static void gl1_raster_font_draw_vertices(gl1_raster_t *font,
const video_coords_t *coords)
{
#ifdef VITA
static float *vertices3 = NULL;
#endif
if (font->atlas->dirty)
{
gl1_raster_font_upload_atlas(font);
@ -270,11 +270,14 @@ static void gl1_raster_font_draw_vertices(gl1_raster_t *font,
if (vertices3)
free(vertices3);
vertices3 = (float*)malloc(sizeof(float) * 3 * coords->vertices);
{
int i;
for (i = 0; i < coords->vertices; i++) {
for (i = 0; i < coords->vertices; i++)
{
memcpy(&vertices3[i*3], &coords->vertex[i*2], sizeof(float) * 2);
vertices3[i*3+2] = 0.0f;
}
}
glVertexPointer(3, GL_FLOAT, 0, vertices3);
#else
glVertexPointer(2, GL_FLOAT, 0, coords->vertex);
@ -350,13 +353,13 @@ static void gl1_raster_font_render_line(
width = glyph->width;
height = glyph->height;
gl1_raster_font_emit(0, 0, 1); /* Bottom-left */
gl1_raster_font_emit(1, 1, 1); /* Bottom-right */
gl1_raster_font_emit(2, 0, 0); /* Top-left */
GL1_RASTER_FONT_EMIT(0, 0, 1); /* Bottom-left */
GL1_RASTER_FONT_EMIT(1, 1, 1); /* Bottom-right */
GL1_RASTER_FONT_EMIT(2, 0, 0); /* Top-left */
gl1_raster_font_emit(3, 1, 0); /* Top-right */
gl1_raster_font_emit(4, 0, 0); /* Top-left */
gl1_raster_font_emit(5, 1, 1); /* Bottom-right */
GL1_RASTER_FONT_EMIT(3, 1, 0); /* Top-right */
GL1_RASTER_FONT_EMIT(4, 0, 0); /* Top-left */
GL1_RASTER_FONT_EMIT(5, 1, 1); /* Bottom-right */
i++;

View File

@ -29,7 +29,7 @@
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define gl_core_raster_font_emit(c, vx, vy) do { \
#define GL_CORE_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
@ -37,8 +37,7 @@
font_color[ 4 * (6 * i + c) + 0] = color[0]; \
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
} while(0)
font_color[ 4 * (6 * i + c) + 3] = color[3]
#define MAX_MSG_LEN_CHUNK 64
@ -261,13 +260,13 @@ static void gl_core_raster_font_render_line(
width = glyph->width;
height = glyph->height;
gl_core_raster_font_emit(0, 0, 1); /* Bottom-left */
gl_core_raster_font_emit(1, 1, 1); /* Bottom-right */
gl_core_raster_font_emit(2, 0, 0); /* Top-left */
GL_CORE_RASTER_FONT_EMIT(0, 0, 1); /* Bottom-left */
GL_CORE_RASTER_FONT_EMIT(1, 1, 1); /* Bottom-right */
GL_CORE_RASTER_FONT_EMIT(2, 0, 0); /* Top-left */
gl_core_raster_font_emit(3, 1, 0); /* Top-right */
gl_core_raster_font_emit(4, 0, 0); /* Top-left */
gl_core_raster_font_emit(5, 1, 1); /* Bottom-right */
GL_CORE_RASTER_FONT_EMIT(3, 1, 0); /* Top-right */
GL_CORE_RASTER_FONT_EMIT(4, 0, 0); /* Top-left */
GL_CORE_RASTER_FONT_EMIT(5, 1, 1); /* Bottom-right */
i++;

View File

@ -28,7 +28,7 @@
/* TODO: Move viewport side effects to the caller: it's a source of bugs. */
#define gl_raster_font_emit(c, vx, vy) do { \
#define GL_RASTER_FONT_EMIT(c, vx, vy) \
font_vertex[ 2 * (6 * i + c) + 0] = (x + (delta_x + off_x + vx * width) * scale) * inv_win_width; \
font_vertex[ 2 * (6 * i + c) + 1] = (y + (delta_y - off_y - vy * height) * scale) * inv_win_height; \
font_tex_coords[ 2 * (6 * i + c) + 0] = (tex_x + vx * width) * inv_tex_size_x; \
@ -38,8 +38,7 @@
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]; \
} while(0)
font_lut_tex_coord[ 2 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]
#define MAX_MSG_LEN_CHUNK 64
@ -330,13 +329,13 @@ static void gl_raster_font_render_line(
width = glyph->width;
height = glyph->height;
gl_raster_font_emit(0, 0, 1); /* Bottom-left */
gl_raster_font_emit(1, 1, 1); /* Bottom-right */
gl_raster_font_emit(2, 0, 0); /* Top-left */
GL_RASTER_FONT_EMIT(0, 0, 1); /* Bottom-left */
GL_RASTER_FONT_EMIT(1, 1, 1); /* Bottom-right */
GL_RASTER_FONT_EMIT(2, 0, 0); /* Top-left */
gl_raster_font_emit(3, 1, 0); /* Top-right */
gl_raster_font_emit(4, 0, 0); /* Top-left */
gl_raster_font_emit(5, 1, 1); /* Bottom-right */
GL_RASTER_FONT_EMIT(3, 1, 0); /* Top-right */
GL_RASTER_FONT_EMIT(4, 0, 0); /* Top-left */
GL_RASTER_FONT_EMIT(5, 1, 1); /* Bottom-right */
i++;

View File

@ -81,10 +81,11 @@
length:(NSUInteger)(_stride * _atlas->height)
options:MTLResourceStorageModeManaged];
// Even though newBufferWithBytes will copy the initial contents
// from our atlas, it doesn't seem to invalidate the buffer when
// doing so, causing corrupted text rendering if we hit this code
// path. To work around it we manually invalidate the buffer.
/* Even though newBufferWithBytes will copy the initial contents
* from our atlas, it doesn't seem to invalidate the buffer when
* doing so, causing corrupted text rendering if we hit this code
* path. To work around it we manually invalidate the buffer.
*/
[_buffer didModifyRange:NSMakeRange(0, _buffer.length)];
}
else

View File

@ -39,7 +39,42 @@ typedef struct
unsigned vertices;
} vulkan_raster_t;
static void vulkan_raster_font_free_font(void *data, bool is_threaded);
static INLINE void vulkan_raster_font_update_glyph(
vulkan_raster_t *font, const struct font_glyph *glyph)
{
if(font->atlas->dirty)
{
unsigned row;
for (row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++)
{
uint8_t *src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x;
uint8_t *dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x;
memcpy(dst, src, glyph->width);
}
font->atlas->dirty = false;
font->needs_update = true;
}
}
static void vulkan_raster_font_free_font(void *data, bool is_threaded)
{
vulkan_raster_t *font = (vulkan_raster_t*)data;
if (!font)
return;
if (font->font_driver && font->font_data)
font->font_driver->free(font->font_data);
vkQueueWaitIdle(font->vk->context->queue);
vulkan_destroy_texture(
font->vk->context->device, &font->texture);
vulkan_destroy_texture(
font->vk->context->device, &font->texture_optimal);
free(font);
}
static void *vulkan_raster_font_init_font(void *data,
const char *font_path, float font_size,
@ -90,41 +125,6 @@ static void *vulkan_raster_font_init_font(void *data,
return font;
}
static void vulkan_raster_font_free_font(void *data, bool is_threaded)
{
vulkan_raster_t *font = (vulkan_raster_t*)data;
if (!font)
return;
if (font->font_driver && font->font_data)
font->font_driver->free(font->font_data);
vkQueueWaitIdle(font->vk->context->queue);
vulkan_destroy_texture(
font->vk->context->device, &font->texture);
vulkan_destroy_texture(
font->vk->context->device, &font->texture_optimal);
free(font);
}
static INLINE void vulkan_raster_font_update_glyph(vulkan_raster_t *font, const struct font_glyph *glyph)
{
if(font->atlas->dirty)
{
unsigned row;
for (row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++)
{
uint8_t *src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x;
uint8_t *dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x;
memcpy(dst, src, glyph->width);
}
font->atlas->dirty = false;
font->needs_update = true;
}
}
static int vulkan_get_message_width(void *data, const char *msg,
unsigned msg_len, float scale)
{
@ -444,7 +444,8 @@ static const struct font_glyph *vulkan_raster_font_get_glyph(
return glyph;
}
static bool vulkan_get_line_metrics(void* data, struct font_line_metrics **metrics)
static bool vulkan_get_line_metrics(void* data,
struct font_line_metrics **metrics)
{
vulkan_raster_t *font = (vulkan_raster_t*)data;

View File

@ -217,7 +217,8 @@ static void fill_content_img(gfx_thumbnail_path_data_t *path_data)
* No-Intro filename standard:
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
* Replace these characters in the entry name with underscores */
while((scrub_char_pointer = strpbrk(path_data->content_img, "&*/:`\"<>?\\|")))
while ((scrub_char_pointer =
strpbrk(path_data->content_img, "&*/:`\"<>?\\|")))
*scrub_char_pointer = '_';
/* Add PNG extension */

View File

@ -593,7 +593,7 @@ static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack)
if (incomplete == 0)
{
RARCH_LOG("All in-flight reads complete.\n");
while(adapters.list != NULL)
while (adapters.list)
{
RARCH_LOG("[hid]: shutting down adapter..\n");
adapter = adapters.list;

View File

@ -37,6 +37,8 @@
#include <xtl.h>
#endif
#define UTF8_WALKBYTE(string) (*((*(string))++))
static unsigned leading_ones(uint8_t c)
{
unsigned ones = 0;
@ -89,13 +91,14 @@ size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
const uint16_t *in, size_t in_size)
{
static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
size_t out_pos = 0;
size_t in_pos = 0;
static const
uint8_t utf8_limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
for (;;)
{
unsigned numAdds;
unsigned num_adds;
uint32_t value;
if (in_pos == in_size)
@ -124,21 +127,21 @@ bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
}
for (numAdds = 1; numAdds < 5; numAdds++)
if (value < (((uint32_t)1) << (numAdds * 5 + 6)))
for (num_adds = 1; num_adds < 5; num_adds++)
if (value < (((uint32_t)1) << (num_adds * 5 + 6)))
break;
if (out)
out[out_pos] = (char)(kUtf8Limits[numAdds - 1]
+ (value >> (6 * numAdds)));
out[out_pos] = (char)(utf8_limits[num_adds - 1]
+ (value >> (6 * num_adds)));
out_pos++;
do
{
numAdds--;
num_adds--;
if (out)
out[out_pos] = (char)(0x80
+ ((value >> (6 * numAdds)) & 0x3F));
+ ((value >> (6 * num_adds)) & 0x3F));
out_pos++;
}while (numAdds != 0);
}while (num_adds != 0);
}
*out_chars = out_pos;
@ -166,13 +169,15 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
while (*sb && chars-- > 0)
{
sb++;
while ((*sb & 0xC0) == 0x80) sb++;
while ((*sb & 0xC0) == 0x80)
sb++;
}
if ((size_t)(sb - sb_org) > d_len-1 /* NUL */)
{
sb = sb_org + d_len-1;
while ((*sb & 0xC0) == 0x80) sb--;
while ((*sb & 0xC0) == 0x80)
sb--;
}
memcpy(d, sb_org, sb-sb_org);
@ -184,14 +189,18 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
const char *utf8skip(const char *str, size_t chars)
{
const uint8_t *strb = (const uint8_t*)str;
if (!chars)
return str;
do
{
strb++;
while ((*strb & 0xC0)==0x80) strb++;
while ((*strb & 0xC0)==0x80)
strb++;
chars--;
}while (chars);
return (const char*)strb;
}
@ -211,24 +220,22 @@ size_t utf8len(const char *string)
return ret;
}
#define utf8_walkbyte(string) (*((*(string))++))
/* Does not validate the input, returns garbage if it's not UTF-8. */
uint32_t utf8_walk(const char **string)
{
uint8_t first = utf8_walkbyte(string);
uint8_t first = UTF8_WALKBYTE(string);
uint32_t ret = 0;
if (first < 128)
return first;
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
ret = (ret << 6) | (UTF8_WALKBYTE(string) & 0x3F);
if (first >= 0xE0)
{
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
ret = (ret << 6) | (UTF8_WALKBYTE(string) & 0x3F);
if (first >= 0xF0)
{
ret = (ret << 6) | (utf8_walkbyte(string) & 0x3F);
ret = (ret << 6) | (UTF8_WALKBYTE(string) & 0x3F);
return ret | (first & 7) << 18;
}
return ret | (first & 15) << 12;

View File

@ -705,7 +705,8 @@ static int png_reverse_filter_adam7_iterate(uint32_t **data_,
if (png_reverse_filter_init(&pngp->ihdr, pngp) == -1)
return IMAGE_PROCESS_ERROR;
do{
do
{
ret = png_reverse_filter_regular_iterate(&pngp->data,
&pngp->ihdr, pngp);
} while (ret == IMAGE_PROCESS_NEXT);

View File

@ -191,7 +191,8 @@ void manual_content_scan_scrub_system_name_custom(void)
* and/or violate the No-Intro filename standard:
* http://datomatic.no-intro.org/stuff/The%20Official%20No-Intro%20Convention%20(20071030).zip
* Replace these characters with underscores */
while((scrub_char_pointer = strpbrk(scan_settings.system_name_custom, "&*/:`\"<>?\\|")))
while ((scrub_char_pointer =
strpbrk(scan_settings.system_name_custom, "&*/:`\"<>?\\|")))
*scrub_char_pointer = '_';
}

View File

@ -396,7 +396,8 @@ static char **waiting_argv;
task_queue_check();
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE) == kCFRunLoopRunHandledSource);
while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE)
== kCFRunLoopRunHandledSource);
if (ret == -1)
{
#ifdef HAVE_QT