[ solved :) ] memmove declaration lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- Gilles · 2018-05-05 06:52 Bonjour à tous I was using "BlockMove" but I found it would not work in 64 Bits And so, "memmove" seems to be the solution but where can I find the declaration, the "external name ..." of it ? ( I used to declare :    procedure BlockMove (srcPtr: UnivPtr; destPtr: UnivPtr; byteCount: Size);    {$IFC TARGET_68K} inline $201F, $225F, $205F, $A02E; {$ENDC}    {$IFC TARGET_CARBON} external name '_BlockMove'; {$ENDC} ) (I found it in a way in "string.h" but don't see the equivalency in pascal) (extern void   *memmove(void *, const void *, size_t); ) ( Tried "System.Move" but it doesn't work ) The question could be : how include C-code in Pascal-code merci d'avance ---------------------------------------------------------------------- marcov · 2018-05-05 14:28 Note that Pascal has its own move(src,dest,count). Which is afaik a builtin function that can be more optimized and inlined for small, constant moves (like you specify for target_68k). All build in, and reasonably, though not extremely, optimized. ---------------------------------------------------------------------- PascalDragon · 2018-05-05 14:45 Quote from: Gilles on May 05, 2018, 08:52:51 am( Tried "System.Move" but it doesn't work ) Would you please explain why you think that System.Move() doesn't work? As it does have a different interface from the mem*-functions provided by the C-library, maybe you simply used it incorrectly. ---------------------------------------------------------------------- Gilles · 2018-05-05 14:46 The problem is : when I replace BlockMove by System.MOVE it doesn't work… I had : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure MyTest (h_src, h_dst: univ Ptr; L_cnt: SInt32);begin        BlockMove(h_src, h_dst, L_cnt)end; where h_src and h_dst could be :    Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Ptr(ord4(H^) + L_adi)   { H: Handle }or    Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i @S[1]                 { S: string } L_cnt and the ranges are correct When I try : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure MyTest (h_src, h_dst: univ Ptr; L_cnt: SInt32);begin        System.Move(h_src, h_dst, L_cnt)end; everything freeze ---------------------------------------------------------------------- marcov · 2018-05-05 15:05 Try Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         System.Move(h_src^, h_dst^, L_cnt) or if that doesn't work (depending on dialect and univ ptr semantics) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         System.Move(pbyte(h_src)^, pbyte(h_dst)^, L_cnt) Note that an own wrapper will invalidate the inline properties, unless (maybe) you also declare the wrapper inline. ---------------------------------------------------------------------- PascalDragon · 2018-05-05 16:15 Quote from: marcov on May 05, 2018, 05:05:13 pmNote that an own wrapper will invalidate the inline properties, unless (maybe) you also declare the wrapper inline. Yes, the wrapper will need to be declared inline as well. Though as Move is an assembler routine on most platforms it won't be inlined anyway... But with an inline there will be at least one less call. ---------------------------------------------------------------------- Gilles · 2018-05-05 16:50 Tank"s a lot  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  System.Move(pbyte(h_src)^, pbyte(h_dst)^, L_cnt) work perfectly, even if I don't yet understand why… (in fact, I poorly uses Pascal language… until now, I didn't need to worry about subtilities of it… I'll go back to school ) ---------------------------------------------------------------------- marcov · 2018-05-05 18:26 Quote from: PascalDragon on May 05, 2018, 06:15:44 pmQuote from: marcov on May 05, 2018, 05:05:13 pmNote that an own wrapper will invalidate the inline properties, unless (maybe) you also declare the wrapper inline. Yes, the wrapper will need to be declared inline as well. Though as Move is an assembler routine on most platforms it won't be inlined anyway... But with an inline there will be at least one less call.  Hmm, seems I'm wrong. move() is not inline optimized for small sizes. Bummer. ---------------------------------------------------------------------- Gilles · 2018-11-13 11:49 the real solution : CFDataGetBytes, CFDataReplaceBytes, … and so on…