提交 1d3e53ba 编写于 作者: L li-tao116

Optimize pthread_mutex_init and pthread_rwlock_init

Use __builtin_memset to init pthread_mutex_t and pthread_rwlock_t.

Issue: #I7MIQ5
Test: libctest, benchmark
Signed-off-by: Nlitao <litao@kaihong.com>
Change-Id: I5744c6cf27e9deff551f20b3dd663648420b4330
上级 cea704b5
......@@ -2119,9 +2119,11 @@ musl_src_porting_file = [
"src/thread/pthread_mutex_lock.c",
"src/thread/pthread_mutex_timedlock_monotonic_np.c",
"src/thread/pthread_mutex_lock_timeout_np.c",
"src/thread/pthread_mutex_init.c",
"src/thread/pthread_rwlock_clockrdlock.c",
"src/thread/pthread_rwlock_timedrdlock.c",
"src/thread/pthread_rwlock_timedrdlock_monotonic_np.c",
"src/thread/pthread_rwlock_init.c",
"src/thread/pthread_cond_timedwait_monotonic_np.c",
"src/thread/pthread_cond_timeout_np.c",
"src/thread/pthread_cond_clockwait.c",
......
#include "pthread_impl.h"
int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a)
{
__builtin_memset(m, 0, sizeof(pthread_mutex_t));
if (a) m->_m_type = a->__attr;
return 0;
}
#include "pthread_impl.h"
int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a)
{
__builtin_memset(rw, 0, sizeof(pthread_rwlock_t));
if (a) rw->_rw_shared = a->__attr[0]*128;
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册