source: rtems/cpukit/posix/src/sempost.c @ 2581a56

5
Last change on this file since 2581a56 was 2581a56, checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 19:39:56

score: Add semaphore variants

  • Property mode set to 100644
File size: 1008 bytes
Line 
1/**
2 *  @file
3 *
4 *  @brief Unlock a Semaphore
5 *  @ingroup POSIX_SEMAPHORE
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-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#include <semaphore.h>
22#include <limits.h>
23
24#include <rtems/posix/semaphoreimpl.h>
25#include <rtems/posix/posixapi.h>
26
27int sem_post(
28  sem_t  *sem
29)
30{
31  POSIX_Semaphore_Control *the_semaphore;
32  Thread_queue_Context     queue_context;
33  Status_Control           status;
34
35  the_semaphore = _POSIX_Semaphore_Get( sem, &queue_context );
36
37  if ( the_semaphore == NULL ) {
38    rtems_set_errno_and_return_minus_one( EINVAL );
39  }
40
41  status = _CORE_semaphore_Surrender(
42    &the_semaphore->Semaphore,
43    POSIX_SEMAPHORE_TQ_OPERATIONS,
44    SEM_VALUE_MAX,
45    &queue_context
46  );
47  return _POSIX_Zero_or_minus_one_plus_errno( status );
48}
Note: See TracBrowser for help on using the repository browser.