source: rtems/cpukit/posix/src/semaphoretranslatereturncode.c @ e511f6d0

4.115
Last change on this file since e511f6d0 was e511f6d0, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/05/11 at 05:15:38

2011-12-05 Ralf Corsépius <ralf.corsepius@…>

  • posix/src/mqueuetranslatereturncode.c: Include <rtems/posix/mqueue.h> (Missing prototypes).
  • posix/src/mutextranslatereturncode.c: Include <rtems/posix/mutex.h> (Missing prototypes).
  • posix/src/semaphoretranslatereturncode.c: Include <rtems/posix/semaphore.h> (Missing prototypes).
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  POSIX Semaphore Error Translation
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <pthread.h>
19#include <errno.h>
20
21#include <rtems/system.h>
22#include <rtems/score/coresem.h>
23#include <rtems/posix/semaphore.h>
24
25/*
26 *  _POSIX_Semaphore_Translate_core_semaphore_return_code
27 *
28 *  Input parameters:
29 *    the_semaphore_status - semaphore status code to translate
30 *
31 *  Output parameters:
32 *    status code - translated POSIX status code
33 *
34 */
35
36static int _POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1] = {
37  0,                   /* CORE_SEMAPHORE_STATUS_SUCCESSFUL */
38  EAGAIN,              /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */
39  EAGAIN,              /* CORE_SEMAPHORE_WAS_DELETED */
40  ETIMEDOUT,           /* CORE_SEMAPHORE_TIMEOUT */
41  /* The next error can not occur since we set the maximum
42   * count to the largest value the count can hold.
43   */
44  ENOSYS,              /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
45};
46
47
48int _POSIX_Semaphore_Translate_core_semaphore_return_code(
49  CORE_semaphore_Status  the_semaphore_status
50)
51{
52  /*
53   *  Internal consistency check for bad status from SuperCore
54   */
55  #if defined(RTEMS_DEBUG)
56    if ( the_semaphore_status > CORE_SEMAPHORE_STATUS_LAST )
57      return EINVAL;
58  #endif
59  return _POSIX_Semaphore_Return_codes[the_semaphore_status];
60}
Note: See TracBrowser for help on using the repository browser.