Merge ~chihchun/libhybris/+git/libhybris-ubuntu:missing-hooks into ~morphis/libhybris/+git/libhybris-ubuntu:missing-hooks

Proposed by Rex Tsai
Status: Needs review
Proposed branch: ~chihchun/libhybris/+git/libhybris-ubuntu:missing-hooks
Merge into: ~morphis/libhybris/+git/libhybris-ubuntu:missing-hooks
Diff against target: 42 lines (+24/-0)
1 file modified
hybris/common/hooks.c (+24/-0)
Reviewer Review Type Date Requested Status
Simon Fels Pending
Review via email: mp+281746@code.launchpad.net

Description of the change

hybris: common: hook pthread_mutex_timedlock function.

./vendor/mediatek/proprietary/platform/common/hardware/audio/include/AudioLock.h uses pthread_mutex_timedlock()

To post a comment you must log in.

Unmerged commits

aa1f896... by Rex Tsai

hybris: common: hook pthread_mutex_timedlock function.

./vendor/mediatek/proprietary/platform/common/hardware/audio/include/AudioLock.h uses pthread_mutex_timedlock()

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hybris/common/hooks.c b/hybris/common/hooks.c
2index 8bc510c..4be32bc 100644
3--- a/hybris/common/hooks.c
4+++ b/hybris/common/hooks.c
5@@ -948,6 +948,29 @@ static int my_pthread_rwlockattr_destroy(pthread_rwlockattr_t *__attr)
6 return ret;
7 }
8
9+static int my_pthread_mutex_timedlock(pthread_mutex_t *__mutex,
10+ const struct timespec *__abs_timeout)
11+{
12+ if (!__mutex) {
13+ LOGD("Null mutex lock, not unlocking.");
14+ return 0;
15+ }
16+
17+ unsigned int value = (*(unsigned int *) __mutex);
18+ if (hybris_check_android_shared_mutex(value)) {
19+ LOGD("Shared mutex with Android, not lock timeout np.");
20+ return 0;
21+ }
22+
23+ pthread_mutex_t *realmutex = (pthread_mutex_t *) value;
24+ if (value <= ANDROID_TOP_ADDR_VALUE_MUTEX) {
25+ realmutex = hybris_alloc_init_mutex(value);
26+ *((int *)__mutex) = (int) realmutex;
27+ }
28+
29+ return pthread_mutex_timedlock(realmutex, __abs_timeout);
30+}
31+
32 static int my_pthread_rwlockattr_setpshared(pthread_rwlockattr_t *__attr,
33 int pshared)
34 {
35@@ -1835,6 +1858,7 @@ static struct _hook hooks[] = {
36 {"pthread_mutex_unlock", my_pthread_mutex_unlock},
37 {"pthread_mutex_trylock", my_pthread_mutex_trylock},
38 {"pthread_mutex_lock_timeout_np", my_pthread_mutex_lock_timeout_np},
39+ {"pthread_mutex_timedlock", my_pthread_mutex_timedlock},
40 {"pthread_mutexattr_init", pthread_mutexattr_init},
41 {"pthread_mutexattr_destroy", pthread_mutexattr_destroy},
42 {"pthread_mutexattr_gettype", pthread_mutexattr_gettype},

Subscribers

People subscribed via source and target branches

to all changes: