mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-08 00:20:38 -09:00
package/libudev-zero: new package
Signed-off-by: Bernd Kuhls <bernd@kuhls.net> [Arnout: rewrite install steps so they use the same make arguments as the build step.] Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
committed by
Arnout Vandecappelle
parent
0cbfc9e991
commit
190bb8890e
@@ -446,6 +446,7 @@ F: package/libsidplay2/
|
||||
F: package/libsilk/
|
||||
F: package/libsndfile/
|
||||
F: package/libsoundtouch/
|
||||
F: package/libudev-zero/
|
||||
F: package/libudfread/
|
||||
F: package/libunibreak/
|
||||
F: package/liburiparser/
|
||||
|
||||
@@ -1860,6 +1860,7 @@ menu "Hardware handling"
|
||||
source "package/libsigrokdecode/Config.in"
|
||||
source "package/libsoc/Config.in"
|
||||
source "package/libss7/Config.in"
|
||||
source "package/libudev-zero/Config.in"
|
||||
source "package/libusb/Config.in"
|
||||
source "package/libusb-compat/Config.in"
|
||||
source "package/libusbgx/Config.in"
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
From 5eca08d71d51074bfe7b14fcf7d89318f4f6ff47 Mon Sep 17 00:00:00 2001
|
||||
From: liamHowatt <30486941+liamHowatt@users.noreply.github.com>
|
||||
Date: Tue, 5 Dec 2023 04:15:26 -0500
|
||||
Subject: [PATCH] Avoidable OOM on small systems (#62)
|
||||
|
||||
* bandaid fix OOM
|
||||
|
||||
* refactor fix OOM
|
||||
|
||||
* Makefile: remove no longer needed -pthread option
|
||||
|
||||
* libudev.pc.in: remove threads requirement
|
||||
|
||||
---------
|
||||
|
||||
Co-authored-by: illiliti <illiliti@protonmail.com>
|
||||
|
||||
Upstream: https://github.com/illiliti/libudev-zero/commit/5eca08d71d51074bfe7b14fcf7d89318f4f6ff47
|
||||
|
||||
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
|
||||
---
|
||||
Makefile | 2 +-
|
||||
libudev.pc.in | 1 -
|
||||
udev_enumerate.c | 65 +++++++++++-------------------------------------
|
||||
3 files changed, 15 insertions(+), 53 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 4e970b8..1fc5a1f 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -5,7 +5,7 @@ PREFIX = /usr/local
|
||||
LIBDIR = ${PREFIX}/lib
|
||||
INCLUDEDIR = ${PREFIX}/include
|
||||
PKGCONFIGDIR = ${LIBDIR}/pkgconfig
|
||||
-XCFLAGS = ${CPPFLAGS} ${CFLAGS} -std=c99 -fPIC -pthread -D_XOPEN_SOURCE=700 \
|
||||
+XCFLAGS = ${CPPFLAGS} ${CFLAGS} -std=c99 -fPIC -D_XOPEN_SOURCE=700 \
|
||||
-Wall -Wextra -Wpedantic -Wmissing-prototypes -Wstrict-prototypes \
|
||||
-Wno-unused-parameter
|
||||
XLDFLAGS = ${LDFLAGS} -shared -Wl,-soname,libudev.so.1
|
||||
diff --git a/libudev.pc.in b/libudev.pc.in
|
||||
index 7e29d8c..2d3f0b0 100644
|
||||
--- a/libudev.pc.in
|
||||
+++ b/libudev.pc.in
|
||||
@@ -9,5 +9,4 @@ Description: Daemonless replacement for libudev
|
||||
Version: @VERSION@
|
||||
URL: https://github.com/illiliti/libudev-zero
|
||||
Libs: -L${libdir} -ludev
|
||||
-Libs.private: -pthread
|
||||
Cflags: -I${includedir}
|
||||
diff --git a/udev_enumerate.c b/udev_enumerate.c
|
||||
index c553269..6fd49c0 100644
|
||||
--- a/udev_enumerate.c
|
||||
+++ b/udev_enumerate.c
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <fnmatch.h>
|
||||
-#include <pthread.h>
|
||||
|
||||
#include "udev.h"
|
||||
#include "udev_list.h"
|
||||
@@ -38,13 +37,6 @@ struct udev_enumerate {
|
||||
int refcount;
|
||||
};
|
||||
|
||||
-struct udev_enumerate_thread {
|
||||
- struct udev_enumerate *udev_enumerate;
|
||||
- pthread_mutex_t *mutex;
|
||||
- char path[PATH_MAX];
|
||||
- pthread_t thread;
|
||||
-};
|
||||
-
|
||||
int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem)
|
||||
{
|
||||
return udev_enumerate ? !!udev_list_entry_add(&udev_enumerate->subsystem_match, subsystem, NULL, 0) - 1 : -1;
|
||||
@@ -231,31 +223,27 @@ static int filter_sysattr(struct udev_enumerate *udev_enumerate, struct udev_dev
|
||||
return 1;
|
||||
}
|
||||
|
||||
-static void *add_device(void *ptr)
|
||||
+static void add_device(struct udev_enumerate *udev_enumerate, const char *path)
|
||||
{
|
||||
- struct udev_enumerate_thread *thread = ptr;
|
||||
struct udev_device *udev_device;
|
||||
|
||||
- udev_device = udev_device_new_from_syspath(thread->udev_enumerate->udev, thread->path);
|
||||
+ udev_device = udev_device_new_from_syspath(udev_enumerate->udev, path);
|
||||
|
||||
if (!udev_device) {
|
||||
- return NULL;
|
||||
+ return;
|
||||
}
|
||||
|
||||
- if (!filter_subsystem(thread->udev_enumerate, udev_device) ||
|
||||
- !filter_sysname(thread->udev_enumerate, udev_device) ||
|
||||
- !filter_property(thread->udev_enumerate, udev_device) ||
|
||||
- !filter_sysattr(thread->udev_enumerate, udev_device)) {
|
||||
+ if (!filter_subsystem(udev_enumerate, udev_device) ||
|
||||
+ !filter_sysname(udev_enumerate, udev_device) ||
|
||||
+ !filter_property(udev_enumerate, udev_device) ||
|
||||
+ !filter_sysattr(udev_enumerate, udev_device)) {
|
||||
udev_device_unref(udev_device);
|
||||
- return NULL;
|
||||
+ return;
|
||||
}
|
||||
|
||||
- pthread_mutex_lock(thread->mutex);
|
||||
- udev_list_entry_add(&thread->udev_enumerate->devices, udev_device_get_syspath(udev_device), NULL, 0);
|
||||
- pthread_mutex_unlock(thread->mutex);
|
||||
+ udev_list_entry_add(&udev_enumerate->devices, udev_device_get_syspath(udev_device), NULL, 0);
|
||||
|
||||
udev_device_unref(udev_device);
|
||||
- return NULL;
|
||||
}
|
||||
|
||||
static int filter_dot(const struct dirent *de)
|
||||
@@ -265,9 +253,7 @@ static int filter_dot(const struct dirent *de)
|
||||
|
||||
static int scan_devices(struct udev_enumerate *udev_enumerate, const char *path)
|
||||
{
|
||||
- struct udev_enumerate_thread *thread;
|
||||
- pthread_mutex_t mutex;
|
||||
- int i, cnt, ret = 1;
|
||||
+ int i, cnt;
|
||||
struct dirent **de;
|
||||
|
||||
cnt = scandir(path, &de, filter_dot, NULL);
|
||||
@@ -276,41 +262,18 @@ static int scan_devices(struct udev_enumerate *udev_enumerate, const char *path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- thread = calloc(cnt, sizeof(*thread));
|
||||
-
|
||||
- if (!thread) {
|
||||
- ret = 0;
|
||||
- goto free_de;
|
||||
- }
|
||||
-
|
||||
- pthread_mutex_init(&mutex, NULL);
|
||||
-
|
||||
for (i = 0; i < cnt; i++) {
|
||||
- thread[i].mutex = &mutex;
|
||||
- thread[i].udev_enumerate = udev_enumerate;
|
||||
-
|
||||
- snprintf(thread[i].path, sizeof(thread[i].path), "%s/%s", path, de[i]->d_name);
|
||||
-
|
||||
- if (pthread_create(&thread[i].thread, NULL, add_device, &thread[i]) != 0) {
|
||||
- ret = 0;
|
||||
- break;
|
||||
- }
|
||||
+ char device_path[PATH_MAX];
|
||||
+ snprintf(device_path, sizeof(device_path), "%s/%s", path, de[i]->d_name);
|
||||
+ add_device(udev_enumerate, device_path);
|
||||
}
|
||||
|
||||
- for (i = 0; i < cnt; i++) {
|
||||
- pthread_join(thread[i].thread, NULL);
|
||||
- }
|
||||
-
|
||||
- free(thread);
|
||||
- pthread_mutex_destroy(&mutex);
|
||||
-
|
||||
-free_de:
|
||||
for (i = 0; i < cnt; i++) {
|
||||
free(de[i]);
|
||||
}
|
||||
|
||||
free(de);
|
||||
- return ret;
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate)
|
||||
--
|
||||
2.47.3
|
||||
|
||||
10
package/libudev-zero/Config.in
Normal file
10
package/libudev-zero/Config.in
Normal file
@@ -0,0 +1,10 @@
|
||||
config BR2_PACKAGE_LIBUDEV_ZERO
|
||||
bool "libudev-zero"
|
||||
depends on !BR2_STATIC_LIBS
|
||||
help
|
||||
Daemonless replacement for libudev
|
||||
|
||||
https://github.com/illiliti/libudev-zero
|
||||
|
||||
comment "libudev-zero needs a toolchain w/ dynamic library"
|
||||
depends on BR2_STATIC_LIBS
|
||||
3
package/libudev-zero/libudev-zero.hash
Normal file
3
package/libudev-zero/libudev-zero.hash
Normal file
@@ -0,0 +1,3 @@
|
||||
# Locally computed
|
||||
sha256 0bd89b657d62d019598e6c7ed726ff8fed80e8ba092a83b484d66afb80b77da5 libudev-zero-1.0.3.tar.gz
|
||||
sha256 9169cc15bda9e4597784ea29530d6754af6fb00adce5907bf0a794c575591d3f LICENSE
|
||||
27
package/libudev-zero/libudev-zero.mk
Normal file
27
package/libudev-zero/libudev-zero.mk
Normal file
@@ -0,0 +1,27 @@
|
||||
################################################################################
|
||||
#
|
||||
# libudev-zero
|
||||
#
|
||||
################################################################################
|
||||
|
||||
LIBUDEV_ZERO_VERSION = 1.0.3
|
||||
LIBUDEV_ZERO_SITE = $(call github,illiliti,libudev-zero,$(LIBUDEV_ZERO_VERSION))
|
||||
LIBUDEV_ZERO_LICENSE = ISC
|
||||
LIBUDEV_ZERO_LICENSE_FILES = LICENSE
|
||||
LIBUDEV_ZERO_INSTALL_STAGING = YES
|
||||
|
||||
define LIBUDEV_ZERO_BUILD_CMDS
|
||||
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS)
|
||||
endef
|
||||
|
||||
define LIBUDEV_ZERO_INSTALL_STAGING_CMDS
|
||||
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) \
|
||||
DESTDIR=$(STAGING_DIR) PREFIX=/usr install
|
||||
endef
|
||||
|
||||
define LIBUDEV_ZERO_INSTALL_TARGET_CMDS
|
||||
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) \
|
||||
DESTDIR=$(TARGET_DIR) PREFIX=/usr install
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
Reference in New Issue
Block a user