Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LasseRosenow committed Oct 22, 2024
1 parent 6b9e60f commit e01140c
Showing 1 changed file with 102 additions and 106 deletions.
208 changes: 102 additions & 106 deletions sys/posix/pthread/pthread_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,147 +20,143 @@

#include "pthread.h"

int pthread_attr_init(pthread_attr_t *attr) {
memset(attr, 0, sizeof(*attr));
return 0;
}

int pthread_attr_destroy(pthread_attr_t *attr) {
(void)attr;
return 0;
}

int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) {
*detachstate =
attr->detached ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE;
return 0;
int pthread_attr_init(pthread_attr_t *attr)
{
memset(attr, 0, sizeof (*attr));
return 0;
}

int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate) {
switch (detachstate) {
case PTHREAD_CREATE_DETACHED:
attr->detached = 1;
return 0;
case PTHREAD_CREATE_JOINABLE:
attr->detached = 0;
int pthread_attr_destroy(pthread_attr_t *attr)
{
(void) attr;
return 0;
default:
return -1;
}
}

int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize) {
// TODO
(void)attr;
(void)guardsize;
return -1;
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
{
*detachstate = attr->detached ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE;
return 0;
}

int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) {
// TODO
(void)attr;
(void)guardsize;
return -1;
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
{
switch (detachstate) {
case PTHREAD_CREATE_DETACHED:
attr->detached = 1;
return 0;
case PTHREAD_CREATE_JOINABLE:
attr->detached = 0;
return 0;
default:
return -1;
}
}

int pthread_attr_getschedparam(const pthread_attr_t *attr,
struct sched_param *param) {
// TODO
(void)attr;
(void)param;
return -1;
int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize)
{
// TODO
(void) attr;
(void) guardsize;
return -1;
}

int pthread_attr_setschedparam(pthread_attr_t *attr,
const struct sched_param *param) {
// TODO
(void)attr;
(void)param;
return -1;
int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
{
// TODO
(void) attr;
(void) guardsize;
return -1;
}

int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) {
// TODO
(void)attr;
(void)policy;
return -1;
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
{
// TODO
(void) attr;
(void) param;
return -1;
}

int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy) {
// TODO
(void)attr;
(void)policy;
return -1;
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
{
// TODO
(void) attr;
(void) param;
return -1;
}

int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit) {
// TODO
(void)attr;
(void)inherit;
return -1;
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
{
// TODO
(void) attr;
(void) policy;
return -1;
}

int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit) {
// TODO
(void)attr;
(void)inherit;
return -1;
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
{
// TODO
(void) attr;
(void) policy;
return -1;
}

int pthread_attr_getscope(const pthread_attr_t *attr, int *scope) {
// TODO
(void)attr;
(void)scope;
return -1;
int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit)
{
// TODO
(void) attr;
(void) inherit;
return -1;
}

int pthread_attr_setscope(pthread_attr_t *attr, int scope) {
// TODO
(void)attr;
(void)scope;
return -1;
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
{
// TODO
(void) attr;
(void) inherit;
return -1;
}

int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr) {
*stackaddr = attr->ss_sp;
return 0;
int pthread_attr_getscope(const pthread_attr_t *attr, int *scope)
{
// TODO
(void) attr;
(void) scope;
return -1;
}

int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) {
attr->ss_sp = (char *)stackaddr;
return 0;
int pthread_attr_setscope(pthread_attr_t *attr, int scope)
{
// TODO
(void) attr;
(void) scope;
return -1;
}

int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) {
*stacksize = attr->ss_size;
if (*stacksize == 0) {
/* FIXME: the standard says that this function should return the default
* value if no explicit value was set. */
}
return 0;
int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
{
*stackaddr = attr->ss_sp;
return 0;
}

int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) {
attr->ss_size = stacksize;
return 0;
int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
{
attr->ss_sp = (char *) stackaddr;
return 0;
}

int pthread_attr_getstack(pthread_attr_t *attr, void **stackaddr,
size_t *stacksize) {
*stackaddr = attr->ss_sp;
*stacksize = attr->ss_size;
if (*stacksize == 0) {
/* FIXME: the standard says that this function should return the default
* value if no explicit value was set. */
}
return 0;
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
{
*stacksize = attr->ss_size;
if (*stacksize == 0) {
/* FIXME: the standard says that this function should return the default value if no explicit value was set. */

Check warning on line 151 in sys/posix/pthread/pthread_attr.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
}
return 0;
}

int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr,
size_t stacksize) {
attr->ss_sp = (char *)stackaddr;
attr->ss_size = stacksize;
return 0;
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
{
attr->ss_size = stacksize;
return 0;
}

int pthread_attr_getstack(pthread_attr_t *attr, void **stackaddr, size_t *stacksize)
Expand Down

0 comments on commit e01140c

Please sign in to comment.