-
Notifications
You must be signed in to change notification settings - Fork 465
Dynamically load libudev in linux-hidraw backend #788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
falkTX
wants to merge
1
commit into
libusb:master
Choose a base branch
from
falkTX:linux-dynamic-libudev
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+128
−5
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| /* SPDX-FileCopyrightText: 2026 Filipe Coelho <falktx@falktx.com> */ | ||
| /* SPDX-License-Identifier: LGPL-2.1-or-later */ | ||
|
|
||
| #include <dlfcn.h> | ||
| #include <stdarg.h> | ||
| #include <stddef.h> | ||
| #include <sys/types.h> | ||
|
|
||
| #define C(FN) \ | ||
| static typeof(FN)* FN; \ | ||
| if (FN == NULL) { \ | ||
| void *realfn = dlsym(NULL, #FN); \ | ||
| FN = *(typeof(FN)*)&realfn; \ | ||
| } | ||
|
|
||
| #define udev_list_entry_foreach(varname, front) \ | ||
| for (varname = front; varname != NULL; varname = udev_list_entry_get_next(varname)) | ||
|
|
||
| struct udev *udev_new(void) | ||
| { | ||
| static void* _lib; | ||
| if (_lib == NULL) | ||
| { | ||
| _lib = dlopen("libudev.so.1", RTLD_NOW | RTLD_GLOBAL); | ||
| if (_lib == NULL) | ||
| return NULL; | ||
| } | ||
|
|
||
| C(udev_new); | ||
| return udev_new(); | ||
| } | ||
|
|
||
| struct udev *udev_unref(struct udev *udev) | ||
| { | ||
| C(udev_unref); | ||
| return udev_unref(udev); | ||
| } | ||
|
|
||
| struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum) | ||
| { | ||
| C(udev_device_new_from_devnum); | ||
| return udev_device_new_from_devnum(udev, type, devnum); | ||
| } | ||
|
|
||
| struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath) | ||
| { | ||
| C(udev_device_new_from_syspath); | ||
| return udev_device_new_from_syspath(udev, syspath); | ||
| } | ||
|
|
||
| struct udev_device *udev_device_unref(struct udev_device *udev_device) | ||
| { | ||
| C(udev_device_unref); | ||
| return udev_device_unref(udev_device); | ||
| } | ||
|
|
||
| struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, | ||
| const char *subsystem, const char *devtype) | ||
| { | ||
| C(udev_device_get_parent_with_subsystem_devtype); | ||
| return udev_device_get_parent_with_subsystem_devtype(udev_device, subsystem, devtype); | ||
| } | ||
|
|
||
| const char* udev_device_get_syspath(struct udev_device *udev_device) | ||
| { | ||
| C(udev_device_get_syspath); | ||
| return udev_device_get_syspath(udev_device); | ||
| } | ||
|
|
||
| const char* udev_device_get_devnode(struct udev_device *udev_device) | ||
| { | ||
| C(udev_device_get_devnode); | ||
| return udev_device_get_devnode(udev_device); | ||
| } | ||
|
|
||
| const char* udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr) | ||
| { | ||
| C(udev_device_get_sysattr_value); | ||
| return udev_device_get_sysattr_value(udev_device, sysattr); | ||
| } | ||
|
|
||
| struct udev_enumerate *udev_enumerate_new(struct udev *udev) | ||
| { | ||
| C(udev_enumerate_new); | ||
| return udev_enumerate_new(udev); | ||
| } | ||
|
|
||
| struct udev_enumerate *udev_enumerate_unref(struct udev_enumerate *udev_enumerate) | ||
| { | ||
| C(udev_enumerate_unref); | ||
| return udev_enumerate_unref(udev_enumerate); | ||
| } | ||
|
|
||
| int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) | ||
| { | ||
| C(udev_enumerate_add_match_subsystem); | ||
| return udev_enumerate_add_match_subsystem(udev_enumerate, subsystem); | ||
| } | ||
|
|
||
| int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate) | ||
| { | ||
| C(udev_enumerate_scan_devices); | ||
| return udev_enumerate_scan_devices(udev_enumerate); | ||
| } | ||
|
|
||
| struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate) | ||
| { | ||
| C(udev_enumerate_get_list_entry); | ||
| return udev_enumerate_get_list_entry(udev_enumerate); | ||
| } | ||
|
|
||
| struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *list_entry) | ||
| { | ||
| C(udev_list_entry_get_next); | ||
| return udev_list_entry_get_next(list_entry); | ||
| } | ||
|
|
||
| const char* udev_list_entry_get_name(struct udev_list_entry *list_entry) | ||
| { | ||
| C(udev_list_entry_get_name); | ||
| return udev_list_entry_get_name(list_entry); | ||
| } | ||
|
|
||
| #undef C |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the documentation and CI scripts also needs to be updated - now the
libudev-devno longer required and only thelibudev1is needed