diff --git a/ChangeLog b/ChangeLog index 2af7bf86..b8f37842 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2005-10-18 Federico Di Gregorio + * psycopg/config.h: ZETA config.h patch from Charlie Clark. + * examples/threads.py: fixed small typo: psycopg -> psycopg2. * Big cleanup of unsigned chars to tame gcc 4. diff --git a/psycopg/config.h b/psycopg/config.h index bed70419..f222fd90 100644 --- a/psycopg/config.h +++ b/psycopg/config.h @@ -48,10 +48,10 @@ static void Dprintf(const char *fmt, ...) {} #endif #endif -/* win32 specific stuff */ -#ifndef _WIN32 -#include -#else +/* pthreads work-arounds for mutilated operating systems */ +#if defined(_WIN32) || defined(__BEOS__) + +#ifdef _WIN32 #include #define pthread_mutex_t HANDLE #define pthread_condvar_t HANDLE @@ -64,8 +64,30 @@ static int pthread_mutex_init(pthread_mutex_t *mutex, void* fake) *mutex = CreateMutex(NULL, FALSE, NULL); return 0; } +#endif /* _WIN32 */ + +#ifdef __BEOS__ +#include +#define pthread_mutex_t sem_id +#define pthread_mutex_lock(object) acquire_sem(object) +#define pthread_mutex_unlock(object) release_sem(object) +#define pthread_mutex_destroy(ref) delete_sem(*ref) +static int pthread_mutex_init(pthread_mutex_t *mutex, void* fake) +{ + *mutex = create_sem(1, "psycopg_mutex"); + if (*mutex < B_OK) + return *mutex; + return 0; +} +#endif /* __BEOS__ */ + +#else /* pthread is available */ +#include +#endif + /* to work around the fact that Windows does not have a gmtime_r function, or a proper gmtime function */ +#ifdef _WIN32 static struct tm *gmtime_r(time_t *t, struct tm *tm) { tm = gmtime(t); diff --git a/psycopg/typecast.c b/psycopg/typecast.c index 1bb3da38..19bcf1f0 100644 --- a/psycopg/typecast.c +++ b/psycopg/typecast.c @@ -221,7 +221,7 @@ typecast_coerce(PyObject **pv, PyObject **pw) return 0; } } - PyErr_SetString(PyExc_TypeError, "psycopg type coercion failed"); + PyErr_SetString(PyExc_TypeError, "type coercion failed"); return -1; }