mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
clean up function declarations to conform to PEP-7 style.
This commit is contained in:
parent
6539d2d3c7
commit
63f0db682e
3 changed files with 44 additions and 22 deletions
|
@ -75,7 +75,8 @@ static int initialized;
|
||||||
|
|
||||||
static void PyThread__init_thread(void); /* Forward */
|
static void PyThread__init_thread(void); /* Forward */
|
||||||
|
|
||||||
void PyThread_init_thread(void)
|
void
|
||||||
|
PyThread_init_thread(void)
|
||||||
{
|
{
|
||||||
#ifdef Py_DEBUG
|
#ifdef Py_DEBUG
|
||||||
char *p = getenv("THREADDEBUG");
|
char *p = getenv("THREADDEBUG");
|
||||||
|
|
|
@ -16,7 +16,8 @@ typedef struct NRMUTEX {
|
||||||
typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ;
|
typedef PVOID WINAPI interlocked_cmp_xchg_t(PVOID *dest, PVOID exc, PVOID comperand) ;
|
||||||
|
|
||||||
/* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */
|
/* Sorry mate, but we haven't got InterlockedCompareExchange in Win95! */
|
||||||
static PVOID WINAPI interlocked_cmp_xchg(PVOID *dest, PVOID exc, PVOID comperand)
|
static PVOID WINAPI
|
||||||
|
interlocked_cmp_xchg(PVOID *dest, PVOID exc, PVOID comperand)
|
||||||
{
|
{
|
||||||
static LONG spinlock = 0 ;
|
static LONG spinlock = 0 ;
|
||||||
PVOID result ;
|
PVOID result ;
|
||||||
|
@ -54,8 +55,10 @@ static PVOID WINAPI interlocked_cmp_xchg(PVOID *dest, PVOID exc, PVOID comperand
|
||||||
return result ;
|
return result ;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
static interlocked_cmp_xchg_t *ixchg ;
|
static interlocked_cmp_xchg_t *ixchg;
|
||||||
BOOL InitializeNonRecursiveMutex(PNRMUTEX mutex)
|
|
||||||
|
BOOL
|
||||||
|
InitializeNonRecursiveMutex(PNRMUTEX mutex)
|
||||||
{
|
{
|
||||||
if (!ixchg)
|
if (!ixchg)
|
||||||
{
|
{
|
||||||
|
@ -76,14 +79,16 @@ BOOL InitializeNonRecursiveMutex(PNRMUTEX mutex)
|
||||||
#endif
|
#endif
|
||||||
#define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand)))
|
#define InterlockedCompareExchange(dest,exchange,comperand) (ixchg((dest), (exchange), (comperand)))
|
||||||
|
|
||||||
VOID DeleteNonRecursiveMutex(PNRMUTEX mutex)
|
VOID
|
||||||
|
DeleteNonRecursiveMutex(PNRMUTEX mutex)
|
||||||
{
|
{
|
||||||
/* No in-use check */
|
/* No in-use check */
|
||||||
CloseHandle(mutex->hevent) ;
|
CloseHandle(mutex->hevent) ;
|
||||||
mutex->hevent = NULL ; /* Just in case */
|
mutex->hevent = NULL ; /* Just in case */
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait)
|
DWORD
|
||||||
|
EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait)
|
||||||
{
|
{
|
||||||
/* Assume that the thread waits successfully */
|
/* Assume that the thread waits successfully */
|
||||||
DWORD ret ;
|
DWORD ret ;
|
||||||
|
@ -104,7 +109,8 @@ DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait)
|
||||||
return ret ;
|
return ret ;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL LeaveNonRecursiveMutex(PNRMUTEX mutex)
|
BOOL
|
||||||
|
LeaveNonRecursiveMutex(PNRMUTEX mutex)
|
||||||
{
|
{
|
||||||
/* We don't own the mutex */
|
/* We don't own the mutex */
|
||||||
mutex->thread_id = 0 ;
|
mutex->thread_id = 0 ;
|
||||||
|
@ -113,7 +119,8 @@ BOOL LeaveNonRecursiveMutex(PNRMUTEX mutex)
|
||||||
SetEvent(mutex->hevent) ; /* Other threads are waiting, wake one on them up */
|
SetEvent(mutex->hevent) ; /* Other threads are waiting, wake one on them up */
|
||||||
}
|
}
|
||||||
|
|
||||||
PNRMUTEX AllocNonRecursiveMutex(void)
|
PNRMUTEX
|
||||||
|
AllocNonRecursiveMutex(void)
|
||||||
{
|
{
|
||||||
PNRMUTEX mutex = (PNRMUTEX)malloc(sizeof(NRMUTEX)) ;
|
PNRMUTEX mutex = (PNRMUTEX)malloc(sizeof(NRMUTEX)) ;
|
||||||
if (mutex && !InitializeNonRecursiveMutex(mutex))
|
if (mutex && !InitializeNonRecursiveMutex(mutex))
|
||||||
|
@ -124,7 +131,8 @@ PNRMUTEX AllocNonRecursiveMutex(void)
|
||||||
return mutex ;
|
return mutex ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeNonRecursiveMutex(PNRMUTEX mutex)
|
void
|
||||||
|
FreeNonRecursiveMutex(PNRMUTEX mutex)
|
||||||
{
|
{
|
||||||
if (mutex)
|
if (mutex)
|
||||||
{
|
{
|
||||||
|
@ -138,7 +146,8 @@ long PyThread_get_thread_ident(void);
|
||||||
/*
|
/*
|
||||||
* Initialization of the C package, should not be needed.
|
* Initialization of the C package, should not be needed.
|
||||||
*/
|
*/
|
||||||
static void PyThread__init_thread(void)
|
static void
|
||||||
|
PyThread__init_thread(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +218,8 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
|
||||||
* Return the thread Id instead of an handle. The Id is said to uniquely identify the
|
* Return the thread Id instead of an handle. The Id is said to uniquely identify the
|
||||||
* thread in the system
|
* thread in the system
|
||||||
*/
|
*/
|
||||||
long PyThread_get_thread_ident(void)
|
long
|
||||||
|
PyThread_get_thread_ident(void)
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
PyThread_init_thread();
|
PyThread_init_thread();
|
||||||
|
@ -217,7 +227,8 @@ long PyThread_get_thread_ident(void)
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_PyThread_exit_thread(int no_cleanup)
|
static void
|
||||||
|
do_PyThread_exit_thread(int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
|
dprintf(("%ld: PyThread_exit_thread called\n", PyThread_get_thread_ident()));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
|
@ -228,18 +239,21 @@ static void do_PyThread_exit_thread(int no_cleanup)
|
||||||
_endthread();
|
_endthread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_exit_thread(void)
|
void
|
||||||
|
PyThread_exit_thread(void)
|
||||||
{
|
{
|
||||||
do_PyThread_exit_thread(0);
|
do_PyThread_exit_thread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread__exit_thread(void)
|
void
|
||||||
|
PyThread__exit_thread(void)
|
||||||
{
|
{
|
||||||
do_PyThread_exit_thread(1);
|
do_PyThread_exit_thread(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_EXIT_PROG
|
#ifndef NO_EXIT_PROG
|
||||||
static void do_PyThread_exit_prog(int status, int no_cleanup)
|
static void
|
||||||
|
do_PyThread_exit_prog(int status, int no_cleanup)
|
||||||
{
|
{
|
||||||
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
dprintf(("PyThread_exit_prog(%d) called\n", status));
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
|
@ -249,12 +263,14 @@ static void do_PyThread_exit_prog(int status, int no_cleanup)
|
||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_exit_prog(int status)
|
void
|
||||||
|
PyThread_exit_prog(int status)
|
||||||
{
|
{
|
||||||
do_PyThread_exit_prog(status, 0);
|
do_PyThread_exit_prog(status, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread__exit_prog(int status)
|
void
|
||||||
|
PyThread__exit_prog(int status)
|
||||||
{
|
{
|
||||||
do_PyThread_exit_prog(status, 1);
|
do_PyThread_exit_prog(status, 1);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +281,8 @@ void PyThread__exit_prog(int status)
|
||||||
* I [Dag] tried to implement it with mutex but I could find a way to
|
* I [Dag] tried to implement it with mutex but I could find a way to
|
||||||
* tell whether a thread already own the lock or not.
|
* tell whether a thread already own the lock or not.
|
||||||
*/
|
*/
|
||||||
PyThread_type_lock PyThread_allocate_lock(void)
|
PyThread_type_lock
|
||||||
|
PyThread_allocate_lock(void)
|
||||||
{
|
{
|
||||||
PNRMUTEX aLock;
|
PNRMUTEX aLock;
|
||||||
|
|
||||||
|
@ -280,7 +297,8 @@ PyThread_type_lock PyThread_allocate_lock(void)
|
||||||
return (PyThread_type_lock) aLock;
|
return (PyThread_type_lock) aLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_free_lock(PyThread_type_lock aLock)
|
void
|
||||||
|
PyThread_free_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
|
dprintf(("%ld: PyThread_free_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
|
||||||
|
|
||||||
|
@ -293,7 +311,8 @@ void PyThread_free_lock(PyThread_type_lock aLock)
|
||||||
* and 0 if the lock was not acquired. This means a 0 is returned
|
* and 0 if the lock was not acquired. This means a 0 is returned
|
||||||
* if the lock has already been acquired by this thread!
|
* if the lock has already been acquired by this thread!
|
||||||
*/
|
*/
|
||||||
int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
int
|
||||||
|
PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
||||||
{
|
{
|
||||||
int success ;
|
int success ;
|
||||||
|
|
||||||
|
@ -306,7 +325,8 @@ int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_release_lock(PyThread_type_lock aLock)
|
void
|
||||||
|
PyThread_release_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
|
dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,8 @@ PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PyThread_release_lock(PyThread_type_lock aLock)
|
void
|
||||||
|
PyThread_release_lock(PyThread_type_lock aLock)
|
||||||
{
|
{
|
||||||
#if !defined(PYCC_GCC)
|
#if !defined(PYCC_GCC)
|
||||||
type_os2_lock lock = (type_os2_lock)aLock;
|
type_os2_lock lock = (type_os2_lock)aLock;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue