-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create cmake-multi-platform.yml (#6)
* Create cmake-multi-platform.yml Signed-off-by: Ryan M. Lederman <[email protected]> * fix typos * ...more typos * gcc does not like this sprintf. * fix c++ configuration provider * fix assert statement * cstring include * _GNU_SOURCE already defined * __has_include, std::bit_cast, std::source_location * bump version 0.3.0, update copyright year --------- Signed-off-by: Ryan M. Lederman <[email protected]>
- Loading branch information
Showing
27 changed files
with
209 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. | ||
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml | ||
name: CMake on multiple platforms | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | ||
fail-fast: false | ||
|
||
# Set up a matrix to run the following 3 configurations: | ||
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> | ||
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator> | ||
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> | ||
# | ||
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
build_type: [Release] | ||
c_compiler: [gcc, clang, cl] | ||
include: | ||
- os: windows-latest | ||
c_compiler: cl | ||
cpp_compiler: cl | ||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
- os: ubuntu-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
- os: macos-latest | ||
c_compiler: clang | ||
cpp_compiler: clang++ | ||
exclude: | ||
- os: windows-latest | ||
c_compiler: gcc | ||
- os: windows-latest | ||
c_compiler: clang | ||
- os: ubuntu-latest | ||
c_compiler: cl | ||
- os: macos-latest | ||
c_compiler: cl | ||
- os: macos-latest | ||
c_compiler: gcc | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set reusable strings | ||
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | ||
id: strings | ||
shell: bash | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
- name: Configure CMake | ||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
run: > | ||
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-S ${{ github.workspace }} | ||
- name: Build | ||
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | ||
|
||
- name: Test | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | ||
run: ctest --build-config ${{ matrix.build_type }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* bal.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* bal.hh | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
@@ -31,10 +31,29 @@ | |
# include <functional> | ||
# include <stdexcept> | ||
# include <cstdlib> | ||
# include <cstring> | ||
# include <vector> | ||
# include <atomic> | ||
# include <string> | ||
# include <bit> | ||
# include <version> | ||
|
||
# if defined(__has_include) | ||
# define __HAS_INCLUDE(hdr) __has_include(hdr) | ||
# else | ||
# define __HAS_INCLUDE(hdr) false | ||
# endif | ||
|
||
# if defined(__cpp_lib_source_location) && __HAS_INCLUDE(<source_location>) | ||
# include <source_location> | ||
# define source_location std::source_location | ||
# endif | ||
|
||
# if defined(__cpp_lib_bit_cast) && __HAS_INCLUDE(<bit>) | ||
# include <bit> | ||
# define bit_cast std::bit_cast | ||
# else | ||
# define bit_cast reinterpret_cast | ||
# endif | ||
|
||
/** The one and only namespace for libbal. */ | ||
namespace bal | ||
|
@@ -551,27 +570,27 @@ namespace bal | |
return throw_on_policy<TPolicy>(ret, false); | ||
} | ||
|
||
bool get_send_timeout(int* value) const | ||
bool get_send_timeout(bal_tvsec* sec, bal_tvusec* usec) const | ||
{ | ||
const auto ret = bal_get_send_timeout(_s, value); | ||
const auto ret = bal_get_send_timeout(_s, sec, usec); | ||
return throw_on_policy<TPolicy>(ret, false); | ||
} | ||
|
||
bool set_send_timeout(int value) const | ||
bool set_send_timeout(bal_tvsec sec, bal_tvusec usec) const | ||
{ | ||
const auto ret = bal_set_send_timeout(_s, value); | ||
const auto ret = bal_set_send_timeout(_s, sec, usec); | ||
return throw_on_policy<TPolicy>(ret, false); | ||
} | ||
|
||
bool get_recv_timeout(int* value) const | ||
bool get_recv_timeout(bal_tvsec* sec, bal_tvusec* usec) const | ||
{ | ||
const auto ret = bal_get_recv_timeout(_s, value); | ||
const auto ret = bal_get_recv_timeout(_s, sec, usec); | ||
return throw_on_policy<TPolicy>(ret, false); | ||
} | ||
|
||
bool set_recv_timeout(int value) const | ||
bool set_recv_timeout(bal_tvsec sec, bal_tvusec usec) const | ||
{ | ||
const auto ret = bal_set_recv_timeout(_s, value); | ||
const auto ret = bal_set_recv_timeout(_s, sec, usec); | ||
return throw_on_policy<TPolicy>(ret, false); | ||
} | ||
|
||
|
@@ -652,12 +671,12 @@ namespace bal | |
|
||
static socket_base* from_user_data(bal_socket* s) | ||
{ | ||
return std::bit_cast<socket_base*>(s->user_data); | ||
return bit_cast<socket_base*>(s->user_data); | ||
} | ||
|
||
uintptr_t to_user_data() const | ||
{ | ||
return std::bit_cast<uintptr_t>(this); | ||
return bit_cast<uintptr_t>(this); | ||
} | ||
|
||
async_io_cb on_read; | ||
|
@@ -705,7 +724,7 @@ namespace bal | |
if (self == nullptr) { | ||
_bal_dbglog("no user_data for socket " BAL_SOCKET_SPEC " (0x%" | ||
PRIxPTR ", mask = %08" PRIx32 ")", s->sd, | ||
std::bit_cast<uintptr_t>(s), s->state.mask); | ||
bit_cast<uintptr_t>(s), s->state.mask); | ||
return; | ||
} | ||
|
||
|
@@ -714,8 +733,7 @@ namespace bal | |
# if defined(BAL_DBGLOG) | ||
_bal_dbglog("early return for socket " BAL_SOCKET_SPEC " (0x%" | ||
PRIxPTR ", evt = %08" PRIx32 ", self = 0x%" PRIxPTR ")", | ||
s->sd, std::bit_cast<uintptr_t>(s), evt, | ||
std::bit_cast<uintptr_t>(self)); | ||
s->sd, bit_cast<uintptr_t>(s), evt, bit_cast<uintptr_t>(self)); | ||
# else | ||
BAL_UNUSED(s); | ||
BAL_UNUSED(self); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* errors.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
@@ -29,7 +29,6 @@ | |
# include "types.h" | ||
|
||
# if defined(__cplusplus) | ||
# include <source_location> | ||
extern "C" { | ||
# endif | ||
|
||
|
@@ -162,10 +161,10 @@ bool __bal_validate(bool expr, int err, const char* func, const char* file, | |
# if defined(BAL_DBGLOG) | ||
void __bal_dbglog(const char* func, const char* file, uint32_t line, | ||
const char* format, ...); | ||
# if defined(__cplusplus) | ||
# if defined(__cplusplus) && defined(source_location) | ||
# define _bal_dbglog(...) \ | ||
do { \ | ||
std::source_location loc = std::source_location::current(); \ | ||
source_location loc = source_location::current(); \ | ||
__bal_dbglog(loc.function_name(), loc.file_name(), loc.line(), __VA_ARGS__); \ | ||
} while (false) | ||
# else | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* helpers.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
@@ -29,13 +29,17 @@ | |
# include "types.h" | ||
# include "errors.h" | ||
|
||
/** Allows a parameter to be unreferenced without compiler warnings. */ | ||
# define BAL_UNUSED(var) (void)(var) | ||
|
||
/** Performs a case-insensitive string comparison and returns true if the | ||
* strings are the same. */ | ||
static inline | ||
bool _bal_strsame(const char* lhs, const char* rhs, size_t len) | ||
{ | ||
# if defined(__WIN__) | ||
return 0 == StrStrIA(lhs, rhs, len); | ||
BAL_UNUSED(len); | ||
return 0 == StrStrIA(lhs, rhs); | ||
# else | ||
return 0 == strncasecmp(lhs, rhs, len); | ||
# endif | ||
|
@@ -78,9 +82,6 @@ void __bal_safefree(void** pp) | |
(void)snprintf(dst, _n, __VA_ARGS__); \ | ||
} while (false) | ||
|
||
/** Allows a parameter to be unreferenced without compiler warnings. */ | ||
# define BAL_UNUSED(var) (void)(var) | ||
|
||
/** getnameinfo flags: do not perform DNS queries. */ | ||
# define _BAL_NI_NODNS (NI_NUMERICHOST | NI_NUMERICSERV) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* internal.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* platform.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
@@ -33,7 +33,9 @@ | |
# define _DARWIN_C_SOURCE | ||
# define __HAVE_LIBC_STRLCPY__ | ||
# elif defined(__linux__) | ||
# define _GNU_SOURCE | ||
# if !defined(_GNU_SOURCE) | ||
# define _GNU_SOURCE | ||
# endif | ||
# define __HAVE_POLLRDHUP__ | ||
# elif defined(__OpenBSD__) | ||
# define __BSD__ | ||
|
@@ -277,7 +279,9 @@ typedef unsigned bal_threadret; | |
# include <inttypes.h> | ||
# include <assert.h> | ||
|
||
# define BAL_MAXERROR 256 | ||
# define BAL_MAXERROR 256 | ||
# define BAL_MAXERRORMISC 256 | ||
# define BAL_MAXERRORFMT BAL_MAXERROR + BAL_MAXERRORMISC | ||
# define BAL_UNKNOWN "<unknown>" | ||
|
||
# define BAL_AS_IPV6 "IPv6" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* state.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* types.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
@@ -76,7 +76,7 @@ typedef struct { | |
/** The public error type. */ | ||
typedef struct { | ||
int code; | ||
char message[BAL_MAXERROR]; | ||
char message[BAL_MAXERRORFMT]; | ||
} bal_error; | ||
|
||
/** The internal error type. */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* version.h | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ | |
* balclient.cc | ||
* | ||
* Author: Ryan M. Lederman <[email protected]> | ||
* Copyright: Copyright (c) 2004-2023 | ||
* Version: 0.2.0 | ||
* Copyright: Copyright (c) 2004-2024 | ||
* Version: 0.3.0 | ||
* License: The MIT License (MIT) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
|
Oops, something went wrong.