Hello again, Here's the code I'm stuck with:-
/* Below is the 3 functions that are supplied to me for testing (alon +g with a whole bunch of others!) */ long ResolveAsync (UCHAR* filepath, ULONG gateway, ULONG *hFS) { long result; ULONG hBiopSRG; // Display hFS value - It is '0', which is correct printf("[DEBUG] Entered ResolveAsync - filepath[%s], gateway[%d], +hFS[%d]\n", filepath, gateway, *hFS); result = FSCacheResolve (filepath, hBiopSRG, hFS, FLAG_NO_LOAD); // Display hFS value - It is '4294967295', which is incorrect. Whe +n this code // is run in a C environment it works fine and the result is eithe +r 2 or 9 // which is what it should be! printf("[DEBUG] Leaving ResolveAsync - filepath[%s], gateway[%d], +hFS[%Lu], Result[%d]\n", filepath, gateway, *hFS, result); return (result); } ////////////////////////////////////////////////////////////////////// +/// long FSCacheResolve (UCHAR* filepath, ULONG gateway, ULONG *handle, UCHAR flag) { // Display the value, it is 0, which it should be printf("[DEBUG] Entered FSCacheResolve(...) - hFS:[%Lu]\n", *handl +e); // ... // Do stuff ... // ... // This is the func that messes the handle!!! *handle = CacheGetHandle (row, hit); // Display the value now, it is WRONG - (handle == 4294967295) printf("[DEBUG] Leaving FSCacheResolve(...) - hFS:[%Lu]\n", *handl +e); return (result); } ////////////////////////////////////////////////////////////////////// +/////////////// // This function is declared as static, so I cant access it directly!! +! // Is there a way round this in PerlXS or will the function HAVE to be // made externaly available to get the correct results in C ??? // The CACHE structure is also declared in a .C file, and is // 'undeclared' as far as PERLXS is concerned. I have the .objs files // included in the makefile settings (O_FILES) static ULONG CacheGetHandle (uint32_t row, CACHE *entry) { ULONG hFS = INVALID_FS_HANDLE; hFS = (entry->llnode[COLLISION_LIST].handle * HASH_TABLE_SIZE) + +row; // hFS now has the correct value, which should be either '2' or '9 +' // but when the value is returned an examined in the calling funct +ion // (FSCacheResolve), its value is shown as 4294967295 // The following line prints either 2 or 9! printf("[DEBUG] In CacheGetHandle(...) - hFS:[%Lu]\n", hFS); return (hFS); } ////////////////////////////////////////////////////////////////////// +/////////////// Here's some of the XS file contents:- long dsmFSResolveAsync(filepath,gateway,hFS) unsigned char *filepath unsigned long gateway unsigned long & hFS OUTPUT: hFS RETVAL long FSCacheResolve(filepath,gateway,handle,flag) unsigned char *filepath unsigned long gateway unsigned long & handle unsigned char flag OUTPUT: handle RETVAL I have tried putting info about CacheGetHandle(...) here but it complains about the unresolved external, so is there a way around this??? ////////////////////////////////////////////////////////////////////// +//////// There's nothing really in the typemap file, just:- unsigned char * T_PV const char * T_PV And here's the test.pl file (Some of it!) $hObject = 0; $result = &testmain::ResolveAsync( "Dir0/binary", $gateway, $hObject); print $result == 0 ? "ok 8 {dsmFSResolveAsync} Handle:[$hObject]\n" : +"not ok 8 {dsmFSResolveAsync} Handle:[$hObject]\n"; # The value of $hObject ends up being 4294967295, when the same functi +on is called # under C, hObject equals either 2 or 9!!!!!
Basically, am I stuck with making the function external, or is there some way round this?
Thanks in advance,
Paul

In reply to Re: (tye)Re: PerlXS type problem by PH
in thread PerlXS type problem by PH

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.