talign2.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. { %VERSION=1.1 }
  2. {%OPT=-Og}
  3. { This verifies if the strings are
  4. correctly aligned, normally the generated assembler
  5. should be verified manually.
  6. }
  7. program talign2;
  8. {$ifdef fpc}
  9. {$mode objfpc}
  10. {$ifndef ver1_0}
  11. {$define haswidestring}
  12. {$endif}
  13. {$else}
  14. {$ifndef ver70}
  15. {$define haswidestring}
  16. {$endif}
  17. {$endif}
  18. procedure test(b : boolean);
  19. begin
  20. if b then exit;
  21. WriteLn('Error in length/alignment!!');
  22. halt(1);
  23. end;
  24. var
  25. pt: pchar;
  26. const
  27. b: byte = 0; { lets just misalign the stuff }
  28. p : pchar = 'simple pchar stuff';
  29. ansistr : ansistring = 'simple ansistring';
  30. {$ifdef haswidestring}
  31. widestr : widestring = 'simple widestring';
  32. {$endif}
  33. shortstr :shortstring = 'simple shortstring';
  34. begin
  35. test(length(ansistr)=17);
  36. {$ifdef haswidestring}
  37. test(length(widestr)=17);
  38. {$endif}
  39. test(length(shortstr)=18);
  40. { verify if the address are correctly aligned! }
  41. pt:=@shortstr;
  42. test((ptruint(pt) mod sizeof(pointer))=0);
  43. pt:=p;
  44. test((ptruint(pt) mod sizeof(pointer))=0);
  45. pt:=pchar(ansistr);
  46. test((ptruint(pt) mod sizeof(pointer))=0);
  47. {$ifdef haswidestring}
  48. pt:=pchar(widestr);
  49. test((ptruint(pt) mod sizeof(pointer))=0);
  50. {$endif}
  51. end.
  52. {
  53. $Log$
  54. Revision 1.4 2005-01-04 20:30:09 olle
  55. - removed unnecessary mode switch
  56. Revision 1.3 2004/04/29 21:04:58 peter
  57. * 64 bit fixes
  58. Revision 1.2 2002/11/09 21:19:21 carl
  59. * now check address of tc's also and give error.
  60. + 1.1 only
  61. Revision 1.1 2002/11/09 13:18:25 carl
  62. * more alignment checking
  63. }