system.pas 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705
  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. HighMemSupported: boolean;
  382. Int_Heap : Pointer;
  383. Int_heapSize : longint;
  384. {$IFDEF DUMPGROW}
  385. {$DEFINE EXTDUMPGROW}
  386. {$ENDIF DUMPGROW}
  387. function SysOSAlloc (Size: PtrInt): pointer;
  388. var
  389. P: pointer;
  390. RC: cardinal;
  391. begin
  392. {$IFDEF EXTDUMPGROW}
  393. WriteLn ('Trying to grow heap by ', Size);
  394. {$ENDIF}
  395. if HighMemSupported then
  396. RC := DosAllocMem (P, Size, $403)
  397. else
  398. RC := DosAllocMem (P, Size, 3);
  399. if RC = 0 then
  400. begin
  401. {$IFDEF EXTDUMPGROW}
  402. WriteLn ('DosAllocMem returned memory at ', cardinal (P));
  403. {$ENDIF}
  404. RC := DosSetMem (P, Size, $410);
  405. if RC = 0 then
  406. begin
  407. {$IFDEF EXTDUMPGROW}
  408. WriteLn ('New heap at ', cardinal (P));
  409. {$ENDIF EXTDUMPGROW}
  410. SysOSAlloc := P;
  411. Inc (Int_HeapSize, Size);
  412. end
  413. else
  414. begin
  415. {$IFDEF EXTDUMPGROW}
  416. WriteLn ('Error ', RC, ' in DosSetMem while trying to commit memory!');
  417. WriteLn ('Total allocated memory is ', Int_HeapSize);
  418. {$ENDIF EXTDUMPGROW}
  419. RC := DosFreeMem (P);
  420. SysOSAlloc := nil;
  421. end;
  422. end
  423. else
  424. begin
  425. SysOSAlloc := nil;
  426. {$IFDEF EXTDUMPGROW}
  427. WriteLn ('Error ', RC, ' during additional memory allocation (DosAllocMem)!');
  428. WriteLn ('Total allocated memory is ', Int_HeapSize);
  429. {$ENDIF EXTDUMPGROW}
  430. end;
  431. end;
  432. {$define HAS_SYSOSFREE}
  433. procedure SysOSFree (P: pointer; Size: PtrInt);
  434. var
  435. RC: cardinal;
  436. begin
  437. {$IFDEF EXTDUMPGROW}
  438. WriteLn ('Trying to free memory!');
  439. WriteLn ('Total allocated memory is ', Int_HeapSize);
  440. {$ENDIF EXTDUMPGROW}
  441. Dec (Int_HeapSize, Size);
  442. RC := DosSetMem (P, Size, $20);
  443. if RC = 0 then
  444. begin
  445. RC := DosFreeMem (P);
  446. {$IFDEF EXTDUMPGROW}
  447. if RC <> 0 then
  448. begin
  449. WriteLn ('Error ', RC, ' during memory deallocation (DosFreeMem)!');
  450. WriteLn ('Total allocated memory is ', Int_HeapSize);
  451. end;
  452. {$ENDIF EXTDUMPGROW}
  453. end
  454. {$IFDEF EXTDUMPGROW}
  455. else
  456. begin
  457. WriteLn ('Error ', RC, ' in DosSetMem while trying to decommit memory!');
  458. WriteLn ('Total allocated memory is ', Int_HeapSize);
  459. end;
  460. {$ENDIF EXTDUMPGROW}
  461. end;
  462. {$i heap.inc}
  463. {****************************************************************************
  464. Low Level File Routines
  465. ****************************************************************************}
  466. procedure allowslash(p:Pchar);
  467. {Allow slash as backslash.}
  468. var i:longint;
  469. begin
  470. for i:=0 to strlen(p) do
  471. if p[i]='/' then p[i]:='\';
  472. end;
  473. procedure do_close(h:thandle);
  474. begin
  475. { Only three standard handles under real OS/2 }
  476. if h>2 then
  477. begin
  478. InOutRes:=DosClose(h);
  479. end;
  480. {$ifdef IODEBUG}
  481. writeln('do_close: handle=', H, ', InOutRes=', InOutRes);
  482. {$endif}
  483. end;
  484. procedure do_erase(p:Pchar);
  485. begin
  486. allowslash(p);
  487. inoutres:=DosDelete(p);
  488. end;
  489. procedure do_rename(p1,p2:Pchar);
  490. begin
  491. allowslash(p1);
  492. allowslash(p2);
  493. inoutres:=DosMove(p1, p2);
  494. end;
  495. function do_read(h:thandle;addr:pointer;len:longint):longint;
  496. Var
  497. T: cardinal;
  498. begin
  499. {$ifdef IODEBUG}
  500. write('do_read: handle=', h, ', addr=', ptrint(addr), ', length=', len);
  501. {$endif}
  502. InOutRes:=DosRead(H, Addr, Len, T);
  503. do_read:= longint (T);
  504. {$ifdef IODEBUG}
  505. writeln(', actual_len=', t, ', InOutRes=', InOutRes);
  506. {$endif}
  507. end;
  508. function do_write(h:thandle;addr:pointer;len:longint) : longint;
  509. Var
  510. T: cardinal;
  511. begin
  512. {$ifdef IODEBUG}
  513. write('do_write: handle=', h, ', addr=', ptrint(addr), ', length=', len);
  514. {$endif}
  515. InOutRes:=DosWrite(H, Addr, Len, T);
  516. do_write:= longint (T);
  517. {$ifdef IODEBUG}
  518. writeln(', actual_len=', t, ', InOutRes=', InOutRes);
  519. {$endif}
  520. end;
  521. function do_filepos(handle:thandle): longint;
  522. var
  523. PosActual: cardinal;
  524. begin
  525. InOutRes:=DosSetFilePtr(Handle, 0, 1, PosActual);
  526. do_filepos:=longint (PosActual);
  527. {$ifdef IODEBUG}
  528. writeln('do_filepos: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
  529. {$endif}
  530. end;
  531. procedure do_seek(handle:thandle;pos:longint);
  532. var
  533. PosActual: cardinal;
  534. begin
  535. InOutRes:=DosSetFilePtr(Handle, Pos, 0 {ZeroBased}, PosActual);
  536. {$ifdef IODEBUG}
  537. writeln('do_seek: handle=', Handle, ', pos=', pos, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
  538. {$endif}
  539. end;
  540. function do_seekend(handle:thandle):longint;
  541. var
  542. PosActual: cardinal;
  543. begin
  544. InOutRes:=DosSetFilePtr(Handle, 0, 2 {EndBased}, PosActual);
  545. do_seekend:=longint (PosActual);
  546. {$ifdef IODEBUG}
  547. writeln('do_seekend: handle=', Handle, ', actual_pos=', PosActual, ', InOutRes=', InOutRes);
  548. {$endif}
  549. end;
  550. function do_filesize(handle:thandle):longint;
  551. var aktfilepos: cardinal;
  552. begin
  553. aktfilepos:=do_filepos(handle);
  554. do_filesize:=do_seekend(handle);
  555. do_seek(handle,aktfilepos);
  556. end;
  557. procedure do_truncate(handle:thandle;pos:longint);
  558. begin
  559. InOutRes:=DosSetFileSize(Handle, Pos);
  560. do_seekend(handle);
  561. end;
  562. const
  563. FileHandleCount: cardinal = 20;
  564. function Increase_File_Handle_Count: boolean;
  565. var Err: word;
  566. L1: longint;
  567. L2: cardinal;
  568. begin
  569. L1 := 10;
  570. if DosSetRelMaxFH (L1, L2) <> 0 then
  571. Increase_File_Handle_Count := false
  572. else
  573. if L2 > FileHandleCount then
  574. begin
  575. FileHandleCount := L2;
  576. Increase_File_Handle_Count := true;
  577. end
  578. else
  579. Increase_File_Handle_Count := false;
  580. end;
  581. procedure do_open(var f;p:pchar;flags:longint);
  582. {
  583. filerec and textrec have both handle and mode as the first items so
  584. they could use the same routine for opening/creating.
  585. when (flags and $100) the file will be append
  586. when (flags and $1000) the file will be truncate/rewritten
  587. when (flags and $10000) there is no check for close (needed for textfiles)
  588. }
  589. var
  590. Action, Attrib, OpenFlags, FM: Cardinal;
  591. begin
  592. // convert unix slashes to normal slashes
  593. allowslash(p);
  594. // close first if opened
  595. if ((flags and $10000)=0) then
  596. begin
  597. case filerec(f).mode of
  598. fminput,fmoutput,fminout : Do_Close(filerec(f).handle);
  599. fmclosed:;
  600. else
  601. begin
  602. inoutres:=102; {not assigned}
  603. exit;
  604. end;
  605. end;
  606. end;
  607. // reset file handle
  608. filerec(f).handle := UnusedHandle;
  609. Attrib:=0;
  610. OpenFlags:=0;
  611. // convert filesharing
  612. FM := Flags and $FF and not (8);
  613. (* DenyNone if sharing not specified. *)
  614. if FM and 112 = 0 then
  615. FM := FM or 64;
  616. // convert filemode to filerec modes and access mode
  617. case (FM and 3) of
  618. 0: filerec(f).mode:=fminput;
  619. 1: filerec(f).mode:=fmoutput;
  620. 2: filerec(f).mode:=fminout;
  621. end;
  622. if (flags and $1000)<>0 then
  623. OpenFlags:=OpenFlags or 2 {doOverwrite} or 16 {doCreate} // Create/overwrite
  624. else
  625. OpenFlags:=OpenFlags or 1 {doOpen}; // Open existing
  626. // Handle Std I/O
  627. if p[0]=#0 then
  628. begin
  629. case FileRec(f).mode of
  630. fminput :
  631. FileRec(f).Handle:=StdInputHandle;
  632. fminout, // this is set by rewrite
  633. fmoutput :
  634. FileRec(f).Handle:=StdOutputHandle;
  635. fmappend :
  636. begin
  637. FileRec(f).Handle:=StdOutputHandle;
  638. FileRec(f).mode:=fmoutput; // fool fmappend
  639. end;
  640. end;
  641. exit;
  642. end;
  643. Attrib:=32 {faArchive};
  644. InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
  645. // If too many open files try to set more file handles and open again
  646. if (InOutRes = 4) then
  647. if Increase_File_Handle_Count then
  648. InOutRes:=DosOpen(p, FileRec(F).Handle, Action, 0, Attrib, OpenFlags, FM, nil);
  649. If InOutRes<>0 then FileRec(F).Handle:=UnusedHandle;
  650. // If Handle created -> make some things
  651. if (FileRec(F).Handle <> UnusedHandle) then
  652. begin
  653. // Move to end of file for Append command
  654. if ((Flags and $100) <> 0) then
  655. begin
  656. do_seekend(FileRec(F).Handle);
  657. FileRec(F).Mode := fmOutput;
  658. end;
  659. end;
  660. {$ifdef IODEBUG}
  661. writeln('do_open,', filerec(f).handle, ',', filerec(f).name, ',', filerec(f).mode, ', InOutRes=', InOutRes);
  662. {$endif}
  663. end;
  664. function do_isdevice (Handle: THandle): boolean;
  665. var
  666. HT, Attr: cardinal;
  667. begin
  668. do_isdevice:=false;
  669. If DosQueryHType(Handle, HT, Attr)<>0 then exit;
  670. if ht=1 then do_isdevice:=true;
  671. end;
  672. {$ASMMODE ATT}
  673. {*****************************************************************************
  674. UnTyped File Handling
  675. *****************************************************************************}
  676. {$i file.inc}
  677. {*****************************************************************************
  678. Typed File Handling
  679. *****************************************************************************}
  680. {$i typefile.inc}
  681. {*****************************************************************************
  682. Text File Handling
  683. *****************************************************************************}
  684. {$DEFINE EOF_CTRLZ}
  685. {$i text.inc}
  686. {****************************************************************************
  687. Directory related routines.
  688. ****************************************************************************}
  689. {*****************************************************************************
  690. Directory Handling
  691. *****************************************************************************}
  692. procedure MkDir (const S: string);[IOCHECK];
  693. var buffer:array[0..255] of char;
  694. Rc : word;
  695. begin
  696. If (s='') or (InOutRes <> 0) then
  697. exit;
  698. move(s[1],buffer,length(s));
  699. buffer[length(s)]:=#0;
  700. allowslash(Pchar(@buffer));
  701. Rc := DosCreateDir(buffer,nil);
  702. if Rc <> 0 then
  703. begin
  704. InOutRes := Rc;
  705. Errno2Inoutres;
  706. end;
  707. end;
  708. procedure rmdir(const s : string);[IOCHECK];
  709. var buffer:array[0..255] of char;
  710. Rc : word;
  711. begin
  712. if (s = '.' ) then
  713. InOutRes := 16;
  714. If (s='') or (InOutRes <> 0) then
  715. exit;
  716. move(s[1],buffer,length(s));
  717. buffer[length(s)]:=#0;
  718. allowslash(Pchar(@buffer));
  719. Rc := DosDeleteDir(buffer);
  720. if Rc <> 0 then
  721. begin
  722. InOutRes := Rc;
  723. Errno2Inoutres;
  724. end;
  725. end;
  726. {$ASMMODE INTEL}
  727. procedure ChDir (const S: string);[IOCheck];
  728. var RC: cardinal;
  729. Buffer: array [0..255] of char;
  730. begin
  731. If (s='') or (InOutRes <> 0) then exit;
  732. if (Length (S) >= 2) and (S [2] = ':') then
  733. begin
  734. RC := DosSetDefaultDisk ((Ord (S [1]) and not ($20)) - $40);
  735. if RC <> 0 then
  736. InOutRes := RC
  737. else
  738. if Length (S) > 2 then
  739. begin
  740. Move (S [1], Buffer, Length (S));
  741. Buffer [Length (S)] := #0;
  742. AllowSlash (PChar (@Buffer));
  743. RC := DosSetCurrentDir (@Buffer);
  744. if RC <> 0 then
  745. begin
  746. InOutRes := RC;
  747. Errno2InOutRes;
  748. end;
  749. end;
  750. end else begin
  751. Move (S [1], Buffer, Length (S));
  752. Buffer [Length (S)] := #0;
  753. AllowSlash (PChar (@Buffer));
  754. RC := DosSetCurrentDir (@Buffer);
  755. if RC <> 0 then
  756. begin
  757. InOutRes:= RC;
  758. Errno2InOutRes;
  759. end;
  760. end;
  761. end;
  762. {$ASMMODE ATT}
  763. procedure GetDir (DriveNr: byte; var Dir: ShortString);
  764. {Written by Michael Van Canneyt.}
  765. var sof: Pchar;
  766. i:byte;
  767. l,l2:cardinal;
  768. begin
  769. Dir [4] := #0;
  770. { Used in case the specified drive isn't available }
  771. sof:=pchar(@dir[4]);
  772. { dir[1..3] will contain '[drivenr]:\', but is not }
  773. { supplied by DOS, so we let dos string start at }
  774. { dir[4] }
  775. { Get dir from drivenr : 0=default, 1=A etc... }
  776. l:=255-3;
  777. InOutRes:=longint (DosQueryCurrentDir(DriveNr, sof^, l));
  778. {$WARNING Result code should be translated in some cases!}
  779. { Now Dir should be filled with directory in ASCIIZ, }
  780. { starting from dir[4] }
  781. dir[0]:=#3;
  782. dir[2]:=':';
  783. dir[3]:='\';
  784. i:=4;
  785. {Conversion to Pascal string }
  786. while (dir[i]<>#0) do
  787. begin
  788. { convert path name to DOS }
  789. if dir[i]='/' then
  790. dir[i]:='\';
  791. dir[0]:=char(i);
  792. inc(i);
  793. end;
  794. { upcase the string (FPC function) }
  795. if drivenr<>0 then { Drive was supplied. We know it }
  796. dir[1]:=chr(64+drivenr)
  797. else
  798. begin
  799. { We need to get the current drive from DOS function 19H }
  800. { because the drive was the default, which can be unknown }
  801. DosQueryCurrentDisk(l, l2);
  802. dir[1]:=chr(64+l);
  803. end;
  804. if not (FileNameCaseSensitive) then dir:=upcase(dir);
  805. end;
  806. {*****************************************************************************
  807. System unit initialization.
  808. ****************************************************************************}
  809. {****************************************************************************
  810. Error Message writing using messageboxes
  811. ****************************************************************************}
  812. type
  813. TWinMessageBox = function (Parent, Owner: cardinal;
  814. BoxText, BoxTitle: PChar; Identity, Style: cardinal): cardinal; cdecl;
  815. TWinInitialize = function (Options: cardinal): cardinal; cdecl;
  816. TWinCreateMsgQueue = function (Handle: cardinal; cmsg: longint): cardinal;
  817. cdecl;
  818. const
  819. ErrorBufferLength = 1024;
  820. mb_OK = $0000;
  821. mb_Error = $0040;
  822. mb_Moveable = $4000;
  823. MBStyle = mb_OK or mb_Error or mb_Moveable;
  824. WinInitialize: TWinInitialize = nil;
  825. WinCreateMsgQueue: TWinCreateMsgQueue = nil;
  826. WinMessageBox: TWinMessageBox = nil;
  827. EnvSize: cardinal = 0;
  828. var
  829. ErrorBuf: array [0..ErrorBufferLength] of char;
  830. ErrorLen: longint;
  831. PMWinHandle: cardinal;
  832. function ErrorWrite (var F: TextRec): integer;
  833. {
  834. An error message should always end with #13#10#13#10
  835. }
  836. var
  837. P: PChar;
  838. I: longint;
  839. begin
  840. if F.BufPos > 0 then
  841. begin
  842. if F.BufPos + ErrorLen > ErrorBufferLength then
  843. I := ErrorBufferLength - ErrorLen
  844. else
  845. I := F.BufPos;
  846. Move (F.BufPtr^, ErrorBuf [ErrorLen], I);
  847. Inc (ErrorLen, I);
  848. ErrorBuf [ErrorLen] := #0;
  849. end;
  850. if ErrorLen > 3 then
  851. begin
  852. P := @ErrorBuf [ErrorLen];
  853. for I := 1 to 4 do
  854. begin
  855. Dec (P);
  856. if not (P^ in [#10, #13]) then
  857. break;
  858. end;
  859. end;
  860. if ErrorLen = ErrorBufferLength then
  861. I := 4;
  862. if (I = 4) then
  863. begin
  864. WinMessageBox (0, 0, @ErrorBuf, PChar ('Error'), 0, MBStyle);
  865. ErrorLen := 0;
  866. end;
  867. F.BufPos := 0;
  868. ErrorWrite := 0;
  869. end;
  870. function ErrorClose (var F: TextRec): integer;
  871. begin
  872. if ErrorLen > 0 then
  873. begin
  874. WinMessageBox (0, 0, @ErrorBuf, PChar ('Error'), 0, MBStyle);
  875. ErrorLen := 0;
  876. end;
  877. ErrorLen := 0;
  878. ErrorClose := 0;
  879. end;
  880. function ErrorOpen (var F: TextRec): integer;
  881. begin
  882. TextRec(F).InOutFunc := @ErrorWrite;
  883. TextRec(F).FlushFunc := @ErrorWrite;
  884. TextRec(F).CloseFunc := @ErrorClose;
  885. ErrorOpen := 0;
  886. end;
  887. procedure AssignError (var T: Text);
  888. begin
  889. Assign (T, '');
  890. TextRec (T).OpenFunc := @ErrorOpen;
  891. Rewrite (T);
  892. end;
  893. procedure SysInitStdIO;
  894. begin
  895. { Setup stdin, stdout and stderr, for GUI apps redirect stderr,stdout to be
  896. displayed in a messagebox }
  897. (*
  898. StdInputHandle := longint(GetStdHandle(cardinal(STD_INPUT_HANDLE)));
  899. StdOutputHandle := longint(GetStdHandle(cardinal(STD_OUTPUT_HANDLE)));
  900. StdErrorHandle := longint(GetStdHandle(cardinal(STD_ERROR_HANDLE)));
  901. if not IsConsole then
  902. begin
  903. if (DosLoadModule (nil, 0, 'PMWIN', PMWinHandle) = 0) and
  904. (DosQueryProcAddr (PMWinHandle, 789, nil, pointer (WinMessageBox)) = 0)
  905. and
  906. (DosQueryProcAddr (PMWinHandle, 763, nil, pointer (WinInitialize)) = 0)
  907. and
  908. (DosQueryProcAddr (PMWinHandle, 716, nil, pointer (WinCreateMsgQueue))
  909. = 0)
  910. then
  911. begin
  912. WinInitialize (0);
  913. WinCreateMsgQueue (0, 0);
  914. end
  915. else
  916. HandleError (2);
  917. AssignError (StdErr);
  918. AssignError (StdOut);
  919. Assign (Output, '');
  920. Assign (Input, '');
  921. end
  922. else
  923. begin
  924. *)
  925. OpenStdIO (Input, fmInput, StdInputHandle);
  926. OpenStdIO (Output, fmOutput, StdOutputHandle);
  927. OpenStdIO (StdOut, fmOutput, StdOutputHandle);
  928. OpenStdIO (StdErr, fmOutput, StdErrorHandle);
  929. (*
  930. end;
  931. *)
  932. end;
  933. function strcopy(dest,source : pchar) : pchar;assembler;
  934. var
  935. saveeax,saveesi,saveedi : longint;
  936. asm
  937. movl %edi,saveedi
  938. movl %esi,saveesi
  939. {$ifdef REGCALL}
  940. movl %eax,saveeax
  941. movl %edx,%edi
  942. {$else}
  943. movl source,%edi
  944. {$endif}
  945. testl %edi,%edi
  946. jz .LStrCopyDone
  947. leal 3(%edi),%ecx
  948. andl $-4,%ecx
  949. movl %edi,%esi
  950. subl %edi,%ecx
  951. {$ifdef REGCALL}
  952. movl %eax,%edi
  953. {$else}
  954. movl dest,%edi
  955. {$endif}
  956. jz .LStrCopyAligned
  957. .LStrCopyAlignLoop:
  958. movb (%esi),%al
  959. incl %edi
  960. incl %esi
  961. testb %al,%al
  962. movb %al,-1(%edi)
  963. jz .LStrCopyDone
  964. decl %ecx
  965. jnz .LStrCopyAlignLoop
  966. .balign 16
  967. .LStrCopyAligned:
  968. movl (%esi),%eax
  969. movl %eax,%edx
  970. leal 0x0fefefeff(%eax),%ecx
  971. notl %edx
  972. addl $4,%esi
  973. andl %edx,%ecx
  974. andl $0x080808080,%ecx
  975. jnz .LStrCopyEndFound
  976. movl %eax,(%edi)
  977. addl $4,%edi
  978. jmp .LStrCopyAligned
  979. .LStrCopyEndFound:
  980. testl $0x0ff,%eax
  981. jz .LStrCopyByte
  982. testl $0x0ff00,%eax
  983. jz .LStrCopyWord
  984. testl $0x0ff0000,%eax
  985. jz .LStrCopy3Bytes
  986. movl %eax,(%edi)
  987. jmp .LStrCopyDone
  988. .LStrCopy3Bytes:
  989. xorb %dl,%dl
  990. movw %ax,(%edi)
  991. movb %dl,2(%edi)
  992. jmp .LStrCopyDone
  993. .LStrCopyWord:
  994. movw %ax,(%edi)
  995. jmp .LStrCopyDone
  996. .LStrCopyByte:
  997. movb %al,(%edi)
  998. .LStrCopyDone:
  999. {$ifdef REGCALL}
  1000. movl saveeax,%eax
  1001. {$else}
  1002. movl dest,%eax
  1003. {$endif}
  1004. movl saveedi,%edi
  1005. movl saveesi,%esi
  1006. end;
  1007. procedure InitEnvironment;
  1008. var env_count : longint;
  1009. dos_env,cp : pchar;
  1010. begin
  1011. env_count:=0;
  1012. cp:=environment;
  1013. while cp ^ <> #0 do
  1014. begin
  1015. inc(env_count);
  1016. while (cp^ <> #0) do inc(longint(cp)); { skip to NUL }
  1017. inc(longint(cp)); { skip to next character }
  1018. end;
  1019. envp := sysgetmem((env_count+1) * sizeof(pchar));
  1020. envc := env_count;
  1021. if (envp = nil) then exit;
  1022. cp:=environment;
  1023. env_count:=0;
  1024. while cp^ <> #0 do
  1025. begin
  1026. envp[env_count] := sysgetmem(strlen(cp)+1);
  1027. strcopy(envp[env_count], cp);
  1028. {$IfDef DEBUGENVIRONMENT}
  1029. Writeln(stderr,'env ',env_count,' = "',envp[env_count],'"');
  1030. {$EndIf}
  1031. inc(env_count);
  1032. while (cp^ <> #0) do
  1033. inc(longint(cp)); { skip to NUL }
  1034. inc(longint(cp)); { skip to next character }
  1035. end;
  1036. envp[env_count]:=nil;
  1037. end;
  1038. procedure InitArguments;
  1039. var
  1040. arglen,
  1041. count : longint;
  1042. argstart,
  1043. pc,arg : pchar;
  1044. quote : char;
  1045. argvlen : longint;
  1046. procedure allocarg(idx,len:longint);
  1047. begin
  1048. if idx>=argvlen then
  1049. begin
  1050. argvlen:=(idx+8) and (not 7);
  1051. sysreallocmem(argv,argvlen*sizeof(pointer));
  1052. end;
  1053. { use realloc to reuse already existing memory }
  1054. { always allocate, even if length is zero, since }
  1055. { the arg. is still present! }
  1056. sysreallocmem(argv[idx],len+1);
  1057. end;
  1058. begin
  1059. count:=0;
  1060. argv:=nil;
  1061. argvlen:=0;
  1062. // Get argv[0]
  1063. pc:=cmdline;
  1064. Arglen:=0;
  1065. repeat
  1066. Inc(Arglen);
  1067. until (pc[Arglen]=#0);
  1068. allocarg(count,arglen);
  1069. move(pc^,argv[count]^,arglen);
  1070. { ReSetup cmdline variable }
  1071. repeat
  1072. Inc(Arglen);
  1073. until (pc[Arglen]=#0);
  1074. Inc(Arglen);
  1075. pc:=GetMem(ArgLen);
  1076. move(cmdline^, pc^, arglen);
  1077. Arglen:=0;
  1078. repeat
  1079. Inc(Arglen);
  1080. until (pc[Arglen]=#0);
  1081. pc[Arglen]:=' '; // combine argv[0] and command line
  1082. CmdLine:=pc;
  1083. { process arguments }
  1084. pc:=cmdline;
  1085. {$IfDef DEBUGARGUMENTS}
  1086. Writeln(stderr,'GetCommandLine is #',pc,'#');
  1087. {$EndIf }
  1088. while pc^<>#0 do
  1089. begin
  1090. { skip leading spaces }
  1091. while pc^ in [#1..#32] do
  1092. inc(pc);
  1093. if pc^=#0 then
  1094. break;
  1095. { calc argument length }
  1096. quote:=' ';
  1097. argstart:=pc;
  1098. arglen:=0;
  1099. while (pc^<>#0) do
  1100. begin
  1101. case pc^ of
  1102. #1..#32 :
  1103. begin
  1104. if quote<>' ' then
  1105. inc(arglen)
  1106. else
  1107. break;
  1108. end;
  1109. '"' :
  1110. begin
  1111. if quote<>'''' then
  1112. begin
  1113. if pchar(pc+1)^<>'"' then
  1114. begin
  1115. if quote='"' then
  1116. quote:=' '
  1117. else
  1118. quote:='"';
  1119. end
  1120. else
  1121. inc(pc);
  1122. end
  1123. else
  1124. inc(arglen);
  1125. end;
  1126. '''' :
  1127. begin
  1128. if quote<>'"' then
  1129. begin
  1130. if pchar(pc+1)^<>'''' then
  1131. begin
  1132. if quote='''' then
  1133. quote:=' '
  1134. else
  1135. quote:='''';
  1136. end
  1137. else
  1138. inc(pc);
  1139. end
  1140. else
  1141. inc(arglen);
  1142. end;
  1143. else
  1144. inc(arglen);
  1145. end;
  1146. inc(pc);
  1147. end;
  1148. { copy argument }
  1149. { Don't copy the first one, it is already there.}
  1150. If Count<>0 then
  1151. begin
  1152. allocarg(count,arglen);
  1153. quote:=' ';
  1154. pc:=argstart;
  1155. arg:=argv[count];
  1156. while (pc^<>#0) do
  1157. begin
  1158. case pc^ of
  1159. #1..#32 :
  1160. begin
  1161. if quote<>' ' then
  1162. begin
  1163. arg^:=pc^;
  1164. inc(arg);
  1165. end
  1166. else
  1167. break;
  1168. end;
  1169. '"' :
  1170. begin
  1171. if quote<>'''' then
  1172. begin
  1173. if pchar(pc+1)^<>'"' then
  1174. begin
  1175. if quote='"' then
  1176. quote:=' '
  1177. else
  1178. quote:='"';
  1179. end
  1180. else
  1181. inc(pc);
  1182. end
  1183. else
  1184. begin
  1185. arg^:=pc^;
  1186. inc(arg);
  1187. end;
  1188. end;
  1189. '''' :
  1190. begin
  1191. if quote<>'"' then
  1192. begin
  1193. if pchar(pc+1)^<>'''' then
  1194. begin
  1195. if quote='''' then
  1196. quote:=' '
  1197. else
  1198. quote:='''';
  1199. end
  1200. else
  1201. inc(pc);
  1202. end
  1203. else
  1204. begin
  1205. arg^:=pc^;
  1206. inc(arg);
  1207. end;
  1208. end;
  1209. else
  1210. begin
  1211. arg^:=pc^;
  1212. inc(arg);
  1213. end;
  1214. end;
  1215. inc(pc);
  1216. end;
  1217. arg^:=#0;
  1218. end;
  1219. {$IfDef DEBUGARGUMENTS}
  1220. Writeln(stderr,'dos arg ',count,' #',arglen,'#',argv[count],'#');
  1221. {$EndIf}
  1222. inc(count);
  1223. end;
  1224. { get argc and create an nil entry }
  1225. argc:=count;
  1226. allocarg(argc,0);
  1227. { free unused memory }
  1228. sysreallocmem(argv,(argc+1)*sizeof(pointer));
  1229. end;
  1230. function GetFileHandleCount: longint;
  1231. var L1: longint;
  1232. L2: cardinal;
  1233. begin
  1234. L1 := 0; (* Don't change the amount, just check. *)
  1235. if DosSetRelMaxFH (L1, L2) <> 0 then GetFileHandleCount := 50
  1236. else GetFileHandleCount := L2;
  1237. end;
  1238. var TIB: PThreadInfoBlock;
  1239. PIB: PProcessInfoBlock;
  1240. RC: cardinal;
  1241. ErrStr: string;
  1242. begin
  1243. IsLibrary := FALSE;
  1244. (* Initialize the amount of file handles *)
  1245. FileHandleCount := GetFileHandleCount;
  1246. DosGetInfoBlocks (@TIB, @PIB);
  1247. StackBottom := TIB^.Stack;
  1248. {Set type of application}
  1249. ApplicationType := PIB^.ProcType;
  1250. ProcessID := PIB^.PID;
  1251. ThreadID := TIB^.TIB2^.TID;
  1252. IsConsole := ApplicationType <> 3;
  1253. exitproc:=nil;
  1254. {Initialize the heap.}
  1255. // Logic is following:
  1256. // Application allocates the amount of memory specified by the compiler
  1257. // switch -Ch but without commiting. On heap growing required amount of
  1258. // memory commited. More memory is allocated as needed within sbrk.
  1259. (* Being changed now - new behaviour will be documented after *)
  1260. (* things settle down a bit and everything is tested properly. *)
  1261. RC := DosAllocMem (Int_Heap, Int_HeapSize, $403);
  1262. if RC = 87 then
  1263. begin
  1264. (* Using of high memory address space (> 512 MB) *)
  1265. (* is not supported on this system. *)
  1266. RC := DosAllocMem (Int_Heap, Int_HeapSize, 3);
  1267. HighMemSupported := false;
  1268. end
  1269. else
  1270. HighMemSupported := true;
  1271. if RC <> 0 then
  1272. begin
  1273. Str (RC, ErrStr);
  1274. ErrStr := 'Error during heap initialization (DosAllocMem - ' + ErrStr + ')!!'#13#10;
  1275. DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
  1276. HandleError (204);
  1277. end
  1278. else
  1279. begin
  1280. RC := DosSetMem (Int_Heap, Int_HeapSize, $410);
  1281. if RC <> 0 then
  1282. begin
  1283. Str (RC, ErrStr);
  1284. ErrStr := 'Error during heap initialization (DosSetMem - ' + ErrStr + ')!!'#13#10;
  1285. DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
  1286. HandleError (204);
  1287. end
  1288. {$IFDEF EXTDUMPGROW}
  1289. else
  1290. begin
  1291. Str (Int_HeapSize, ErrStr);
  1292. ErrStr := 'Initially allocated ' + ErrStr + ' bytes of memory.'#13#10;
  1293. DosWrite (1, @ErrStr [1], Length (ErrStr), RC);
  1294. end
  1295. {$ENDIF}
  1296. end;
  1297. InitHeap;
  1298. { ... and exceptions }
  1299. SysInitExceptions;
  1300. { ... and I/O }
  1301. SysInitStdIO;
  1302. { no I/O-Error }
  1303. inoutres:=0;
  1304. {Initialize environment (must be after InitHeap because allocates memory)}
  1305. Environment := pointer (PIB^.Env);
  1306. InitEnvironment;
  1307. CmdLine := pointer (PIB^.Cmd);
  1308. InitArguments;
  1309. {$ifdef HASVARIANT}
  1310. initvariantmanager;
  1311. {$endif HASVARIANT}
  1312. {$IFDEF DUMPGROW}
  1313. WriteLn ('Initial brk size is ', GetHeapSize);
  1314. {$ENDIF DUMPGROW}
  1315. end.
  1316. {
  1317. $Log$
  1318. Revision 1.75 2004-10-25 15:38:59 peter
  1319. * compiler defined HEAP and HEAPSIZE removed
  1320. Revision 1.74 2004/09/18 11:12:09 hajny
  1321. * handle type changed to thandle in do_isdevice
  1322. Revision 1.73 2004/09/11 19:43:11 hajny
  1323. * missing MaxExitCode added
  1324. Revision 1.72 2004/07/18 15:20:38 hajny
  1325. + Memory allocation routines changed to support the new memory manager
  1326. Revision 1.71 2004/05/16 18:51:20 peter
  1327. * use thandle in do_*
  1328. Revision 1.70 2004/04/22 21:10:56 peter
  1329. * do_read/do_write addr argument changed to pointer
  1330. Revision 1.69 2004/03/24 19:23:09 hajny
  1331. * misleading warning removed
  1332. Revision 1.68 2004/03/24 19:15:59 hajny
  1333. * heap management modified to be able to grow heap as needed
  1334. Revision 1.67 2004/02/22 15:01:49 hajny
  1335. * lots of fixes (regcall, THandle, string operations in sysutils, longint2cardinal according to OS/2 docs, dosh.inc, ...)
  1336. Revision 1.66 2004/02/16 22:18:44 hajny
  1337. * LastDosExitCode changed back from threadvar temporarily
  1338. Revision 1.65 2004/02/02 03:24:09 yuri
  1339. - prt1.as removed
  1340. - removed tmporary code/comments
  1341. - prt1 compilation error workaround removed
  1342. Revision 1.64 2004/01/25 21:41:48 hajny
  1343. * reformatting of too long comment lines - not accepted by FP IDE
  1344. Revision 1.63 2004/01/21 14:15:42 florian
  1345. * fixed win32 compilation
  1346. Revision 1.62 2004/01/20 23:11:20 hajny
  1347. * ExecuteProcess fixes, ProcessID and ThreadID added
  1348. Revision 1.61 2003/12/04 21:22:38 peter
  1349. * regcall updates (untested)
  1350. Revision 1.60 2003/11/23 07:21:16 yuri
  1351. * native heap
  1352. Revision 1.59 2003/11/19 18:21:11 yuri
  1353. * Memory allocation bug fixed
  1354. Revision 1.58 2003/11/19 16:50:21 yuri
  1355. * Environment and arguments initialization now native
  1356. Revision 1.57 2003/11/06 17:20:44 yuri
  1357. * Unused constants removed
  1358. Revision 1.56 2003/11/03 09:42:28 marco
  1359. * Peter's Cardinal<->Longint fixes patch
  1360. Revision 1.55 2003/11/02 00:51:17 hajny
  1361. * corrections for do_open and os_mode back
  1362. Revision 1.54 2003/10/28 14:57:31 yuri
  1363. * do_* functions now native
  1364. Revision 1.53 2003/10/27 04:33:58 yuri
  1365. * os_mode removed (not required anymore)
  1366. Revision 1.52 2003/10/25 22:45:37 hajny
  1367. * file handling related fixes
  1368. Revision 1.51 2003/10/19 12:13:41 hajny
  1369. * UnusedHandle value made the same as with other targets
  1370. Revision 1.50 2003/10/19 09:37:00 hajny
  1371. * minor fix in non-default sbrk code
  1372. Revision 1.49 2003/10/19 09:06:28 hajny
  1373. * fix for terrible long-time bug in do_open
  1374. Revision 1.48 2003/10/18 16:58:39 hajny
  1375. * stdcall fixes again
  1376. Revision 1.47 2003/10/16 15:43:13 peter
  1377. * THandle is platform dependent
  1378. Revision 1.46 2003/10/14 21:10:06 hajny
  1379. * another longint2cardinal fix
  1380. Revision 1.45 2003/10/13 21:17:31 hajny
  1381. * longint to cardinal corrections
  1382. Revision 1.44 2003/10/12 18:07:30 hajny
  1383. * wrong use of Intel syntax
  1384. Revision 1.43 2003/10/12 17:59:40 hajny
  1385. * wrong use of Intel syntax
  1386. Revision 1.42 2003/10/12 17:52:28 hajny
  1387. * wrong use of Intel syntax
  1388. Revision 1.41 2003/10/12 10:45:36 hajny
  1389. * sbrk error handling corrected
  1390. Revision 1.40 2003/10/07 21:26:35 hajny
  1391. * stdcall fixes and asm routines cleanup
  1392. Revision 1.39 2003/10/06 16:58:27 yuri
  1393. * Another set of native functions.
  1394. Revision 1.38 2003/10/06 14:22:40 yuri
  1395. * Some emx code removed. Now withous so stupid error as with dos ;)
  1396. Revision 1.37 2003/10/04 08:30:59 yuri
  1397. * at&t syntax instead of intel syntax was used
  1398. Revision 1.36 2003/10/03 21:46:41 peter
  1399. * stdcall fixes
  1400. Revision 1.35 2003/10/01 18:42:49 yuri
  1401. * Unclosed comment
  1402. Revision 1.34 2003/09/29 18:39:59 hajny
  1403. * append fix applied to GO32v2, OS/2 and EMX
  1404. Revision 1.33 2003/09/27 11:52:36 peter
  1405. * sbrk returns pointer
  1406. Revision 1.32 2003/03/30 09:20:30 hajny
  1407. * platform extension unification
  1408. Revision 1.31 2003/01/15 22:16:12 hajny
  1409. * default sharing mode changed to DenyNone
  1410. Revision 1.30 2002/12/15 22:41:41 hajny
  1411. * First_Meg fixed + Environment initialization under Dos
  1412. Revision 1.29 2002/12/08 16:39:58 hajny
  1413. - WriteLn in GUI mode support commented out until fixed
  1414. Revision 1.28 2002/12/07 19:17:14 hajny
  1415. * GetEnv correction, better PM support, ...
  1416. Revision 1.27 2002/11/17 22:31:02 hajny
  1417. * type corrections (longint x cardinal)
  1418. Revision 1.26 2002/10/27 14:29:00 hajny
  1419. * heap management (hopefully) fixed
  1420. Revision 1.25 2002/10/14 19:39:17 peter
  1421. * threads unit added for thread support
  1422. Revision 1.24 2002/10/13 09:28:45 florian
  1423. + call to initvariantmanager inserted
  1424. Revision 1.23 2002/09/07 16:01:25 peter
  1425. * old logs removed and tabs fixed
  1426. Revision 1.22 2002/07/01 16:29:05 peter
  1427. * sLineBreak changed to normal constant like Kylix
  1428. Revision 1.21 2002/04/21 15:54:20 carl
  1429. + initialize some global variables
  1430. Revision 1.20 2002/04/12 17:42:16 carl
  1431. + generic stack checking
  1432. Revision 1.19 2002/03/11 19:10:33 peter
  1433. * Regenerated with updated fpcmake
  1434. Revision 1.18 2002/02/10 13:46:20 hajny
  1435. * heap management corrected (heap_brk)
  1436. }