system.pas 49 KB

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