ctypes.pp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2004 by Marco van de Voort, member of the
  4. Free Pascal development team
  5. Implements C types for in header conversions
  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. unit ctypes;
  13. interface
  14. {$ifdef unix}
  15. uses unixtype;
  16. {$i aliasctp.inc}
  17. {$else}
  18. type
  19. {$ifndef FPC}
  20. qword = int64; // Keep h2pas "uses ctypes" headers working with delphi.
  21. {$endif}
  22. { the following type definitions are compiler dependant }
  23. { and system dependant }
  24. cint8 = shortint; pcint8 = ^cint8;
  25. cuint8 = byte; pcuint8 = ^cuint8;
  26. cchar = cint8; pcchar = ^cchar;
  27. cschar = cint8; pcschar = ^cschar;
  28. cuchar = cuint8; pcuchar = ^cuchar;
  29. cint16 = smallint; pcint16 = ^cint16;
  30. cuint16 = word; pcuint16 = ^cuint16;
  31. cshort = cint16; pcshort = ^cshort;
  32. csshort = cint16; pcsshort = ^csshort;
  33. cushort = cuint16; pcushort = ^cushort;
  34. cint32 = longint; pcint32 = ^cint32;
  35. cuint32 = longword; pcuint32 = ^cuint32;
  36. cint = cint32; pcint = ^cint; { minimum range is : 32-bit }
  37. csint = cint32; pcsint = ^csint; { minimum range is : 32-bit }
  38. cuint = cuint32; pcuint = ^cuint; { minimum range is : 32-bit }
  39. csigned = cint; pcsigned = ^csigned;
  40. cunsigned = cuint; pcunsigned = ^cunsigned;
  41. cint64 = int64; pcint64 = ^cint64;
  42. cuint64 = qword; pcuint64 = ^cuint64;
  43. clonglong = cint64; pclonglong = ^clonglong;
  44. cslonglong = cint64; pcslonglong = ^cslonglong;
  45. culonglong = cuint64; pculonglong = ^culonglong;
  46. cbool = longbool; pcbool = ^cbool;
  47. {$if defined(cpu64) and not(defined(win64) and defined(cpux86_64))}
  48. clong = int64; pclong = ^clong;
  49. cslong = int64; pcslong = ^cslong;
  50. culong = qword; pculong = ^culong;
  51. {$else}
  52. clong = longint; pclong = ^clong;
  53. cslong = longint; pcslong = ^cslong;
  54. culong = cardinal; pculong = ^culong;
  55. {$endif}
  56. cfloat = single; pcfloat = ^cfloat;
  57. cdouble = double; pcdouble = ^cdouble;
  58. {$ifdef windows}
  59. clongdouble=double;
  60. {$else}
  61. {$define longdouble_assignment_overload}
  62. clongdouble = packed record
  63. value:extended;
  64. {$ifdef defined(cpu64) or defined(darwin)}
  65. padding:array[0..5] of byte;
  66. {$else}
  67. padding:array[0..1] of byte;
  68. {$endif}
  69. end;
  70. {$endif}
  71. Pclongdouble=^clongdouble;
  72. // Kylix compat types
  73. u_long = culong;
  74. u_short = cushort;
  75. {$endif}
  76. {$ifdef longdouble_assignment_overload}
  77. operator := (const v:clongdouble):r:extended;
  78. operator := (const v:extended):r:clongdouble;
  79. {$endif}
  80. implementation
  81. {$ifdef longdouble_assignment_overload}
  82. operator := (const v:clongdouble):r:extended;inline;
  83. begin
  84. r:=v.value;
  85. end;
  86. operator := (const v:extended):r:clongdouble;inline;
  87. begin
  88. r.value:=v;
  89. end;
  90. {$endif}
  91. end.