Re: vc 2005 intrinsics



Hi qfel!
The new VC compiler does not inline memcpy when buffer size is not known at compile time. Is it possible to somehow force it to do so?

For me the following code works perfectly without CRT:

<code>

#include <windows.h>
#pragma intrinsic(memcpy)
#pragma comment(linker, "/ENTRY:myEntry")

void DoSomeTest(void *v1, void *v2)
{
  memcpy(v1, v2, 10);
}

int myEntry()
{
  void *v1 = HeapAlloc(GetProcessHeap(), 0, 100);
  void *v2 = HeapAlloc(GetProcessHeap(), 0, 100);
  DoSomeTest(v1, v2);
  return 0;
}
</code>

Or what do you mean?



dumpbin /ALL reports the following:


Microsoft (R) COFF/PE Dumper Version 8.00.50727.42 Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file CPP_OwnEntry.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES
             14C machine (x86)
               3 number of sections
        43DC8F62 time date stamp Sun Jan 29 10:48:18 2006
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
             103 characteristics
                   Relocations stripped
                   Executable
                   32 bit word machine

OPTIONAL HEADER VALUES
10B magic # (PE32)
8.00 linker version
200 size of code
600 size of initialized data
0 size of uninitialized data
1000 entry point (00401000) ?myEntry@@YAHXZ (int __cdecl myEntry(void))
1000 base of code
2000 base of data
400000 image base (00400000 to 00403FFF)
1000 section alignment
200 file alignment
4.00 operating system version
0.00 image version
4.00 subsystem version
0 Win32 version
4000 size of image
400 size of headers
0 checksum
3 subsystem (Windows CUI)
400 DLL characteristics
No structured exception handler
100000 size of stack reserve
1000 size of stack commit
100000 size of heap reserve
1000 size of heap commit
0 loader flags
10 number of directories
0 [ 0] RVA [size] of Export Directory
2034 [ 28] RVA [size] of Import Directory
0 [ 0] RVA [size] of Resource Directory
0 [ 0] RVA [size] of Exception Directory
0 [ 0] RVA [size] of Certificates Directory
0 [ 0] RVA [size] of Base Relocation Directory
2010 [ 1C] RVA [size] of Debug Directory
0 [ 0] RVA [size] of Architecture Directory
0 [ 0] RVA [size] of Global Pointer Directory
0 [ 0] RVA [size] of Thread Storage Directory
0 [ 0] RVA [size] of Load Configuration Directory
0 [ 0] RVA [size] of Bound Import Directory
2000 [ C] RVA [size] of Import Address Table Directory
0 [ 0] RVA [size] of Delay Import Directory
0 [ 0] RVA [size] of COM Descriptor Directory
0 [ 0] RVA [size] of Reserved Directory



SECTION HEADER #1 .text name 3B virtual size 1000 virtual address (00401000 to 0040103A) 200 size of raw data 400 file pointer to raw data (00000400 to 000005FF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 60000020 flags Code Execute Read

RAW DATA #1
00401000: 53 56 57 8B 3D 00 20 40 00 6A 64 6A 00 FF D7 8B SVW.=. @.jdj.ÿ×.
00401010: 1D 04 20 40 00 50 FF D3 6A 64 6A 00 8B F0 FF D7 .. @.PÿÓjdj..ðÿ×
00401020: 50 FF D3 8B 08 89 0E 8B 50 04 89 56 04 66 8B 40 PÿÓ.....P..V.f.@
00401030: 08 5F 66 89 46 08 5E 33 C0 5B C3 ._f.F.^3À[Ã


SECTION HEADER #2
  .rdata name
      DA virtual size
    2000 virtual address (00402000 to 004020D9)
     200 size of raw data
     600 file pointer to raw data (00000600 to 000007FF)
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
40000040 flags
         Initialized Data
         Read Only

RAW DATA #2
00402000: 74 20 00 00 68 20 00 00 00 00 00 00 00 00 00 00 t ..h ...........
00402010: 00 00 00 00 62 8F DC 43 00 00 00 00 02 00 00 00 .....b.ÜC........
00402020: 46 00 00 00 94 20 00 00 94 06 00 00 00 30 40 00 F.... ........0@.
00402030: 58 30 40 00 5C 20 00 00 00 00 00 00 00 00 00 00 X0@.\ ...........
00402040: 86 20 00 00 00 20 00 00 00 00 00 00 00 00 00 00 . ... ...........
00402050: 00 00 00 00 00 00 00 00 00 00 00 00 74 20 00 00 .............t ..
00402060: 68 20 00 00 00 00 00 00 10 02 48 65 61 70 41 6C h .........HeapAl
00402070: 6C 6F 63 00 A3 01 47 65 74 50 72 6F 63 65 73 73 loc.£.GetProcess
00402080: 48 65 61 70 00 00 4B 45 52 4E 45 4C 33 32 2E 64 Heap..KERNEL32.d
00402090: 6C 6C 00 00 52 53 44 53 11 FA B2 77 15 75 69 48 ll..RSDS.ú²w.uiH
004020A0: A8 06 13 6C 1B 94 EF A5 01 00 00 00 65 3A 5C 74 ¨..l..ï¥....e:\t
004020B0: 65 73 74 5C 63 70 70 5F 6F 77 6E 65 6E 74 72 79 est\cpp_ownentry
004020C0: 5C 72 65 6C 65 61 73 65 5C 43 50 50 5F 4F 77 6E \release\CPP_Own
004020D0: 45 6E 74 72 79 2E 70 64 62 00 Entry.pdb.


  Debug Directories

Time Type Size RVA Pointer
-------- ------ -------- -------- --------
43DC8F62 cv 46 00002094 694 Format: RSDS, {77B2FA11-7515-4869-A806-136C1B94EFA5}, 1, e:\test\cpp_ownentry\release\CPP_OwnEntry.pdb


  Section contains the following imports:

    KERNEL32.dll
                402000 Import Address Table
                40205C Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                  1A3 GetProcessHeap
                  210 HeapAlloc

SECTION HEADER #3
   .data name
     324 virtual size
    3000 virtual address (00403000 to 00403323)
       0 size of raw data
       0 file pointer to raw data
       0 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0000040 flags
         Initialized Data
         Read Write

  Summary

        1000 .data
        1000 .rdata
        1000 .text




-- Greetings Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/
.



Relevant Pages