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_solaris.h

    r2 r391  
    1818 */
    1919struct func_arg {
    20         void (*func)(void *);
    21         void *arg;
     20    void (*func)(void *);
     21    void *arg;
    2222};
    2323
     
    2525new_func(void *funcarg)
    2626{
    27         void (*func)(void *);
    28         void *arg;
     27    void (*func)(void *);
     28    void *arg;
    2929
    30         func = ((struct func_arg *) funcarg)->func;
    31         arg = ((struct func_arg *) funcarg)->arg;
    32         free(funcarg);
    33         (*func)(arg);
    34         return 0;
     30    func = ((struct func_arg *) funcarg)->func;
     31    arg = ((struct func_arg *) funcarg)->arg;
     32    free(funcarg);
     33    (*func)(arg);
     34    return 0;
    3535}
    3636
     
    3939PyThread_start_new_thread(void (*func)(void *), void *arg)
    4040{
    41         thread_t tid;
    42         struct func_arg *funcarg;
     41    thread_t tid;
     42    struct func_arg *funcarg;
    4343
    44         dprintf(("PyThread_start_new_thread called\n"));
    45         if (!initialized)
    46                 PyThread_init_thread();
    47         funcarg = (struct func_arg *) malloc(sizeof(struct func_arg));
    48         funcarg->func = func;
    49         funcarg->arg = arg;
    50         if (thr_create(0, 0, new_func, funcarg,
    51                        THR_DETACHED | THR_NEW_LWP, &tid)) {
    52                 perror("thr_create");
    53                 free((void *) funcarg);
    54                 return -1;
    55         }
    56         return tid;
     44    dprintf(("PyThread_start_new_thread called\n"));
     45    if (!initialized)
     46        PyThread_init_thread();
     47    funcarg = (struct func_arg *) malloc(sizeof(struct func_arg));
     48    funcarg->func = func;
     49    funcarg->arg = arg;
     50    if (thr_create(0, 0, new_func, funcarg,
     51                   THR_DETACHED | THR_NEW_LWP, &tid)) {
     52        perror("thr_create");
     53        free((void *) funcarg);
     54        return -1;
     55    }
     56    return tid;
    5757}
    5858
     
    6060PyThread_get_thread_ident(void)
    6161{
    62         if (!initialized)
    63                 PyThread_init_thread();
    64         return thr_self();
     62    if (!initialized)
     63        PyThread_init_thread();
     64    return thr_self();
    6565}
    6666
    67 static void
    68 do_PyThread_exit_thread(int no_cleanup)
    69 {
    70         dprintf(("PyThread_exit_thread called\n"));
    71         if (!initialized)
    72                 if (no_cleanup)
    73                         _exit(0);
    74                 else
    75                         exit(0);
    76         thr_exit(0);
    77 }
    78 
    79 void
     67void
    8068PyThread_exit_thread(void)
    8169{
    82         do_PyThread_exit_thread(0);
     70    dprintf(("PyThread_exit_thread called\n"));
     71    if (!initialized)
     72        exit(0);
     73    thr_exit(0);
    8374}
    84 
    85 void
    86 PyThread__exit_thread(void)
    87 {
    88         do_PyThread_exit_thread(1);
    89 }
    90 
    91 #ifndef NO_EXIT_PROG
    92 static void
    93 do_PyThread_exit_prog(int status, int no_cleanup)
    94 {
    95         dprintf(("PyThread_exit_prog(%d) called\n", status));
    96         if (!initialized)
    97                 if (no_cleanup)
    98                         _exit(status);
    99                 else
    100                         exit(status);
    101         if (no_cleanup)
    102                 _exit(status);
    103         else
    104                 exit(status);
    105 }
    106 
    107 void
    108 PyThread_exit_prog(int status)
    109 {
    110         do_PyThread_exit_prog(status, 0);
    111 }
    112 
    113 void
    114 PyThread__exit_prog(int status)
    115 {
    116         do_PyThread_exit_prog(status, 1);
    117 }
    118 #endif /* NO_EXIT_PROG */
    11975
    12076/*
    12177 * Lock support.
    12278 */
    123 PyThread_type_lock 
     79PyThread_type_lock
    12480PyThread_allocate_lock(void)
    12581{
    126         mutex_t *lock;
     82    mutex_t *lock;
    12783
    128         dprintf(("PyThread_allocate_lock called\n"));
    129         if (!initialized)
    130                 PyThread_init_thread();
     84    dprintf(("PyThread_allocate_lock called\n"));
     85    if (!initialized)
     86        PyThread_init_thread();
    13187
    132         lock = (mutex_t *) malloc(sizeof(mutex_t));
    133         if (mutex_init(lock, USYNC_THREAD, 0)) {
    134                 perror("mutex_init");
    135                 free((void *) lock);
    136                 lock = 0;
    137         }
    138         dprintf(("PyThread_allocate_lock() -> %p\n", lock));
    139         return (PyThread_type_lock) lock;
     88    lock = (mutex_t *) malloc(sizeof(mutex_t));
     89    if (mutex_init(lock, USYNC_THREAD, 0)) {
     90        perror("mutex_init");
     91        free((void *) lock);
     92        lock = 0;
     93    }
     94    dprintf(("PyThread_allocate_lock() -> %p\n", lock));
     95    return (PyThread_type_lock) lock;
    14096}
    14197
    142 void 
     98void
    14399PyThread_free_lock(PyThread_type_lock lock)
    144100{
    145         dprintf(("PyThread_free_lock(%p) called\n", lock));
    146         mutex_destroy((mutex_t *) lock);
    147         free((void *) lock);
     101    dprintf(("PyThread_free_lock(%p) called\n", lock));
     102    mutex_destroy((mutex_t *) lock);
     103    free((void *) lock);
    148104}
    149105
    150 int 
     106int
    151107PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
    152108{
    153         int success;
     109    int success;
    154110
    155         dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
    156         if (waitflag)
    157                 success = mutex_lock((mutex_t *) lock);
    158         else
    159                 success = mutex_trylock((mutex_t *) lock);
    160         if (success < 0)
    161                 perror(waitflag ? "mutex_lock" : "mutex_trylock");
    162         else
    163                 success = !success; /* solaris does it the other way round */
    164         dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
    165         return success;
     111    dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag));
     112    if (waitflag)
     113        success = mutex_lock((mutex_t *) lock);
     114    else
     115        success = mutex_trylock((mutex_t *) lock);
     116    if (success < 0)
     117        perror(waitflag ? "mutex_lock" : "mutex_trylock");
     118    else
     119        success = !success; /* solaris does it the other way round */
     120    dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success));
     121    return success;
    166122}
    167123
    168 void 
     124void
    169125PyThread_release_lock(PyThread_type_lock lock)
    170126{
    171         dprintf(("PyThread_release_lock(%p) called\n", lock));
    172         if (mutex_unlock((mutex_t *) lock))
    173                 perror("mutex_unlock");
     127    dprintf(("PyThread_release_lock(%p) called\n", lock));
     128    if (mutex_unlock((mutex_t *) lock))
     129        perror("mutex_unlock");
    174130}
Note: See TracChangeset for help on using the changeset viewer.