[wpiutil] Rename CreateEvent and CreateSemaphore to Make (#8710)

CreateEvent and CreateSemaphore are macros in Windows.h, which causes a
ton of trouble. Just rename the functions.

Closes #7303

Replaces #7336
This commit is contained in:
Thad House
2026-03-30 15:54:42 -07:00
committed by GitHub
parent d248c040bf
commit bf218113db
20 changed files with 47 additions and 48 deletions

View File

@@ -36,7 +36,7 @@ extern "C" {
* @param initial_state true to make the event initially in signaled state
* @return Event handle
*/
WPI_EventHandle WPI_CreateEvent(int manual_reset, int initial_state);
WPI_EventHandle WPI_MakeEvent(int manual_reset, int initial_state);
/**
* Destroys an event. Destruction wakes up any waiters.
@@ -70,7 +70,7 @@ void WPI_ResetEvent(WPI_EventHandle handle);
* @param maximum_count maximum value for the semaphore's internal counter
* @return Semaphore handle
*/
WPI_SemaphoreHandle WPI_CreateSemaphore(int initial_count, int maximum_count);
WPI_SemaphoreHandle WPI_MakeSemaphore(int initial_count, int maximum_count);
/**
* Destroys a semaphore. Destruction wakes up any waiters.

View File

@@ -39,8 +39,7 @@ constexpr int HANDLE_TYPE_USER_BASE = 80;
* @param initialState true to make the event initially in signaled state
* @return Event handle
*/
WPI_EventHandle CreateEvent(bool manualReset = false,
bool initialState = false);
WPI_EventHandle MakeEvent(bool manualReset = false, bool initialState = false);
/**
* Destroys an event. Destruction wakes up any waiters.
@@ -74,8 +73,8 @@ void ResetEvent(WPI_EventHandle handle);
* @param maximumCount maximum value for the semaphore's internal counter
* @return Semaphore handle
*/
WPI_SemaphoreHandle CreateSemaphore(int initialCount = 0,
int maximumCount = INT_MAX);
WPI_SemaphoreHandle MakeSemaphore(int initialCount = 0,
int maximumCount = INT_MAX);
/**
* Destroys a semaphore. Destruction wakes up any waiters.
@@ -237,7 +236,7 @@ class Event final {
* @param initialState true to make the event initially in signaled state
*/
explicit Event(bool manualReset = false, bool initialState = false)
: m_handle{CreateEvent(manualReset, initialState)} {}
: m_handle{MakeEvent(manualReset, initialState)} {}
~Event() {
if (m_handle != 0) {
DestroyEvent(m_handle);
@@ -302,7 +301,7 @@ class Semaphore final {
* @param maximumCount maximum value for the semaphore's internal counter
*/
explicit Semaphore(int initialCount = 0, int maximumCount = INT_MAX)
: m_handle{CreateSemaphore(initialCount, maximumCount)} {}
: m_handle{MakeSemaphore(initialCount, maximumCount)} {}
~Semaphore() {
if (m_handle != 0) {
DestroySemaphore(m_handle);