[posix] POSIX standard implementation for PSE51 (#5384)

* [posix] POSIX standard implementation for PSE51

- add some posix's interfaces that we haven't before.
- these PR have passed the interface definition test across gcc platfrom;
- have tested base on qemu-a9 and stm32h750-art-pi.

* [newlib] only enable POSIX.1-1990

* update projects
This commit is contained in:
Man, Jianting (Meco)
2021-12-17 02:34:17 -05:00
committed by GitHub
parent 417efc370f
commit 6369e89502
480 changed files with 25486 additions and 21117 deletions

View File

@@ -18,6 +18,7 @@
RT_DEFINE_SPINLOCK(pth_lock);
_pthread_data_t *pth_table[PTHREAD_NUM_MAX] = {NULL};
static int concurrency_level;
_pthread_data_t *_pthread_get_data(pthread_t thread)
{
@@ -151,19 +152,6 @@ void _pthread_data_destroy(pthread_t pth)
}
}
int pthread_system_init(void)
{
/* initialize key area */
pthread_key_system_init();
/* initialize posix mqueue */
posix_mq_system_init();
/* initialize posix semaphore */
posix_sem_system_init();
return 0;
}
INIT_COMPONENT_EXPORT(pthread_system_init);
static void _pthread_destroy(_pthread_data_t *ptd)
{
pthread_t pth = _pthread_data_get_pth(ptd);
@@ -451,6 +439,70 @@ pthread_t pthread_self (void)
}
RTM_EXPORT(pthread_self);
int pthread_getcpuclockid(pthread_t thread, clockid_t *clock_id)
{
if(_pthread_get_data(thread) == NULL)
{
return EINVAL;
}
*clock_id = (clockid_t)rt_tick_get();
return 0;
}
RTM_EXPORT(pthread_getcpuclockid);
int pthread_getconcurrency(void)
{
return concurrency_level;
}
RTM_EXPORT(pthread_getconcurrency);
int pthread_setconcurrency(int new_level)
{
concurrency_level = new_level;
return 0;
}
RTM_EXPORT(pthread_setconcurrency);
int pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
{
_pthread_data_t *ptd;
ptd = _pthread_get_data(thread);
pthread_attr_getschedpolicy(&ptd->attr, policy);
pthread_attr_getschedparam(&ptd->attr, param);
return 0;
}
RTM_EXPORT(pthread_getschedparam);
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param)
{
_pthread_data_t *ptd;
ptd = _pthread_get_data(thread);
pthread_attr_setschedpolicy(&ptd->attr, policy);
pthread_attr_setschedparam(&ptd->attr, param);
return 0;
}
RTM_EXPORT(pthread_setschedparam);
int pthread_setschedprio(pthread_t thread, int prio)
{
_pthread_data_t *ptd;
struct sched_param param;
ptd = _pthread_get_data(thread);
param.sched_priority = prio;
pthread_attr_setschedparam(&ptd->attr, &param);
return 0;
}
RTM_EXPORT(pthread_setschedprio);
void pthread_exit(void *value)
{
_pthread_data_t *ptd;