Changeset cff773f in rtems


Ignore:
Timestamp:
Sep 10, 2015, 3:12:06 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
2f5e3c7
Parents:
e333089
git-author:
Sebastian Huber <sebastian.huber@…> (09/10/15 15:12:06)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/14/15 05:47:12)
Message:

libstdthreads: Add C11 threads

Files:
5 added
10 edited

Legend:

Unmodified
Added
Removed
  • cpukit/Makefile.am

    re333089 rcff773f  
    1717SUBDIRS += libgnat
    1818SUBDIRS += libdl
     19SUBDIRS += libstdthreads
    1920SUBDIRS += wrapup
    2021
  • cpukit/configure.ac

    re333089 rcff773f  
    141141AC_CHECK_HEADERS([semaphore.h])
    142142AM_CONDITIONAL([HAVE_SEMAPHORE_H],[test x"$ac_cv_header_semaphore_h" = x"yes"])
     143
     144AC_CHECK_HEADERS([threads.h])
     145AM_CONDITIONAL([HAVE_THREADS_H],[test x"$ac_cv_header_threads_h" = x"yes"])
    143146
    144147## error out if libc doesn't provide stdint.h
     
    482485libmd/Makefile
    483486libdl/Makefile
     487libstdthreads/Makefile
    484488zlib/Makefile
    485489ftpd/Makefile
  • cpukit/libstdthreads/call_once.c

    re333089 rcff773f  
    2727 */
    2828
    29 #include <sys/cdefs.h>
    30 __FBSDID("$FreeBSD$");
    31 
     29#include <threads.h>
    3230#include <pthread.h>
    33 
    34 #include "threads.h"
    3531
    3632void
  • cpukit/libstdthreads/cnd.c

    re333089 rcff773f  
    11/*-
    22 * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
     3 * Copyright (c) 2015 embedded brains GmbH <info@embedded-brains.de>
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 #include <sys/cdefs.h>
    30 __FBSDID("$FreeBSD$");
    31 
     30#include <threads.h>
    3231#include <errno.h>
    33 #include <pthread.h>
    34 
    35 #include "threads.h"
    3632
    3733int
     
    3935{
    4036
    41         if (pthread_cond_broadcast(cond) != 0)
    42                 return (thrd_error);
     37        _Condition_Broadcast(cond);
    4338        return (thrd_success);
    4439}
     
    4843{
    4944
    50         (void)pthread_cond_destroy(cond);
     45        _Condition_Destroy(cond);
    5146}
    5247
     
    5550{
    5651
    57         switch (pthread_cond_init(cond, NULL)) {
    58         case 0:
    59                 return (thrd_success);
    60         case ENOMEM:
    61                 return (thrd_nomem);
    62         default:
    63                 return (thrd_error);
    64         }
     52        _Condition_Initialize(cond);
     53        return (thrd_success);
    6554}
    6655
     
    6958{
    7059
    71         if (pthread_cond_signal(cond) != 0)
    72                 return (thrd_error);
     60        _Condition_Signal(cond);
    7361        return (thrd_success);
    7462}
     
    7967{
    8068
    81         switch (pthread_cond_timedwait(cond, mtx, ts)) {
     69        switch (_Condition_Wait_recursive_timed(cond, mtx, ts)) {
    8270        case 0:
    8371                return (thrd_success);
     
    9381{
    9482
    95         if (pthread_cond_wait(cond, mtx) != 0)
    96                 return (thrd_error);
     83        _Condition_Wait_recursive(cond, mtx);
    9784        return (thrd_success);
    9885}
  • cpukit/libstdthreads/mtx.c

    re333089 rcff773f  
    11/*-
    22 * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
     3 * Copyright (c) 2015 embedded brains GmbH <info@embedded-brains.de>
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 #include <sys/cdefs.h>
    30 __FBSDID("$FreeBSD$");
    31 
     30#include <threads.h>
     31#include <sys/lock.h>
    3232#include <errno.h>
    33 #include <pthread.h>
    34 
    35 #include "threads.h"
    3633
    3734void
     
    3936{
    4037
    41         (void)pthread_mutex_destroy(mtx);
     38        _Mutex_recursive_Destroy(mtx);
    4239}
    4340
     
    4542mtx_init(mtx_t *mtx, int type)
    4643{
    47         pthread_mutexattr_t attr;
    48         int mt;
    4944
    50         switch (type) {
    51         case mtx_plain:
    52         case mtx_timed:
    53                 mt = PTHREAD_MUTEX_NORMAL;
    54                 break;
    55         case mtx_plain | mtx_recursive:
    56         case mtx_timed | mtx_recursive:
    57                 mt = PTHREAD_MUTEX_RECURSIVE;
    58                 break;
    59         default:
    60                 return (thrd_error);
    61         }
    62 
    63         if (pthread_mutexattr_init(&attr) != 0)
    64                 return (thrd_error);
    65         if (pthread_mutexattr_settype(&attr, mt) != 0)
    66                 return (thrd_error);
    67         if (pthread_mutex_init(mtx, &attr) != 0)
    68                 return (thrd_error);
     45        (void)type;
     46        _Mutex_recursive_Initialize(mtx);
    6947        return (thrd_success);
    7048}
     
    7452{
    7553
    76         if (pthread_mutex_lock(mtx) != 0)
    77                 return (thrd_error);
     54        _Mutex_recursive_Acquire(mtx);
    7855        return (thrd_success);
    7956}
     
    8360{
    8461
    85         switch (pthread_mutex_timedlock(mtx, ts)) {
     62        switch (_Mutex_recursive_Acquire_timed(mtx, ts)) {
    8663        case 0:
    8764                return (thrd_success);
     
    9774{
    9875
    99         switch (pthread_mutex_trylock(mtx)) {
     76        switch (_Mutex_recursive_Try_acquire(mtx)) {
    10077        case 0:
    10178                return (thrd_success);
    102         case EBUSY:
     79        default:
    10380                return (thrd_busy);
    104         default:
    105                 return (thrd_error);
    10681        }
    10782}
     
    11186{
    11287
    113         if (pthread_mutex_unlock(mtx) != 0)
    114                 return (thrd_error);
     88        _Mutex_recursive_Release(mtx);
    11589        return (thrd_success);
    11690}
  • cpukit/libstdthreads/thrd.c

    re333089 rcff773f  
    2727 */
    2828
    29 #include <sys/cdefs.h>
    30 __FBSDID("$FreeBSD$");
    31 
     29#include <threads.h>
    3230#include <pthread.h>
     31#include <sched.h>
    3332#include <stdint.h>
    3433#include <stdlib.h>
    35 
    36 #include "threads.h"
    3734
    3835struct thrd_param {
     
    125122{
    126123
    127         pthread_yield();
     124        sched_yield();
    128125}
  • cpukit/libstdthreads/tss.c

    re333089 rcff773f  
    2727 */
    2828
    29 #include <sys/cdefs.h>
    30 __FBSDID("$FreeBSD$");
    31 
     29#include <threads.h>
     30#include <limits.h>
    3231#include <pthread.h>
    33 
    34 #include "threads.h"
    3532
    3633int
  • cpukit/wrapup/Makefile.am

    re333089 rcff773f  
    2121
    2222TMP_LIBS += ../libcrypt/libcrypt.a
     23TMP_LIBS += ../libstdthreads/libstdthreads.a
    2324TMP_LIBS += ../libcsupport/libcsupport.a
    2425TMP_LIBS += ../libcsupport/libcalloc.a
  • testsuites/sptests/Makefile.am

    re333089 rcff773f  
    4141_SUBDIRS += spsyslock01
    4242endif
     43if HAS_THREADS_H
     44_SUBDIRS += spstdthreads01
     45endif
    4346_SUBDIRS += sptasknopreempt01
    4447_SUBDIRS += spintrcritical23
  • testsuites/sptests/configure.ac

    re333089 rcff773f  
    3434AM_CONDITIONAL(HAS__THREAD_QUEUE_QUEUE,test x"${ac_cv_type_struct__Thread_queue_Queue}" = x"yes")
    3535
     36AC_CHECK_HEADERS([threads.h])
     37AM_CONDITIONAL([HAS_THREADS_H],[test x"$ac_cv_header_threads_h" = x"yes"])
     38
    3639# Added to newlib pthreads for RTEMS SMP (np), may not be present
    3740AC_CHECK_HEADERS([sys/cpuset.h])
     
    4447# Explicitly list all Makefiles here
    4548AC_CONFIG_FILES([Makefile
     49spstdthreads01/Makefile
    4650spsyslock01/Makefile
    4751sptasknopreempt01/Makefile
Note: See TracChangeset for help on using the changeset viewer.