posix: rwlock: pthread_rwlockattr_init / destroy in lib
Move the implementation of the following functions into the posix library rather than having themn as static inline functions. * pthread_rwlockattr_init() * pthread_rwlockattr_destroy() Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This commit is contained in:
parent
457e44073b
commit
61c4139925
|
@ -390,22 +390,14 @@ int pthread_equal(pthread_t pt1, pthread_t pt2);
|
||||||
*
|
*
|
||||||
* See IEEE 1003.1
|
* See IEEE 1003.1
|
||||||
*/
|
*/
|
||||||
static inline int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
|
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
|
||||||
{
|
|
||||||
ARG_UNUSED(attr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief initialize the read-write lock attributes object.
|
* @brief initialize the read-write lock attributes object.
|
||||||
*
|
*
|
||||||
* See IEEE 1003.1
|
* See IEEE 1003.1
|
||||||
*/
|
*/
|
||||||
static inline int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
|
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
|
||||||
{
|
|
||||||
ARG_UNUSED(attr);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int pthread_attr_getguardsize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT guardsize);
|
int pthread_attr_getguardsize(const pthread_attr_t *ZRESTRICT attr, size_t *ZRESTRICT guardsize);
|
||||||
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
|
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
|
||||||
|
|
|
@ -21,6 +21,10 @@ struct posix_rwlock {
|
||||||
k_tid_t wr_owner;
|
k_tid_t wr_owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct posix_rwlockattr {
|
||||||
|
bool initialized: 1;
|
||||||
|
};
|
||||||
|
|
||||||
int64_t timespec_to_timeoutms(const struct timespec *abstime);
|
int64_t timespec_to_timeoutms(const struct timespec *abstime);
|
||||||
static uint32_t read_lock_acquire(struct posix_rwlock *rwl, int32_t timeout);
|
static uint32_t read_lock_acquire(struct posix_rwlock *rwl, int32_t timeout);
|
||||||
static uint32_t write_lock_acquire(struct posix_rwlock *rwl, int32_t timeout);
|
static uint32_t write_lock_acquire(struct posix_rwlock *rwl, int32_t timeout);
|
||||||
|
@ -384,3 +388,31 @@ static uint32_t write_lock_acquire(struct posix_rwlock *rwl, int32_t timeout)
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
|
||||||
|
{
|
||||||
|
struct posix_rwlockattr *const a = (struct posix_rwlockattr *)attr;
|
||||||
|
|
||||||
|
if (a == NULL) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = (struct posix_rwlockattr){
|
||||||
|
.initialized = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
|
||||||
|
{
|
||||||
|
struct posix_rwlockattr *const a = (struct posix_rwlockattr *)attr;
|
||||||
|
|
||||||
|
if (a == NULL || !a->initialized) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*a = (struct posix_rwlockattr){0};
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue