Skip to content

Commit 8ea55b8

Browse files
authored
v1.0.0 - fold in changes from use in libplctag
This updates this repo with the changes made in the vendored version in libplctag to implement EtherNet/IP and Modbus servers.
2 parents e97780a + e2a0212 commit 8ea55b8

27 files changed

Lines changed: 1795 additions & 176 deletions

‎.github/workflows/ci.yml‎

Lines changed: 61 additions & 63 deletions
Large diffs are not rendered by default.

‎.github/workflows/coverage.yml‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: coverage
2-
true:
2+
on:
33
push:
44
branches:
55
- prerelease
@@ -18,21 +18,21 @@ jobs:
1818
runner: ubuntu-24.04-arm
1919
runs-on: ${{ matrix.runner }}
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v7
2222
- name: Install dependencies
2323
run: 'sudo apt-get update
2424
2525
sudo apt-get install -y lcov cmake build-essential
2626
2727
'
2828
- name: Configure
29-
run: 'cmake -S . -B build -DENABLE_COVERAGE=ON
29+
run: 'cmake -S . -B build -DENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug
3030
3131
'
3232
- name: Build
3333
run: cmake --build build
3434
- name: Test
35-
run: ctest --test-dir build --output-on-failure
35+
run: ctest --no-tests=error --test-dir build --output-on-failure
3636
- name: Generate coverage report
3737
run: 'lcov --capture --directory build --output-file coverage.info
3838
@@ -51,7 +51,7 @@ jobs:
5151
5252
'
5353
- name: Upload Coverage Artifacts
54-
uses: actions/upload-artifact@v4
54+
uses: actions/upload-artifact@v7
5555
with:
5656
name: coverage-linux-${{ matrix.arch }}
5757
path: 'docs/coverage
@@ -69,7 +69,7 @@ jobs:
6969
cmake_arch: x64
7070
runs-on: ${{ matrix.runner }}
7171
steps:
72-
- uses: actions/checkout@v4
72+
- uses: actions/checkout@v7
7373
- name: Install OpenCppCoverage
7474
run: 'choco install opencppcoverage
7575
@@ -89,7 +89,7 @@ jobs:
8989
\ {\n Write-Error \"OpenCppCoverage.exe not found\"\n exit 1\n}\nWrite-Host\
9090
\ \"Using OpenCppCoverage from: $($opencppcoverage.FullName)\"\n& $opencppcoverage.FullName\
9191
\ --sources \"${{ github.workspace }}\" --cover_children --export_type=html:build/coverage_report\
92-
\ --export_type=cobertura:build/cobertura.xml -- ctest --test-dir build\
92+
\ --export_type=cobertura:build/cobertura.xml -- ctest --no-tests=error --test-dir build\
9393
\ -C Debug --output-on-failure\n"
9494
shell: pwsh
9595
- name: Generate Coverage Badge
@@ -117,7 +117,7 @@ jobs:
117117
\ $badgePath | Select-Object -First 5\n} else {\n Write-Error \"Failed\
118118
\ to create badge file\"\n exit 1\n}\n"
119119
- name: Upload Coverage Report
120-
uses: actions/upload-artifact@v4
120+
uses: actions/upload-artifact@v7
121121
with:
122122
name: coverage-windows-${{ matrix.arch }}
123123
path: 'build/coverage_report
@@ -138,7 +138,7 @@ jobs:
138138
cmake_arch: arm64
139139
runs-on: ${{ matrix.runner }}
140140
steps:
141-
- uses: actions/checkout@v4
141+
- uses: actions/checkout@v7
142142
- name: Install dependencies
143143
run: brew install lcov
144144
- name: Configure
@@ -147,7 +147,7 @@ jobs:
147147
- name: Build
148148
run: cmake --build build
149149
- name: Test
150-
run: ctest --test-dir build --output-on-failure
150+
run: ctest --no-tests=error --test-dir build --output-on-failure
151151
- name: Create gcov wrapper
152152
run: 'cat > /usr/local/bin/llvm-gcov << ''EOF''
153153
@@ -179,7 +179,7 @@ jobs:
179179
180180
'
181181
- name: Upload Coverage Report
182-
uses: actions/upload-artifact@v4
182+
uses: actions/upload-artifact@v7
183183
with:
184184
name: coverage-macos-${{ matrix.arch }}
185185
path: 'docs/coverage
@@ -195,9 +195,9 @@ jobs:
195195
runs-on: ubuntu-latest
196196
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/prerelease'
197197
steps:
198-
- uses: actions/checkout@v4
198+
- uses: actions/checkout@v7
199199
- name: Download all artifacts
200-
uses: actions/download-artifact@v4
200+
uses: actions/download-artifact@v8
201201
with:
202202
path: artifacts
203203
- name: Move badges

‎.github/workflows/release.yml‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
2828
'
2929
- name: Checkout Code
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@v7
3131
with:
3232
ref: ${{ github.event.workflow_run.head_branch }}
3333
- name: Read VERSION
@@ -41,7 +41,7 @@ jobs:
4141
'
4242
- name: Get Release Details
4343
id: release_details
44-
uses: actions/github-script@v7
44+
uses: actions/github-script@v9
4545
with:
4646
script:
4747
"const commit_sha = \"${{ github.event.workflow_run.head_sha }}\"\
@@ -57,7 +57,7 @@ jobs:
5757
\ Using commit message: ${title}`);\n}\n\ncore.setOutput('title', title);\n\
5858
core.setOutput('body', body);\n"
5959
- name: Create Release
60-
uses: softprops/action-gh-release@v2
60+
uses: softprops/action-gh-release@v3
6161
with:
6262
tag_name: v${{ env.VERSION }}
6363
name: Release v${{ env.VERSION }}
@@ -77,5 +77,25 @@ jobs:
7777
generate_release_notes: false
7878
draft: false
7979
prerelease: false
80+
- name: Update README on release
81+
run: |
82+
git config user.name "GitHub Actions"
83+
git config user.email "actions@github.com"
84+
sed -i "s/^\*\*Latest Release:\*\*.*/**Latest Release:** v${VERSION}/" README.md
85+
git add README.md
86+
git diff --cached --quiet || git commit -m "Update README with release v${VERSION} [skip ci]"
87+
git push origin HEAD:release
88+
- name: Checkout prerelease
89+
uses: actions/checkout@v7
90+
with:
91+
ref: prerelease
92+
- name: Bump patch version on prerelease
93+
run: |
94+
git config user.name "GitHub Actions"
95+
git config user.email "actions@github.com"
96+
bash scripts/increment_version.sh patch
97+
git add VERSION
98+
git commit -m "Bump patch version to $(cat VERSION) [skip ci]"
99+
git push origin prerelease
80100
env:
81101
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

‎.github/workflows/update-version-readme.yml‎

Lines changed: 0 additions & 70 deletions
This file was deleted.

‎CMakeLists.txt‎

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
cmake_minimum_required(VERSION 3.10)
88

99
# Read version from file (format: major.minor.patch)
10-
set(PROJECT_VERSION_FULL "0.1.0")
10+
set(PROJECT_VERSION_FULL "1.0.0")
1111
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
1212
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VER_FILE_CONTENT)
1313
if(VER_FILE_CONTENT)
@@ -78,12 +78,33 @@ endif()
7878
# Compiler Flags
7979
# ============================================================================
8080

81-
# Enable ASAN/UBSAN in Debug builds (Generic)
81+
# Enable ASAN/UBSAN in Debug builds (Generic).
82+
#
83+
# When built standalone, default to ASan+UBSan. When built as part of a parent
84+
# project that defines USE_MEM_SANITIZERS/USE_THREAD_SANITIZERS, defer entirely
85+
# to the parent's choice: the parent already added the right -fsanitize=... flags
86+
# to CMAKE_C_FLAGS_DEBUG (which apply here too), and ASan/LeakSan cannot be linked
87+
# into the same binary as TSan, so this library must never add its own ASan flags
88+
# on top of a parent-selected TSan build.
89+
set(YAFL_ASAN_ACTIVE FALSE)
90+
set(YAFL_TSAN_ACTIVE FALSE)
91+
8292
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT MSVC)
83-
message(STATUS "Debug build detected: Enabling ASAN/UBSAN")
84-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fsanitize=address,undefined>)
85-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fno-omit-frame-pointer>)
86-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined")
93+
if(DEFINED USE_MEM_SANITIZERS OR DEFINED USE_THREAD_SANITIZERS)
94+
if(USE_THREAD_SANITIZERS)
95+
message(STATUS "Debug build detected: using parent-selected ThreadSanitizer")
96+
set(YAFL_TSAN_ACTIVE TRUE)
97+
elseif(USE_MEM_SANITIZERS)
98+
message(STATUS "Debug build detected: using parent-selected ASAN/UBSAN")
99+
set(YAFL_ASAN_ACTIVE TRUE)
100+
endif()
101+
else()
102+
message(STATUS "Debug build detected: Enabling ASAN/UBSAN")
103+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fsanitize=address,undefined>)
104+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fno-omit-frame-pointer>)
105+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined")
106+
set(YAFL_ASAN_ACTIVE TRUE)
107+
endif()
87108

88109
# Automatically enable watermark checking in debug builds
89110
message(STATUS "Enabling stack watermark for Debug build")
@@ -130,6 +151,10 @@ else()
130151
set(HOST_ARCH "x86_64")
131152
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64|ARM64|AARCH64")
132153
set(HOST_ARCH "aarch64")
154+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm|^ARM")
155+
set(HOST_ARCH "arm")
156+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^x86$|^i386$|^i686$|^Win32$")
157+
set(HOST_ARCH "i386")
133158
else()
134159
message(FATAL_ERROR "Could not auto-detect architecture. Please specify -DTARGET=<triple>")
135160
endif()
@@ -184,6 +209,20 @@ endif()
184209

185210
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
186211
message(STATUS "Skipping stack direction check for ${CMAKE_SYSTEM_NAME} (assuming downward)")
212+
elseif(YAFL_ASAN_ACTIVE)
213+
# Under ASan, this probe is unreliable: ASan's stack-use-after-return "fake stack"
214+
# can allocate a function's locals off the real machine stack entirely, so comparing
215+
# caller/callee frame addresses no longer reflects true hardware stack growth
216+
# direction. Skip the runtime probe and rely on the well-known fact that every
217+
# architecture this project ships a toolchain/asm implementation for grows downward.
218+
message(STATUS "Skipping stack direction check under ASan/UBSan (assuming downward)")
219+
elseif(CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR MATCHES "qemu")
220+
# ponytail: QEMU user-mode emulation (e.g. the s390x CI leg) has been observed to make
221+
# this probe report "upward" on architectures that are well-documented to grow the
222+
# stack downward under their native SysV/Linux ABI (s390x included) and for which this
223+
# project already ships a hand-verified downward-stack asm implementation (gated by the
224+
# toolchains/${TRIPLE}.cmake lookup above). Trust the ABI instead of an emulator-only probe.
225+
message(STATUS "Skipping stack direction check under QEMU user-mode emulation (assuming downward per target ABI)")
187226
elseif(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
188227
message(STATUS "Checking stack direction...")
189228
try_run(STACK_DIR_EXITCODE STACK_DIR_COMPILED
@@ -192,7 +231,11 @@ elseif(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
192231
)
193232

194233
if(STACK_DIR_COMPILED)
195-
if(STACK_DIR_EXITCODE EQUAL 0)
234+
if(STACK_DIR_EXITCODE STREQUAL "FAILED_TO_RUN")
235+
# ponytail: sandboxed/CI environments can deny exec of the freshly-built probe
236+
# even when not cross-compiling. That's "couldn't test it", not "tested upward".
237+
message(WARNING "Could not execute stack direction check (sandboxed environment?). Assuming downward stack.")
238+
elseif(STACK_DIR_EXITCODE EQUAL 0)
196239
message(STATUS "Stack grows downward (supported)")
197240
else()
198241
message(FATAL_ERROR "Stack grows upward! This architecture is not supported by yafl.")
@@ -204,6 +247,15 @@ else()
204247
message(STATUS "Cross-compiling without emulator: Skipping stack direction check (assuming downward)")
205248
endif()
206249

250+
# ============================================================================
251+
# Library
252+
# ============================================================================
253+
254+
# Create static library
255+
add_library(yafl STATIC src/yafl.c ${ASM_FILES})
256+
target_include_directories(yafl PUBLIC include)
257+
set_target_properties(yafl PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
258+
207259
# ============================================================================
208260
# Test Executables
209261
# ============================================================================
@@ -216,14 +268,12 @@ set(TESTS
216268
test_yafl_watermark
217269
)
218270

219-
# Create static library
220-
add_library(yafl STATIC src/yafl.c ${ASM_FILES})
221-
target_include_directories(yafl PUBLIC include)
222-
set_target_properties(yafl PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
223-
224271
foreach(test ${TESTS})
225272
add_executable(${test} tests/${test}.c)
226273
target_link_libraries(${test} PRIVATE yafl)
274+
# Tests are assert()-based: keep asserts live even in Release so the shipped
275+
# (optimized) library is what gets tested.
276+
target_compile_options(${test} PRIVATE $<IF:$<C_COMPILER_ID:MSVC>,/UNDEBUG,-UNDEBUG>)
227277
# Link dl library for test_yafl_guard on Linux/Unix for dladdr
228278
if("${test}" STREQUAL "test_yafl_guard" AND UNIX)
229279
target_link_libraries(${test} PRIVATE ${CMAKE_DL_LIBS})

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.7.1
1+
1.0.0

0 commit comments

Comments
 (0)