summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/semaphorecreatesupp.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-12 08:09:16 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-05 14:29:01 +0200
commitc090db7405b72ce6d0b726c0a39fb1c1aebab7ea (patch)
tree099a887f445115e9b40d25cd6a2b2b11908d347d /cpukit/posix/src/semaphorecreatesupp.c
parentposix: Optimize pthread_once_t (diff)
downloadrtems-c090db7405b72ce6d0b726c0a39fb1c1aebab7ea.tar.bz2
posix: Implement self-contained POSIX semaphores
For semaphore object pointer and object validation see POSIX_SEMAPHORE_VALIDATE_OBJECT(). Destruction or close of a busy semaphore returns an error status. The object is not flushed. POSIX semaphores are now available in all configurations and no longer depend on --enable-posix. Update #2514. Update #3116.
Diffstat (limited to 'cpukit/posix/src/semaphorecreatesupp.c')
-rw-r--r--cpukit/posix/src/semaphorecreatesupp.c102
1 files changed, 0 insertions, 102 deletions
diff --git a/cpukit/posix/src/semaphorecreatesupp.c b/cpukit/posix/src/semaphorecreatesupp.c
deleted file mode 100644
index 4a33336230..0000000000
--- a/cpukit/posix/src/semaphorecreatesupp.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * @file
- *
- * @brief Function does Actual creation and Initialization of POSIX Semaphore
- * @ingroup POSIXAPI
- */
-
-/*
- * COPYRIGHT (c) 1989-2009.
- * On-Line Applications Research Corporation (OAR).
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdarg.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <limits.h>
-#include <string.h> /* strlen */
-
-#include <rtems/system.h>
-#include <rtems/score/wkspace.h>
-#include <rtems/posix/semaphoreimpl.h>
-#include <rtems/seterr.h>
-
-/*
- * _POSIX_Semaphore_Create_support
- *
- * This routine does the actual creation and initialization of
- * a poxix semaphore. It is a support routine for sem_init and
- * sem_open.
- */
-int _POSIX_Semaphore_Create_support(
- const char *name_arg,
- size_t name_len,
- unsigned int value,
- POSIX_Semaphore_Control **the_sem
-)
-{
- POSIX_Semaphore_Control *the_semaphore;
- char *name;
-
- /*
- * Make a copy of the user's string for name just in case it was
- * dynamically constructed.
- */
- if ( name_arg != NULL ) {
- name = _Workspace_String_duplicate( name_arg, name_len );
- if ( !name ) {
- rtems_set_errno_and_return_minus_one( ENOMEM );
- }
- } else {
- name = NULL;
- }
-
- the_semaphore = _POSIX_Semaphore_Allocate_unprotected();
- if ( !the_semaphore ) {
- _Workspace_Free( name );
- rtems_set_errno_and_return_minus_one( ENOSPC );
- }
-
- if ( name ) {
- the_semaphore->named = true;
- the_semaphore->open_count = 1;
- the_semaphore->linked = true;
- } else {
- the_semaphore->named = false;
- the_semaphore->open_count = 0;
- the_semaphore->linked = false;
- }
-
- /*
- * POSIX does not appear to specify what the discipline for
- * blocking tasks on this semaphore should be. It could somehow
- * be derived from the current scheduling policy. One
- * thing is certain, no matter what we decide, it won't be
- * the same as all other POSIX implementations. :)
- */
- _CORE_semaphore_Initialize( &the_semaphore->Semaphore, value );
-
- /*
- * Make the semaphore available for use.
- */
- _Objects_Open_string(
- &_POSIX_Semaphore_Information,
- &the_semaphore->Object,
- name
- );
-
- *the_sem = the_semaphore;
-
- return 0;
-}