system.pas 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709
  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 (ErrOutput, fmOutput, StdErrorHandle);
  928. OpenStdIO (StdOut, fmOutput, StdOutputHandle);
  929. OpenStdIO (StdErr, fmOutput, StdErrorHandle);
  930. (*
  931. end;
  932. *)
  933. end;
  934. function strcopy(dest,source : pchar) : pchar;assembler;
  935. var
  936. saveeax,saveesi,saveedi : longint;
  937. asm
  938. movl %edi,saveedi
  939. movl %esi,saveesi
  940. {$ifdef REGCALL}
  941. movl %eax,saveeax
  942. movl %edx,%edi
  943. {$else}
  944. movl source,%edi
  945. {$endif}
  946. testl %edi,%edi
  947. jz .LStrCopyDone
  948. leal 3(%edi),%ecx
  949. andl $-4,%ecx
  950. movl %edi,%esi
  951. subl %edi,%ecx
  952. {$ifdef REGCALL}
  953. movl %eax,%edi
  954. {$else}
  955. movl dest,%edi
  956. {$endif}
  957. jz .LStrCopyAligned
  958. .LStrCopyAlignLoop:
  959. movb (%esi),%al
  960. incl %edi
  961. incl %esi
  962. testb %al,%al
  963. movb %al,-1(%edi)
  964. jz .LStrCopyDone
  965. decl %ecx
  966. jnz .LStrCopyAlignLoop
  967. .balign 16
  968. .LStrCopyAligned:
  969. movl (%esi),%eax
  970. movl %eax,%edx
  971. leal 0x0fefefeff(%eax),%ecx
  972. notl %edx
  973. addl $4,%esi
  974. andl %edx,%ecx
  975. andl $0x080808080,%ecx
  976. jnz .LStrCopyEndFound
  977. movl %eax,(%edi)
  978. addl $4,%edi
  979. jmp .LStrCopyAligned
  980. .LStrCopyEndFound:
  981. testl $0x0ff,%eax
  982. jz .LStrCopyByte
  983. testl $0x0ff00,%eax
  984. jz .LStrCopyWord
  985. testl $0x0ff0000,%eax
  986. jz .LStrCopy3Bytes
  987. movl %eax,(%edi)
  988. jmp .LStrCopyDone
  989. .LStrCopy3Bytes:
  990. xorb %dl,%dl
  991. movw %ax,(%edi)
  992. movb %dl,2(%edi)
  993. jmp .LStrCopyDone
  994. .LStrCopyWord:
  995. movw %ax,(%edi)
  996. jmp .LStrCopyDone
  997. .LStrCopyByte:
  998. movb %al,(%edi)
  999. .LStrCopyDone:
  1000. {$ifdef REGCALL}
  1001. movl saveeax,%eax
  1002. {$else}
  1003. movl dest,%eax
  1004. {$endif}
  1005. movl saveedi,%edi
  1006. movl saveesi,%esi
  1007. end;
  1008. procedure InitEnvironment;
  1009. var env_count : longint;
  1010. dos_env,cp : pchar;
  1011. begin
  1012. env_count:=0;
  1013. cp:=environment;
  1014. while cp ^ <> #0 do
  1015. begin
  1016. inc(env_count);
  1017. while (cp^ <> #0) do inc(longint(cp)); { skip to NUL }
  1018. inc(longint(cp)); { skip to next character }
  1019. end;
  1020. envp := sysgetmem((env_count+1) * sizeof(pchar));
  1021. envc := env_count;
  1022. if (envp = nil) then exit;
  1023. cp:=environment;
  1024. env_count:=0;
  1025. while cp^ <> #0 do
  1026. begin
  1027. envp[env_count] := sysgetmem(strlen(cp)+1);
  1028. strcopy(envp[env_count], cp);
  1029. {$IfDef DEBUGENVIRONMENT}
  1030. Writeln(stderr,'env ',env_count,' = "',envp[env_count],'"');
  1031. {$EndIf}
  1032. inc(env_count);
  1033. while (cp^ <> #0) do
  1034. inc(longint(cp)); { skip to NUL }
  1035. inc(longint(cp)); { skip to next character }
  1036. end;
  1037. envp[env_count]:=nil;
  1038. end;
  1039. procedure InitArguments;
  1040. var
  1041. arglen,
  1042. count : longint;
  1043. argstart,
  1044. pc,arg : pchar;
  1045. quote : char;
  1046. argvlen : longint;
  1047. procedure allocarg(idx,len:longint);
  1048. begin
  1049. if idx>=argvlen then
  1050. begin
  1051. argvlen:=(idx+8) and (not 7);
  1052. sysreallocmem(argv,argvlen*sizeof(pointer));
  1053. end;
  1054. { use realloc to reuse already existing memory }
  1055. { always allocate, even if length is zero, since }
  1056. { the arg. is still present! }
  1057. sysreallocmem(argv[idx],len+1);
  1058. end;
  1059. begin
  1060. count:=0;
  1061. argv:=nil;
  1062. argvlen:=0;
  1063. // Get argv[0]
  1064. pc:=cmdline;
  1065. Arglen:=0;
  1066. repeat
  1067. Inc(Arglen);
  1068. until (pc[Arglen]=#0);
  1069. allocarg(count,arglen);
  1070. move(pc^,argv[count]^,arglen);
  1071. { ReSetup cmdline variable }
  1072. repeat
  1073. Inc(Arglen);
  1074. until (pc[Arglen]=#0);
  1075. Inc(Arglen);
  1076. pc:=GetMem(ArgLen);
  1077. move(cmdline^, pc^, arglen);
  1078. Arglen:=0;
  1079. repeat
  1080. Inc(Arglen);
  1081. until (pc[Arglen]=#0);
  1082. pc[Arglen]:=' '; // combine argv[0] and command line
  1083. CmdLine:=pc;
  1084. { process arguments }
  1085. pc:=cmdline;
  1086. {$IfDef DEBUGARGUMENTS}
  1087. Writeln(stderr,'GetCommandLine is #',pc,'#');
  1088. {$EndIf }
  1089. while pc^<>#0 do
  1090. begin
  1091. { skip leading spaces }
  1092. while pc^ in [#1..#32] do
  1093. inc(pc);
  1094. if pc^=#0 then
  1095. break;
  1096. { calc argument length }
  1097. quote:=' ';
  1098. argstart:=pc;
  1099. arglen:=0;
  1100. while (pc^<>#0) do
  1101. begin
  1102. case pc^ of
  1103. #1..#32 :
  1104. begin
  1105. if quote<>' ' then
  1106. inc(arglen)
  1107. else
  1108. break;
  1109. end;
  1110. '"' :
  1111. begin
  1112. if quote<>'''' then
  1113. begin
  1114. if pchar(pc+1)^<>'"' then
  1115. begin
  1116. if quote='"' then
  1117. quote:=' '
  1118. else
  1119. quote:='"';
  1120. end
  1121. else
  1122. inc(pc);
  1123. end
  1124. else
  1125. inc(arglen);
  1126. end;
  1127. '''' :
  1128. begin
  1129. if quote<>'"' then
  1130. begin
  1131. if pchar(pc+1)^<>'''' then
  1132. begin
  1133. if quote='''' then
  1134. quote:=' '
  1135. else
  1136. quote:='''';
  1137. end
  1138. else
  1139. inc(pc);
  1140. end
  1141. else
  1142. inc(arglen);
  1143. end;
  1144. else
  1145. inc(arglen);
  1146. end;
  1147. inc(pc);
  1148. end;
  1149. { copy argument }
  1150. { Don't copy the first one, it is already there.}
  1151. If Count<>0 then
  1152. begin
  1153. allocarg(count,arglen);
  1154. quote:=' ';
  1155. pc:=argstart;
  1156. arg:=argv[count];
  1157. while (pc^<>#0) do
  1158. begin
  1159. case pc^ of
  1160. #1..#32 :
  1161. begin
  1162. if quote<>' ' then
  1163. begin
  1164. arg^:=pc^;
  1165. inc(arg);
  1166. end
  1167. else
  1168. break;
  1169. end;
  1170. '"' :
  1171. begin
  1172. if quote<>'''' then
  1173. begin
  1174. if pchar(pc+1)^<>'"' then
  1175. begin
  1176. if quote='"' then
  1177. quote:=' '
  1178. else
  1179. quote:='"';
  1180. end
  1181. else
  1182. inc(pc);
  1183. end
  1184. else
  1185. begin
  1186. arg^:=pc^;
  1187. inc(arg);
  1188. end;
  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. begin
  1206. arg^:=pc^;
  1207. inc(arg);
  1208. end;
  1209. end;
  1210. else
  1211. begin
  1212. arg^:=pc^;
  1213. inc(arg);
  1214. end;
  1215. end;
  1216. inc(pc);
  1217. end;
  1218. arg^:=#0;
  1219. end;
  1220. {$IfDef DEBUGARGUMENTS}
  1221. Writeln(stderr,'dos arg ',count,' #',arglen,'#',argv[count],'#');
  1222. {$EndIf}
  1223. inc(count);
  1224. end;
  1225. { get argc and create an nil entry }
  1226. argc:=count;
  1227. allocarg(argc,0);
  1228. { free unused memory }
  1229. sysreallocmem(argv,(argc+1)*sizeof(pointer));
  1230. end;
  1231. function GetFileHandleCount: longint;
  1232. var L1: longint;
  1233. L2: cardinal;
  1234. begin
  1235. L1 := 0; (* Don't change the amount, just check. *)
  1236. if DosSetRelMaxFH (L1, L2) <> 0 then GetFileHandleCount := 50
  1237. else GetFileHandleCount := L2;
  1238. end;
  1239. var TIB: PThreadInfoBlock;
  1240. PIB: PProcessInfoBlock;
  1241. RC: cardinal;
  1242. ErrStr: string;
  1243. begin
  1244. IsLibrary := FALSE;
  1245. (* Initialize the amount of file handles *)
  1246. FileHandleCount := GetFileHandleCount;
  1247. DosGetInfoBlocks (@TIB, @PIB);
  1248. StackBottom := TIB^.Stack;
  1249. {Set type of application}
  1250. ApplicationType := PIB^.ProcType;
  1251. ProcessID := PIB^.PID;
  1252. ThreadID := TIB^.TIB2^.TID;
  1253. IsConsole := ApplicationType <> 3;
  1254. exitproc:=nil;
  1255. {Initialize the heap.}
  1256. // Logic is following:
  1257. // Application allocates the amount of memory specified by the compiler
  1258. // switch -Ch but without commiting. On heap growing required amount of
  1259. // memory commited. More memory is allocated as needed within sbrk.
  1260. (* Being changed now - new behaviour will be documented after *)
  1261. (* things settle down a bit and everything is tested properly. *)
  1262. RC := DosAllocMem (Int_Heap, Int_HeapSize, $403);
  1263. if RC = 87 then
  1264. begin
  1265. (* Using of high memory address space (> 512 MB) *)
  1266. (* is not supported on this system. *)
  1267. RC := DosAllocMem (Int_Heap, Int_HeapSize, 3);
  1268. HighMemSupported := false;
  1269. end
  1270. else
  1271. HighMemSupported := true;
  1272. if RC <> 0 then
  1273. begin
  1274. Str (RC, ErrStr);
  1275. ErrStr := 'Error during heap initialization (DosAllocMem - ' + ErrStr + ')!!'#13#10;
  1276. DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
  1277. HandleError (204);
  1278. end
  1279. else
  1280. begin
  1281. RC := DosSetMem (Int_Heap, Int_HeapSize, $410);
  1282. if RC <> 0 then
  1283. begin
  1284. Str (RC, ErrStr);
  1285. ErrStr := 'Error during heap initialization (DosSetMem - ' + ErrStr + ')!!'#13#10;
  1286. DosWrite (2, @ErrStr [1], Length (ErrStr), RC);
  1287. HandleError (204);
  1288. end
  1289. {$IFDEF EXTDUMPGROW}
  1290. else
  1291. begin
  1292. Str (Int_HeapSize, ErrStr);
  1293. ErrStr := 'Initially allocated ' + ErrStr + ' bytes of memory.'#13#10;
  1294. DosWrite (1, @ErrStr [1], Length (ErrStr), RC);
  1295. end
  1296. {$ENDIF}
  1297. end;
  1298. InitHeap;
  1299. { ... and exceptions }
  1300. SysInitExceptions;
  1301. { ... and I/O }
  1302. SysInitStdIO;
  1303. { no I/O-Error }
  1304. inoutres:=0;
  1305. {Initialize environment (must be after InitHeap because allocates memory)}
  1306. Environment := pointer (PIB^.Env);
  1307. InitEnvironment;
  1308. CmdLine := pointer (PIB^.Cmd);
  1309. InitArguments;
  1310. {$ifdef HASVARIANT}
  1311. initvariantmanager;
  1312. {$endif HASVARIANT}
  1313. {$IFDEF DUMPGROW}
  1314. WriteLn ('Initial brk size is ', GetHeapSize);
  1315. {$ENDIF DUMPGROW}
  1316. end.
  1317. {
  1318. $Log$
  1319. Revision 1.76 2004-11-04 09:32:31 peter
  1320. ErrOutput added
  1321. Revision 1.75 2004/10/25 15:38:59 peter
  1322. * compiler defined HEAP and HEAPSIZE removed
  1323. Revision 1.74 2004/09/18 11:12:09 hajny
  1324. * handle type changed to thandle in do_isdevice
  1325. Revision 1.73 2004/09/11 19:43:11 hajny
  1326. * missing MaxExitCode added
  1327. Revision 1.72 2004/07/18 15:20:38 hajny
  1328. + Memory allocation routines changed to support the new memory manager
  1329. Revision 1.71 2004/05/16 18:51:20 peter
  1330. * use thandle in do_*
  1331. Revision 1.70 2004/04/22 21:10:56 peter
  1332. * do_read/do_write addr argument changed to pointer
  1333. Revision 1.69 2004/03/24 19:23:09 hajny
  1334. * misleading warning removed
  1335. Revision 1.68 2004/03/24 19:15:59 hajny
  1336. * heap management modified to be able to grow heap as needed
  1337. Revision 1.67 2004/02/22 15:01:49 hajny
  1338. * lots of fixes (regcall, THandle, string operations in sysutils, longint2cardinal according to OS/2 docs, dosh.inc, ...)
  1339. Revision 1.66 2004/02/16 22:18:44 hajny
  1340. * LastDosExitCode changed back from threadvar temporarily
  1341. Revision 1.65 2004/02/02 03:24:09 yuri
  1342. - prt1.as removed
  1343. - removed tmporary code/comments
  1344. - prt1 compilation error workaround removed
  1345. Revision 1.64 2004/01/25 21:41:48 hajny
  1346. * reformatting of too long comment lines - not accepted by FP IDE
  1347. Revision 1.63 2004/01/21 14:15:42 florian
  1348. * fixed win32 compilation
  1349. Revision 1.62 2004/01/20 23:11:20 hajny
  1350. * ExecuteProcess fixes, ProcessID and ThreadID added
  1351. Revision 1.61 2003/12/04 21:22:38 peter
  1352. * regcall updates (untested)
  1353. Revision 1.60 2003/11/23 07:21:16 yuri
  1354. * native heap
  1355. Revision 1.59 2003/11/19 18:21:11 yuri
  1356. * Memory allocation bug fixed
  1357. Revision 1.58 2003/11/19 16:50:21 yuri
  1358. * Environment and arguments initialization now native
  1359. Revision 1.57 2003/11/06 17:20:44 yuri
  1360. * Unused constants removed
  1361. Revision 1.56 2003/11/03 09:42:28 marco
  1362. * Peter's Cardinal<->Longint fixes patch
  1363. Revision 1.55 2003/11/02 00:51:17 hajny
  1364. * corrections for do_open and os_mode back
  1365. Revision 1.54 2003/10/28 14:57:31 yuri
  1366. * do_* functions now native
  1367. Revision 1.53 2003/10/27 04:33:58 yuri
  1368. * os_mode removed (not required anymore)
  1369. Revision 1.52 2003/10/25 22:45:37 hajny
  1370. * file handling related fixes
  1371. Revision 1.51 2003/10/19 12:13:41 hajny
  1372. * UnusedHandle value made the same as with other targets
  1373. Revision 1.50 2003/10/19 09:37:00 hajny
  1374. * minor fix in non-default sbrk code
  1375. Revision 1.49 2003/10/19 09:06:28 hajny
  1376. * fix for terrible long-time bug in do_open
  1377. Revision 1.48 2003/10/18 16:58:39 hajny
  1378. * stdcall fixes again
  1379. Revision 1.47 2003/10/16 15:43:13 peter
  1380. * THandle is platform dependent
  1381. Revision 1.46 2003/10/14 21:10:06 hajny
  1382. * another longint2cardinal fix
  1383. Revision 1.45 2003/10/13 21:17:31 hajny
  1384. * longint to cardinal corrections
  1385. Revision 1.44 2003/10/12 18:07:30 hajny
  1386. * wrong use of Intel syntax
  1387. Revision 1.43 2003/10/12 17:59:40 hajny
  1388. * wrong use of Intel syntax
  1389. Revision 1.42 2003/10/12 17:52:28 hajny
  1390. * wrong use of Intel syntax
  1391. Revision 1.41 2003/10/12 10:45:36 hajny
  1392. * sbrk error handling corrected
  1393. Revision 1.40 2003/10/07 21:26:35 hajny
  1394. * stdcall fixes and asm routines cleanup
  1395. Revision 1.39 2003/10/06 16:58:27 yuri
  1396. * Another set of native functions.
  1397. Revision 1.38 2003/10/06 14:22:40 yuri
  1398. * Some emx code removed. Now withous so stupid error as with dos ;)
  1399. Revision 1.37 2003/10/04 08:30:59 yuri
  1400. * at&t syntax instead of intel syntax was used
  1401. Revision 1.36 2003/10/03 21:46:41 peter
  1402. * stdcall fixes
  1403. Revision 1.35 2003/10/01 18:42:49 yuri
  1404. * Unclosed comment
  1405. Revision 1.34 2003/09/29 18:39:59 hajny
  1406. * append fix applied to GO32v2, OS/2 and EMX
  1407. Revision 1.33 2003/09/27 11:52:36 peter
  1408. * sbrk returns pointer
  1409. Revision 1.32 2003/03/30 09:20:30 hajny
  1410. * platform extension unification
  1411. Revision 1.31 2003/01/15 22:16:12 hajny
  1412. * default sharing mode changed to DenyNone
  1413. Revision 1.30 2002/12/15 22:41:41 hajny
  1414. * First_Meg fixed + Environment initialization under Dos
  1415. Revision 1.29 2002/12/08 16:39:58 hajny
  1416. - WriteLn in GUI mode support commented out until fixed
  1417. Revision 1.28 2002/12/07 19:17:14 hajny
  1418. * GetEnv correction, better PM support, ...
  1419. Revision 1.27 2002/11/17 22:31:02 hajny
  1420. * type corrections (longint x cardinal)
  1421. Revision 1.26 2002/10/27 14:29:00 hajny
  1422. * heap management (hopefully) fixed
  1423. Revision 1.25 2002/10/14 19:39:17 peter
  1424. * threads unit added for thread support
  1425. Revision 1.24 2002/10/13 09:28:45 florian
  1426. + call to initvariantmanager inserted
  1427. Revision 1.23 2002/09/07 16:01:25 peter
  1428. * old logs removed and tabs fixed
  1429. Revision 1.22 2002/07/01 16:29:05 peter
  1430. * sLineBreak changed to normal constant like Kylix
  1431. Revision 1.21 2002/04/21 15:54:20 carl
  1432. + initialize some global variables
  1433. Revision 1.20 2002/04/12 17:42:16 carl
  1434. + generic stack checking
  1435. Revision 1.19 2002/03/11 19:10:33 peter
  1436. * Regenerated with updated fpcmake
  1437. Revision 1.18 2002/02/10 13:46:20 hajny
  1438. * heap management corrected (heap_brk)
  1439. }