Skip to content

Fix clockid include - #1626

Merged
wengxt merged 2 commits into
masterfrom
clockid
Aug 3, 2026
Merged

Fix clockid include#1626
wengxt merged 2 commits into
masterfrom
clockid

Conversation

@wengxt

@wengxt wengxt commented Aug 3, 2026

Copy link
Copy Markdown
Member
  • Fix headers Include sys/types for clockid_t
  • Add header for clockid_t on windows

Summary by CodeRabbit

  • Bug Fixes

    • Improved event-loop portability and build compatibility across platforms, including Windows.
    • Preserved event-loop timing calculations while improving type handling and header compatibility.
  • Tests

    • Updated event-loop test coverage to compile consistently across supported platforms.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request updates event-loop platform includes, adds Windows-specific pthread support, adjusts internal libuv linkage, discards an unused exit result, and clarifies an unchanged time conversion expression.

Changes

Event loop updates

Layer / File(s) Summary
Platform and filesystem include coverage
src/lib/fcitx-utils/event*.h, src/lib/fcitx-utils/event*.cpp, src/lib/fcitx-utils/eventloopinterface.h, test/testcustomeventloop.cpp
The event-loop sources, headers, and custom event loop test add required system type, Windows pthread, filesystem, and standard library includes.
Event implementation cleanup
src/lib/fcitx-utils/event.cpp, src/lib/fcitx-utils/event_libuv.cpp, src/lib/fcitx-utils/event_libuv.h
EventLoop::exit() discards the implementation return value. The libuv log category has internal linkage. LibUVSource::handle() no longer declares inline.
Time conversion support
src/lib/fcitx-utils/eventloopinterface.cpp
The nanosecond conversion uses explicit parentheses. Its calculation remains unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • fcitx/fcitx5#1623: It contains matching event-loop include and implementation changes.
  • fcitx/fcitx5#1625: It also updates eventloopinterface.h with platform type includes.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: correcting clock ID header inclusion.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch clockid

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/fcitx-utils/event.h`:
- Around line 19-22: Update the Fcitx5Utils CMake target’s Pthread::Pthread
linkage from PRIVATE to PUBLIC so consumers of Fcitx5::Utils inherit the
required pthread include configuration. This applies to the public-header usage
in src/lib/fcitx-utils/event.h lines 19-22, src/lib/fcitx-utils/event_libuv.h
lines 22-25, and src/lib/fcitx-utils/eventloopinterface.h lines 19-22; no direct
changes are required in those headers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ed47516-aec1-4c83-b9f1-1ac64da0fccc

📥 Commits

Reviewing files that changed from the base of the PR and between 0a33f39 and ef6b3ec.

📒 Files selected for processing (8)
  • src/lib/fcitx-utils/event.cpp
  • src/lib/fcitx-utils/event.h
  • src/lib/fcitx-utils/event_libuv.cpp
  • src/lib/fcitx-utils/event_libuv.h
  • src/lib/fcitx-utils/event_sdevent.cpp
  • src/lib/fcitx-utils/eventloopinterface.cpp
  • src/lib/fcitx-utils/eventloopinterface.h
  • test/testcustomeventloop.cpp

Comment on lines +19 to +22
#if defined(_WIN32)
#include <pthread.h>
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate relevant files =="
git ls-files | rg '(^|/)src/lib/fcitx-utils/(event\.h|event_libuv\.h|eventloopinterface\.h)$|CMakeLists\.txt|meson\.build|cmake|\.cmake$|config'

echo
echo "== headers snippets =="
for f in src/lib/fcitx-utils/event.h src/lib/fcitx-utils/event_libuv.h src/lib/fcetx-utils/eventloopinterface.h; do
  truecase=${f/src/lib/fcetx-utils/src/lib/fcitx-utils}
  if [ -f "$truecase" ]; then
    echo "--- $truecase ---"
    sed -n '1,80p' "$truecase" | cat -n
  fi
done

echo
echo "== include pthread occurrences =="
rg -n '`#include` <pthread\.h>|pthread_t|pthread_' src include CMakeLists.txt meson.build .github 2>/dev/null || true

echo
echo "== cmake/meson target definitions mentioning fcitx-utils/libuv/event =="
rg -n 'fcitx-utils|fcitx-utils.*(event|interface)|Pthread|thread|LIBUV|libuv|pthread|h' -g 'CMakeLists.txt' -g '*.cmake' -g 'meson.build' -g 'CMakeLists.txt' .

Repository: fcitx/fcitx5

Length of output: 43046


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== src/lib/fcitx-utils/CMakeLists.txt relevant sections =="
sed -n '1,220p' src/lib/fcetx-utils/CMakeLists.txt | cat -n || sed -n '1,220p' src/lib/fcitx-utils/CMakeLists.txt | cat -n

echo
echo "== FindPthread.cmake full =="
sed -n '1,90p' cmake/FindPthread.cmake | cat -n

echo
echo "== Fcitx5Macros export helpers =="
sed -n '1,120p' src/lib/fcetx-utils/Fcitx5Macros.cmake | cat -n || sed -n '1,120p' src/lib/fcitx-utils/Fcitx5Macros.cmake | cat -n

echo
echo "== consumer link to Fcitx5Utils and pthread =="
rg -n 'Fcitx5Utils|Fcitx5::Utils|Fcitx5::Utils|Fcitx5::Utils|Fcitx5::Utils|Pthread::Pthread|pthread\.h' src test modules config -g '*CMakeLists.txt' -g '*.h' -g '*.cpp' 2>/dev/null || true

Repository: fcitx/fcitx5

Length of output: 21724


🌐 Web query:

CMake target_link_libraries PRIVATE INTERFACE PUBLIC INTERFACE_INCLUDE_DIRECTORIES exported targets include directories

💡 Result:

In CMake, the keywords PRIVATE, PUBLIC, and INTERFACE define how dependencies and their usage requirements (such as include directories) are propagated to other targets [1][2]. When using target_link_libraries, these keywords control the visibility of the link dependency and the propagation of its usage requirements [1][3]. PRIVATE The dependency is used only by the target itself for its own implementation [2][3]. It is not part of the target's public link interface, so consumers of the target do not need to link against this dependency, nor do they inherit its usage requirements (such as INTERFACE_INCLUDE_DIRECTORIES) [1][2]. INTERFACE The dependency is not linked into the target itself, but it is part of the target's link interface [1][3]. This means consumers of the target will inherit the dependency's usage requirements (including its INTERFACE_INCLUDE_DIRECTORIES) and will link against it, but the target itself does not use it for its own implementation [2][3]. PUBLIC This is a combination of PRIVATE and INTERFACE [2]. The dependency is linked into the target, and it is also part of the target's public link interface [1][3]. Consequently, both the target and any consumers of the target will link against it and inherit its usage requirements [1][2]. INTERFACE_INCLUDE_DIRECTORIES and Exported Targets The INTERFACE_INCLUDE_DIRECTORIES property is key to how CMake handles transitive usage requirements [4][5]. When a target is exported via install(EXPORT) or export, CMake automatically generates IMPORTED targets [5]. These generated targets carry the appropriate usage requirements—such as INTERFACE_INCLUDE_DIRECTORIES—so that when a consumer links to these imported targets using target_link_libraries, CMake automatically provides the correct include paths required to compile against the dependency [4][5]. Best Practices It is highly recommended to always specify one of these keywords when using target_link_libraries, as relying on the legacy keywordless signature (which defaults to PUBLIC) can lead to unintended propagation of dependencies and headers [6][3]. When setting include directories, use target_include_directories with the same scoping keywords (PRIVATE, PUBLIC, INTERFACE) to ensure the target's own headers are properly exposed to its consumers [7][8]. Avoid hard-coding absolute paths to dependencies in your export configurations; instead, rely on the INTERFACE_INCLUDE_DIRECTORIES properties of the imported dependency targets themselves [7][5][8].

Citations:


Make Pthread::Pthread part of Fcitx5Utils’ public usage requirements.

src/lib/fcitx-utils/CMakeLists.txt:153 links Pthread::Pthread with PRIVATE, so downstream targets that only consume Fcitx5::Utils do not inherit ${PTHREAD_INCLUDE_DIR}. The public headers include <pthread.h> under _WIN32 at src/lib/fcitx-utils/event.h, src/lib/fcitx-utils/event_libuv.h, and src/lib/fcitx-utils/eventloopinterface.h, so use PUBLIC here or link consumers directly.

📍 Affects 3 files
  • src/lib/fcitx-utils/event.h#L19-L22 (this comment)
  • src/lib/fcitx-utils/event_libuv.h#L22-L25
  • src/lib/fcitx-utils/eventloopinterface.h#L19-L22
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/fcitx-utils/event.h` around lines 19 - 22, Update the Fcitx5Utils
CMake target’s Pthread::Pthread linkage from PRIVATE to PUBLIC so consumers of
Fcitx5::Utils inherit the required pthread include configuration. This applies
to the public-header usage in src/lib/fcitx-utils/event.h lines 19-22,
src/lib/fcitx-utils/event_libuv.h lines 22-25, and
src/lib/fcitx-utils/eventloopinterface.h lines 19-22; no direct changes are
required in those headers.

@wengxt
wengxt merged commit 6c73980 into master Aug 3, 2026
6 checks passed
@wengxt
wengxt deleted the clockid branch August 3, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant