macpas.pp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {
  2. This file is part of the Free Pascal Run time library.
  3. Copyright (c) 2004 by Olle Raab
  4. This unit contain procedures specific for mode MacPas.
  5. It should be platform independant.
  6. See the file COPYING.FPC, included in this distribution,
  7. For details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$mode objfpc}
  13. unit MacPas;
  14. interface
  15. { Using inlining for small system functions/wrappers }
  16. {$inline on}
  17. {$define SYSTEMINLINE}
  18. type
  19. LongDouble = ValReal;
  20. {FourCharCode coercion
  21. This routine coreces string literals to a FourCharCode.}
  22. function FCC(literal: string): LongWord; {$ifdef systeminline}inline;{$endif}
  23. {Same as FCC, to be compatible with GPC}
  24. function FOUR_CHAR_CODE(literal: string): LongWord; {$ifdef systeminline}inline;{$endif}
  25. {This makes casts from ShortString to FourCharCode automatically,
  26. to emulate the behaviour of mac pascal compilers}
  27. operator := (s: ShortString) res: LongWord; {$ifdef systeminline}inline;{$endif}
  28. { Same as the "is" operator }
  29. Function Member (Instance : TObject; AClass : TClass) : boolean; {$ifdef systeminline}inline;{$endif}
  30. function ord4(i: smallint): smallint; {$ifdef systeminline}inline;{$endif}
  31. function ord4(l: longint): longint; {$ifdef systeminline}inline;{$endif}
  32. function ord4(c: cardinal): cardinal; {$ifdef systeminline}inline;{$endif}
  33. function ord4(p: pointer): ptrint; {$ifdef systeminline}inline;{$endif}
  34. implementation
  35. function FCC(literal: string): LongWord; {$ifdef systeminline}inline;{$endif}
  36. begin
  37. FCC := PLongWord(@literal[1])^;
  38. end;
  39. function FOUR_CHAR_CODE(literal: string): LongWord; {$ifdef systeminline}inline;{$endif}
  40. begin
  41. FOUR_CHAR_CODE := PLongWord(@literal[1])^;
  42. end;
  43. operator := (s: ShortString) res: LongWord; {$ifdef systeminline}inline;{$endif}
  44. begin
  45. res := PLongWord(@s[1])^;
  46. end;
  47. Function Member (Instance : TObject; AClass : TClass) : boolean; {$ifdef systeminline}inline;{$endif}
  48. begin
  49. Result:=Instance is AClass;
  50. end;
  51. function ord4(i: smallint): smallint; {$ifdef systeminline}inline;{$endif}
  52. begin
  53. result:=i;
  54. end;
  55. function ord4(l: longint): longint; {$ifdef systeminline}inline;{$endif}
  56. begin
  57. result := l;
  58. end;
  59. function ord4(c: cardinal): cardinal; {$ifdef systeminline}inline;{$endif}
  60. begin
  61. result := c;
  62. end;
  63. function ord4(p: pointer): ptrint; {$ifdef systeminline}inline;{$endif}
  64. begin
  65. result := ptrint(p);
  66. end;
  67. {$ifdef cpupowerpc}
  68. begin
  69. asm
  70. mtfsfi 6,1
  71. end;
  72. {$endif cpupowerpc}
  73. end.