source: rtems/cpukit/posix/src/pthreadsetaffinitynp.c @ 5c332349

4.115
Last change on this file since 5c332349 was 5c332349, checked in by Jennifer Averett <jennifer.averett@…>, on 03/07/14 at 15:06:57

Remove trailing whitespace in previous patches

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Pthread Set Affinity
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#if HAVE_DECL_PTHREAD_SETAFFINITY_NP
22
23#define  _GNU_SOURCE
24#include <pthread.h>
25#include <errno.h>
26
27#include <rtems/posix/pthreadimpl.h>
28#include <rtems/posix/priorityimpl.h>
29#include <rtems/score/threadimpl.h>
30#include <rtems/score/cpusetimpl.h>
31
32int pthread_setaffinity_np(
33  pthread_t          id,
34  size_t             cpusetsize,
35  const cpu_set_t   *cpuset)
36{
37  Objects_Locations        location;
38  POSIX_API_Control       *api;
39  Thread_Control          *the_thread;
40  int                      error;
41
42  if ( !cpuset )
43    return EFAULT;
44
45  error = _CPU_set_Is_valid( cpuset, cpusetsize );
46  if ( error != 0 )
47    return EINVAL;
48
49  the_thread = _Thread_Get( id, &location );
50  switch ( location ) {
51
52    case OBJECTS_LOCAL:
53      api = the_thread->API_Extensions[ THREAD_API_POSIX ];
54      CPU_COPY( the_thread->affinity.set, cpuset );
55      CPU_COPY( api->Attributes.affinityset, cpuset );
56      _Objects_Put( &the_thread->Object );
57      return 0;
58      break;
59
60#if defined(RTEMS_MULTIPROCESSING)
61    case OBJECTS_REMOTE:
62#endif
63    case OBJECTS_ERROR:
64      break;
65  }
66
67  return ESRCH;
68}
69#endif
Note: See TracBrowser for help on using the repository browser.