/* Copyright (c) 1999 Ng Pheng Siong. All rights reserved. */ /* $Id: _threads.i 393 2006-03-31 22:11:55Z heikki $ */ %{ #include #include #ifdef THREADING static PyThread_type_lock lock_cs[CRYPTO_NUM_LOCKS]; static long lock_count[CRYPTO_NUM_LOCKS]; static int thread_mode = 0; #endif void threading_locking_callback(int mode, int type, const char *file, int line) { #ifdef THREADING if (mode & CRYPTO_LOCK) { PyThread_acquire_lock(lock_cs[type], 0); lock_count[type]++; } else { PyThread_release_lock(lock_cs[type]); lock_count[type]--; } #endif } unsigned long threading_id_callback(void) { #ifdef THREADING return (unsigned long)PyThread_get_thread_ident(); #else return (unsigned long)0; #endif } %} %inline %{ void threading_init(void) { #ifdef THREADING int i; thread_mode = 1; /*PyThread_init_thread();*/ for (i=0; i