From nobody Wed Aug 6 14:20:30 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bxsrv4YNmz63mlK; Wed, 06 Aug 2025 14:20:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bxsrv0579z3rJx; Wed, 06 Aug 2025 14:20:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754490031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wpI/743zx/tKAvoqnhp8X3RR1Ya6Odf2/ZuYqkrOZfQ=; b=CrwlvHeWPEinzodmi51dEutrjd++MOszfOV46GFMwg6WCpOOcQM8DrwvCw+i5llnNiML4w qbqOcR1/S5rNOyOOdwdoGxe65QM70w3kBkpoZCPbxoBpfr/IIEcai1PXtWVXZtDAHDrJA1 DwDTJ7WSjS4XNO+uQmcUyPbw1TmY5sChj79+vogpW2NQyY5eKUMUNQxaDXSu5ThX/0qrbZ 6WzHysinmnaiqdGbnh+2fHx7lUpHrGaedQrw1d9yH9aiGPwxrBq7OYDiX1dKiBtRbYIy36 YKfPV0LxNjKku5lbkWIcOJPk9/5Ei2Ka9pol8fIadjdjTBaqN/Z1WIhpr3ijqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754490031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wpI/743zx/tKAvoqnhp8X3RR1Ya6Odf2/ZuYqkrOZfQ=; b=AlrSgAClPqutQEReUqIJErZOc+yv85mN5XTYTJl0iFHrv9/kqskfWWbHyuUqJRpm8KfIIJ DwENlzyDoizRjDxpr1p6Bhq/TFmCi1Z3hS4JIoAoCL6Gy/tI9bNNknAkyS5A+9rEIErxrK NZxSdOhnlMvPZA66MAFjQ97U4Js3kRXSZmRfeOySx3msEBk22D5jJ3P+9Tz1C45lyTsbuj NFXH0MCEHHb8mAFRMCuXUcY240k1hYNFXVE+7I4vDcaJ0yH1JjoWKjAfbGzjf7IdPzmA+t VzAIlZ7NMyEU7/GnGHvAJX4EqS6E4bcnhDLhOXY0Xs8+Ea3I/wvjCLK5XL9lug== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754490031; a=rsa-sha256; cv=none; b=wqWEj3GWQNoT96dXHAKd5k7insPCDiHhlgQgVw7ajK8dYpBm+MpxBIgyBIhK9RtEfogqUQ l2gQD0hEHMsl+ButP7n3IHGHagYAGzrK7cTwib6niOTxC99aZOfps8ToTFP+tTAL7//6E+ L5JYvDERYmRxgZjjftjenMNnVJG5zDvF1jcjN5vjr7zXJ0C3PFGrxesyUHbb6YDlCx/K9x HlVpPKXeW4KsSvEa0bsTzFSy1UI67z3OrvP6t3F0zAdj9l7ZzkRaM+uLPozywAqbBTw5Ko +waR26F87lmqL6Cs7bKVSXSuEq6rfg0Zp2MtIrqbLhesNfg4ZKAcpsXBfhDXVA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bxsrt6kWGz8K3; Wed, 06 Aug 2025 14:20:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 576EKUNV009579; Wed, 6 Aug 2025 14:20:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 576EKU4E009576; Wed, 6 Aug 2025 14:20:30 GMT (envelope-from git) Date: Wed, 6 Aug 2025 14:20:30 GMT Message-Id: <202508061420.576EKU4E009576@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: b0d5c1cfda76 - main - libusb: implement libusb_pollfds_handle_timeouts List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b0d5c1cfda7696e62fa0256b5aab0e218ab98c45 Auto-Submitted: auto-generated The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=b0d5c1cfda7696e62fa0256b5aab0e218ab98c45 commit b0d5c1cfda7696e62fa0256b5aab0e218ab98c45 Author: ShengYi Hung AuthorDate: 2025-08-05 15:25:31 +0000 Commit: ShengYi Hung CommitDate: 2025-08-06 14:05:40 +0000 libusb: implement libusb_pollfds_handle_timeouts This function tells applications who maintain the pollfds themselves if they should handle the timeout for each xfer themselves. In FreeBSD, the timeout for each xfer is handled by kernel and doesn't need a special timer to do so. Therefore, we return 1 to indicate that it is handled by libusb internally. Approved by: lwhsu (mentor), markj (mentor) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D51742 --- lib/libusb/libusb.3 | 8 ++++++++ lib/libusb/libusb.h | 1 + lib/libusb/libusb10_io.c | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index 9dc752f0fd7b..3093737c05d7 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -734,6 +734,14 @@ another thread is already doing so. Must be called with the event lock held. .Pp .Ft int +.Fn libusb_pollfds_handle_timeouts "libusb_context *ctx" +This function determines whether applications maintaining libusb events using +.Fn libusb_get_pollfds +are responsible for handling timeout events themselves. +Returns 1 if libusb handles the timeout internally, 0 if the application +needs to set a dedicated timer to handle it. +.Pp +.Ft int .Fn libusb_get_next_timeout "libusb_context *ctx" "struct timeval *tv" Determine the next internal timeout that libusb needs to handle. Returns 0 diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h index 85e24bc68474..d8a3e4b62995 100644 --- a/lib/libusb/libusb.h +++ b/lib/libusb/libusb.h @@ -587,6 +587,7 @@ int libusb_handle_events_completed(libusb_context * ctx, int *completed); int libusb_handle_events_timeout(libusb_context * ctx, struct timeval *tv); int libusb_handle_events(libusb_context * ctx); int libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv); +int libusb_pollfds_handle_timeouts(libusb_context *ctx); int libusb_get_next_timeout(libusb_context * ctx, struct timeval *tv); void libusb_set_pollfd_notifiers(libusb_context * ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data); const struct libusb_pollfd **libusb_get_pollfds(libusb_context *ctx); diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c index c99586ff650d..2047712e9e39 100644 --- a/lib/libusb/libusb10_io.c +++ b/lib/libusb/libusb10_io.c @@ -422,6 +422,12 @@ libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv) return (0); } +int +libusb_pollfds_handle_timeouts(libusb_context *ctx) +{ + return (1); +} + void libusb_set_pollfd_notifiers(libusb_context *ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,