Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Python/thread_cthread.h

    r2 r391  
    1515{
    1616#ifndef HURD_C_THREADS
    17         /* Roland McGrath said this should not be used since this is
    18         done while linking to threads */
    19         cthread_init();
     17    /* Roland McGrath said this should not be used since this is
     18    done while linking to threads */
     19    cthread_init();
    2020#else
    2121/* do nothing */
    22         ;
     22    ;
    2323#endif
    2424}
     
    3030PyThread_start_new_thread(void (*func)(void *), void *arg)
    3131{
    32         int success = 0;        /* init not needed when SOLARIS_THREADS and */
    33                                 /* C_THREADS implemented properly */
     32    int success = 0;            /* init not needed when SOLARIS_THREADS and */
     33                /* C_THREADS implemented properly */
    3434
    35         dprintf(("PyThread_start_new_thread called\n"));
    36         if (!initialized)
    37                 PyThread_init_thread();
    38         /* looks like solaris detaches the thread to never rejoin
    39         * so well do it here
    40         */
    41         cthread_detach(cthread_fork((cthread_fn_t) func, arg));
    42         return success < 0 ? -1 : 0;
     35    dprintf(("PyThread_start_new_thread called\n"));
     36    if (!initialized)
     37        PyThread_init_thread();
     38    /* looks like solaris detaches the thread to never rejoin
     39    * so well do it here
     40    */
     41    cthread_detach(cthread_fork((cthread_fn_t) func, arg));
     42    return success < 0 ? -1 : 0;
    4343}
    4444
     
    4646PyThread_get_thread_ident(void)
    4747{
    48         if (!initialized)
    49                 PyThread_init_thread();
    50         return (long) cthread_self();
    51 }
    52 
    53 static void
    54 do_PyThread_exit_thread(int no_cleanup)
    55 {
    56         dprintf(("PyThread_exit_thread called\n"));
    57         if (!initialized)
    58                 if (no_cleanup)
    59                         _exit(0);
    60                 else
    61                         exit(0);
    62         cthread_exit(0);
     48    if (!initialized)
     49        PyThread_init_thread();
     50    return (long) cthread_self();
    6351}
    6452
     
    6654PyThread_exit_thread(void)
    6755{
    68         do_PyThread_exit_thread(0);
     56    dprintf(("PyThread_exit_thread called\n"));
     57    if (!initialized)
     58        exit(0);
     59    cthread_exit(0);
    6960}
    70 
    71 void
    72 PyThread__exit_thread(void)
    73 {
    74         do_PyThread_exit_thread(1);
    75 }
    76 
    77 #ifndef NO_EXIT_PROG
    78 static
    79 void do_PyThread_exit_prog(int status, int no_cleanup)
    80 {
    81         dprintf(("PyThread_exit_prog(%d) called\n", status));
    82         if (!initialized)
    83                 if (no_cleanup)
    84                         _exit(status);
    85                 else
    86                         exit(status);
    87         if (no_cleanup)
    88                 _exit(status);
    89         else
    90                 exit(status);
    91 }
    92 
    93 void
    94 PyThread_exit_prog(int status)
    95 {
    96         do_PyThread_exit_prog(status, 0);
    97 }
    98 
    99 void
    100 PyThread__exit_prog(int status)
    101 {
    102         do_PyThread_exit_prog(status, 1);
    103 }
    104 #endif /* NO_EXIT_PROG */
    10561
    10662/*
     
    11066PyThread_allocate_lock(void)
    11167{
    112         mutex_t lock;
     68    mutex_t lock;
    11369
    114         dprintf(("PyThread_allocate_lock called\n"));
    115         if (!initialized)
    116                 PyThread_init_thread();
     70    dprintf(("PyThread_allocate_lock called\n"));
     71    if (!initialized)
     72        PyThread_init_thread();
    11773
    118         lock = mutex_alloc();
    119         if (mutex_init(lock)) {
    120                 perror("mutex_init");
    121                 free((void *) lock);
    122                 lock = 0;
    123         }
    124         dprintf(("PyThread_allocate_lock() -> %p\n", lock));
    125         return (PyThread_type_lock) lock;
     74    lock = mutex_alloc();
     75    if (mutex_init(lock)) {
     76        perror("mutex_init");
     77        free((void *) lock);
     78        lock = 0;
     79    }
     80    dprintf(("PyThread_allocate_lock() -> %p\n", lock));
     81    return (PyThread_type_lock) lock;
    12682}
    12783
     
    12985PyThread_free_lock(PyThread_type_lock lock)
    13086{
    131         dprintf(("PyThread_free_lock(%p) called\n", lock));
    132         mutex_free(lock);
     87    dprintf(("PyThread_free_lock(%p) called\n", lock));
     88    mutex_free(lock);
    13389}
    13490
     
    13692PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
    13793{
    138         int success = FALSE;
     94    int success = FALSE;
    13995
    140         dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
    141         if (waitflag) {         /* blocking */
    142                 mutex_lock((mutex_t)lock);
    143                 success = TRUE;
    144         } else {                /* non blocking */
    145                 success = mutex_try_lock((mutex_t)lock);
    146         }
    147         dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
    148         return success;
     96    dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
     97    if (waitflag) {             /* blocking */
     98        mutex_lock((mutex_t)lock);
     99        success = TRUE;
     100    } else {                    /* non blocking */
     101        success = mutex_try_lock((mutex_t)lock);
     102    }
     103    dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
     104    return success;
    149105}
    150106
     
    152108PyThread_release_lock(PyThread_type_lock lock)
    153109{
    154         dprintf(("PyThread_release_lock(%p) called\n", lock));
    155         mutex_unlock((mutex_t )lock);
     110    dprintf(("PyThread_release_lock(%p) called\n", lock));
     111    mutex_unlock((mutex_t )lock);
    156112}
Note: See TracChangeset for help on using the changeset viewer.