Back to index

glibc  2.9
pthread_attr_setdetachstate.c File Reference
#include <assert.h>
#include <errno.h>
#include "pthreadP.h"

Go to the source code of this file.


int __pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)

Function Documentation

int __pthread_attr_setdetachstate ( pthread_attr_t attr,
int  detachstate 

Definition at line 26 of file pthread_attr_setdetachstate.c.

  struct pthread_attr *iattr;

  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
  iattr = (struct pthread_attr *) attr;

  /* Catch invalid values.  */
  if (detachstate != PTHREAD_CREATE_DETACHED
      && __builtin_expect (detachstate != PTHREAD_CREATE_JOINABLE, 0))
    return EINVAL;

  /* Set the flag.  It is nonzero if threads are created detached.  */
  if (detachstate == PTHREAD_CREATE_DETACHED)
    iattr->flags |= ATTR_FLAG_DETACHSTATE;
    iattr->flags &= ~ATTR_FLAG_DETACHSTATE;

  return 0;