Skip to content

Commit

Permalink
add clang 16b support
Browse files Browse the repository at this point in the history
  • Loading branch information
Владимир Чиж authored and Владимир Чиж committed Mar 1, 2024
1 parent 7fc52ff commit e863b81
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
build_type: [Release, Debug]
os: [macos-14]
build_type: [Release,]
c_compiler: [gcc, cl, clang]
include:
- os: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion srcbpatch/bpatchfolders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "fileprocessing.h"
#include "bpatchfolders.h"

#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
#include <unistd.h>
#else
#include <tchar.h>
Expand Down
2 changes: 1 addition & 1 deletion srcbpatch/coloredconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <algorithm>
#include "coloredconsole.h"

#ifndef __linux__
#if !defined(__linux__) && !((defined(__APPLE__) && defined(__MACH__)))
#include <windows.h>
#endif

Expand Down
8 changes: 8 additions & 0 deletions srcbpatch/fileprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ using namespace std::filesystem;

FileProcessing::FileProcessing(const char* fname, const char* mode)
{
#if !defined(__linux__) && !(defined(__APPLE__) && defined(__MACH__))
#pragma warning(disable: 4996) // I would like to use fopen instead of fopen_s, because
// 1. I would like to write fast code
// 2. MSVS compiler does not respect C++ standard and __STDC_LIB_EXT1__ define
#endif
if (stream_ = fopen(fname, mode); nullptr == stream_)
#if !defined(__linux__) && !(defined(__APPLE__) && defined(__MACH__))
#pragma warning(default: 4996)
#endif
{
throw filesystem_error(fio_errors[0], filesystem::path(fname), error_code());
}
Expand Down Expand Up @@ -59,6 +63,8 @@ span<char> ReadFileProcessing::ReadData(const span<char> place)
{
#ifdef __linux__
const size_t readed = fread_unlocked(place.data(), sizeof(*place.data()), place.size(), stream_);
#elif defined(__APPLE__) && defined(__MACH__)
const size_t readed = fread(place.data(), sizeof(*place.data()), place.size(), stream_);
#else
const size_t readed = _fread_nolock(place.data(), sizeof(*place.data()), place.size(), stream_);
#endif
Expand Down Expand Up @@ -101,6 +107,8 @@ size_t WriteFileProcessing::WriteAndThrowIfFail(const string_view& sv)
{
#ifdef __linux__
const size_t written = fwrite_unlocked(sv.data(), sizeof(sv.data()[0]), sv.size(), stream_);
#elif defined(__APPLE__) && defined(__MACH__)
const size_t written = fwrite(sv.data(), sizeof(sv.data()[0]), sv.size(), stream_);
#else
const size_t written = _fwrite_nolock(sv.data(), sizeof(sv.data()[0]), sv.size(), stream_);
#endif
Expand Down
12 changes: 6 additions & 6 deletions testbpatch/test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "pch.h"
#include <gtest/gtest.h>

#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
#include <unistd.h>
#else
#include <tchar.h>
Expand Down Expand Up @@ -29,7 +29,7 @@ TEST(WildCharacters, ProcessingValidTrue)
}
okMask[] =
{
#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
{R"(/Users/Bobby/kon?e?.txt)", R"(./kon?e?.txt)"}
, {R"(../Bobby/kon*e*.*)", R"(../kon*e*.*)"}
, {R"(kon*e*.*)", R"(./kon*e*.*)"}
Expand Down Expand Up @@ -77,7 +77,7 @@ TEST(WildCharacters, ProcessingValidFalse)
}
okMask[] =
{
#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
{R"(/Users/Bobby/kon?e?.txt)", R"(/Users/Bobby/kon?e?.txt)"}
, {R"(./../*.???)", R"(./../*.???)"}
, {R"(*.*)", R"(*.*)"}
Expand Down Expand Up @@ -111,7 +111,7 @@ TEST(WildCharacters, ProcessingInvalid)
}
badMask[] =
{
#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
{R"(/Users/Bo?by/kon?e?.txt)", emptySV}
, {R"(../Bo*by/kon*e*.*)", emptySV}
, {R"(*/kon*e*.*)", emptySV}
Expand Down Expand Up @@ -158,7 +158,7 @@ TEST(WildCharacters, ProcessingInvalid)
TEST(WildCharacters, SearchingTests)
{
// get full path for executable
#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
char pathBuffer[PATH_MAX] = {0};
[[maybe_unused]] auto result = readlink(R"(/proc/self/exe)", pathBuffer, PATH_MAX);
#else
Expand All @@ -172,7 +172,7 @@ TEST(WildCharacters, SearchingTests)
filesystem::path pathTestFolder(pathBuffer);
pathTestFolder = pathTestFolder.parent_path();

#ifdef __linux__
#if defined(__linux__) || ((defined(__APPLE__) && defined(__MACH__)))
#else
pathTestFolder /= ".."; // creation of Debug or Release subfolder is Window's 'EVERYTHING'
#endif
Expand Down

0 comments on commit e863b81

Please sign in to comment.