Well, right idea, wrong fix.  I did not realize the structs could be
returned from functions in C89.  I updated the code in pdlmagic.c
to work for cygwin+pthreads (as long as the detection was hard-
wired to pass).

For windows, the problems are the detection (plan to add some
Devel::CheckLib checks) and the incorrect printf usage trying
to print a pthread_t object as a number.  This would only work,
or be correct, on a platform that implemented pthread_t as a
flavor of integer.

I've also added some parameters in the perldl.conf to allow
the user to set the library and include locations by hand although
the implementing code still needs to be added to the Makefile.PL.

Cheers,
Chris

On Thu, Sep 1, 2011 at 7:36 AM, chm <[email protected]> wrote:
> These are the only pthread routines that appear to be
> used in pdlmagic.c.  I grepped through the source tree
> and did not find any other pthread_ routines so I
> think/hope these should be all:
>
>> pthread_exit
>> pthread_getspecific
>> pthread_join
>> pthread_key_create
>> pthread_key_delete
>> pthread_mutex_lock
>> pthread_mutex_unlock
>> pthread_self
>> pthread_setspecific
>
> --Chris
>
> On 8/31/2011 11:08 PM, chm wrote:
>>
>> I also note that a number of the pthread_* calls
>> have return values that should be checked for: usually
>> zero for ints is no error, NULL for pointers is error
>> or no value... At the least we should be barfing if
>> something fails rather than silently continuing on.
>>
>> --Chris
>>
>> On 8/31/2011 11:03 PM, chm wrote:
>>>
>>> On 8/31/2011 8:40 PM, Sisyphus wrote:
>>>>
>>>> ----- Original Message ----- From: "Chris Marshall"
>>>>
>>>>> Thanks for the confirmation. It means that it should be
>>>>> possible to get pthreads support in for win32 and cygwin
>>>>> platforms.
>>>>
>>>> I've hacked Basic/Core/Makefile.PL so that pthread.h and the pthread
>>>> library are found on my win32 box.
>>>> But the PDL build doesn't get very far.
>>>>
>>>> My pthread.h contains:
>>>>
>>>> #######################
>>>> typedef struct {
>>>> void * p;
>>>> unsigned int x;
>>>> } ptw32_handle_t;
>>>>
>>>> typedef ptw32_handle_t pthread_t;
>>>> #######################
>>>
>>> I believe this is an error in our implementation. According
>>> to discussion at
>>>
>>> https://computing.llnl.gov/tutorials/pthreads/#PthreadsAPI
>>>
>>> "The concept of opaque objects pervades the design of
>>> the API. The basic calls work to create or modify opaque
>>> objects - the opaque objects can be modified by calls
>>> to attribute functions, which deal with opaque attributes."
>>>
>>> Our use of knowledge of the underlying pthread_t type
>>> is the problem. The code needs to be rewritten to be
>>> less specific to a given pthreads implementation.
>>> Not like this would be the first part of PDL with
>>> platform-specific coding... :-)
>>>
>>>> But line 20 of Basic/Core/pdlmagic.c is:
>>>>
>>>> static pthread_t pdl_main_pthreadID = 0;
>>>
>>> I think this should be a pointer to pthread_t
>>> which can be initialized to NULL.
>>>
>>>> which, of course, generates the error:
>>>> pdlmagic.c:20: error: invalid initializer
>>>>
>>>> Also, line 429 of pdlmagic.c contains the expression
>>>> "!pdl_main_pthreadID" - which generates the error:
>>>>
>>>> pdlmagic.c:429: error: wrong type argument to unary exclamation mark
>>>
>>> I think the pointer would work ok here too but
>>> *pdl_main_pthreadID would need to be used rather
>>> than the pointer itself.
>>>
>>>> I think this could well turn out to be a not-so-trivial exercise ...
>>>
>>> The two fixes so far seem simple. I hope the rest turn out
>>> as clear to sort out. I wouldn't mind having multi-core
>>> acceleration for win32 and cygwin PDL.
>>>
>>> --Chris
>>>
>>
>>
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>>
>> -----
>> No virus found in this message.
>> Checked by AVG - www.avg.com
>> Version: 10.0.1392 / Virus Database: 1520/3869 - Release Date: 08/31/11
>>
>>
>
>

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to