Unfortunately I just found that we still cannot build in thread safety
mode on Windows, due to an error on my part - specifically, I
concentrated on libpq, not realising that ecpglib is also thread aware.

It seems that ecpglib uses far more of pthreads than libpq does, so our
mini implementation used in libpq just won't cut it. I've bitten the
bullet (well, more of a jelly bean actually) and started rewriting
things to use the official win32 pthreads library, however I ran into an
error that I'm not sure about:

make[3]: Entering directory `/cvs/pgsql/src/interfaces/libpq'
gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wold-style-definition -Wendif-labels
-fno-strict-aliasing -D_REENTRANT -D_THREAD_SAFE
-D_POSIX_PTHREAD_SEMANTICS  -DFRONTEND -I. -I../../../src/include
-I./src/include/port/win32 -DEXEC_BACKEND
"-I../../../src/include/port/win32" -I../../../src/port  -c -o
fe-secure.o fe-secure.c
fe-secure.c: In function `pq_threadidcallback':
fe-secure.c:879: error: aggregate value used where an integer was
expected

Which relates to:

static unsigned long
pq_threadidcallback(void)
{
    return (unsigned long) pthread_self();
}

In pthread.h we have:

typedef struct {
    void * p;                   /* Pointer to actual object */
    unsigned int x;             /* Extra information - reuse count etc
*/
} ptw32_handle_t;

typedef ptw32_handle_t pthread_t;

PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void);

Is it enough just to pass p back on Windows? - eg:

static unsigned long
pq_threadidcallback(void)
{
#ifdef WIN32
        return (unsigned long) pthread_self().p;
#else
        return (unsigned long) pthread_self();
#endif
}

Everything builds OK with this change - I'm just not sure if it's right.

Regards, Dave

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to