1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8#include <xplatform.h>
9#include <platformdefines.h>
10
11const int NumArrElements = 2;
12struct InnerSequential
13{
14 int f1;
15 float f2;
16 LPCSTR f3;
17};
18
19void PrintInnerSequential(InnerSequential* p, const char* name)
20{
21 printf("\t%s.f1 = %d\n", name, p->f1);
22 printf("\t%s.f2 = %f\n", name, p->f2);
23 printf("\t%s.f3 = %s\n", name, p->f3);
24}
25
26void ChangeInnerSequential(InnerSequential* p)
27{
28 p->f1 = 77;
29 p->f2 = 77.0;
30
31 const char* lpstr = "changed string";
32 size_t size = sizeof(char) * (strlen(lpstr) + 1);
33 LPSTR temp = (LPSTR)CoreClrAlloc( size );
34 memset(temp, 0, size);
35 if(temp)
36 {
37 strncpy_s((char*)temp,size,lpstr,size-1);
38 p->f3 = temp;
39 }
40 else
41 {
42 printf("Memory Allocated Failed!");
43 }
44}
45
46bool IsCorrectInnerSequential(InnerSequential* p)
47{
48 if(p->f1 != 1)
49 return false;
50 if(p->f2 != 1.0)
51 return false;
52 if(strcmp((char*)p->f3,"some string") != 0 )
53 return false;
54
55 return true;
56}
57
58struct INNER2 // size = 12 bytes
59{
60 INT f1;
61 FLOAT f2;
62 LPCSTR f3;
63};
64
65void ChangeINNER2(INNER2* p)
66{
67 p->f1 = 77;
68 p->f2 = 77.0;
69 const char* temp = "changed string";
70 size_t len = strlen(temp);
71 LPCSTR str = (LPCSTR)CoreClrAlloc( sizeof(char)*(len+1) );
72 memset((LPVOID)str,0,len+1);
73 strncpy_s((char*)str,len+1,temp,len);
74 p->f3 = str;
75}
76
77void PrintINNER2(INNER2* p, const char* name)
78{
79 printf("\t%s.f1 = %d\n", name, p->f1);
80 printf("\t%s.f2 = %f\n", name, p->f2);
81 printf("\t%s.f3 = %s\n", name, p->f3);
82}
83
84bool IsCorrectINNER2(INNER2* p)
85{
86 if(p->f1 != 1)
87 return false;
88 if(p->f2 != 1.0)
89 return false;
90 if(memcmp(p->f3, "some string",11*sizeof(char)) != 0 )
91 return false;
92 return true;
93}
94
95struct InnerExplicit
96{
97#ifdef WINDOWS
98 union
99 {
100 INT f1;
101 FLOAT f2;
102 };
103 CHAR _unused0[4];
104 LPCSTR f3;
105#else
106 union
107 {
108 INT f1;
109 FLOAT f2;
110 };
111 INT _unused0;
112 LPCSTR f3;
113#endif
114};
115
116
117void PrintInnerExplicit(InnerExplicit* p, const char* name)
118{
119 printf("\t%s.f1 = %d\n", name, p->f1);
120 printf("\t%s.f2 = %f\n", name, p->f2);
121 printf("\t%s.f3 = %s\n", name, p->f3);
122}
123
124void ChangeInnerExplicit(InnerExplicit* p)
125{
126 p->f1 = 77;
127
128 const char* temp = "changed string";
129 size_t len = strlen(temp);
130 LPCSTR str = (LPCSTR)CoreClrAlloc( sizeof(char)*(len+1) );
131 memset((LPVOID)str,0,len+1);
132 strncpy_s((char*)str,len+1,temp,len);
133 p->f3 = str;
134}
135
136struct InnerArraySequential
137{
138 InnerSequential arr[NumArrElements];
139};
140
141void PrintInnerArraySequential(InnerArraySequential* p, const char* name)
142{
143 for(int i = 0; i < NumArrElements; i++)
144 {
145 printf("\t%s.arr[%d].f1 = %d\n", name, i, (p->arr)[i].f1);
146 printf("\t%s.arr[%d].f2 = %f\n", name, i, (p->arr)[i].f2);
147 printf("\t%s.arr[%d].f2 = %s\n", name, i, (p->arr)[i].f3);
148 }
149}
150
151void ChangeInnerArraySequential(InnerArraySequential* p)
152{
153 const char* lpstr = "changed string";
154 LPSTR temp;
155 for(int i = 0; i < NumArrElements; i++)
156 {
157 (p->arr)[i].f1 = 77;
158 (p->arr)[i].f2 = 77.0;
159
160 size_t size = sizeof(char) * (strlen(lpstr) + 1);
161 temp = (LPSTR)CoreClrAlloc( size );
162 memset(temp, 0, size);
163 if(temp)
164 {
165 strncpy_s((char*)temp,strlen(lpstr)+1,lpstr,strlen(lpstr));
166 (p->arr)[i].f3 = temp;
167 }
168 else
169 {
170 printf("Memory Allocated Failed!");
171 }
172 }
173}
174
175bool IsCorrectInnerArraySequential(InnerArraySequential* p)
176{
177 for(int i = 0; i < NumArrElements; i++)
178 {
179 if( (p->arr)[i].f1 != 1 )
180 return false;
181 if( (p->arr)[i].f2 != 1.0 )
182 return false;
183 }
184 return true;
185}
186
187union InnerArrayExplicit // size = 32 bytes
188{
189 struct InnerSequential arr[2];
190 struct
191 {
192 LONG64 _unused0;
193 LPCSTR f4;
194 };
195
196};
197
198#ifdef _WIN64
199union OUTER3 // size = 32 bytes
200{
201 struct InnerSequential arr[2];
202 struct
203 {
204 CHAR _unused0[24];
205 LPCSTR f4;
206 };
207};
208#else
209struct OUTER3 // size = 28 bytes
210{
211 struct InnerSequential arr[2];
212 LPCSTR f4;
213};
214#endif
215
216void PrintOUTER3(OUTER3* p, const char* name)
217{
218 for(int i = 0; i < NumArrElements; i++)
219 {
220 printf("\t%s.arr[%d].f1 = %d\n", name, i, (p->arr)[i].f1);
221 printf("\t%s.arr[%d].f2 = %f\n", name, i, (p->arr)[i].f2);
222 printf("\t%s.arr[%d].f3 = %s\n", name, i, (p->arr)[i].f3);
223 }
224 printf("\t%s.f4 = %s\n",name,p->f4);
225}
226
227void ChangeOUTER3(OUTER3* p)
228{
229 const char* temp = "changed string";
230 size_t len = strlen(temp);
231 LPCSTR str = NULL;
232 for(int i = 0; i < NumArrElements; i++)
233 {
234 (p->arr)[i].f1 = 77;
235 (p->arr)[i].f2 = 77.0;
236
237 str = (LPCSTR)CoreClrAlloc( sizeof(char)*(len+1) );
238 memset((LPVOID)str,0,len+1);
239 strncpy_s((char*)str,len+1,temp,len);
240 (p->arr)[i].f3 = str;
241 }
242
243 str = (LPCSTR)CoreClrAlloc( sizeof(char)*(len+1) );
244 memset((LPVOID)str,0,len+1);
245 strncpy_s((char*)str,len+1,temp,len);
246 p->f4 = str;
247}
248
249bool IsCorrectOUTER3(OUTER3* p)
250{
251 for(int i = 0; i < NumArrElements; i++)
252 {
253 if( (p->arr)[i].f1 != 1 )
254 return false;
255 if( (p->arr)[i].f2 != 1.0 )
256 return false;
257 if( memcmp((p->arr)[i].f3, "some string",11*sizeof(char)) != 0 )
258 return false;
259 }
260 if(memcmp(p->f4,"some string",11*sizeof(char)) != 0)
261 {
262 return false;
263 }
264 return true;
265}
266
267struct CharSetAnsiSequential
268{
269 LPCSTR f1;
270 char f2;
271};
272
273void PrintCharSetAnsiSequential(CharSetAnsiSequential* p, const char* name)
274{
275 printf("\t%s.f1 = %s\n", name, p->f1);
276 printf("\t%s.f2 = %c\n", name, p->f2);
277}
278
279void ChangeCharSetAnsiSequential(CharSetAnsiSequential* p)
280{
281 const char* strSource = "change string";
282 size_t size = strlen(strSource) + 1;
283 LPSTR temp = (LPSTR)CoreClrAlloc(size);
284 if(temp != NULL)
285 {
286 memset(temp,0,size);
287 strncpy_s((char*)temp,size,strSource,size-1);
288 p->f1 = temp;
289 p->f2 = 'n';
290 }
291 else
292 {
293 printf("Memory Allocated Failed!");
294 }
295}
296
297bool IsCorrectCharSetAnsiSequential(CharSetAnsiSequential* p)
298{
299 if(strcmp((char*)p->f1, (char*)"some string") != 0 )
300 return false;
301 if(p->f2 != 'c')
302 return false;
303 return true;
304}
305
306
307struct CharSetUnicodeSequential
308{
309 LPCWSTR f1;
310 WCHAR f2;
311};
312
313void PrintCharSetUnicodeSequential(CharSetUnicodeSequential* p, const char* name)
314{
315#ifdef _WIN32
316 wprintf(L"\t%S.first = %s\n", name, p->f1);
317 wprintf(L"\t%S.last = %c\n", name, p->f2);
318#else
319 wprintf(L"\t%s.first = %s\n", name, p->f1);
320 wprintf(L"\t%s.last = %c\n", name, p->f2);
321#endif
322}
323
324void ChangeCharSetUnicodeSequential(CharSetUnicodeSequential* p)
325{
326 WCHAR* strSource = (WCHAR*)(W("change string"));
327 size_t len =TP_slen(strSource);
328 LPCWSTR temp = (LPCWSTR)CoreClrAlloc(sizeof(WCHAR)*(len+1));
329 if(temp != NULL)
330 {
331 memset((LPWSTR)temp,0,len+1);
332 wcsncpy_s((WCHAR*)temp, len, strSource, len);
333 p->f1 = temp;
334 p->f2 = L'n';
335 }
336 else
337 {
338 printf("Memory Allocated Failed!");
339 }
340}
341
342bool IsCorrectCharSetUnicodeSequential(CharSetUnicodeSequential* p)
343{
344 WCHAR* expected= const_cast<WCHAR*>(W("some string"));
345 WCHAR* actual = const_cast<WCHAR*>(p->f1);
346 if(0 != TP_wcmp_s(actual, expected))
347 {
348 return false;
349 }
350 if(p->f2 != L'c')
351 {
352 return false;
353 }
354 return true;
355}
356
357struct NumberSequential // size = 64 bytes
358{
359 LONG64 i64;
360 ULONG64 ui64;
361 DOUBLE d;
362 INT i32;
363 UINT ui32;
364 SHORT s1;
365 WORD us1;
366 SHORT i16;
367 WORD ui16;
368 FLOAT sgl;
369 BYTE b;
370 CHAR sb;
371};
372
373void PrintNumberSequential(NumberSequential* str, const char* name)
374{
375 printf("\t%s.i32 = %d\n", name, str->i32);
376 printf("\t%s.ui32 = %d\n", name, str->ui32);
377 printf("\t%s.s1 = %d\n", name, str->s1);
378 printf("\t%s.us1 = %u\n", name, str->us1);
379 printf("\t%s.b = %u\n", name, str->b);
380 printf("\t%s.sb = %d\n", name, str->sb);
381 printf("\t%s.i16 = %d\n", name, str->i16);
382 printf("\t%s.ui16 = %u\n", name, str->ui16);
383 printf("\t%s.i64 = %lld\n", name, str->i64);
384 printf("\t%s.ui64 = %llu\n", name, str->ui64);
385 printf("\t%s.sgl = %f\n", name, str->sgl);
386 printf("\t%s.d = %f\n",name, str->d);
387}
388
389void ChangeNumberSequential(NumberSequential* p)
390{
391 p->i32 = 0;
392 p->ui32 = 32;
393 p->s1 = 0;
394 p->us1 = 16;
395 p->b = 0;
396 p->sb = 8;
397 p->i16 = 0;
398 p->ui16 = 16;
399 p->i64 = 0;
400 p->ui64 = 64;
401 p->sgl = 64.0;
402 p->d = 6.4;
403}
404
405bool IsCorrectNumberSequential(NumberSequential* p)
406{
407 if(p->i32 != INT_MIN || p->ui32 != 0xffffffff || p->s1 != -0x8000 || p->us1 != 0xffff || p->b != 0 ||
408 p->sb != 0x7f ||p->i16 != -0x8000 || p->ui16 != 0xffff || p->i64 != -1234567890 ||
409 p->ui64 != 1234567890 || (p->sgl) != 32.0 || p->d != 3.2)
410 {
411 return false;
412 }
413 return true;
414}
415
416struct S3 // size = 1032 bytes
417{
418 BOOL flag;
419 LPCSTR str;
420 INT vals[256];
421};
422
423void PrintS3(S3* str, const char* name)
424{
425 printf("\t%s.flag = %d\n", name, str->flag);
426 printf("\t%s.str = %s\n", name, str->str);
427 for(int i = 0; i<256 ;i++)
428 {
429 printf("\t%s.vals[%d] = %d\n",name,i,str->vals[i]);
430 }
431}
432
433void ChangeS3(S3* p)
434{
435 p->flag = false;
436
437 const char* strSource = "change string";
438 size_t len =strlen(strSource)+1;
439 LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len);
440 if(temp != NULL)
441 {
442 memset((LPVOID)temp,0,len);
443 strncpy_s((char*)temp,len,strSource,len-1);
444 p->str = temp;
445 }
446 for(int i = 1;i<257;i++)
447 {
448 p->vals[i-1] = i;
449 }
450}
451
452bool IsCorrectS3(S3* p)
453{
454 int iflag = 0;
455 if(!p->flag || strcmp((char*)p->str,"some string") != 0)
456 return false;
457 for (int i = 0; i < 256; i++)
458 {
459 if (p->vals[i] != i)
460 {
461 printf("\tThe Index of %i is not expected",i);
462 iflag++;
463 }
464 }
465 if (iflag != 0)
466 {
467 return false;
468 }
469 return true;
470}
471
472struct S4 // size = 8 bytes
473{
474 INT age;
475 LPCSTR name;
476};
477
478enum Enum1
479{
480 e1 = 1,
481 e2 = 3
482};
483
484struct S5 // size = 8 bytes
485{
486 struct S4 s4;
487 Enum1 ef;
488};
489
490void PrintS5(S5* str, const char* name)
491{
492 printf("\t%s.s4.age = %d", name, str->s4.age);
493 printf("\t%s.s4.name = %s", name, str->s4.name);
494 printf("\t%s.ef = %d", name, str->ef);
495}
496
497void ChangeS5(S5* str)
498{
499 Enum1 eInstance = e2;
500 const char* strSource = "change string";
501 size_t len =strlen(strSource)+1;
502 LPCSTR temp = (LPCSTR)CoreClrAlloc(sizeof(char)*len);
503 if(temp != NULL)
504 {
505 memset((LPVOID)temp,0,len);
506 strncpy_s((char*)temp,len,strSource,len-1);
507 str->s4.name = temp;
508 }
509 str->s4.age = 64;
510 str->ef = eInstance;
511}
512
513bool IsCorrectS5(S5* str)
514{
515 Enum1 eInstance = e1;
516 if(str->s4.age != 32 || strcmp((char*)str->s4.name,"some string") != 0)
517 return false;
518 if(str->ef != eInstance)
519 {
520 return false;
521 }
522 return true;
523}
524
525struct StringStructSequentialAnsi // size = 8 bytes
526{
527 LPCSTR first;
528 LPCSTR last;
529};
530
531void PrintStringStructSequentialAnsi(StringStructSequentialAnsi* str, const char* name)
532{
533 printf("\t%s.first = %s\n", name, str->first);
534 printf("\t%s.last = %s\n", name, str->last);
535}
536
537bool IsCorrectStringStructSequentialAnsi(StringStructSequentialAnsi* str)
538{
539 char strOne[512];
540 char strTwo[512];
541 for(int i = 0;i<512;i++)
542 {
543 strOne[i] = 'a';
544 strTwo[i] = 'b';
545 }
546
547 if(memcmp(str->first,strOne,512)!= 0)
548 return false;
549
550 if(memcmp(str->last,strTwo,512)!= 0)
551 return false;
552
553 return true;
554}
555
556void ChangeStringStructSequentialAnsi(StringStructSequentialAnsi* str)
557{
558 char* newFirst = (char*)CoreClrAlloc(sizeof(char)*513);
559 char* newLast = (char*)CoreClrAlloc(sizeof(char)*513);
560 for (int i = 0; i < 512; ++i)
561 {
562 newFirst[i] = 'b';
563 newLast[i] = 'a';
564 }
565 newFirst[512] = '\0';
566 newLast[512] = '\0';
567
568 str->first = newFirst;
569 str->last = newLast;
570}
571
572struct StringStructSequentialUnicode // size = 8 bytes
573{
574 LPCWSTR first;
575 LPCWSTR last;
576};
577
578void PrintStringStructSequentialUnicode(StringStructSequentialUnicode* str, const char* name)
579{
580#ifdef _WIN32
581 wprintf(L"\t%S.first = %s\n", name, str->first);
582 wprintf(L"\t%S.last = %s\n", name, str->last);
583#else
584 wprintf(L"\t%s.first = %s\n", name, str->first);
585 wprintf(L"\t%s.last = %s\n", name, str->last);
586#endif
587}
588
589bool IsCorrectStringStructSequentialUnicode(StringStructSequentialUnicode* str)
590{
591 WCHAR strOne[256+1];
592 WCHAR strTwo[256+1];
593
594 for(int i = 0;i<256;++i)
595 {
596 strOne[i] = L'a';
597 strTwo[i] = L'b';
598 }
599 strOne[256] = L'\0';
600 strTwo[256] = L'\0';
601
602 if(memcmp(str->first,strOne,256*sizeof(WCHAR)) != 0)
603 return false;
604 if(memcmp(str->last,strTwo,256*sizeof(WCHAR)) != 0)
605 return false;
606 return true;
607}
608
609void ChangeStringStructSequentialUnicode(StringStructSequentialUnicode* str)
610{
611 WCHAR* newFirst = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257);
612 WCHAR* newLast = (WCHAR*)CoreClrAlloc(sizeof(WCHAR)*257);
613 for (int i = 0; i < 256; ++i)
614 {
615 newFirst[i] = L'b';
616 newLast[i] = L'a';
617 }
618 newFirst[256] = L'\0';
619 newLast[256] = L'\0';
620 str->first = (const WCHAR*)newFirst;
621 str->last = (const WCHAR*)newLast;
622}
623
624struct S8 // size = 32 bytes
625{
626 LPCSTR name;
627 BOOL gender;
628 HRESULT i32;
629 HRESULT ui32;
630 WORD jobNum;
631 CHAR mySByte;
632};
633
634void PrintS8(S8* str, const char* name)
635{
636 printf("\t%s.name = %s\n",name, str->name);
637 printf("\t%s.gender = %d\n", name, str->gender);
638 printf("\t%s.jobNum = %d\n",name, str->jobNum);
639 printf("\t%s.i32 = %d\n", name, (int)(str->i32));
640 printf("\t%s.ui32 = %u\n", name, (unsigned int)(str->ui32));
641 printf("\t%s.mySByte = %c\n", name, str->mySByte);
642}
643
644bool IsCorrectS8(S8* str)
645{
646 if(memcmp( str->name,"hello", strlen("hello")*sizeof(char)+1 )!= 0)
647 return false;
648 if(!str->gender)
649 return false;
650 if(str->jobNum != 10)
651 return false;
652 if(str->i32!= 128 || str->ui32 != 128)
653 return false;
654 if(str->mySByte != 32)
655 return false;
656 return true;
657}
658
659void ChangeS8(S8* str)
660{
661 const char* lpstr = "world";
662 size_t size = sizeof(char) * (strlen(lpstr) + 1);
663 LPSTR temp = (LPSTR)CoreClrAlloc( size );
664 memset(temp, 0, size);
665 if(temp)
666 {
667 strcpy_s((char*)temp,size,lpstr);
668 str->name = temp;
669 }
670 else
671 {
672 printf("Memory Allocated Failed!");
673 }
674 str->gender = false;
675 str->jobNum = 1;
676 str->i32 = 256;
677 str->ui32 = 256;
678 str->mySByte = 64;
679}
680
681#pragma pack (8)
682struct S_int // size = 4 bytes
683{
684 INT i;
685};
686
687struct S9;
688typedef void (*TestDelegate1)(struct S9 myStruct);
689
690struct S9 // size = 8 bytes
691{
692 HRESULT i32;
693 TestDelegate1 myDelegate1;
694};
695
696struct S101 // size = 8 bytes
697{
698 INT i;
699 struct S_int s_int;
700};
701
702struct S10 // size = 8 bytes
703{
704 struct S101 s;
705};
706
707void PrintS10(S10* str, const char* name)
708{
709 printf("\t%s.s.s_int.i = %d\n", name, str->s.s_int.i);
710 printf("\t%s.s.i = %d\n", name, str->s.i);
711}
712
713bool IsCorrectS10(S10* str)
714{
715 if(str->s.s_int.i != 32)
716 return false;
717 if(str->s.i != 32)
718 return false;
719 return true;
720}
721
722void ChangeS10(S10* str)
723{
724 str->s.s_int.i = 64;
725 str->s.i = 64;
726}
727
728#ifndef WINDOWS
729typedef int* LPINT;
730#endif
731
732struct S11 // size = 8 bytes
733{
734 LPINT i32;
735 INT i;
736};
737
738union U // size = 8 bytes
739{
740 INT i32;
741 UINT ui32;
742 LPVOID iPtr;
743 LPVOID uiPtr;
744 SHORT s;
745 WORD us;
746 BYTE b;
747 CHAR sb;
748 LONG64 l;
749 ULONG64 ul;
750 FLOAT f;
751 DOUBLE d;
752};
753
754void PrintU(U* str, const char* name)
755{
756 printf("\t%s.i32 = %d\n", name, str->i32);
757 printf("\t%s.ui32 = %u\n", name, str->ui32);
758 printf("\t%s.iPtr = %zu\n", name, (size_t)(str->iPtr));
759 printf("\t%s.uiPtr = %zu\n", name, (size_t)(str->uiPtr));
760 printf("\t%s.s = %d\n", name, str->s);
761 printf("\t%s.us = %u\n", name, str->us);
762 printf("\t%s.b = %u\n", name, str->b);
763 printf("\t%s.sb = %d\n", name, str->sb);
764 printf("\t%s.l = %lld\n", name, str->l);
765 printf("\t%s.ul = %llu\n", name, str->ul);
766 printf("\t%s.f = %f\n", name, str->f);
767 printf("\t%s.d = %f\n", name, str->d);
768}
769
770void ChangeU(U* p)
771{
772 p->i32 = 2147483647;
773 p->ui32 = 0;
774 p->iPtr = (LPVOID)(-64);
775 p->uiPtr = (LPVOID)(64);
776 p->s = 32767;
777 p->us = 0;
778 p->b = 255;
779 p->sb = -128;
780 p->l = -1234567890;
781 p->ul = 0;
782 p->f = 64.0;
783 p->d = 6.4;
784}
785
786bool IsCorrectU(U* p)
787{
788 if(p->d != 3.2)
789 {
790 return false;
791 }
792 return true;
793}
794
795struct ByteStructPack2Explicit // size = 2 bytes
796{
797 BYTE b1;
798 BYTE b2;
799};
800
801void PrintByteStructPack2Explicit(ByteStructPack2Explicit* str, const char* name)
802{
803 printf("\t%s.b1 = %d", name, str->b1);
804 printf("\t%s.b2 = %d", name, str->b2);
805}
806
807void ChangeByteStructPack2Explicit(ByteStructPack2Explicit* p)
808{
809 p->b1 = 64;
810 p->b2 = 64;
811}
812
813bool IsCorrectByteStructPack2Explicit(ByteStructPack2Explicit* p)
814{
815 if(p->b1 != 32 || p->b2 != 32)
816 return false;
817 return true;
818}
819
820struct ShortStructPack4Explicit // size = 4 bytes
821{
822 SHORT s1;
823 SHORT s2;
824};
825
826void PrintShortStructPack4Explicit(ShortStructPack4Explicit* str, const char* name)
827{
828 printf("\t%s.s1 = %d", name, str->s1);
829 printf("\t%s.s2 = %d", name, str->s2);
830}
831
832void ChangeShortStructPack4Explicit(ShortStructPack4Explicit* p)
833{
834 p->s1 = 64;
835 p->s2 = 64;
836}
837
838bool IsCorrectShortStructPack4Explicit(ShortStructPack4Explicit* p)
839{
840 if(p->s1 != 32 || p->s2 != 32)
841 return false;
842 return true;
843}
844
845struct IntStructPack8Explicit // size = 8 bytes
846{
847 INT i1;
848 INT i2;
849};
850
851void PrintIntStructPack8Explicit(IntStructPack8Explicit* str, const char* name)
852{
853 printf("\t%s.i1 = %d", name, str->i1);
854 printf("\t%s.i2 = %d", name, str->i2);
855}
856
857void ChangeIntStructPack8Explicit(IntStructPack8Explicit* p)
858{
859 p->i1 = 64;
860 p->i2 = 64;
861}
862
863bool IsCorrectIntStructPack8Explicit(IntStructPack8Explicit* p)
864{
865 if(p->i1 != 32 || p->i2 != 32)
866 return false;
867 return true;
868}
869
870struct LongStructPack16Explicit // size = 16 bytes
871{
872 LONG64 l1;
873 LONG64 l2;
874};
875
876void PrintLongStructPack16Explicit(LongStructPack16Explicit* str, const char* name)
877{
878 printf("\t%s.l1 = %lld", name, str->l1);
879 printf("\t%s.l2 = %lld", name, str->l2);
880}
881
882void ChangeLongStructPack16Explicit(LongStructPack16Explicit* p)
883{
884 p->l1 = 64;
885 p->l2 = 64;
886}
887
888bool IsCorrectLongStructPack16Explicit(LongStructPack16Explicit* p)
889{
890 if(p->l1 != 32 || p->l2 != 32)
891 return false;
892 return true;
893}
894
895LPSTR GetNativeString()
896{
897 const char* lNativeStr = "Native";
898 const size_t lsize = strlen(lNativeStr);
899 LPSTR str = NULL;
900
901 str = (LPSTR)CoreClrAlloc( lsize+1 );
902 memset(str,0,lsize+1);
903 strcpy_s((char*)str,lsize+1,lNativeStr);
904
905 return str;
906}
907
908LPSTR GetSomeString()
909{
910 const char* lNativeStr = "some string";
911 const size_t lsize = strlen(lNativeStr);
912 LPSTR str = NULL;
913
914 str = (LPSTR)CoreClrAlloc( lsize+1 );
915 memset(str,0,lsize+1);
916 strcpy_s((char*)str,lsize+1,lNativeStr);
917
918 return str;
919}
920