develooper Front page | perl.perl5.porters | Postings from March 2006

THREAD_RET_TYPE definition

From:
Jerry D. Hedden
Date:
March 23, 2006 08:03
Subject:
THREAD_RET_TYPE definition
Message ID:
20060323090346.fb30e530d17747c2b054d625b8945d88.2cf80825d5.wbe@email.email.secureserver.net
While building the threads module under WIN32, the compiler output the
following:

threads.xs:572: warning: passing arg 3 of `CreateThread' from
incompatible pointer type

Looking in winbase.h, I found the following prototype for CreateThreads:

    WINBASEAPI HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES,
                                          DWORD,
                                          LPTHREAD_START_ROUTINE,
                                          PVOID,
                                          DWORD,
                                          PDWORD);

The 3rd arg (LPTHREAD_START_ROUTINE) is defined as:

    typedef DWORD (WINAPI *LPTHREAD_START_ROUTINE)(LPVOID);

Now, looking in threads.xs, the 3rd arg to CreateThreads is the
Perl_ithread_run which has the following prototype (for WIN32):

    static THREAD_RET_TYPE
    Perl_ithread_run(LPVOID arg)

Looking in Perl's win32thread.h, we find:

    #  define THREAD_RET_TYPE         DWORD WINAPI

Evidently, this isn't quite correct.  Should win32thread.h be changed
to:

    #  define THREAD_RET_TYPE         LPTHREAD_START_ROUTINE

or perhaps conditionally:

    #  ifdef LPTHREAD_START_ROUTINE
    #    define THREAD_RET_TYPE         LPTHREAD_START_ROUTINE
    #  else
    #    define THREAD_RET_TYPE         DWORD WINAPI
    #  endif




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About