Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (21 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28dir.info
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libobjc/thr.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    4949  so it can implement the NSBecomingMultiThreaded notification.
    5050  */
    51 objc_thread_callback objc_set_thread_callback(objc_thread_callback func)
     51objc_thread_callback objc_set_thread_callback (objc_thread_callback func)
    5252{
    5353  objc_thread_callback temp = _objc_became_multi_threaded;
     
    7777
    7878static volatile void
    79 __objc_thread_detach_function(struct __objc_thread_start_state *istate)
     79__objc_thread_detach_function (struct __objc_thread_start_state *istate)
    8080{
    8181  /* Valid state? */
    8282  if (istate) {
    83     id (*imp)(id,SEL,id);
     83    id (*imp) (id, SEL, id);
    8484    SEL selector = istate->selector;
    8585    id object   = istate->object;
     
    8787
    8888    /* Don't need anymore so free it */
    89     objc_free(istate);
     89    objc_free (istate);
    9090
    9191    /* Clear out the thread local storage */
    92     objc_thread_set_data(NULL);
     92    objc_thread_set_data (NULL);
    9393
    9494    /* Check to see if we just became multi threaded */
    95     if (!__objc_is_multi_threaded)
     95    if (! __objc_is_multi_threaded)
    9696      {
    9797        __objc_is_multi_threaded = 1;
     
    9999        /* Call the hook function */
    100100        if (_objc_became_multi_threaded != NULL)
    101           (*_objc_became_multi_threaded)();
     101          (*_objc_became_multi_threaded) ();
    102102      }
    103103
    104104    /* Call the method */
    105     if ((imp = (id(*)(id, SEL, id))objc_msg_lookup(object, selector)))
    106         (*imp)(object, selector, argument);
     105    if ((imp = (id (*) (id, SEL, id))objc_msg_lookup (object, selector)))
     106        (*imp) (object, selector, argument);
    107107    else
    108       objc_error(object, OBJC_ERR_UNIMPLEMENTED,
    109                  "objc_thread_detach called with bad selector.\n");
     108      objc_error (object, OBJC_ERR_UNIMPLEMENTED,
     109                  "objc_thread_detach called with bad selector.\n");
    110110  }
    111111  else
    112     objc_error(nil, OBJC_ERR_BAD_STATE,
    113                "objc_thread_detach called with NULL state.\n");
     112    objc_error (nil, OBJC_ERR_BAD_STATE,
     113                "objc_thread_detach called with NULL state.\n");
    114114
    115115  /* Exit the thread */
    116   objc_thread_exit();
     116  objc_thread_exit ();
    117117}
    118118
     
    132132  */
    133133objc_thread_t
    134 objc_thread_detach(SEL selector, id object, id argument)
     134objc_thread_detach (SEL selector, id object, id argument)
    135135{
    136136  struct __objc_thread_start_state *istate;
     
    138138
    139139  /* Allocate the state structure */
    140   if (!(istate = (struct __objc_thread_start_state *)
    141         objc_malloc(sizeof(*istate))))
     140  if (! (istate = (struct __objc_thread_start_state *)
     141         objc_malloc (sizeof (*istate))))
    142142    return NULL;
    143143
     
    148148
    149149  /* lock access */
    150   objc_mutex_lock(__objc_runtime_mutex);
     150  objc_mutex_lock (__objc_runtime_mutex);
    151151
    152152  /* Call the backend to spawn the thread */
    153   if ((thread_id = __objc_thread_detach((void *)__objc_thread_detach_function,
    154                                         istate)) == NULL)
     153  if ((thread_id = __objc_thread_detach ((void *)__objc_thread_detach_function,
     154                                         istate)) == NULL)
    155155    {
    156156      /* failed! */
    157       objc_mutex_unlock(__objc_runtime_mutex);
    158       objc_free(istate);
     157      objc_mutex_unlock (__objc_runtime_mutex);
     158      objc_free (istate);
    159159      return NULL;
    160160    }
     
    162162  /* Increment our thread counter */
    163163  __objc_runtime_threads_alive++;
    164   objc_mutex_unlock(__objc_runtime_mutex);
     164  objc_mutex_unlock (__objc_runtime_mutex);
    165165
    166166  return thread_id;
     
    169169/* Set the current thread's priority. */
    170170int
    171 objc_thread_set_priority(int priority)
     171objc_thread_set_priority (int priority)
    172172{
    173173  /* Call the backend */
    174   return __objc_thread_set_priority(priority);
     174  return __objc_thread_set_priority (priority);
    175175}
    176176
    177177/* Return the current thread's priority. */
    178178int
    179 objc_thread_get_priority(void)
     179objc_thread_get_priority (void)
    180180{
    181181  /* Call the backend */
    182   return __objc_thread_get_priority();
     182  return __objc_thread_get_priority ();
    183183}
    184184
     
    189189  */
    190190void
    191 objc_thread_yield(void)
     191objc_thread_yield (void)
    192192{
    193193  /* Call the backend */
    194   __objc_thread_yield();
     194  __objc_thread_yield ();
    195195}
    196196
     
    200200  */
    201201int
    202 objc_thread_exit(void)
     202objc_thread_exit (void)
    203203{
    204204  /* Decrement our counter of the number of threads alive */
    205   objc_mutex_lock(__objc_runtime_mutex);
     205  objc_mutex_lock (__objc_runtime_mutex);
    206206  __objc_runtime_threads_alive--;
    207   objc_mutex_unlock(__objc_runtime_mutex);
     207  objc_mutex_unlock (__objc_runtime_mutex);
    208208
    209209  /* Call the backend to terminate the thread */
    210   return __objc_thread_exit();
     210  return __objc_thread_exit ();
    211211}
    212212
     
    216216  */
    217217objc_thread_t
    218 objc_thread_id(void)
     218objc_thread_id (void)
    219219{
    220220  /* Call the backend */
    221   return __objc_thread_id();
     221  return __objc_thread_id ();
    222222}
    223223
     
    227227  */
    228228int
    229 objc_thread_set_data(void *value)
     229objc_thread_set_data (void *value)
    230230{
    231231  /* Call the backend */
    232   return __objc_thread_set_data(value);
     232  return __objc_thread_set_data (value);
    233233}
    234234
     
    237237  */
    238238void *
    239 objc_thread_get_data(void)
     239objc_thread_get_data (void)
    240240{
    241241  /* Call the backend */
    242   return __objc_thread_get_data();
     242  return __objc_thread_get_data ();
    243243}
    244244
     
    250250  */
    251251objc_mutex_t
    252 objc_mutex_allocate(void)
     252objc_mutex_allocate (void)
    253253{
    254254  objc_mutex_t mutex;
    255255
    256256  /* Allocate the mutex structure */
    257   if (!(mutex = (objc_mutex_t)objc_malloc(sizeof(struct objc_mutex))))
     257  if (! (mutex = (objc_mutex_t)objc_malloc (sizeof (struct objc_mutex))))
    258258    return NULL;
    259259
    260260  /* Call backend to create the mutex */
    261   if (__objc_mutex_allocate(mutex))
     261  if (__objc_mutex_allocate (mutex))
    262262    {
    263263      /* failed! */
    264       objc_free(mutex);
     264      objc_free (mutex);
    265265      return NULL;
    266266    }
     
    280280  */
    281281int
    282 objc_mutex_deallocate(objc_mutex_t mutex)
     282objc_mutex_deallocate (objc_mutex_t mutex)
    283283{
    284284  int depth;
    285285
    286286  /* Valid mutex? */
    287   if (!mutex)
     287  if (! mutex)
    288288    return -1;
    289289
    290290  /* Acquire lock on mutex */
    291   depth = objc_mutex_lock(mutex);
     291  depth = objc_mutex_lock (mutex);
    292292
    293293  /* Call backend to destroy mutex */
    294   if (__objc_mutex_deallocate(mutex))
     294  if (__objc_mutex_deallocate (mutex))
    295295    return -1;
    296296
    297297  /* Free the mutex structure */
    298   objc_free(mutex);
     298  objc_free (mutex);
    299299
    300300  /* Return last depth */
     
    309309  */
    310310int
    311 objc_mutex_lock(objc_mutex_t mutex)
     311objc_mutex_lock (objc_mutex_t mutex)
    312312{
    313313  objc_thread_t thread_id;
     
    315315
    316316  /* Valid mutex? */
    317   if (!mutex)
     317  if (! mutex)
    318318    return -1;
    319319
    320320  /* If we already own the lock then increment depth */
    321   thread_id = __objc_thread_id();
     321  thread_id = __objc_thread_id ();
    322322  if (mutex->owner == thread_id)
    323323    return ++mutex->depth;
    324324
    325325  /* Call the backend to lock the mutex */
    326   status = __objc_mutex_lock(mutex);
     326  status = __objc_mutex_lock (mutex);
    327327
    328328  /* Failed? */
     
    341341  */
    342342int
    343 objc_mutex_trylock(objc_mutex_t mutex)
     343objc_mutex_trylock (objc_mutex_t mutex)
    344344{
    345345  objc_thread_t thread_id;
     
    347347
    348348  /* Valid mutex? */
    349   if (!mutex)
     349  if (! mutex)
    350350    return -1;
    351351
    352352  /* If we already own the lock then increment depth */
    353   thread_id = __objc_thread_id();
     353  thread_id = __objc_thread_id ();
    354354  if (mutex->owner == thread_id)
    355355    return ++mutex->depth;
    356356   
    357357  /* Call the backend to try to lock the mutex */
    358   status = __objc_mutex_trylock(mutex);
     358  status = __objc_mutex_trylock (mutex);
    359359
    360360  /* Failed? */
     
    376376  */
    377377int
    378 objc_mutex_unlock(objc_mutex_t mutex)
     378objc_mutex_unlock (objc_mutex_t mutex)
    379379{
    380380  objc_thread_t thread_id;
     
    382382
    383383  /* Valid mutex? */
    384   if (!mutex)
     384  if (! mutex)
    385385    return -1;
    386386
    387387  /* If another thread owns the lock then abort */
    388   thread_id = __objc_thread_id();
     388  thread_id = __objc_thread_id ();
    389389  if (mutex->owner != thread_id)
    390390    return -1;
     
    399399
    400400  /* Have the backend unlock the mutex */
    401   status = __objc_mutex_unlock(mutex);
     401  status = __objc_mutex_unlock (mutex);
    402402
    403403  /* Failed? */
     
    415415  */
    416416objc_condition_t
    417 objc_condition_allocate(void)
     417objc_condition_allocate (void)
    418418{
    419419  objc_condition_t condition;
    420420   
    421421  /* Allocate the condition mutex structure */
    422   if (!(condition =
    423         (objc_condition_t)objc_malloc(sizeof(struct objc_condition))))
     422  if (! (condition =
     423         (objc_condition_t) objc_malloc (sizeof (struct objc_condition))))
    424424    return NULL;
    425425
    426426  /* Call the backend to create the condition mutex */
    427   if (__objc_condition_allocate(condition))
     427  if (__objc_condition_allocate (condition))
    428428    {
    429429      /* failed! */
    430       objc_free(condition);
     430      objc_free (condition);
    431431      return NULL;
    432432    }
     
    444444  */
    445445int
    446 objc_condition_deallocate(objc_condition_t condition)
     446objc_condition_deallocate (objc_condition_t condition)
    447447{
    448448  /* Broadcast the condition */
    449   if (objc_condition_broadcast(condition))
     449  if (objc_condition_broadcast (condition))
    450450    return -1;
    451451
    452452  /* Call the backend to destroy */
    453   if (__objc_condition_deallocate(condition))
     453  if (__objc_condition_deallocate (condition))
    454454    return -1;
    455455
    456456  /* Free the condition mutex structure */
    457   objc_free(condition);
     457  objc_free (condition);
    458458
    459459  return 0;
     
    461461
    462462/*
    463   Wait on the condition unlocking the mutex until objc_condition_signal()
    464   or objc_condition_broadcast() are called for the same condition. The
     463  Wait on the condition unlocking the mutex until objc_condition_signal ()
     464  or objc_condition_broadcast () are called for the same condition. The
    465465  given mutex *must* have the depth set to 1 so that it can be unlocked
    466466  here, so that someone else can lock it and signal/broadcast the condition.
     
    469469  */
    470470int
    471 objc_condition_wait(objc_condition_t condition, objc_mutex_t mutex)
     471objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex)
    472472{
    473473  objc_thread_t thread_id;
    474474
    475475  /* Valid arguments? */
    476   if (!mutex || !condition)
     476  if (! mutex || ! condition)
    477477    return -1;
    478478
    479479  /* Make sure we are owner of mutex */
    480   thread_id = __objc_thread_id();
     480  thread_id = __objc_thread_id ();
    481481  if (mutex->owner != thread_id)
    482482    return -1;
     
    491491
    492492  /* Call the backend to wait */
    493   __objc_condition_wait(condition, mutex);
     493  __objc_condition_wait (condition, mutex);
    494494
    495495  /* Make ourselves owner of the mutex */
     
    507507  */
    508508int
    509 objc_condition_broadcast(objc_condition_t condition)
     509objc_condition_broadcast (objc_condition_t condition)
    510510{
    511511  /* Valid condition mutex? */
    512   if (!condition)
    513     return -1;
    514 
    515   return __objc_condition_broadcast(condition);
     512  if (! condition)
     513    return -1;
     514
     515  return __objc_condition_broadcast (condition);
    516516}
    517517
     
    523523  */
    524524int
    525 objc_condition_signal(objc_condition_t condition)
     525objc_condition_signal (objc_condition_t condition)
    526526{
    527527  /* Valid condition mutex? */
    528   if (!condition)
    529     return -1;
    530 
    531   return __objc_condition_signal(condition);
     528  if (! condition)
     529    return -1;
     530
     531  return __objc_condition_signal (condition);
    532532}
    533533
     
    536536   from now on.  This is used when you are interfacing with some
    537537   external non-objc-based environment/system - you must call
    538    objc_thread_add() before an alien thread makes any calls to
     538   objc_thread_add () before an alien thread makes any calls to
    539539   Objective-C.  Do not cause the _objc_became_multi_threaded hook to
    540540   be executed. */
    541541void
    542 objc_thread_add(void)
    543 {
    544   objc_mutex_lock(__objc_runtime_mutex);
     542objc_thread_add (void)
     543{
     544  objc_mutex_lock (__objc_runtime_mutex);
    545545  __objc_is_multi_threaded = 1;
    546546  __objc_runtime_threads_alive++;
    547   objc_mutex_unlock(__objc_runtime_mutex); 
     547  objc_mutex_unlock (__objc_runtime_mutex); 
    548548}
    549549
     
    551551   stopped) by some external code will no longer access objc and thus
    552552   can be forgotten by the objc thread system.  Call
    553    objc_thread_remove() when your alien thread is done with making
     553   objc_thread_remove () when your alien thread is done with making
    554554   calls to Objective-C. */
    555555void
    556 objc_thread_remove(void)
    557 {
    558   objc_mutex_lock(__objc_runtime_mutex);
     556objc_thread_remove (void)
     557{
     558  objc_mutex_lock (__objc_runtime_mutex);
    559559  __objc_runtime_threads_alive--;
    560   objc_mutex_unlock(__objc_runtime_mutex); 
     560  objc_mutex_unlock (__objc_runtime_mutex); 
    561561}
    562562
Note: See TracChangeset for help on using the changeset viewer.