Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 54 additions & 8 deletions .github/workflows/Linux-libretro-common-samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ jobs:
task_queue_title_error_test
tpool_wait_test
retro_atomic_test
retro_atomic_extern_c_linkage_test
retro_atomic_extern_c_linkage_test_cxx
retro_spsc_test
)

Expand Down Expand Up @@ -212,6 +214,25 @@ jobs:
# behavioural SPSC stress is already covered by the C test
# binary above on this same host, and the C++11 backend bottoms
# out through the same libstdc++ __atomic_* builtins.
#
# Two fixtures share the g++/clang++ x c++11/14/17 sweep:
#
# cxx_smoke.cpp : header included at C++ linkage,
# the "ordinary" C++ TU shape.
# cxx_smoke_extern_c.cpp : header included from inside an
# extern "C" { ... } wrap, the
# shape ui_qt.cpp uses under
# !CXX_BUILD. This is the
# regression case for the
# RETRO_BEGIN_DECLS_CXX shield in
# retro_atomic.h's C++11 backend.
# The standalone build of the
# sample at samples/atomic/
# retro_atomic_extern_c_linkage/
# covers the same case under the
# default toolchain; this matrix
# extends coverage to clang++ and
# the higher language standards.
set -u
set -o pipefail

Expand Down Expand Up @@ -254,16 +275,41 @@ jobs:
}
EOF

# Regression fixture: include retro_atomic.h from inside an
# extern "C" wrap. Faithful mirror of ui_qt.cpp's pattern.
# Pre-fix retro_atomic.h would emit ~80 "template with C
# linkage" errors here; the RETRO_BEGIN_DECLS_CXX shield
# around <atomic> makes this compile cleanly.
cat > "$tmpdir/cxx_smoke_extern_c.cpp" <<'EOF'
#include <cstdio>
#include <cstddef>

extern "C" {
#include <retro_atomic.h>
}

int main(void) {
retro_atomic_int_t ai; retro_atomic_int_init(&ai, 0);
retro_atomic_store_release_int(&ai, 7);
int v = retro_atomic_load_acquire_int(&ai);
std::printf("backend: %s\n", RETRO_ATOMIC_BACKEND_NAME);
std::puts(v == 7 ? "ALL OK" : "FAIL");
return v == 7 ? 0 : 1;
}
EOF

for cxx in g++ clang++; do
for std in c++11 c++14 c++17; do
echo "==> compile-test with $cxx -std=$std"
$cxx -std=$std -Wall -Wextra -pedantic -O2 \
-I include \
"$tmpdir/cxx_smoke.cpp" \
-o "$tmpdir/cxx_smoke" \
|| { echo "::error title=C++ compile failed::$cxx -std=$std"; exit 1; }
"$tmpdir/cxx_smoke" \
|| { echo "::error title=C++ smoke failed::$cxx -std=$std"; exit 1; }
for fixture in cxx_smoke cxx_smoke_extern_c; do
echo "==> compile-test with $cxx -std=$std ($fixture)"
$cxx -std=$std -Wall -Wextra -pedantic -O2 \
-I include \
"$tmpdir/$fixture.cpp" \
-o "$tmpdir/$fixture" \
|| { echo "::error title=C++ compile failed::$cxx -std=$std $fixture"; exit 1; }
"$tmpdir/$fixture" \
|| { echo "::error title=C++ smoke failed::$cxx -std=$std $fixture"; exit 1; }
done
done
done

Expand Down
4 changes: 2 additions & 2 deletions deps/switchres/custom_video_xrandr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,13 +676,13 @@ bool xrandr_timing::add_mode(modeline *mode)
// remove unlinked modeline
if (mode->platform_data)
{
log_error("XRANDR: <%d> (add_mode) [ERROR] remove mode [%04lx]\n", m_id, mode->platform_data);
log_error("XRANDR: <%d> (add_mode) [ERROR] remove mode [%04llx]\n", m_id, (unsigned long long)mode->platform_data);
XRRDestroyMode(m_pdisplay, mode->platform_data);
mode->platform_data = 0;
}
}
else
log_verbose("XRANDR: <%d> (add_mode) mode %04lx %dx%d refresh %.6f added\n", m_id, mode->platform_data, mode->hactive, mode->vactive, mode->vfreq);
log_verbose("XRANDR: <%d> (add_mode) mode %04llx %dx%d refresh %.6f added\n", m_id, (unsigned long long)mode->platform_data, mode->hactive, mode->vactive, mode->vfreq);

return ms_xerrors == 0;
}
Expand Down
2 changes: 1 addition & 1 deletion deps/switchres/display_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int linux_display::get_available_video_modes()
video_modes.push_back(mode);
backup_modes.push_back(mode);

log_verbose("Switchres: [%3ld] %4dx%4d @%3d%s%s %s: ", video_modes.size(), mode.width, mode.height, mode.refresh, mode.interlace ? "i" : "p", mode.type & MODE_DESKTOP ? "*" : "", mode.type & MODE_ROTATED ? "rot" : "");
log_verbose("Switchres: [%3zu] %4dx%4d @%3d%s%s %s: ", video_modes.size(), mode.width, mode.height, mode.refresh, mode.interlace ? "i" : "p", mode.type & MODE_DESKTOP ? "*" : "", mode.type & MODE_ROTATED ? "rot" : "");
log_mode(&mode);
};

Expand Down
2 changes: 2 additions & 0 deletions gfx/drivers/vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -6744,6 +6744,7 @@ static bool vulkan_frame(void *data, const void *frame,
if ((vk->context->flags & VK_CTX_FLAG_HDR_ENABLE) &&
((vk->flags & VK_FLAG_MENU_ENABLE) || (vk->flags & VK_FLAG_OVERLAY_ENABLE)
|| message_visible
|| statistics_show
#ifdef HAVE_GFX_WIDGETS
|| widgets_visible
#endif
Expand Down Expand Up @@ -6858,6 +6859,7 @@ static bool vulkan_frame(void *data, const void *frame,
if ((vk->context->flags & VK_CTX_FLAG_HDR_ENABLE) &&
((vk->flags & VK_FLAG_MENU_ENABLE) || (vk->flags & VK_FLAG_OVERLAY_ENABLE)
|| message_visible
|| statistics_show
#ifdef HAVE_GFX_WIDGETS
|| widgets_visible
#endif
Expand Down
11 changes: 7 additions & 4 deletions gfx/drivers_shader/slang_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ static bool spirv_cache_get_dir(char *cache_dir_out, size_t cache_dir_out_len)
return false;

/* Build the spirv subdirectory path */
snprintf(cache_dir_out, cache_dir_out_len, "%s/%s",
settings->paths.directory_cache, SPIRV_CACHE_SUBDIR);
fill_pathname_join_special(cache_dir_out,
settings->paths.directory_cache, SPIRV_CACHE_SUBDIR,
cache_dir_out_len);

return true;
}
Expand Down Expand Up @@ -65,12 +66,14 @@ static bool spirv_cache_get_filename(const char *hash,
char *cache_file_out, size_t cache_file_out_len)
{
char cache_dir[PATH_MAX_LENGTH];
char hash_filename[128];

if (!spirv_cache_get_dir(cache_dir, sizeof(cache_dir)))
return false;

snprintf(cache_file_out, cache_file_out_len, "%s/%s.spirv",
cache_dir, hash);
snprintf(hash_filename, sizeof(hash_filename), "%s.spirv", hash);
fill_pathname_join_special(cache_file_out, cache_dir, hash_filename,
cache_file_out_len);

return true;
}
Expand Down
14 changes: 10 additions & 4 deletions libretro-common/include/retro_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef __LIBRETRO_SDK_ATOMIC_H
#define __LIBRETRO_SDK_ATOMIC_H

#include <retro_common_api.h>

/* Minimal portable atomic operations for SPSC patterns.
*
* This header consolidates the ad-hoc atomic shims previously duplicated
Expand Down Expand Up @@ -321,10 +323,12 @@
#endif

/* The header contains only macros and integer typedefs; there are no
* function declarations and therefore no need for RETRO_BEGIN_DECLS /
* extern "C" wrapping. In particular the C++11 backend below
* #includes <atomic>, whose templates cannot be declared with C
* linkage, so the wrapper would actively break that path. */
* function declarations and therefore no need for RETRO_BEGIN_DECLS
* around the file. The C++11 backend below #includes <atomic>, whose
* templates cannot be declared with C linkage; if a caller wraps its
* #include of this header in extern "C" { ... } (e.g. ui_qt.cpp under
* !CXX_BUILD), libstdc++ <atomic> emits dozens of "template with C
* linkage" errors. RETRO_BEGIN_DECLS_CXX below escapes that. */

/* ---- C11 <stdatomic.h> ------------------------------------------------- */
#if defined(RETRO_ATOMIC_BACKEND_C11)
Expand Down Expand Up @@ -359,8 +363,10 @@ typedef atomic_size_t retro_atomic_size_t;
/* ---- C++11 <atomic> --------------------------------------------------- */
#elif defined(RETRO_ATOMIC_BACKEND_CXX11)

RETRO_BEGIN_DECLS_CXX
#include <atomic>
#include <cstddef>
RETRO_END_DECLS_CXX
/* This header is included by C++ TUs in C++11+ mode (gated on
* __cplusplus >= 201103L or _MSVC_LANG >= 201103L). We use the
* std::atomic_* free-function forms rather than the member-function
Expand Down
9 changes: 9 additions & 0 deletions libretro-common/include/retro_common_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ special technique is called for.

#define RETRO_BEGIN_DECLS
#define RETRO_END_DECLS
#define RETRO_BEGIN_DECLS_CXX
#define RETRO_END_DECLS_CXX

#ifdef __cplusplus

Expand All @@ -50,6 +52,13 @@ special technique is called for.
#undef RETRO_END_DECLS
#define RETRO_BEGIN_DECLS extern "C" {
#define RETRO_END_DECLS }
/* Force C++ linkage for a region inside a header that may be included
* from within a caller's extern "C" { ... } block -- needed when the
* region pulls in a C++ standard library header (e.g. <atomic>). */
#undef RETRO_BEGIN_DECLS_CXX
#undef RETRO_END_DECLS_CXX
#define RETRO_BEGIN_DECLS_CXX extern "C++" {
#define RETRO_END_DECLS_CXX }
#endif

#else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
TARGET := retro_atomic_extern_c_linkage_test
TARGET_TEST := retro_atomic_extern_c_linkage_test_cxx

LIBRETRO_COMM_DIR := ../../..

# Two binaries from one source. The source mirrors ui_qt.cpp's pattern
# of wrapping a RetroArch header include in extern "C" { ... }, gated
# on !CXX_BUILD. We build it once each way:
#
# $(TARGET) : non-unity / separate-TU build (extern "C" wrap is
# active). This is the configuration that triggered
# the original "template with C linkage" failure on
# g++ before the retro_common_api.h fix.
#
# $(TARGET_TEST) : unity / griffin build (CXX_BUILD defined, extern
# "C" wrappers compile out). Validates that the
# fix did not regress the unity-build path.
#
# Both must compile and pass. Build failure on $(TARGET) is the
# regression signal for the original bug.

SOURCE := retro_atomic_extern_c_linkage_test.cpp

# C++11 is the minimum that engages retro_atomic.h's CXX11 backend.
# -Wall -Wextra to catch any incidental warning the test's macro
# expansions might produce on a future toolchain.
CXXFLAGS += -Wall -Wextra -pedantic -std=c++11 -g -O0 \
-I$(LIBRETRO_COMM_DIR)/include

ifneq ($(SANITIZER),)
CXXFLAGS := -fsanitize=$(SANITIZER) -fno-omit-frame-pointer $(CXXFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
endif

# The unity-build target gets CXX_BUILD defined, exactly as
# Makefile.griffin does for griffin_cpp.cpp's TUs.
$(TARGET_TEST): CXXFLAGS += -DCXX_BUILD

all: $(TARGET) $(TARGET_TEST)

$(TARGET): $(SOURCE)
$(CXX) -o $@ $< $(CXXFLAGS) $(LDFLAGS)

$(TARGET_TEST): $(SOURCE)
$(CXX) -o $@ $< $(CXXFLAGS) $(LDFLAGS)

clean:
rm -f $(TARGET) $(TARGET_TEST)

.PHONY: all clean
Loading
Loading