system.pas 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797
  1. {
  2. $Id$
  3. ****************************************************************************
  4. This file is part of the Free Pascal run time library.
  5. Copyright (c) 1999-2002 by Free Pascal development team
  6. Free Pascal - OS/2 runtime library
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. ****************************************************************************}
  13. unit {$ifdef VER1_0}sysos2{$else}System{$endif};
  14. interface
  15. {$ifdef SYSTEMDEBUG}
  16. {$define SYSTEMEXCEPTIONDEBUG}
  17. {.$define IODEBUG}
  18. {.$define DEBUGENVIRONMENT}
  19. {.$define DEBUGARGUMENTS}
  20. {$endif SYSTEMDEBUG}
  21. { $DEFINE OS2EXCEPTIONS}
  22. {$I systemh.inc}
  23. {$IFDEF OS2EXCEPTIONS}
  24. (* Types and constants for exception handler support *)
  25. type
  26. {x} PEXCEPTION_FRAME = ^TEXCEPTION_FRAME;
  27. {x} TEXCEPTION_FRAME = record
  28. {x} next : PEXCEPTION_FRAME;
  29. {x} handler : pointer;
  30. {x} end;
  31. {$ENDIF OS2EXCEPTIONS}
  32. {$I heaph.inc}
  33. {Platform specific information}
  34. type
  35. THandle = Longint;
  36. const
  37. LineEnding = #13#10;
  38. { LFNSupport is defined separately below!!! }
  39. DirectorySeparator = '\';
  40. DriveSeparator = ':';
  41. PathSeparator = ';';
  42. { FileNameCaseSensitive is defined separately below!!! }
  43. MaxExitCode = 65535;
  44. type Tos=(osDOS,osOS2,osDPMI);
  45. const os_mode: Tos = osOS2;
  46. first_meg: pointer = nil;
  47. {$IFDEF OS2EXCEPTIONS}
  48. {x} System_exception_frame : PEXCEPTION_FRAME =nil;
  49. {$ENDIF OS2EXCEPTIONS}
  50. type TByteArray = array [0..$ffff] of byte;
  51. PByteArray = ^TByteArray;
  52. TSysThreadIB = record
  53. TID,
  54. Priority,
  55. Version: cardinal;
  56. MCCount,
  57. MCForceFlag: word;
  58. end;
  59. PSysThreadIB = ^TSysThreadIB;
  60. TThreadInfoBlock = record
  61. PExChain,
  62. Stack,
  63. StackLimit: pointer;
  64. TIB2: PSysThreadIB;
  65. Version,
  66. Ordinal: cardinal;
  67. end;
  68. PThreadInfoBlock = ^TThreadInfoBlock;
  69. PPThreadInfoBlock = ^PThreadInfoBlock;
  70. TProcessInfoBlock = record
  71. PID,
  72. ParentPid,
  73. Handle: cardinal;
  74. Cmd,
  75. Env: PByteArray;
  76. Status,
  77. ProcType: cardinal;
  78. end;
  79. PProcessInfoBlock = ^TProcessInfoBlock;
  80. PPProcessInfoBlock = ^PProcessInfoBlock;
  81. const UnusedHandle=-1;
  82. StdInputHandle=0;
  83. StdOutputHandle=1;
  84. StdErrorHandle=2;
  85. LFNSupport: boolean = true;
  86. FileNameCaseSensitive: boolean = false;
  87. sLineBreak = LineEnding;
  88. DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCRLF;
  89. var
  90. { C-compatible arguments and environment }
  91. argc : longint;
  92. argv : ppchar;
  93. envp : ppchar;
  94. EnvC: cardinal;
  95. (* Pointer to the block of environment variables - used e.g. in unit Dos. *)
  96. Environment: PChar;
  97. var
  98. (* Type / run mode of the current process: *)
  99. (* 0 .. full screen OS/2 session *)
  100. (* 1 .. DOS session *)
  101. (* 2 .. VIO windowable OS/2 session *)
  102. (* 3 .. Presentation Manager OS/2 session *)
  103. (* 4 .. detached (background) OS/2 process *)
  104. ApplicationType: cardinal;
  105. implementation
  106. {$I system.inc}
  107. procedure DosGetInfoBlocks (PATIB: PPThreadInfoBlock;
  108. PAPIB: PPProcessInfoBlock); cdecl;
  109. external 'DOSCALLS' index 312;
  110. function DosLoadModule (ObjName: PChar; ObjLen: cardinal; DLLName: PChar;
  111. var Handle: cardinal): cardinal; cdecl;
  112. external 'DOSCALLS' index 318;
  113. function DosQueryProcAddr (Handle, Ordinal: cardinal; ProcName: PChar;
  114. var Address: pointer): cardinal; cdecl;
  115. external 'DOSCALLS' index 321;
  116. function DosSetRelMaxFH (var ReqCount: longint; var CurMaxFH: cardinal):
  117. cardinal; cdecl;
  118. external 'DOSCALLS' index 382;
  119. function DosSetCurrentDir (Name:PChar): cardinal; cdecl;
  120. external 'DOSCALLS' index 255;
  121. procedure DosQueryCurrentDisk(var DiskNum:cardinal;var Logical:cardinal); cdecl;
  122. external 'DOSCALLS' index 275;
  123. function DosSetDefaultDisk (DiskNum:cardinal): cardinal; cdecl;
  124. external 'DOSCALLS' index 220;
  125. { This is not real prototype, but is close enough }
  126. { for us (the 2nd parameter is actually a pointer }
  127. { to a structure). }
  128. function DosCreateDir (Name: PChar; P: pointer): cardinal; cdecl;
  129. external 'DOSCALLS' index 270;
  130. function DosDeleteDir (Name: PChar): cardinal; cdecl;
  131. external 'DOSCALLS' index 226;
  132. function DosQueryCurrentDir(DiskNum:cardinal;var Buffer;
  133. var BufLen:cardinal): cardinal; cdecl;
  134. external 'DOSCALLS' index 274;
  135. function DosMove(OldFile,NewFile:PChar):cardinal; cdecl;
  136. external 'DOSCALLS' index 271;
  137. function DosDelete(FileName:PChar):cardinal; cdecl;
  138. external 'DOSCALLS' index 259;
  139. procedure DosExit(Action, Result: cardinal); cdecl;
  140. external 'DOSCALLS' index 234;
  141. // EAs not used in System unit
  142. function DosOpen(FileName:PChar;var Handle: THandle;var Action:cardinal;
  143. InitSize,Attrib,OpenFlags,FileMode:cardinal;
  144. EA:Pointer): cardinal; cdecl;
  145. external 'DOSCALLS' index 273;
  146. function DosClose(Handle: THandle): cardinal; cdecl;
  147. external 'DOSCALLS' index 257;
  148. function DosRead(Handle: THandle; Buffer: Pointer; Count: cardinal;
  149. var ActCount: cardinal): cardinal; cdecl;
  150. external 'DOSCALLS' index 281;
  151. function DosWrite(Handle: THandle; Buffer: Pointer;Count: cardinal;
  152. var ActCount: cardinal): cardinal; cdecl;
  153. external 'DOSCALLS' index 282;
  154. function DosSetFilePtr(Handle: THandle; Pos:longint; Method:cardinal;
  155. var PosActual: cardinal): cardinal; cdecl;
  156. external 'DOSCALLS' index 256;
  157. function DosSetFileSize(Handle: THandle; Size: cardinal): cardinal; cdecl;
  158. external 'DOSCALLS' index 272;
  159. function DosQueryHType(Handle: THandle; var HandType: cardinal;
  160. var Attr: cardinal): cardinal; cdecl;
  161. external 'DOSCALLS' index 224;
  162. type
  163. TSysDateTime=packed record
  164. Hour,
  165. Minute,
  166. Second,
  167. Sec100,
  168. Day,
  169. Month: byte;
  170. Year: word;
  171. TimeZone: smallint;
  172. WeekDay: byte;
  173. end;
  174. function DosGetDateTime(var Buf:TSysDateTime): cardinal; cdecl;
  175. external 'DOSCALLS' index 230;
  176. { converts an OS/2 error code to a TP compatible error }
  177. { code. Same thing exists under most other supported }
  178. { systems. }
  179. { Only call for OS/2 DLL imported routines }
  180. Procedure Errno2InOutRes;
  181. Begin
  182. { errors 1..18 are the same as in DOS }
  183. case InOutRes of
  184. { simple offset to convert these error codes }
  185. { exactly like the error codes in Win32 }
  186. 19..31 : InOutRes := InOutRes + 131;
  187. { gets a bit more complicated ... }
  188. 32..33 : InOutRes := 5;
  189. 38 : InOutRes := 100;
  190. 39 : InOutRes := 101;
  191. 112 : InOutRes := 101;
  192. 110 : InOutRes := 5;
  193. 114 : InOutRes := 6;
  194. 290 : InOutRes := 290;
  195. end;
  196. { all other cases ... we keep the same error code }
  197. end;
  198. {$IFDEF OS2EXCEPTIONS}
  199. (*
  200. The operating system defines a class of error conditions called exceptions, and specifies the default actions that are taken when these exceptions occur. The system default action in most cases is to terminate the thread that caused the exception.
  201. Exception values have the following 32-bit format:
  202. 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  203. 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  204. ÚÄÄÄÂÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  205. ³Sev³C³ Facility ³ Code ³
  206. ÀÄÄÄÁÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  207. Sev Severity code. Possible values are described in the following list:
  208. 00 Success
  209. 01 Informational
  210. 10 Warning
  211. 11 Error
  212. C Customer code flag.
  213. Facility Facility code.
  214. Code Facility's status code.
  215. Exceptions that are specific to OS/2 Version 2.X (for example, XCPT_SIGNAL)
  216. have a facility code of 1.
  217. System exceptions include both synchronous and asynchronous exceptions.
  218. Synchronous exceptions are caused by events that are internal to a thread's
  219. execution. For example, synchronous exceptions could be caused by invalid
  220. parameters, or by a thread's request to end its own execution.
  221. Asynchronous exceptions are caused by events that are external to a thread's
  222. execution. For example, an asynchronous exception can be caused by a user's
  223. entering a Ctrl+C or Ctrl+Break key sequence, or by a process' issuing
  224. DosKillProcess to end the execution of another process.
  225. The Ctrl+Break and Ctrl+C exceptions are also known as signals, or as signal
  226. exceptions.
  227. The following tables show the symbolic names of system exceptions, their
  228. numerical values, and related information fields.
  229. Portable, Non-Fatal, Software-Generated Exceptions
  230. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
  231. ³Exception Name ³Value ³
  232. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
  233. ³XCPT_GUARD_PAGE_VIOLATION ³0x80000001³
  234. ³ ExceptionInfo[0] - R/W flag ³ ³
  235. ³ ExceptionInfo[1] - FaultAddr ³ ³
  236. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
  237. ³XCPT_UNABLE_TO_GROW_STACK ³0x80010001³
  238. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
  239. Portable, Fatal, Hardware-Generated Exceptions
  240. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  241. ³Exception Name ³Value ³Related Trap ³
  242. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  243. ³XCPT_ACCESS_VIOLATION ³0xC0000005³0x09, 0x0B, ³
  244. ³ ExceptionInfo[0] - Flags ³ ³0x0C, 0x0D, ³
  245. ³ XCPT_UNKNOWN_ACCESS 0x0 ³ ³0x0E ³
  246. ³ XCPT_READ_ACCESS 0x1 ³ ³ ³
  247. ³ XCPT_WRITE_ACCESS 0x2 ³ ³ ³
  248. ³ XCPT_EXECUTE_ACCESS 0x4 ³ ³ ³
  249. ³ XCPT_SPACE_ACCESS 0x8 ³ ³ ³
  250. ³ XCPT_LIMIT_ACCESS 0x10 ³ ³ ³
  251. ³ ExceptionInfo[1] - FaultAddr ³ ³ ³
  252. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  253. ³XCPT_INTEGER_DIVIDE_BY_ZERO ³0xC000009B³0 ³
  254. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  255. ³XCPT_FLOAT_DIVIDE_BY_ZERO ³0xC0000095³0x10 ³
  256. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  257. ³XCPT_FLOAT_INVALID_OPERATION ³0xC0000097³0x10 ³
  258. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  259. ³XCPT_ILLEGAL_INSTRUCTION ³0xC000001C³0x06 ³
  260. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  261. ³XCPT_PRIVILEGED_INSTRUCTION ³0xC000009D³0x0D ³
  262. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  263. ³XCPT_INTEGER_OVERFLOW ³0xC000009C³0x04 ³
  264. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  265. ³XCPT_FLOAT_OVERFLOW ³0xC0000098³0x10 ³
  266. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  267. ³XCPT_FLOAT_UNDERFLOW ³0xC000009A³0x10 ³
  268. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  269. ³XCPT_FLOAT_DENORMAL_OPERAND ³0xC0000094³0x10 ³
  270. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  271. ³XCPT_FLOAT_INEXACT_RESULT ³0xC0000096³0x10 ³
  272. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  273. ³XCPT_FLOAT_STACK_CHECK ³0xC0000099³0x10 ³
  274. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  275. ³XCPT_DATATYPE_MISALIGNMENT ³0xC000009E³0x11 ³
  276. ³ ExceptionInfo[0] - R/W flag ³ ³ ³
  277. ³ ExceptionInfo[1] - Alignment ³ ³ ³
  278. ³ ExceptionInfo[2] - FaultAddr ³ ³ ³
  279. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  280. ³XCPT_BREAKPOINT ³0xC000009F³0x03 ³
  281. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  282. ³XCPT_SINGLE_STEP ³0xC00000A0³0x01 ³
  283. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  284. Portable, Fatal, Software-Generated Exceptions
  285. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  286. ³Exception Name ³Value ³Related Trap ³
  287. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  288. ³XCPT_IN_PAGE_ERROR ³0xC0000006³0x0E ³
  289. ³ ExceptionInfo[0] - FaultAddr ³ ³ ³
  290. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  291. ³XCPT_PROCESS_TERMINATE ³0xC0010001³ ³
  292. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  293. ³XCPT_ASYNC_PROCESS_TERMINATE ³0xC0010002³ ³
  294. ³ ExceptionInfo[0] - TID of ³ ³ ³
  295. ³ terminating thread ³ ³ ³
  296. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  297. ³XCPT_NONCONTINUABLE_EXCEPTION ³0xC0000024³ ³
  298. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  299. ³XCPT_INVALID_DISPOSITION ³0xC0000025³ ³
  300. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  301. Non-Portable, Fatal Exceptions
  302. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  303. ³Exception Name ³Value ³Related Trap ³
  304. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  305. ³XCPT_INVALID_LOCK_SEQUENCE ³0xC000001D³ ³
  306. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  307. ³XCPT_ARRAY_BOUNDS_EXCEEDED ³0xC0000093³0x05 ³
  308. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  309. Unwind Operation Exceptions
  310. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
  311. ³Exception Name ³Value ³
  312. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
  313. ³XCPT_UNWIND ³0xC0000026³
  314. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
  315. ³XCPT_BAD_STACK ³0xC0000027³
  316. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
  317. ³XCPT_INVALID_UNWIND_TARGET ³0xC0000028³
  318. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
  319. Fatal Signal Exceptions
  320. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄ¿
  321. ³Exception Name ³Value ³
  322. ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄ´
  323. ³XCPT_SIGNAL ³0xC0010003³
  324. ³ ExceptionInfo[ 0 ] - Signal ³ ³
  325. ³ Number ³ ³
  326. ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÙ
  327. *)
  328. {$ENDIF OS2EXCEPTIONS}
  329. {****************************************************************************
  330. Miscellaneous related routines.
  331. ****************************************************************************}
  332. procedure system_exit;
  333. begin
  334. DosExit(1{process}, exitcode);
  335. end;
  336. {$ASMMODE ATT}
  337. function paramcount:longint;assembler;
  338. asm
  339. movl argc,%eax
  340. decl %eax
  341. end {['EAX']};
  342. function args:pointer;assembler;
  343. asm
  344. movl argv,%eax
  345. end {['EAX']};
  346. function paramstr(l:longint):string;
  347. var p:^Pchar;
  348. begin
  349. if (l>=0) and (l<=paramcount) then
  350. begin
  351. p:=args;
  352. paramstr:=strpas(p[l]);
  353. end
  354. else paramstr:='';
  355. end;
  356. procedure randomize;
  357. var
  358. dt: TSysDateTime;
  359. begin
  360. // Hmm... Lets use timer
  361. DosGetDateTime(dt);
  362. randseed:=dt.hour+(dt.minute shl 8)+(dt.second shl 16)+(dt.sec100 shl 32);
  363. end;
  364. {$ASMMODE ATT}
  365. {****************************************************************************
  366. Heap management releated routines.
  367. ****************************************************************************}
  368. {Get some memory.
  369. P = Pointer to memory will be returned here.
  370. Size = Number of bytes to get. The size is rounded up to a multiple
  371. of 4096. This is probably not the case on non-intel 386
  372. versions of OS/2.
  373. Flags = One or more of the mfXXXX constants.}
  374. function DosAllocMem(var P:pointer;Size,Flag:cardinal): cardinal; cdecl;
  375. external 'DOSCALLS' index 299;
  376. function DosSetMem(P:pointer;Size,Flag:cardinal): cardinal; cdecl;
  377. external 'DOSCALLS' index 305;
  378. function DosFreeMem (P: pointer): cardinal; cdecl;
  379. external 'DOSCALLS' index 304;
  380. var
  381. { Int_Heap_End: pointer;}
  382. Int_Heap: pointer;
  383. {$IFNDEF VER1_0}
  384. external name 'HEAP';
  385. {$ENDIF VER1_0}
  386. Int_HeapSize: cardinal; external name 'HEAPSIZE';
  387. HighMemSupported: boolean;
  388. { PreviousHeap: cardinal;
  389. AllocatedMemory: cardinal;
  390. function GetHeapSize: longint;
  391. begin
  392. GetHeapSize := PreviousHeap + longint (Int_Heap_End) - longint (Int_Heap);
  393. end;
  394. }
  395. function GetHeapSize: longint; assembler;
  396. asm
  397. movl Int_HeapSize, %eax
  398. end ['EAX'];
  399. (*
  400. function Sbrk (Size: longint): pointer;
  401. var
  402. P: pointer;
  403. RC: cardinal;
  404. const
  405. MemAllocBlock = 4 * 1024 * 1024;
  406. begin
  407. { $IFDEF DUMPGROW}
  408. WriteLn ('Trying to grow heap by ', Size, ' to ', HeapSize + Size);
  409. { $ENDIF}
  410. // commit memory
  411. RC := DosSetMem (Int_Heap_End, Size, $13);
  412. if RC <> 0 then
  413. ( * Not enough memory was allocated - let's try to allocate more
  414. (4 MB steps or as much as requested if more than 4 MB needed). * )
  415. begin
  416. if Size > MemAllocBlock then
  417. begin
  418. RC := DosAllocMem (P, Size, 3);
  419. if RC = 0 then Inc (AllocatedMemory, Size);
  420. end
  421. else
  422. begin
  423. RC := DosAllocMem (P, MemAllocBlock, 3);
  424. if RC = 0 then Inc (AllocatedMemory, MemAllocBlock);
  425. end;
  426. if RC = 0 then
  427. begin
  428. PreviousHeap := GetHeapSize;
  429. Int_Heap := P;
  430. Int_Heap_End := P;
  431. RC := DosSetMem (Int_Heap_End, Size, $13);
  432. end
  433. else
  434. begin
  435. Sbrk := nil;
  436. { $IFDEF DUMPGROW}
  437. WriteLn ('Error ', RC, ' during additional memory allocation!');
  438. WriteLn ('Total allocated memory is ', cardinal (AllocatedMemory), ', ',
  439. GetHeapSize, ' committed.');
  440. { $ENDIF DUMPGROW}
  441. Exit;
  442. end;
  443. end;
  444. if RC <> 0 then
  445. begin
  446. { $IFDEF DUMPGROW}
  447. WriteLn ('Error ', RC, ' while trying to commit more memory!');
  448. WriteLn ('Current memory object starts at ', cardinal (Int_Heap),
  449. ' and committed until ', cardinal (Int_Heap_End));
  450. WriteLn ('Total allocated memory is ', cardinal (AllocatedMemory), ', ',
  451. GetHeapSize, ' committed.');
  452. { $ENDIF DUMPGROW}
  453. Sbrk := nil;
  454. end
  455. else
  456. begin
  457. Sbrk := Int_Heap_End;
  458. { $IFDEF DUMPGROW}
  459. WriteLn ('New heap at ', cardinal (Int_Heap_End));
  460. { $ENDIF DUMPGROW}
  461. Inc (Int_Heap_End, Size);
  462. end;
  463. end;
  464. *)
  465. {$IFDEF DUMPGROW}
  466. {$DEFINE EXTDUMPGROW}
  467. {$ENDIF DUMPGROW}
  468. function SysOSAlloc (Size: PtrInt): pointer;
  469. var
  470. P: pointer;
  471. RC: cardinal;
  472. begin
  473. {$IFDEF EXTDUMPGROW}
  474. WriteLn ('Trying to grow heap by ', Size, ' to ', Int_HeapSize
  475. + cardinal (Size));
  476. {$ENDIF}
  477. if HighMemSupported then
  478. RC := DosAllocMem (P, Size, $403)
  479. else
  480. RC := DosAllocMem (P, Size, 3);
  481. if RC = 0 then
  482. begin
  483. {$IFDEF EXTDUMPGROW}
  484. WriteLn ('DosAllocMem returned memory at ', cardinal (P));
  485. {$ENDIF}
  486. RC := DosSetMem (P, Size, $410);
  487. if RC = 0 then
  488. begin
  489. {$IFDEF EXTDUMPGROW}
  490. WriteLn ('New heap at ', cardinal (P));
  491. {$ENDIF EXTDUMPGROW}
  492. SysOSAlloc := P;
  493. Inc (Int_HeapSize, Size);
  494. end
  495. else
  496. begin
  497. {$IFDEF EXTDUMPGROW}
  498. WriteLn ('Error ', RC, ' in DosSetMem while trying to commit memory!');
  499. WriteLn ('Total allocated memory is ', Int_HeapSize);
  500. {$ENDIF EXTDUMPGROW}
  501. RC := DosFreeMem (P);
  502. SysOSAlloc := nil;
  503. end;
  504. end
  505. else
  506. begin
  507. SysOSAlloc := nil;
  508. {$IFDEF EXTDUMPGROW}
  509. WriteLn ('Error ', RC, ' during additional memory allocation (DosAllocMem)!');
  510. WriteLn ('Total allocated memory is ', Int_HeapSize);
  511. {$ENDIF EXTDUMPGROW}
  512. end;
  513. end;
  514. {$define HAS_SYSOSFREE}
  515. procedure SysOSFree (P: pointer; Size: PtrInt);
  516. var
  517. RC: cardinal;
  518. begin
  519. {$IFDEF EXTDUMPGROW}
  520. WriteLn ('Trying to free memory!');
  521. WriteLn ('Total allocated memory is ', Int_HeapSize);
  522. {$ENDIF EXTDUMPGROW}
  523. Dec (Int_HeapSize, Size);
  524. RC := DosSetMem (P, Size, $20);
  525. if RC = 0 then
  526. begin
  527. RC := DosFreeMem (P);
  528. {$IFDEF EXTDUMPGROW}
  529. if RC <> 0 then
  530. begin
  531. WriteLn ('Error ', RC, ' during memory deallocation (DosFreeMem)!');
  532. WriteLn ('Total allocated memory is ', Int_HeapSize);
  533. end;
  534. {$ENDIF EXTDUMPGROW}
  535. end
  536. {$IFDEF EXTDUMPGROW}
  537. else
  538. begin
  539. WriteLn ('Error ', RC, ' in DosSetMem while trying to decommit memory!');
  540. WriteLn ('Total allocated memory is ', Int_HeapSize);
  541. end;
  542. {$ENDIF EXTDUMPGROW}
  543. end;
  544. function GetHeapStart: pointer;
  545. begin
  546. GetHeapStart := Int_Heap;
  547. end;
  548. {$i heap.inc}
  549. {****************************************************************************
  550. Low Level File Routines
  551. ****************************************************************************}
  552. procedure allowslash(p:Pchar);
  553. {Allow slash as backslash.}
  554. var i:longint;
  555. begin
  556. for i:=0 to strlen(p) do
  557. if p[i]='/' then p[i]:='\';
  558. end;
  559. procedure do_close(h:thandle);
  560. begin
  561. { Only three standard handles under real OS/2 }
  562. if h>2 then
  563. begin
  564. InOutRes:=DosClose(h);
  565. end;
  566. {$ifdef IODEBUG}
  567. writeln('do_close: handle=', H, ', InOutRes=', InOutRes);
  568. {$endif}
  569. end;
  570. procedure do_erase(p:Pchar);
  571. begin
  572. allowslash(p);
  573. inoutres:=DosDelete(p);
  574. end;
  575. procedure do_rename(p1,p2:Pchar);
  576. begin
  577. allowslash(p1);
  578. allowslash(p2);
  579. inoutres:=DosMove(p1, p2);
  580. end;
  581. function do_read(h:thandle;addr:pointer;len:longint):longint;
  582. Var
  583. T: cardinal;
  584. begin
  585. {$ifdef IODEBUG}
  586. write('do_read: handle=', h, ', addr=', ptrint(addr), ', length=', len);
  587. {$endif}
  588. InOutRes:=DosRead(H, Addr, Len, T);
  589. do_read:= longint (T);
  590. {$ifdef IODEBUG}
  591. writeln(', actual_len=', t, ', InOutRes=', InOutRes);
  592. {$endif}
  593. end;
  594. function do_write(h:thandle;addr:pointer;len:longint) : longint;
  595. Var
  596. T: cardinal;
  597. begin
  598. {$ifdef IODEBUG}
  599. write('do_write: handle=', h, ', addr=', ptrint(addr), ', length=', len);
  600. {$endif}
  601. InOutRes:=DosWrite(H, Addr, Len, T);
  602. do_write:= longint (T);
  603. {$ifdef IODEBUG}
  604. writeln(', actual_len=', t, ', InOutRes=', InOutRes);
  605. {$endif}
  606. end;
  607. function do_filepos(handle:thandle): longint;
  608. var
  609. PosActual: cardinal;
  610. begin
  611. InOutRes:=DosSetFilePtr(Handle, 0, 1, PosActual);
  612. do_filepos:=longint (PosActual);
  613. {$ifdef IODEBUG}
  614. writeln('do_filepos: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
  615. {$endif}
  616. end;
  617. procedure do_seek(handle:thandle;pos:longint);
  618. var
  619. PosActual: cardinal;
  620. begin
  621. InOutRes:=DosSetFilePtr(Handle, Pos, 0 {ZeroBased}, PosActual);
  622. {$ifdef IODEBUG}
  623. writeln('do_seek: handle=', Handle, ', pos=', pos, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
  624. {$endif}
  625. end;
  626. function do_seekend(handle:thandle):longint;
  627. var
  628. PosActual: cardinal;
  629. begin
  630. InOutRes:=DosSetFilePtr(Handle, 0, 2 {EndBased}, PosActual);
  631. do_seekend:=longint (PosActual);
  632. {$ifdef IODEBUG}
  633. writeln('do_seekend: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
  634. {$endif}
  635. end;
  636. function do_filesize(handle:thandle):longint;
  637. var aktfilepos: cardinal;
  638. begin
  639. aktfilepos:=do_filepos(handle);
  640. do_filesize:=do_seekend(handle);
  641. do_seek(handle,aktfilepos);
  642. end;
  643. procedure do_truncate(handle:thandle;pos:longint);
  644. begin
  645. InOutRes:=DosSetFileSize(Handle, Pos);
  646. do_seekend(handle);
  647. end;
  648. const
  649. FileHandleCount: cardinal = 20;
  650. function Increase_File_Handle_Count: boolean;
  651. var Err: word;
  652. L1: longint;
  653. L2: cardinal;
  654. begin
  655. L1 := 10;
  656. if DosSetRelMaxFH (L1, L2) <> 0 then
  657. Increase_File_Handle_Count := false
  658. else
  659. if L2 > FileHandleCount then
  660. begin
  661. FileHandleCount := L2;
  662. Increase_File_Handle_Count := true;
  663. end
  664. else
  665. Increase_File_Handle_Count := false;
  666. end;
  667. procedure do_open(var f;p:pchar;flags:longint);
  668. {
  669. filerec and textrec have both handle and mode as the first items so
  670. they could use the same routine for opening/creating.
  671. when (flags and $100) the file will be append
  672. when (flags and $1000) the file will be truncate/rewritten
  673. when (flags and $10000) there is no check for close (needed for textfiles)
  674. }
  675. var
  676. Action, Attrib, OpenFlags, FM: Cardinal;
  677. begin
  678. // convert unix slashes to normal slashes
  679. allowslash(p);
  680. // close first if opened
  681. if ((flags and $10000)=0) then
  682. begin
  683. case filerec(f).mode of
  684. fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
  685. fmclosed:;
  686. else
  687. begin
  688. inoutres:=102; {not assigned}
  689. exit;
  690. end;
  691. end;
  692. end;
  693. // reset file handle
  694. filerec(f).handle := UnusedHandle;
  695. Attrib:=0;
  696. OpenFlags:=0;
  697. // convert filesharing
  698. FM := Flags and $FF and not (8);
  699. (* DenyNone if sharing not specified. *)
  700. if FM and 112 = 0 then
  701. FM := FM or 64;
  702. // convert filemode to filerec modes and access mode
  703. case (FM and 3) of
  704. 0: filerec(f).mode:=fminput;
  705. 1: filerec(f).mode:=fmoutput;
  706. 2: filerec(f).mode:=fminout;
  707. end;
  708. if (flags and $1000)<>0 then
  709. OpenFlags:=OpenFlags or 2 {doOverwrite} or 16 {doCreate} // Create/overwrite
  710. else
  711. OpenFlags:=OpenFlags or 1 {doOpen}; // Open existing
  712. // Handle Std I/O
  713. if p[0]=#0 then
  714. begin
  715. case FileRec(f).mode of
  716. fminput :
  717. FileRec(f).Handle:=StdInputHandle;
  718. fminout, // this is set by rewrite
  719. fmoutput :
  720. FileRec(f).Handle:=StdOutputHandle;
  721. fmappend :
  722. begin
  723. FileRec(f).Handle:=StdOutputHandle;
  724. FileRec(f).mode:=fmoutput; // fool fmappend
  725. end;
  726. end;
  727. exit;
  728. end;
  729. Attrib:=32 {faArchive};
  730. InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
  731. // If too many open files try to set more file handles and open again
  732. if (InOutRes = 4) then
  733. if Increase_File_Handle_Count then
  734. InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
  735. If InOutRes<>0 then FileRec(F).Handle:=UnusedHandle;
  736. // If Handle created -> make some things
  737. if (FileRec(F).Handle <> UnusedHandle) then
  738. begin
  739. // Move to end of file for Append command
  740. if ((Flags and $100) <> 0) then
  741. begin
  742. do_seekend(FileRec(F).Handle);
  743. FileRec(F).Mode := fmOutput;
  744. end;
  745. end;
  746. {$ifdef IODEBUG}
  747. writeln('do_open,', filerec(f).handle, ',', filerec(f).name, ',', filerec(f).mode, ', InOutRes=', InOutRes);
  748. {$endif}
  749. end;
  750. function do_isdevice (Handle: THandle): boolean;
  751. var
  752. HT, Attr: cardinal;
  753. begin
  754. do_isdevice:=false;
  755. If DosQueryHType(Handle, HT, Attr)<>0 then exit;
  756. if ht=1 then do_isdevice:=true;
  757. end;
  758. {$ASMMODE ATT}
  759. {*****************************************************************************
  760. UnTyped File Handling
  761. *****************************************************************************}
  762. {$i file.inc}
  763. {*****************************************************************************
  764. Typed File Handling
  765. *****************************************************************************}
  766. {$i typefile.inc}
  767. {*****************************************************************************
  768. Text File Handling
  769. *****************************************************************************}
  770. {$DEFINE EOF_CTRLZ}
  771. {$i text.inc}
  772. {****************************************************************************
  773. Directory related routines.
  774. ****************************************************************************}
  775. {*****************************************************************************
  776. Directory Handling
  777. *****************************************************************************}
  778. procedure MkDir (const S: string);[IOCHECK];
  779. var buffer:array[0..255] of char;
  780. Rc : word;
  781. begin
  782. If (s='') or (InOutRes <> 0) then
  783. exit;
  784. move(s[1],buffer,length(s));
  785. buffer[length(s)]:=#0;
  786. allowslash(Pchar(@buffer));
  787. Rc := DosCreateDir(buffer,nil);
  788. if Rc <> 0 then
  789. begin
  790. InOutRes := Rc;
  791. Errno2Inoutres;
  792. end;
  793. end;
  794. procedure rmdir(const s : string);[IOCHECK];
  795. var buffer:array[0..255] of char;
  796. Rc : word;
  797. begin
  798. if (s = '.' ) then
  799. InOutRes := 16;
  800. If (s='') or (InOutRes <> 0) then
  801. exit;
  802. move(s[1],buffer,length(s));
  803. buffer[length(s)]:=#0;
  804. allowslash(Pchar(@buffer));
  805. Rc := DosDeleteDir(buffer);
  806. if Rc <> 0 then
  807. begin
  808. InOutRes := Rc;
  809. Errno2Inoutres;
  810. end;
  811. end;
  812. {$ASMMODE INTEL}
  813. procedure ChDir (const S: string);[IOCheck];
  814. var RC: cardinal;
  815. Buffer: array [0..255] of char;
  816. begin
  817. If (s='') or (InOutRes <> 0) then exit;
  818. if (Length (S) >= 2) and (S [2] = ':') then
  819. begin
  820. RC := DosSetDefaultDisk ((Ord (S [1]) and not ($20)) - $40);
  821. if RC <> 0 then
  822. InOutRes := RC
  823. else
  824. if Length (S) > 2 then
  825. begin
  826. Move (S [1], Buffer, Length (S));
  827. Buffer [Length (S)] := #0;
  828. AllowSlash (PChar (@Buffer));
  829. RC := DosSetCurrentDir (@Buffer);
  830. if RC <> 0 then
  831. begin
  832. InOutRes := RC;
  833. Errno2InOutRes;
  834. end;
  835. end;
  836. end else begin
  837. Move (S [1], Buffer, Length (S));
  838. Buffer [Length (S)] := #0;
  839. AllowSlash (PChar (@Buffer));
  840. RC := DosSetCurrentDir (@Buffer);
  841. if RC <> 0 then
  842. begin
  843. InOutRes:= RC;
  844. Errno2InOutRes;
  845. end;
  846. end;
  847. end;
  848. {$ASMMODE ATT}
  849. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  850. {Written by Michael Van Canneyt.}
  851. var sof: Pchar;
  852. i:byte;
  853. l,l2:cardinal;
  854. begin
  855. Dir [4] := #0;
  856. { Used in case the specified drive isn't available }
  857. sof:=pchar(@dir[4]);
  858. { dir[1..3] will contain '[drivenr]:\', but is not }
  859. { supplied by DOS, so we let dos string start at }
  860. { dir[4] }
  861. { Get dir from drivenr : 0=default, 1=A etc... }
  862. l:=255-3;
  863. InOutRes:=longint (DosQueryCurrentDir(DriveNr, sof^, l));
  864. {$WARNING Result code should be translated in some cases!}
  865. { Now Dir should be filled with directory in ASCIIZ, }
  866. { starting from dir[4] }
  867. dir[0]:=#3;
  868. dir[2]:=':';
  869. dir[3]:='\';
  870. i:=4;
  871. {Conversion to Pascal string }
  872. while (dir[i]<>#0) do
  873. begin
  874. { convert path name to DOS }
  875. if dir[i]='/' then
  876. dir[i]:='\';
  877. dir[0]:=char(i);
  878. inc(i);
  879. end;
  880. { upcase the string (FPC function) }
  881. if drivenr<>0 then { Drive was supplied. We know it }
  882. dir[1]:=chr(64+drivenr)
  883. else
  884. begin
  885. { We need to get the current drive from DOS function 19H }
  886. { because the drive was the default, which can be unknown }
  887. DosQueryCurrentDisk(l, l2);
  888. dir[1]:=chr(64+l);
  889. end;
  890. if not (FileNameCaseSensitive) then dir:=upcase(dir);
  891. end;
  892. {*****************************************************************************
  893. System unit initialization.
  894. ****************************************************************************}
  895. {****************************************************************************
  896. Error Message writing using messageboxes
  897. ****************************************************************************}
  898. type
  899. TWinMessageBox = function (Parent, Owner: cardinal;
  900. BoxText, BoxTitle: PChar; Identity, Style: cardinal): cardinal; cdecl;
  901. TWinInitialize = function (Options: cardinal): cardinal; cdecl;
  902. TWinCreateMsgQueue = function (Handle: cardinal; cmsg: longint): cardinal;
  903. cdecl;
  904. const
  905. ErrorBufferLength = 1024;
  906. mb_OK = $0000;
  907. mb_Error = $0040;
  908. mb_Moveable = $4000;
  909. MBStyle = mb_OK or mb_Error or mb_Moveable;
  910. WinInitialize: TWinInitialize = nil;
  911. WinCreateMsgQueue: TWinCreateMsgQueue = nil;
  912. WinMessageBox: TWinMessageBox = nil;
  913. EnvSize: cardinal = 0;
  914. var
  915. ErrorBuf: array [0..ErrorBufferLength] of char;
  916. ErrorLen: longint;
  917. PMWinHandle: cardinal;
  918. function ErrorWrite (var F: TextRec): integer;
  919. {
  920. An error message should always end with #13#10#13#10
  921. }
  922. var
  923. P: PChar;
  924. I: longint;
  925. begin
  926. if F.BufPos > 0 then
  927. begin
  928. if F.BufPos + ErrorLen > ErrorBufferLength then
  929. I := ErrorBufferLength - ErrorLen
  930. else
  931. I := F.BufPos;
  932. Move (F.BufPtr^, ErrorBuf [ErrorLen], I);
  933. Inc (ErrorLen, I);
  934. ErrorBuf [ErrorLen] := #0;
  935. end;
  936. if ErrorLen > 3 then
  937. begin
  938. P := @ErrorBuf [ErrorLen];
  939. for I := 1 to 4 do
  940. begin
  941. Dec (P);
  942. if not (P^ in [#10, #13]) then
  943. break;
  944. end;
  945. end;
  946. if ErrorLen = ErrorBufferLength then
  947. I := 4;
  948. if (I = 4) then
  949. begin
  950. WinMessageBox (0, 0, @ErrorBuf, PChar ('Error'), 0, MBStyle);
  951. ErrorLen := 0;
  952. end;
  953. F.BufPos := 0;
  954. ErrorWrite := 0;
  955. end;
  956. function ErrorClose (var F: TextRec): integer;
  957. begin
  958. if ErrorLen > 0 then
  959. begin
  960. WinMessageBox (0, 0, @ErrorBuf, PChar ('Error'), 0, MBStyle);
  961. ErrorLen := 0;
  962. end;
  963. ErrorLen := 0;
  964. ErrorClose := 0;
  965. end;
  966. function ErrorOpen (var F: TextRec): integer;
  967. begin
  968. TextRec(F).InOutFunc := @ErrorWrite;
  969. TextRec(F).FlushFunc := @ErrorWrite;
  970. TextRec(F).CloseFunc := @ErrorClose;
  971. ErrorOpen := 0;
  972. end;
  973. procedure AssignError (var T: Text);
  974. begin
  975. Assign (T, '');
  976. TextRec (T).OpenFunc := @ErrorOpen;
  977. Rewrite (T);
  978. end;
  979. procedure SysInitStdIO;
  980. begin
  981. { Setup stdin, stdout and stderr, for GUI apps redirect stderr,stdout to be
  982. displayed in a messagebox }
  983. (*
  984. StdInputHandle := longint(GetStdHandle(cardinal(STD_INPUT_HANDLE)));
  985. StdOutputHandle := longint(GetStdHandle(cardinal(STD_OUTPUT_HANDLE)));
  986. StdErrorHandle := longint(GetStdHandle(cardinal(STD_ERROR_HANDLE)));
  987. if not IsConsole then
  988. begin
  989. if (DosLoadModule (nil, 0, 'PMWIN', PMWinHandle) = 0) and
  990. (DosQueryProcAddr (PMWinHandle, 789, nil, pointer (WinMessageBox)) = 0)
  991. and
  992. (DosQueryProcAddr (PMWinHandle, 763, nil, pointer (WinInitialize)) = 0)
  993. and
  994. (DosQueryProcAddr (PMWinHandle, 716, nil, pointer (WinCreateMsgQueue))
  995. = 0)
  996. then
  997. begin
  998. WinInitialize (0);
  999. WinCreateMsgQueue (0, 0);
  1000. end
  1001. else
  1002. HandleError (2);
  1003. AssignError (StdErr);
  1004. AssignError (StdOut);
  1005. Assign (Output, '');
  1006. Assign (Input, '');
  1007. end
  1008. else
  1009. begin
  1010. *)
  1011. OpenStdIO (Input, fmInput, StdInputHandle);
  1012. OpenStdIO (Output, fmOutput, StdOutputHandle);
  1013. OpenStdIO (StdOut, fmOutput, StdOutputHandle);
  1014. OpenStdIO (StdErr, fmOutput, StdErrorHandle);
  1015. (*
  1016. end;
  1017. *)
  1018. end;
  1019. function strcopy(dest,source : pchar) : pchar;assembler;
  1020. var
  1021. saveeax,saveesi,saveedi : longint;
  1022. asm
  1023. movl %edi,saveedi
  1024. movl %esi,saveesi
  1025. {$ifdef REGCALL}
  1026. movl %eax,saveeax
  1027. movl %edx,%edi
  1028. {$else}
  1029. movl source,%edi
  1030. {$endif}
  1031. testl %edi,%edi
  1032. jz .LStrCopyDone
  1033. leal 3(%edi),%ecx
  1034. andl $-4,%ecx
  1035. movl %edi,%esi
  1036. subl %edi,%ecx
  1037. {$ifdef REGCALL}
  1038. movl %eax,%edi
  1039. {$else}
  1040. movl dest,%edi
  1041. {$endif}
  1042. jz .LStrCopyAligned
  1043. .LStrCopyAlignLoop:
  1044. movb (%esi),%al
  1045. incl %edi
  1046. incl %esi
  1047. testb %al,%al
  1048. movb %al,-1(%edi)
  1049. jz .LStrCopyDone
  1050. decl %ecx
  1051. jnz .LStrCopyAlignLoop
  1052. .balign 16
  1053. .LStrCopyAligned:
  1054. movl (%esi),%eax
  1055. movl %eax,%edx
  1056. leal 0x0fefefeff(%eax),%ecx
  1057. notl %edx
  1058. addl $4,%esi
  1059. andl %edx,%ecx
  1060. andl $0x080808080,%ecx
  1061. jnz .LStrCopyEndFound
  1062. movl %eax,(%edi)
  1063. addl $4,%edi
  1064. jmp .LStrCopyAligned
  1065. .LStrCopyEndFound:
  1066. testl $0x0ff,%eax
  1067. jz .LStrCopyByte
  1068. testl $0x0ff00,%eax
  1069. jz .LStrCopyWord
  1070. testl $0x0ff0000,%eax
  1071. jz .LStrCopy3Bytes
  1072. movl %eax,(%edi)
  1073. jmp .LStrCopyDone
  1074. .LStrCopy3Bytes:
  1075. xorb %dl,%dl
  1076. movw %ax,(%edi)
  1077. movb %dl,2(%edi)
  1078. jmp .LStrCopyDone
  1079. .LStrCopyWord:
  1080. movw %ax,(%edi)
  1081. jmp .LStrCopyDone
  1082. .LStrCopyByte:
  1083. movb %al,(%edi)
  1084. .LStrCopyDone:
  1085. {$ifdef REGCALL}
  1086. movl saveeax,%eax
  1087. {$else}
  1088. movl dest,%eax
  1089. {$endif}
  1090. movl saveedi,%edi
  1091. movl saveesi,%esi
  1092. end;
  1093. procedure InitEnvironment;
  1094. var env_count : longint;
  1095. dos_env,cp : pchar;
  1096. begin
  1097. env_count:=0;
  1098. cp:=environment;
  1099. while cp ^ <> #0 do
  1100. begin
  1101. inc(env_count);
  1102. while (cp^ <> #0) do inc(longint(cp)); { skip to NUL }
  1103. inc(longint(cp)); { skip to next character }
  1104. end;
  1105. envp := sysgetmem((env_count+1) * sizeof(pchar));
  1106. envc := env_count;
  1107. if (envp = nil) then exit;
  1108. cp:=environment;
  1109. env_count:=0;
  1110. while cp^ <> #0 do
  1111. begin
  1112. envp[env_count] := sysgetmem(strlen(cp)+1);
  1113. strcopy(envp[env_count], cp);
  1114. {$IfDef DEBUGENVIRONMENT}
  1115. Writeln(stderr,'env ',env_count,' = "',envp[env_count],'"');
  1116. {$EndIf}
  1117. inc(env_count);
  1118. while (cp^ <> #0) do
  1119. inc(longint(cp)); { skip to NUL }
  1120. inc(longint(cp)); { skip to next character }
  1121. end;
  1122. envp[env_count]:=nil;
  1123. end;
  1124. procedure InitArguments;
  1125. var
  1126. arglen,
  1127. count : longint;
  1128. argstart,
  1129. pc,arg : pchar;
  1130. quote : char;
  1131. argvlen : longint;
  1132. procedure allocarg(idx,len:longint);
  1133. begin
  1134. if idx>=argvlen then
  1135. begin
  1136. argvlen:=(idx+8) and (not 7);
  1137. sysreallocmem(argv,argvlen*sizeof(pointer));
  1138. end;
  1139. { use realloc to reuse already existing memory }
  1140. { always allocate, even if length is zero, since }
  1141. { the arg. is still present! }
  1142. sysreallocmem(argv[idx],len+1);
  1143. end;
  1144. begin
  1145. count:=0;
  1146. argv:=nil;
  1147. argvlen:=0;
  1148. // Get argv[0]
  1149. pc:=cmdline;
  1150. Arglen:=0;
  1151. repeat
  1152. Inc(Arglen);
  1153. until (pc[Arglen]=#0);
  1154. allocarg(count,arglen);
  1155. move(pc^,argv[count]^,arglen);
  1156. { ReSetup cmdline variable }
  1157. repeat
  1158. Inc(Arglen);
  1159. until (pc[Arglen]=#0);
  1160. Inc(Arglen);
  1161. pc:=GetMem(ArgLen);
  1162. move(cmdline^, pc^, arglen);
  1163. Arglen:=0;
  1164. repeat
  1165. Inc(Arglen);
  1166. until (pc[Arglen]=#0);
  1167. pc[Arglen]:=' '; // combine argv[0] and command line
  1168. CmdLine:=pc;
  1169. { process arguments }
  1170. pc:=cmdline;
  1171. {$IfDef DEBUGARGUMENTS}
  1172. Writeln(stderr,'GetCommandLine is #',pc,'#');
  1173. {$EndIf }
  1174. while pc^<>#0 do
  1175. begin
  1176. { skip leading spaces }
  1177. while pc^ in [#1..#32] do
  1178. inc(pc);
  1179. if pc^=#0 then
  1180. break;
  1181. { calc argument length }
  1182. quote:=' ';
  1183. argstart:=pc;
  1184. arglen:=0;
  1185. while (pc^<>#0) do
  1186. begin
  1187. case pc^ of
  1188. #1..#32 :
  1189. begin
  1190. if quote<>' ' then
  1191. inc(arglen)
  1192. else
  1193. break;
  1194. end;
  1195. '"' :
  1196. begin
  1197. if quote<>'''' then
  1198. begin
  1199. if pchar(pc+1)^<>'"' then
  1200. begin
  1201. if quote='"' then
  1202. quote:=' '
  1203. else
  1204. quote:='"';
  1205. end
  1206. else
  1207. inc(pc);
  1208. end
  1209. else
  1210. inc(arglen);
  1211. end;
  1212. '''' :
  1213. begin
  1214. if quote<>'"' then
  1215. begin
  1216. if pchar(pc+1)^<>'''' then
  1217. begin
  1218. if quote='''' then
  1219. quote:=' '
  1220. else
  1221. quote:='''';
  1222. end
  1223. else
  1224. inc(pc);
  1225. end
  1226. else
  1227. inc(arglen);
  1228. end;
  1229. else
  1230. inc(arglen);
  1231. end;
  1232. inc(pc);
  1233. end;
  1234. { copy argument }
  1235. { Don't copy the first one, it is already there.}
  1236. If Count<>0 then
  1237. begin
  1238. allocarg(count,arglen);
  1239. quote:=' ';
  1240. pc:=argstart;
  1241. arg:=argv[count];
  1242. while (pc^<>#0) do
  1243. begin
  1244. case pc^ of
  1245. #1..#32 :
  1246. begin
  1247. if quote<>' ' then
  1248. begin
  1249. arg^:=pc^;
  1250. inc(arg);
  1251. end
  1252. else
  1253. break;
  1254. end;
  1255. '"' :
  1256. begin
  1257. if quote<>'''' then
  1258. begin
  1259. if pchar(pc+1)^<>'"' then
  1260. begin
  1261. if quote='"' then
  1262. quote:=' '
  1263. else
  1264. quote:='"';
  1265. end
  1266. else
  1267. inc(pc);
  1268. end
  1269. else
  1270. begin
  1271. arg^:=pc^;
  1272. inc(arg);
  1273. end;
  1274. end;
  1275. '''' :
  1276. begin
  1277. if quote<>'"' then
  1278. begin
  1279. if pchar(pc+1)^<>'''' then
  1280. begin
  1281. if quote='''' then
  1282. quote:=' '
  1283. else
  1284. quote:='''';
  1285. end
  1286. else
  1287. inc(pc);
  1288. end
  1289. else
  1290. begin
  1291. arg^:=pc^;
  1292. inc(arg);
  1293. end;
  1294. end;
  1295. else
  1296. begin
  1297. arg^:=pc^;
  1298. inc(arg);
  1299. end;
  1300. end;
  1301. inc(pc);
  1302. end;
  1303. arg^:=#0;
  1304. end;
  1305. {$IfDef DEBUGARGUMENTS}
  1306. Writeln(stderr,'dos arg ',count,' #',arglen,'#',argv[count],'#');
  1307. {$EndIf}
  1308. inc(count);
  1309. end;
  1310. { get argc and create an nil entry }
  1311. argc:=count;
  1312. allocarg(argc,0);
  1313. { free unused memory }
  1314. sysreallocmem(argv,(argc+1)*sizeof(pointer));
  1315. end;
  1316. function GetFileHandleCount: longint;
  1317. var L1: longint;
  1318. L2: cardinal;
  1319. begin
  1320. L1 := 0; (* Don't change the amount, just check. *)
  1321. if DosSetRelMaxFH (L1, L2) <> 0 then GetFileHandleCount := 50
  1322. else GetFileHandleCount := L2;
  1323. end;
  1324. var TIB: PThreadInfoBlock;
  1325. PIB: PProcessInfoBlock;
  1326. RC: cardinal;
  1327. ErrStr: string;
  1328. begin
  1329. IsLibrary := FALSE;
  1330. (* Initialize the amount of file handles *)
  1331. FileHandleCount := GetFileHandleCount;
  1332. DosGetInfoBlocks (@TIB, @PIB);
  1333. StackBottom := TIB^.Stack;
  1334. {Set type of application}
  1335. ApplicationType := PIB^.ProcType;
  1336. ProcessID := PIB^.PID;
  1337. ThreadID := TIB^.TIB2^.TID;
  1338. IsConsole := ApplicationType <> 3;
  1339. exitproc:=nil;
  1340. {Initialize the heap.}
  1341. // Logic is following:
  1342. // Application allocates the amount of memory specified by the compiler
  1343. // switch -Ch but without commiting. On heap growing required amount of
  1344. // memory commited. More memory is allocated as needed within sbrk.
  1345. (* Being changed now - new behaviour will be documented after *)
  1346. (* things settle down a bit and everything is tested properly. *)
  1347. RC := DosAllocMem (Int_Heap, Int_HeapSize, $403);
  1348. if RC = 87 then
  1349. begin
  1350. (* Using of high memory address space (> 512 MB) *)
  1351. (* is not supported on this system. *)
  1352. RC := DosAllocMem (Int_Heap, Int_HeapSize, 3);
  1353. HighMemSupported := false;
  1354. end
  1355. else
  1356. HighMemSupported := true;
  1357. if RC <> 0 then
  1358. begin
  1359. Str (RC, ErrStr);
  1360. ErrStr := 'Error during heap initialization (DosAllocMem - ' + ErrStr + ')!!'#13#10;
  1361. DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
  1362. HandleError (204);
  1363. end
  1364. else
  1365. begin
  1366. RC := DosSetMem (Int_Heap, Int_HeapSize, $410);
  1367. if RC <> 0 then
  1368. begin
  1369. Str (RC, ErrStr);
  1370. ErrStr := 'Error during heap initialization (DosSetMem - ' + ErrStr + ')!!'#13#10;
  1371. DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
  1372. HandleError (204);
  1373. end
  1374. {$IFDEF EXTDUMPGROW}
  1375. else
  1376. begin
  1377. Str (Int_HeapSize, ErrStr);
  1378. ErrStr := 'Initially allocated ' + ErrStr + ' bytes of memory.'#13#10;
  1379. DosWrite (1, @ErrStr [1], Length (ErrStr), RC);
  1380. end
  1381. {$ENDIF}
  1382. end;
  1383. InitHeap;
  1384. { ... and exceptions }
  1385. SysInitExceptions;
  1386. { ... and I/O }
  1387. SysInitStdIO;
  1388. { no I/O-Error }
  1389. inoutres:=0;
  1390. {Initialize environment (must be after InitHeap because allocates memory)}
  1391. Environment := pointer (PIB^.Env);
  1392. InitEnvironment;
  1393. CmdLine := pointer (PIB^.Cmd);
  1394. InitArguments;
  1395. {$ifdef HASVARIANT}
  1396. initvariantmanager;
  1397. {$endif HASVARIANT}
  1398. {$IFDEF DUMPGROW}
  1399. WriteLn ('Initial brk size is ', GetHeapSize);
  1400. {$ENDIF DUMPGROW}
  1401. end.
  1402. {
  1403. $Log$
  1404. Revision 1.74 2004-09-18 11:12:09 hajny
  1405. * handle type changed to thandle in do_isdevice
  1406. Revision 1.73 2004/09/11 19:43:11 hajny
  1407. * missing MaxExitCode added
  1408. Revision 1.72 2004/07/18 15:20:38 hajny
  1409. + Memory allocation routines changed to support the new memory manager
  1410. Revision 1.71 2004/05/16 18:51:20 peter
  1411. * use thandle in do_*
  1412. Revision 1.70 2004/04/22 21:10:56 peter
  1413. * do_read/do_write addr argument changed to pointer
  1414. Revision 1.69 2004/03/24 19:23:09 hajny
  1415. * misleading warning removed
  1416. Revision 1.68 2004/03/24 19:15:59 hajny
  1417. * heap management modified to be able to grow heap as needed
  1418. Revision 1.67 2004/02/22 15:01:49 hajny
  1419. * lots of fixes (regcall, THandle, string operations in sysutils, longint2cardinal according to OS/2 docs, dosh.inc, ...)
  1420. Revision 1.66 2004/02/16 22:18:44 hajny
  1421. * LastDosExitCode changed back from threadvar temporarily
  1422. Revision 1.65 2004/02/02 03:24:09 yuri
  1423. - prt1.as removed
  1424. - removed tmporary code/comments
  1425. - prt1 compilation error workaround removed
  1426. Revision 1.64 2004/01/25 21:41:48 hajny
  1427. * reformatting of too long comment lines - not accepted by FP IDE
  1428. Revision 1.63 2004/01/21 14:15:42 florian
  1429. * fixed win32 compilation
  1430. Revision 1.62 2004/01/20 23:11:20 hajny
  1431. * ExecuteProcess fixes, ProcessID and ThreadID added
  1432. Revision 1.61 2003/12/04 21:22:38 peter
  1433. * regcall updates (untested)
  1434. Revision 1.60 2003/11/23 07:21:16 yuri
  1435. * native heap
  1436. Revision 1.59 2003/11/19 18:21:11 yuri
  1437. * Memory allocation bug fixed
  1438. Revision 1.58 2003/11/19 16:50:21 yuri
  1439. * Environment and arguments initialization now native
  1440. Revision 1.57 2003/11/06 17:20:44 yuri
  1441. * Unused constants removed
  1442. Revision 1.56 2003/11/03 09:42:28 marco
  1443. * Peter's Cardinal<->Longint fixes patch
  1444. Revision 1.55 2003/11/02 00:51:17 hajny
  1445. * corrections for do_open and os_mode back
  1446. Revision 1.54 2003/10/28 14:57:31 yuri
  1447. * do_* functions now native
  1448. Revision 1.53 2003/10/27 04:33:58 yuri
  1449. * os_mode removed (not required anymore)
  1450. Revision 1.52 2003/10/25 22:45:37 hajny
  1451. * file handling related fixes
  1452. Revision 1.51 2003/10/19 12:13:41 hajny
  1453. * UnusedHandle value made the same as with other targets
  1454. Revision 1.50 2003/10/19 09:37:00 hajny
  1455. * minor fix in non-default sbrk code
  1456. Revision 1.49 2003/10/19 09:06:28 hajny
  1457. * fix for terrible long-time bug in do_open
  1458. Revision 1.48 2003/10/18 16:58:39 hajny
  1459. * stdcall fixes again
  1460. Revision 1.47 2003/10/16 15:43:13 peter
  1461. * THandle is platform dependent
  1462. Revision 1.46 2003/10/14 21:10:06 hajny
  1463. * another longint2cardinal fix
  1464. Revision 1.45 2003/10/13 21:17:31 hajny
  1465. * longint to cardinal corrections
  1466. Revision 1.44 2003/10/12 18:07:30 hajny
  1467. * wrong use of Intel syntax
  1468. Revision 1.43 2003/10/12 17:59:40 hajny
  1469. * wrong use of Intel syntax
  1470. Revision 1.42 2003/10/12 17:52:28 hajny
  1471. * wrong use of Intel syntax
  1472. Revision 1.41 2003/10/12 10:45:36 hajny
  1473. * sbrk error handling corrected
  1474. Revision 1.40 2003/10/07 21:26:35 hajny
  1475. * stdcall fixes and asm routines cleanup
  1476. Revision 1.39 2003/10/06 16:58:27 yuri
  1477. * Another set of native functions.
  1478. Revision 1.38 2003/10/06 14:22:40 yuri
  1479. * Some emx code removed. Now withous so stupid error as with dos ;)
  1480. Revision 1.37 2003/10/04 08:30:59 yuri
  1481. * at&t syntax instead of intel syntax was used
  1482. Revision 1.36 2003/10/03 21:46:41 peter
  1483. * stdcall fixes
  1484. Revision 1.35 2003/10/01 18:42:49 yuri
  1485. * Unclosed comment
  1486. Revision 1.34 2003/09/29 18:39:59 hajny
  1487. * append fix applied to GO32v2, OS/2 and EMX
  1488. Revision 1.33 2003/09/27 11:52:36 peter
  1489. * sbrk returns pointer
  1490. Revision 1.32 2003/03/30 09:20:30 hajny
  1491. * platform extension unification
  1492. Revision 1.31 2003/01/15 22:16:12 hajny
  1493. * default sharing mode changed to DenyNone
  1494. Revision 1.30 2002/12/15 22:41:41 hajny
  1495. * First_Meg fixed + Environment initialization under Dos
  1496. Revision 1.29 2002/12/08 16:39:58 hajny
  1497. - WriteLn in GUI mode support commented out until fixed
  1498. Revision 1.28 2002/12/07 19:17:14 hajny
  1499. * GetEnv correction, better PM support, ...
  1500. Revision 1.27 2002/11/17 22:31:02 hajny
  1501. * type corrections (longint x cardinal)
  1502. Revision 1.26 2002/10/27 14:29:00 hajny
  1503. * heap management (hopefully) fixed
  1504. Revision 1.25 2002/10/14 19:39:17 peter
  1505. * threads unit added for thread support
  1506. Revision 1.24 2002/10/13 09:28:45 florian
  1507. + call to initvariantmanager inserted
  1508. Revision 1.23 2002/09/07 16:01:25 peter
  1509. * old logs removed and tabs fixed
  1510. Revision 1.22 2002/07/01 16:29:05 peter
  1511. * sLineBreak changed to normal constant like Kylix
  1512. Revision 1.21 2002/04/21 15:54:20 carl
  1513. + initialize some global variables
  1514. Revision 1.20 2002/04/12 17:42:16 carl
  1515. + generic stack checking
  1516. Revision 1.19 2002/03/11 19:10:33 peter
  1517. * Regenerated with updated fpcmake
  1518. Revision 1.18 2002/02/10 13:46:20 hajny
  1519. * heap management corrected (heap_brk)
  1520. }