Files
RetroArch/samples/input/gekko_hid/Makefile
LibretroAdmin 65225e1d2c Wii HID: take pads away without sleeping
A pad that leaves is asked to stop and its reader cancelled; the worker
asks again on every pass, since a cancel only returns a transfer
already waiting, and reaps the pad once the reader says it is done. No
thread sleeps for it.

A driver freed while a reader still waits leaves the pad to that
reader, which frees it when its transfer returns. The driver itself is
freed by the last of it and the readers still running, so a late
reader no longer touches a freed driver.

samples/input/gekko_hid runs the driver against os/gekko stand-ins:
unplugging while the reader waits, with its cancel lost, and freeing
the driver under a waiting reader; a build that asks only once must
fail.
2026-10-31 11:39:31 +01:00

53 lines
1.6 KiB
Makefile

# The Wii's USB HID driver (input/drivers_hid/gekko_hid.c) taking pads
# away, with os/gekko's threads and USB calls stood in for on pthreads.
# The os/gekko headers are the tree's own. The test includes the
# driver's source itself. Builds for Linux and, with
# CC=x86_64-w64-mingw32-gcc EXE=.exe RUNNER=wine, for Windows.
#
# check also builds the driver asking a reader to stop only once, which
# must fail.
TARGET := gekko_hid_test$(EXE)
TARGET_BROKEN := gekko_hid_broken_test$(EXE)
RARCH_DIR := ../../..
LIBRETRO_COMM_DIR := $(RARCH_DIR)/libretro-common
CFLAGS += -Wall -std=gnu89 -g1 -O1 -DRARCH_INTERNAL -DGEKKO -DHW_RVL \
-DHAVE_HID -I$(RARCH_DIR) -I$(RARCH_DIR)/os/gekko/include \
-I$(LIBRETRO_COMM_DIR)/include
LDFLAGS += -lpthread
ifeq ($(EXE),.exe)
LDFLAGS += -static
endif
ifneq ($(SANITIZER),)
CFLAGS := -fsanitize=$(SANITIZER) -fno-omit-frame-pointer $(CFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
endif
DEPS := gekko_hid_test.c $(RARCH_DIR)/input/drivers_hid/gekko_hid.c
all: $(TARGET) $(TARGET_BROKEN)
$(TARGET): $(DEPS)
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
$(TARGET_BROKEN): $(DEPS)
$(CC) $(CFLAGS) -DGEKKO_HID_TEST_NO_RECANCEL -o $@ $< $(LDFLAGS)
check: all
$(RUNNER) ./$(TARGET)
@if $(RUNNER) ./$(TARGET_BROKEN) >/dev/null 2>&1; then \
echo "FAIL: the test passed with a reader asked to stop only once"; \
exit 1; \
else \
echo "gekko_hid: asking only once failed, as it must"; \
fi
clean:
rm -f gekko_hid_test gekko_hid_test.exe \
gekko_hid_broken_test gekko_hid_broken_test.exe
.PHONY: all check clean