Skip to content

Commit

Permalink
Update to GCC 14.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed Jun 1, 2024
1 parent 34cc8b7 commit dab29f4
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 374 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ jobs:
- name: Increase swap space
run: |
sudo swapoff -a
sudo fallocate -l 15G '/mnt/swapfile'
sudo fallocate -l '15G' '/mnt/swapfile'
sudo mkswap '/mnt/swapfile'
sudo swapon '/mnt/swapfile'
- name: Install required dependencies
run: |
sudo apt-get install libxml2-dev
sudo apt-get install 'libxml2-dev'
- name: Setup Linux cross-compiler
run: |
declare -r SPHYNX_TAG="$(jq --raw-output '.tag_name' <<< "$(curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --url 'https://api.github.com/repos/AmanoTeam/Sphynx/releases/latest')")"
Expand Down Expand Up @@ -269,7 +269,7 @@ jobs:
echo '/tmp/nul/bin' >> "${GITHUB_PATH}"
- name: Build with CMake
run: |
declare -r targets=(
declare -ra targets=(
x86_64-unknown-linux-gnu
# hppa-unknown-openbsd
arm-unknown-openbsd
Expand Down Expand Up @@ -391,7 +391,7 @@ jobs:
for target in "${targets[@]}"; do
echo "Building for ${target}"
KAI_ENABLE_LTO='ON'
KAI_ENABLE_LTO='OFF'
if [[ "${target}" == *-apple-darwin ]] || [[ "${target}" == *-w64-mingw32 ]] || [[ "${target}" == *-unknown-openbsd ]]; then
KAI_ENABLE_LTO=OFF
Expand All @@ -401,7 +401,7 @@ jobs:
-DKAI_ENABLE_LTO="${KAI_ENABLE_LTO}" \
-DCMAKE_TOOLCHAIN_FILE="./.github/workflows/cmake_toolchains/${target}.cmake" \
-DCMAKE_INSTALL_PREFIX="${target}" \
-DCMAKE_BUILD_TYPE='MinSizeRel' ../
-DCMAKE_BUILD_TYPE='MinSizeRel' ../ 1>/dev/null
pushd './ffmpeg-build'
make --jobs 1>/dev/null
Expand All @@ -412,6 +412,8 @@ jobs:
cmake --build ./ -- --jobs 1>/dev/null
cmake --install ./ --strip 1>/dev/null
chmod 644 "${target}/lib/libav"*
if [[ "${target}" == *'mingw32' ]]; then
zip --recurse-paths -9 "${OUTPUT_DIRECTORY}/${target}.zip" "${target}" 1>/dev/null
else
Expand Down
19 changes: 3 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ set(
--enable-small
--enable-version3
--extra-cflags=-Dstatic_assert=_Static_assert
--extra-cflags=-w
--extra-ldflags=-fPIC
--prefix="${FFMPEG_INSTALL_PREFIX}"
)
Expand Down Expand Up @@ -646,7 +647,7 @@ foreach(source ${libraries})
endif()

if (UNIX)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android")
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD")
string(APPEND destination "${CMAKE_SHARED_LIBRARY_SUFFIX}")
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
string(APPEND destination "${SOVERSION_SEPARATOR}${major_version}${CMAKE_SHARED_LIBRARY_SUFFIX}")
Expand Down Expand Up @@ -714,16 +715,9 @@ add_executable(
src/showformats.c
src/callbacks.c
src/resources.c
src/biggestint.c
)

if (NOT (WIN32 OR SERENITYOS))
target_sources(
kai
PRIVATE
src/getdents.c
)
endif()

foreach(target kai)
target_compile_options(
${target}
Expand Down Expand Up @@ -855,13 +849,6 @@ target_link_libraries(
# libswresample
)

if (WIN32)
target_link_libraries(
kai
shlwapi
)
endif()

foreach(target kai bearssl libcurl_shared)
install(
TARGETS ${target}
Expand Down
27 changes: 27 additions & 0 deletions src/biggestint.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdint.h>

#include "biggestint.h"

bigint_t ptobigint(const void* const pointer) {
/*
Convert a pointer to a bigint_t.
*/

const intptr_t value = (intptr_t) pointer;
const bigint_t result = (bigint_t) value;

return result;

}

biguint_t ptobiguint(const void* const pointer) {
/*
Convert a pointer to a biguint_t.
*/

const uintptr_t value = (uintptr_t) pointer;
const biguint_t result = (biguint_t) value;

return result;

}
3 changes: 3 additions & 0 deletions src/biggestint.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ typedef long double bigfloat_t;
#define strtobui strtoul
#endif

bigint_t ptobigint(const void* const pointer);
biguint_t ptobiguint(const void* const pointer);

#endif
125 changes: 0 additions & 125 deletions src/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#if defined(_WIN32)
#include <windows.h>
#include <fileapi.h>
#include <shlwapi.h>
#endif

#if defined(__FreeBSD__)
Expand Down Expand Up @@ -41,10 +40,6 @@
#include "walkdir.h"
#include "pathsep.h"

#if !(defined(_WIN32) || defined(__serenity__))
#include "getdents.h"
#endif

#if defined(_WIN32) || defined(__OpenBSD__)
#include "path.h"
#endif
Expand Down Expand Up @@ -466,126 +461,6 @@ int directory_exists(const char* const directory) {

}

int directory_empty(const char* const directory) {
/*
Determines whether a specified path is an empty directory.
Returns (1) if directory is empty, (0) if it does not, (-1) on error.
*/

#if defined(_WIN32)
DWORD attributes = 0;
BOOL status = FALSE;

#if defined(_UNICODE)
wchar_t* wdirectory = NULL;

/* This prefix is required to support long paths in Windows 10+ */
const size_t prefixs = isabsolute(directory) ? wcslen(WIN10_LONG_PATH_PREFIX) : 0;

const int wdirectorys = MultiByteToWideChar(CP_UTF8, 0, directory, -1, NULL, 0);

if (wdirectorys == 0) {
return -1;
}

wdirectory = malloc(prefixs + (size_t) wdirectorys);

if (wdirectory == NULL) {
return -1;
}

if (prefixs > 0) {
wcscpy(wdirectory, WIN10_LONG_PATH_PREFIX);
}

if (MultiByteToWideChar(CP_UTF8, 0, directory, -1, wdirectory + prefixs, wdirectorys) == 0) {
free(wdirectory);
return -1;
}

attributes = GetFileAttributesW(wdirectory);
#else
attributes = GetFileAttributesA(directory);
#endif

if (attributes == INVALID_FILE_ATTRIBUTES) {
#if defined(_UNICODE)
free(wdirectory);
#endif

return -1;
}

if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
#if defined(_UNICODE)
free(wdirectory);
#endif

return -1;
}

#if defined(_UNICODE)
status = PathIsDirectoryEmptyW(wdirectory);
#else
status = PathIsDirectoryEmptyA(directory);
#endif

#if defined(_UNICODE)
free(wdirectory);
#endif

return (int) status;
#else
#if !defined(__serenity__)
long index = 0;

directory_entry_t item;
directory_entry_t items[3];

const int fd = open_dir(directory);

if (fd == -1) {
return -1;
}

while (1) {
const ssize_t size = get_directory_entries(fd, (char*) items, sizeof(items));

if (size == 0) {
close_dir(fd);
break;
}

if (size == -1) {
close_dir(fd);

if (errno == EINVAL) {
return 0;
}

return -1;
}

for (index = 0; index < size;) {
const char* const ptr = (((char*) items) + index);
memcpy(&item, ptr, sizeof(item));

if (!(strcmp(item.d_name, ".") == 0 || strcmp(item.d_name, "..") == 0)) {
close(fd);
return 0;
}

index += directory_entry_size(&item);
}
}
#endif

return 1;
#endif

}

int file_exists(const char* const filename) {
/*
Checks if file exists and is a regular file or symlink.
Expand Down
1 change: 0 additions & 1 deletion src/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ int file_exists(const char* const filename);
int create_directory(const char* const directory);
int move_file(const char* const source, const char* const destination);
int copy_file(const char* const source, const char* const destination);
int directory_empty(const char* const directory);

#define remove_directory(directory) remove_recursive(directory, 1)
#define remove_directory_contents(directory) remove_recursive(directory, 0)
Loading

0 comments on commit dab29f4

Please sign in to comment.