Changeset e72bc298 in rtems


Ignore:
Timestamp:
Jul 1, 2010, 3:37:48 PM (10 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
5ef1164c
Parents:
92119ed
Message:

2010-07-01 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/getegid.c, libcsupport/src/gxx_wrappers.c, libcsupport/src/issetugid.c: Formatting and spacing.
Location:
cpukit
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r92119ed re72bc298  
     12010-07-01      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * libcsupport/src/getegid.c, libcsupport/src/gxx_wrappers.c,
     4        libcsupport/src/issetugid.c: Formatting and spacing.
     5
    162010-07-01      Jennifer Averett <Jennifer.Averett@OARcorp.com>
    27
  • cpukit/libcsupport/src/getegid.c

    r92119ed re72bc298  
    1717
    1818/*
    19  * MACRO in userenv.h
    20 gid_t _POSIX_types_Egid = 0;
    21 */
    22 
    23 /*PAGE
    24  *
    2519 *  4.2.1 Get Real User, Effective User, Ral Group, and Effective Group IDs,
    2620 *        P1003.1b-1993, p. 84
  • cpukit/libcsupport/src/gxx_wrappers.c

    r92119ed re72bc298  
    11/*
    2  * RTEMS threads compatibily routines for libgcc2.
     2 *  RTEMS threads compatibility routines for libgcc2.
    33 *
    4  * by: Rosimildo da Silva ( rdasilva@connecttel.com
     4 *  by: Rosimildo da Silva (rdasilva@connecttel.com)
    55 *
    6  * Used ideas from:
     6 *  Used ideas from:
    77 *    W. Eric Norum
    88 *    Canadian Light Source
     
    1111 *    eric@cls.usask.ca
    1212 *
    13  * Eric sent some e-mail in the rtems-list as a start point for this
    14  * module implementation.
     13 *  Eric sent some e-mail in the rtems-list as a start point for this
     14 *  module implementation.
    1515 *
    16  * $Id$
     16 *  $Id$
    1717 */
    1818
     
    2626#endif
    2727
    28 /* We might not need, defined just in case */
    29 #define  __RTEMS_INSIDE__  1
    30 
    31 
    3228#include <stdlib.h>
    3329#include <stdio.h>
     
    3531#include <rtems.h>
    3632#include <rtems/system.h>
    37 #include <rtems/error.h>        /* rtems_panic */
     33#include <rtems/error.h>
    3834#include <rtems/rtems/tasks.h>
     35
     36/* uncomment this if you need to debug this interface */
     37/*#define DEBUG_GXX_WRAPPERS 1*/
    3938
    4039/*
     
    4544 */
    4645typedef struct __gthread_key_ {
    47         void *val;                 /* this is switched with the task      */
    48         void (*dtor)(void*);   /* this remains in place for all tasks */
     46  void *val;             /* this is switched with the task      */
     47  void (*dtor)(void*);   /* this remains in place for all tasks */
    4948} __gthread_key, *__gthread_key_t;
     49
    5050typedef int   __gthread_once_t;
    5151typedef void *__gthread_mutex_t;
    5252typedef void *__gthread_recursive_mutex_t;
    5353
    54 /* uncomment this if you need to debug this interface */
    55 /*#define DEBUG_GXX_WRAPPERS 1*/
    56 
    57 #ifdef DEBUG_GXX_WRAPPERS
    58 /* local function to return the ID of the calling thread */
    59 static rtems_id gxx_get_tid( void )
    60 {
    61    rtems_id id = 0;
    62    rtems_task_ident( RTEMS_SELF, 0, &id );
    63    return id;
    64 }
    65 #endif
    66 
    67 
    6854int rtems_gxx_once(__gthread_once_t *once, void (*func) (void))
    6955{
    70 #ifdef DEBUG_GXX_WRAPPERS
    71    printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );
    72 #endif
    73    if( *(volatile __gthread_once_t *)once == 0 )
    74    {
    75       rtems_mode saveMode;
    76       __gthread_once_t o;
    77       rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode);
    78       if( (o = *(volatile __gthread_once_t *)once) == 0 )
    79       {
    80          *(volatile __gthread_once_t *)once = 1;
    81       }
    82       rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode);
    83       if ( o == 0 )
    84          (*func)();
    85    }
    86    return 0;
    87 }
    88 
     56  #ifdef DEBUG_GXX_WRAPPERS
     57    printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );
     58  #endif
     59
     60  if ( *(volatile __gthread_once_t *)once == 0 ) {
     61    rtems_mode saveMode;
     62    __gthread_once_t o;
     63
     64    rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode);
     65    if ( (o = *(volatile __gthread_once_t *)once) == 0 ) {
     66      *(volatile __gthread_once_t *)once = 1;
     67    }
     68    rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode);
     69    if ( o == 0 )
     70      (*func)();
     71  }
     72  return 0;
     73}
    8974
    9075int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *))
    9176{
     77  rtems_status_code status;
     78
    9279  /* Ok, this can be a bit tricky. We are going to return a "key" as a
    9380   * pointer to the buffer that will hold the value of the key itself.
     
    9683   */
    9784   /* Do not pull your hair, trust me this works. :-) */
    98   __gthread_key_t new_key = ( __gthread_key_t )malloc( sizeof( *new_key ) );
     85  __gthread_key_t new_key = (__gthread_key_t) malloc( sizeof( *new_key ) );
    9986  *key = new_key;
    10087  new_key->val  = NULL;
    10188  new_key->dtor = dtor;
    10289
    103 #ifdef DEBUG_GXX_WRAPPERS
    104   printk( "gxx_wrappers: create key=%x, dtor=%x, new_key=%x\n", key, dtor, new_key );
    105 #endif
     90  #ifdef DEBUG_GXX_WRAPPERS
     91    printk(
     92      "gxx_wrappers: create key=%x, dtor=%x, new_key=%x\n", key, dtor, new_key
     93    );
     94  #endif
     95
    10696  /* register with RTEMS the buffer that will hold the key values */
    107   if( rtems_task_variable_add( RTEMS_SELF, (void **)new_key, dtor ) == RTEMS_SUCCESSFUL )
     97  status = rtems_task_variable_add( RTEMS_SELF, (void **)new_key, dtor );
     98  if ( status == RTEMS_SUCCESSFUL )
    10899    return 0;
    109100  return -1;
     
    112103int rtems_gxx_key_dtor (__gthread_key_t key, void *ptr)
    113104{
    114 #ifdef DEBUG_GXX_WRAPPERS
    115   printk( "gxx_wrappers: dtor key=%x, ptr=%x\n", key, ptr );
    116 #endif
    117    key->val  = 0;
    118    return 0;
     105  #ifdef DEBUG_GXX_WRAPPERS
     106    printk( "gxx_wrappers: dtor key=%x, ptr=%x\n", key, ptr );
     107  #endif
     108
     109  key->val  = 0;
     110  return 0;
    119111}
    120112
    121113int rtems_gxx_key_delete (__gthread_key_t key)
    122114{
    123 #ifdef DEBUG_GXX_WRAPPERS
    124   printk( "gxx_wrappers: delete key=%x\n", key );
    125 #endif
     115  rtems_status_code status;
     116
     117  #ifdef DEBUG_GXX_WRAPPERS
     118    printk( "gxx_wrappers: delete key=%x\n", key );
     119  #endif
     120
    126121  /* register with RTEMS the buffer that will hold the key values */
    127   if( rtems_task_variable_delete( RTEMS_SELF, (void **)key ) == RTEMS_SUCCESSFUL )
    128   {
    129      /* Hmm - hopefully all tasks using this key have gone away... */
    130      if( key ) free( (void *)key );
    131      return 0;
     122  status = rtems_task_variable_delete( RTEMS_SELF, (void **)key );
     123  if ( status == RTEMS_SUCCESSFUL ) {
     124    /* Hmm - hopefully all tasks using this key have gone away... */
     125    if ( key ) free( (void *)key );
     126    return 0;
    132127  }
    133128  return 0;
    134129}
    135130
    136 
    137131void *rtems_gxx_getspecific(__gthread_key_t key)
    138132{
    139   void *p= 0;
     133  rtems_status_code  status;
     134  void              *p= 0;
    140135
    141136  /* register with RTEMS the buffer that will hold the key values */
    142   if( rtems_task_variable_get( RTEMS_SELF, (void **)key, &p ) == RTEMS_SUCCESSFUL )
    143   {
     137  status = rtems_task_variable_get( RTEMS_SELF, (void **)key, &p );
     138  if ( status == RTEMS_SUCCESSFUL ) {
    144139    /* We do not have to do this, but what the heck ! */
    145140     p= key->val;
    146   }
    147   else
    148   {
     141  } else {
    149142    /* fisrt time, always set to zero, it is unknown the value that the others
    150143     * threads are using at the moment of this call
    151144     */
    152     if( rtems_task_variable_add( RTEMS_SELF, (void **)key, key->dtor ) != RTEMS_SUCCESSFUL )
    153     {
     145    status = rtems_task_variable_add( RTEMS_SELF, (void **)key, key->dtor );
     146    if ( status != RTEMS_SUCCESSFUL ) {
    154147       rtems_panic ("rtems_gxx_getspecific");
    155148    }
     
    157150  }
    158151
    159 #ifdef DEBUG_GXX_WRAPPERS
    160    printk( "gxx_wrappers: getspecific key=%x, ptr=%x, id=%x\n", key, p, gxx_get_tid() );
    161 #endif
    162    return p;
    163 }
    164 
     152  #ifdef DEBUG_GXX_WRAPPERS
     153    printk(
     154      "gxx_wrappers: getspecific key=%x, ptr=%x, id=%x\n",
     155       key,
     156       p,
     157       rtems_task_self()
     158    );
     159  #endif
     160  return p;
     161}
    165162
    166163int rtems_gxx_setspecific(__gthread_key_t key, const void *ptr)
    167164{
    168 #ifdef DEBUG_GXX_WRAPPERS
    169   printk( "gxx_wrappers: setspecific key=%x, ptr=%x, id=%x\n", key, ptr, gxx_get_tid() );
    170 #endif
     165  rtems_status_code status;
     166
     167  #ifdef DEBUG_GXX_WRAPPERS
     168    printk(
     169      "gxx_wrappers: setspecific key=%x, ptr=%x, id=%x\n",
     170      key,
     171      ptr,
     172      rtems_task_self()
     173      );
     174  #endif
     175
    171176  /* register with RTEMS the buffer that will hold the key values */
    172   if( rtems_task_variable_add( RTEMS_SELF, (void **)key, key->dtor ) == RTEMS_SUCCESSFUL )
    173   {
     177  status = rtems_task_variable_add( RTEMS_SELF, (void **)key, key->dtor );
     178  if ( status == RTEMS_SUCCESSFUL ) {
    174179    /* now let's set the proper value */
    175180    key->val =  (void *)ptr;
    176      return 0;
     181    return 0;
    177182  }
    178183  return -1;
     
    185190void rtems_gxx_mutex_init (__gthread_mutex_t *mutex)
    186191{
    187   rtems_status_code s;
    188 #ifdef DEBUG_GXX_WRAPPERS
    189   printk( "gxx_wrappers: mutex init =%X\n", *mutex );
    190 #endif
    191   if( (s = rtems_semaphore_create( rtems_build_name ('G', 'C', 'C', '2'),
    192                               1,
    193                              RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE
    194                              |RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
    195                              0,
    196                              (rtems_id *)mutex )) != RTEMS_SUCCESSFUL )
    197   {
    198 #ifdef DEBUG_GXX_WRAPPERS
    199       printk( "gxx_wrappers: mutex init failed %s (%d)\n", rtems_status_text(s), s );
    200 #endif
    201       rtems_panic ("rtems_gxx_mutex_init");
    202   }
    203 #ifdef DEBUG_GXX_WRAPPERS
    204   printk( "gxx_wrappers: mutex init complete =%X\n", *mutex );
    205 #endif
     192  rtems_status_code status;
     193
     194  #ifdef DEBUG_GXX_WRAPPERS
     195    printk( "gxx_wrappers: mutex init =%X\n", *mutex );
     196  #endif
     197
     198  status = rtems_semaphore_create(
     199    rtems_build_name ('G', 'C', 'C', '2'),
     200    1,
     201    RTEMS_PRIORITY|RTEMS_BINARY_SEMAPHORE|
     202      RTEMS_INHERIT_PRIORITY|RTEMS_NO_PRIORITY_CEILING|RTEMS_LOCAL,
     203    0,
     204    (rtems_id *)mutex
     205  );
     206  if ( status != RTEMS_SUCCESSFUL ) {
     207    #ifdef DEBUG_GXX_WRAPPERS
     208      printk(
     209        "gxx_wrappers: mutex init failed %s (%d)\n",
     210        rtems_status_text(status),
     211        status
     212      );
     213    #endif
     214    rtems_panic ("rtems_gxx_mutex_init");
     215  }
     216  #ifdef DEBUG_GXX_WRAPPERS
     217    printk( "gxx_wrappers: mutex init complete =%X\n", *mutex );
     218  #endif
    206219}
    207220
    208221int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex)
    209222{
    210 #ifdef DEBUG_GXX_WRAPPERS
    211   printk( "gxx_wrappers: lock mutex=%X\n", *mutex );
    212 #endif
    213   return ( rtems_semaphore_obtain( *(rtems_id *)mutex,
    214             RTEMS_WAIT, RTEMS_NO_TIMEOUT ) ==  RTEMS_SUCCESSFUL) ? 0 : -1;
     223  rtems_status_code status;
     224
     225  #ifdef DEBUG_GXX_WRAPPERS
     226    printk( "gxx_wrappers: lock mutex=%X\n", *mutex );
     227  #endif
     228
     229  status = rtems_semaphore_obtain(
     230    *(rtems_id *)mutex,
     231    RTEMS_WAIT,
     232    RTEMS_NO_TIMEOUT
     233  );
     234  if ( status == RTEMS_SUCCESSFUL )
     235    return 0;
     236  return -1;
    215237}
    216238
    217239int rtems_gxx_mutex_destroy (__gthread_mutex_t *mutex)
    218240{
    219 #ifdef DEBUG_GXX_WRAPPERS
    220   printk( "gxx_wrappers: destroy mutex=%X\n", *mutex );
    221 #endif
    222   return ( rtems_semaphore_delete(*(rtems_id *)mutex)
    223              ==  RTEMS_SUCCESSFUL) ? 0 : -1;
     241  rtems_status_code status;
     242
     243  #ifdef DEBUG_GXX_WRAPPERS
     244    printk( "gxx_wrappers: destroy mutex=%X\n", *mutex );
     245  #endif
     246
     247  status = rtems_semaphore_delete(*(rtems_id *)mutex);
     248  if ( status == RTEMS_SUCCESSFUL )
     249    return 0;
     250  return -1;
    224251}
    225252
    226253int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex)
    227254{
    228 #ifdef DEBUG_GXX_WRAPPERS
    229   printk( "gxx_wrappers: trylock mutex=%X\n", *mutex );
    230 #endif
    231   return (rtems_semaphore_obtain (*(rtems_id *)mutex,
    232                RTEMS_NO_WAIT, 0) == RTEMS_SUCCESSFUL) ? 0 : -1;
     255  rtems_status_code status;
     256
     257  #ifdef DEBUG_GXX_WRAPPERS
     258    printk( "gxx_wrappers: trylock mutex=%X\n", *mutex );
     259  #endif
     260
     261  status = rtems_semaphore_obtain (*(rtems_id *)mutex, RTEMS_NO_WAIT, 0);
     262  if ( status == RTEMS_SUCCESSFUL )
     263    return 0;
     264  return -1;
    233265}
    234266
    235267int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex)
    236268{
    237 #ifdef DEBUG_GXX_WRAPPERS
    238    printk( "gxx_wrappers: unlock mutex=%X\n", *mutex );
    239 #endif
    240   return (rtems_semaphore_release( *(rtems_id *)mutex )
    241       == RTEMS_SUCCESSFUL) ? 0 :-1;
     269  rtems_status_code status;
     270
     271  #ifdef DEBUG_GXX_WRAPPERS
     272    printk( "gxx_wrappers: unlock mutex=%X\n", *mutex );
     273  #endif
     274
     275  status = rtems_semaphore_release( *(rtems_id *)mutex );
     276  if ( status == RTEMS_SUCCESSFUL )
     277    return 0;
     278  return -1;
    242279}
    243280
  • cpukit/libcsupport/src/issetugid.c

    r92119ed re72bc298  
    11/*
    2  * Dummy version of BSD routine
     2 *  Dummy version of BSD routine
    33 *
    44 *  $Id$
     
    1010
    1111#if defined(RTEMS_NEWLIB) && !defined(HAVE_ISSETUGID)
    12 int
    13 issetugid (void)
     12int issetugid (void)
    1413{
    15         return 0;
     14  return 0;
    1615}
    1716#endif
Note: See TracChangeset for help on using the changeset viewer.