system.pas 49 KB

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