static int my_pthread_rwlock_destroy(pthread_rwlock_t *__rwlock) { int ret; pthread_rwlock_t *realrwlock = (pthread_rwlock_t *) *(unsigned int *) __rwlock; if (!hybris_is_pointer_in_shm((void*)realrwlock)) { ret = pthread_rwlock_destroy(realrwlock); free(realrwlock); } else { ret = pthread_rwlock_destroy(realrwlock); realrwlock = (pthread_rwlock_t *)hybris_get_shmpointer((hybris_shm_pointer_t)realrwlock); } return ret; }
static int my_pthread_cond_broadcast(pthread_cond_t *cond) { unsigned int value = (*(unsigned int *) cond); if (hybris_check_android_shared_cond(value)) { LOGD("shared condition with Android, not broadcasting."); return 0; } pthread_cond_t *realcond = (pthread_cond_t *) value; if (hybris_is_pointer_in_shm((void*)value)) realcond = (pthread_cond_t *)hybris_get_shmpointer((hybris_shm_pointer_t)value); if (value <= ANDROID_TOP_ADDR_VALUE_COND) { realcond = hybris_alloc_init_cond(); *((unsigned int *) cond) = (unsigned int) realcond; } return pthread_cond_broadcast(realcond); }
static int my_pthread_mutex_trylock(pthread_mutex_t *__mutex) { unsigned int value = (*(unsigned int *) __mutex); if (hybris_check_android_shared_mutex(value)) { LOGD("Shared mutex with Android, not try locking."); return 0; } pthread_mutex_t *realmutex = (pthread_mutex_t *) value; if (hybris_is_pointer_in_shm((void*)value)) realmutex = (pthread_mutex_t *)hybris_get_shmpointer((hybris_shm_pointer_t)value); if (value <= ANDROID_TOP_ADDR_VALUE_MUTEX) { realmutex = hybris_alloc_init_mutex(value); *((unsigned int *)__mutex) = (unsigned int) realmutex; } return pthread_mutex_trylock(realmutex); }
static int my_pthread_cond_destroy(pthread_cond_t *cond) { int ret; pthread_cond_t *realcond = (pthread_cond_t *) *(unsigned int *) cond; if (!realcond) { return EINVAL; } if (!hybris_is_pointer_in_shm((void*)realcond)) { ret = pthread_cond_destroy(realcond); free(realcond); } else { realcond = (pthread_cond_t *)hybris_get_shmpointer((hybris_shm_pointer_t)realcond); ret = pthread_cond_destroy(realcond); } *((unsigned int *)cond) = 0; return ret; }