pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
frida-glib2: Implement frida's specific threading utilities
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Tue Mar 13 02:54:19 2018 +0100
Changeset: 4134498c876157c638bdbe423a6246cd2edd9226
Modified Files:
frida-glib2/distinfo
frida-glib2/patches/patch-glib_gthread-posix.c
Log Message:
frida-glib2: Implement frida's specific threading utilities
Implement:
- g_thread_lifetime_beacon_new
- g_thread_lifetime_beacon_free
- g_thread_lifetime_beacon_check
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=4134498c876157c638bdbe423a6246cd2edd9226
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
frida-glib2/distinfo | 2 +-
frida-glib2/patches/patch-glib_gthread-posix.c | 83 ++++++++++++++++++++++++++
2 files changed, 84 insertions(+), 1 deletion(-)
diffs:
diff --git a/frida-glib2/distinfo b/frida-glib2/distinfo
index 3b435a5772..06e209a346 100644
--- a/frida-glib2/distinfo
+++ b/frida-glib2/distinfo
@@ -4,4 +4,4 @@ SHA1 (glib-2.54.3-d8a2acabac5c04d3ca5eb4f0aa050582b8a9c7ac.tar.gz) = 5eae4e940ae
RMD160 (glib-2.54.3-d8a2acabac5c04d3ca5eb4f0aa050582b8a9c7ac.tar.gz) = b399e316fdbb3f83a88bdd107de721581bed8db7
SHA512 (glib-2.54.3-d8a2acabac5c04d3ca5eb4f0aa050582b8a9c7ac.tar.gz) = c1f8f2e37a778f77b3e27566e18004c484be7626eaafb644a288ef93f253e48d1c57c88cb03dc0dde001437f6d57d098452ed327b891382b682b6a0aa2e35b46
Size (glib-2.54.3-d8a2acabac5c04d3ca5eb4f0aa050582b8a9c7ac.tar.gz) = 8068479 bytes
-SHA1 (patch-glib_gthread-posix.c) = b0689e3c6729ef31f0c5e3be75ea7211d4f3023e
+SHA1 (patch-glib_gthread-posix.c) = ffb13535432767a34492c9377a0a056fddbf078c
diff --git a/frida-glib2/patches/patch-glib_gthread-posix.c b/frida-glib2/patches/patch-glib_gthread-posix.c
index 44d7abc608..851cc99fdb 100644
--- a/frida-glib2/patches/patch-glib_gthread-posix.c
+++ b/frida-glib2/patches/patch-glib_gthread-posix.c
@@ -32,3 +32,86 @@ $NetBSD$
#else
#error Cannot support GCond on your platform.
#endif
+@@ -1659,6 +1675,82 @@ g_thread_lifetime_beacon_check (GThreadB
+ return status == -1 && errno == ESRCH;
+ }
+
++#elif defined(__NetBSD__)
++
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <lwp.h>
++
++struct _GThreadBeacon
++{
++ pid_t process_id;
++ lwpid_t thread_id;
++};
++
++GThreadBeacon *
++g_thread_lifetime_beacon_new (void)
++{
++ GThreadBeacon *beacon;
++
++ beacon = g_slice_new (GThreadBeacon);
++ beacon->process_id = getpid ();
++ beacon->thread_id = _lwp_self();
++
++ return beacon;
++}
++
++void
++g_thread_lifetime_beacon_free (GThreadBeacon *beacon)
++{
++ g_slice_free (GThreadBeacon, beacon);
++}
++
++gboolean
++g_thread_lifetime_beacon_check (GThreadBeacon *beacon)
++{
++ int st;
++ int mib[5];
++ size_t size, nlwps, i;
++ struct kinfo_lwp *kl;
++ int found = 0;
++
++ mib[0] = CTL_KERN;
++ mib[1] = KERN_LWP;
++ mib[2] = beacon->process_id;
++ mib[3] = sizeof(struct kinfo_lwp);
++ mib[4] = 0;
++
++ st = sysctl(mib, 5, NULL, &size, NULL, 0);
++ if (st == -1 || size == 0)
++ return FALSE;
++
++ mib[4] = size / sizeof(struct kinfo_lwp);
++
++ kl = (struct kinfo_lwp *)malloc(mib[4]);
++ if (!kl)
++ return FALSE;
++
++ st = sysctl(mib, 5, kl, &size, NULL, 0);
++ if (st == -1 || size == 0)
++ goto fail;
++
++ nlwps = size / sizeof(struct kinfo_lwp);
++ for (i = 0; i < nlwps; i++) {
++ if ((kl + i)->l_lid == beacon->thread_id) {
++ found = 1;
++ break;
++ }
++ }
++
++ free(kl);
++
++ return found ? TRUE : FALSE;
++
++fail:
++ free(kl);
++ return TRUE;
++}
++
+ #else
+ #error Please implement for your OS
+ #endif
Home |
Main Index |
Thread Index |
Old Index