{ $Id$ This file is part of the Free Pascal Run time library. Copyright (c) 1999-2000 by the Free Pascal development team This file contains the declarations of internal compiler helper routines. That means you can *NOT* call these directly, as they may be changed or even removed at any time. The only reason they are included in the interface of the system unit, is so that the compiler doesn't need special code to access their parameter list information etc. Note that due to the "compilerproc" directive, it isn't even possible to use these routines in your programs. See the File COPYING.FPC, included in this distribution, for details about the copyright. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} { some dummy types necessary to have generic resulttypes for certain compilerprocs } type { normally the array shall be maxlongint big, but that will confuse the debugger } fpc_big_chararray = array[0..1023] of char; fpc_small_set = longint; fpc_normal_set = array[0..7] of longint; {$ifdef hascompilerproc} { Needed to solve overloading problem with call from assembler (PFV) } {$ifdef valuegetmem} Function fpc_getmem(size:Longint):pointer;compilerproc; {$endif} {$ifdef valuefreemem} Procedure fpc_freemem(p:pointer);compilerproc; {$endif valuefreemem} procedure fpc_Shortstr_SetLength(var s:shortstring;len:StrLenInt); compilerproc; function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; compilerproc; function fpc_shortstr_concat(const s1,s2:shortstring): shortstring; compilerproc; procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring); compilerproc; function fpc_shortstr_compare(const left,right:shortstring) : longint; compilerproc; function fpc_pchar_to_shortstr(p:pchar):shortstring; compilerproc; function fpc_pchar_length(p:pchar):longint; compilerproc; function fpc_pwidechar_length(p:pwidechar):longint; compilerproc; function fpc_chararray_to_shortstr(const arr: array of char):shortstring; compilerproc; function fpc_shortstr_to_chararray(arraysize: longint; const src: ShortString): fpc_big_chararray; compilerproc; Function fpc_shortstr_Copy(const s:shortstring;index:StrLenInt;count:StrLenInt):shortstring;compilerproc; Function fpc_ansistr_Copy (Const S : AnsiString; Index,Size : Longint) : AnsiString;compilerproc; Function fpc_widestr_Copy (Const S : WideString; Index,Size : Longint) : WideString;compilerproc; function fpc_char_copy(c:char;index : StrLenInt;count : StrLenInt): shortstring;compilerproc; procedure fpc_dynarray_copy(var pdest : pointer;psrc : pointer;ti : pointer;lowidx,highidx:longint);compilerproc; function fpc_dynarray_length(p : pointer) : tdynarrayindex; compilerproc; function fpc_dynarray_high(p : pointer) : tdynarrayindex; compilerproc; procedure fpc_dynarray_clear(var p : pointer;ti : pointer); compilerproc; procedure fpc_dynarray_decr_ref(var p : pointer;ti : pointer); compilerproc; procedure fpc_dynarray_incr_ref(p : pointer); compilerproc; procedure fpc_dynarray_setlength(var p : pointer;pti : pointer; dimcount : dword;dims : pdynarrayindex); compilerproc; procedure fpc_ShortStr_Float(d : ValReal;len,fr,rt : longint;var s : shortstring); compilerproc; procedure fpc_ShortStr_Longint(v : longint;len : longint;var s : shortstring); compilerproc; procedure fpc_shortstr_longword(v : longword;len : longint;var s : shortstring); compilerproc; procedure fpc_chararray_Float(d : ValReal;len,fr,rt : longint;var a : array of char); compilerproc; procedure fpc_chararray_Longint(v : longint;len : longint;var a : array of char); compilerproc; procedure fpc_chararray_longword(v : longword;len : longint;var a : array of char); compilerproc; Function fpc_Val_SInt_ShortStr(DestSize: longint; Const S: ShortString; var Code: ValSInt): ValSInt; compilerproc; Function fpc_Val_UInt_Shortstr(Const S: ShortString; var Code: ValSInt): ValUInt; compilerproc; Function fpc_Val_Real_ShortStr(const s : shortstring; var code : ValSInt): ValReal; compilerproc; Procedure fpc_AnsiStr_Decr_Ref (Var S : Pointer); compilerproc; Procedure fpc_AnsiStr_Incr_Ref (S : Pointer); compilerproc; Procedure fpc_AnsiStr_Assign (Var S1 : Pointer;S2 : Pointer); compilerproc; function fpc_AnsiStr_Concat (const S1,S2 : AnsiString): AnsiString; compilerproc; Procedure fpc_ansistr_append_char(Var S : AnsiString;c : char); compilerproc; Procedure fpc_ansistr_append_shortstring(Var S : AnsiString;Str : ShortString); compilerproc; Procedure fpc_ansistr_append_ansistring(Var S : AnsiString;Str : AnsiString); compilerproc; {$ifdef EXTRAANSISHORT} Procedure fpc_AnsiStr_ShortStr_Concat (Var S1: AnsiString; Var S2 : ShortString); compilerproc; {$endif EXTRAANSISHORT} function fpc_AnsiStr_To_ShortStr (high_of_res: longint;const S2 : Ansistring): shortstring; compilerproc; Function fpc_ShortStr_To_AnsiStr (Const S2 : ShortString): ansistring; compilerproc; Function fpc_Char_To_AnsiStr(const c : Char): AnsiString; compilerproc; Function fpc_PChar_To_AnsiStr(const p : pchar): ansistring; compilerproc; Function fpc_CharArray_To_AnsiStr(const arr: array of char): ansistring; compilerproc; function fpc_ansistr_to_chararray(arraysize: longint; const src: ansistring): fpc_big_chararray; compilerproc; Function fpc_AnsiStr_Compare(const S1,S2 : AnsiString): Longint; compilerproc; Procedure fpc_AnsiStr_CheckZero(p : pointer); compilerproc; Procedure fpc_AnsiStr_CheckRange(len,index : longint); compilerproc; Procedure fpc_AnsiStr_SetLength (Var S : AnsiString; l : Longint); compilerproc; {$ifdef EXTRAANSISHORT} Function fpc_AnsiStr_ShortStr_Compare (Var S1 : Pointer; Var S2 : ShortString): Longint; compilerproc; {$endif EXTRAANSISHORT} { pointer argument because otherwise when calling this, we get } { an endless loop since a 'var s: ansistring' must be made } { unique as well } Function fpc_ansistr_Unique(Var S : Pointer): Pointer; compilerproc; Procedure fpc_WideStr_Decr_Ref (Var S : Pointer); compilerproc; Procedure fpc_WideStr_Incr_Ref (S : Pointer); compilerproc; function fpc_WideStr_To_ShortStr (high_of_res: longint;const S2 : WideString): shortstring; compilerproc; Function fpc_ShortStr_To_WideStr (Const S2 : ShortString): WideString; compilerproc; Function fpc_WideStr_To_AnsiStr (const S2 : WideString): AnsiString; compilerproc; Function fpc_AnsiStr_To_WideStr (Const S2 : AnsiString): WideString; compilerproc; Procedure fpc_WideStr_Assign (Var S1 : Pointer;S2 : Pointer); compilerproc; Function fpc_WideStr_Concat (const S1,S2 : WideString) : WideString; compilerproc; Function fpc_Char_To_WideStr(const c : Char): WideString; compilerproc; Function fpc_PChar_To_WideStr(const p : pchar): WideString; compilerproc; Function fpc_CharArray_To_WideStr(const arr: array of char): WideString; compilerproc; function fpc_widestr_to_chararray(arraysize: longint; const src: WideString): fpc_big_chararray; compilerproc; Function fpc_WideStr_Compare(const S1,S2 : WideString): Longint; compilerproc; Procedure fpc_WideStr_CheckZero(p : pointer); compilerproc; Procedure fpc_WideStr_CheckRange(len,index : longint); compilerproc; Procedure fpc_WideStr_SetLength (Var S : WideString; l : Longint); compilerproc; function fpc_widestr_Unique(Var S : Pointer): Pointer; compilerproc; {$ifdef HASWIDECHAR} Function fpc_PWideChar_To_AnsiStr(const p : pwidechar): ansistring; compilerproc; Function fpc_PWideChar_To_WideStr(const p : pwidechar): widestring; compilerproc; Function fpc_PWideChar_To_ShortStr(const p : pwidechar): shortstring; compilerproc; {$endif HASWIDECHAR} Function fpc_Val_Real_AnsiStr(Const S : AnsiString; Var Code : ValSInt): ValReal; compilerproc; Function fpc_Val_UInt_AnsiStr (Const S : AnsiString; Var Code : ValSInt): ValUInt; compilerproc; Function fpc_Val_SInt_AnsiStr (DestSize: longint; Const S : AnsiString; Var Code : ValSInt): ValSInt; compilerproc; Function fpc_Val_qword_AnsiStr (Const S : AnsiString; Var Code : ValSInt): qword;compilerproc; Function fpc_Val_int64_AnsiStr (Const S : AnsiString; Var Code : ValSInt): Int64; compilerproc; procedure fpc_AnsiStr_Float(d : ValReal;len,fr,rt : longint;var s : ansistring); compilerproc; Procedure fpc_AnsiStr_Longword(C : Longword;Len : Longint; Var S : AnsiString); compilerproc; Procedure fpc_AnsiStr_Longint(L : Longint; Len : Longint; Var S : AnsiString); compilerproc; Function fpc_Val_Real_WideStr(Const S : WideString; Var Code : ValSInt): ValReal; compilerproc; Function fpc_Val_UInt_WideStr (Const S : WideString; Var Code : ValSInt): ValUInt; compilerproc; Function fpc_Val_SInt_WideStr (DestSize: longint; Const S : WideString; Var Code : ValSInt): ValSInt; compilerproc; Function fpc_Val_qword_WideStr (Const S : WideString; Var Code : ValSInt): qword; compilerproc; Function fpc_Val_int64_WideStr (Const S : WideString; Var Code : ValSInt): Int64; compilerproc; procedure fpc_WideStr_Float(d : ValReal;len,fr,rt : longint;var s : WideString); compilerproc; Procedure fpc_WideStr_Longword(C : Longword;Len : Longint; Var S : WideString); compilerproc; Procedure fpc_WideStr_Longint(L : Longint; Len : Longint; Var S : WideString); compilerproc; { from text.inc } Procedure fpc_Write_End(var f:Text); compilerproc; Procedure fpc_Writeln_End(var f:Text); compilerproc; Procedure fpc_Write_Text_ShortStr(Len : Longint;var f : Text;const s : String); compilerproc; Procedure fpc_Write_Text_Pchar_as_Array(Len : Longint;var f : Text;const s : array of char); compilerproc; Procedure fpc_Write_Text_PChar_As_Pointer(Len : Longint;var f : Text;p : PChar); compilerproc; Procedure fpc_Write_Text_AnsiStr (Len : Longint; Var f : Text; S : AnsiString); compilerproc; {$ifdef HASWIDESTRING} Procedure fpc_Write_Text_WideStr (Len : Longint; Var f : Text; S : WideString); compilerproc; {$endif HASWIDESTRING} Procedure fpc_Write_Text_SInt(Len : Longint;var t : Text;l : ValSInt); compilerproc; Procedure fpc_Write_Text_UInt(Len : Longint;var t : Text;l : ValUInt); compilerproc; procedure fpc_write_text_qword(len : longint;var t : text;q : qword); compilerproc; procedure fpc_write_text_int64(len : longint;var t : text;i : int64); compilerproc; Procedure fpc_Write_Text_Float(rt,fixkomma,Len : Longint;var t : Text;r : ValReal); compilerproc; Procedure fpc_Write_Text_Boolean(Len : Longint;var t : Text;b : Boolean); compilerproc; Procedure fpc_Write_Text_Char(Len : Longint;var t : Text;c : Char); compilerproc; {$ifdef HASWIDECHAR} Procedure fpc_Write_Text_WideChar(Len : Longint;var t : Text;c : WideChar); compilerproc; {$endif HASWIDECHAR} {$ifdef HASVARIANT} // Procedure fpc_Write_Text_Variant(Len : Longint;var f : Text;const v : variant);compilerproc; // function fpc_variant_to_dynarray(const v : variant;typeinfo : pointer) : pointer;compilerproc; {$endif HASVARIANT} Procedure fpc_Read_End(var f:Text); compilerproc; Procedure fpc_ReadLn_End(var f : Text); compilerproc; Procedure fpc_Read_Text_ShortStr(var f : Text;var s : String); compilerproc; Procedure fpc_Read_Text_PChar_As_Pointer(var f : Text;var s : PChar); compilerproc; Procedure fpc_Read_Text_PChar_As_Array(var f : Text;var s : array of char); compilerproc; Procedure fpc_Read_Text_AnsiStr(var f : Text;var s : AnsiString); compilerproc; Procedure fpc_Read_Text_Char(var f : Text; var c : char); compilerproc; Procedure fpc_Read_Text_SInt(var f : Text; var l :ValSInt); compilerproc; Procedure fpc_Read_Text_UInt(var f : Text; var u :ValUInt); compilerproc; Procedure fpc_Read_Text_Float(var f : Text; var v :ValReal); compilerproc; Procedure fpc_Read_Text_QWord(var f : text; var q : qword); compilerproc; Procedure fpc_Read_Text_Int64(var f : text; var i : int64); compilerproc; { from int64.inc } procedure fpc_shortstr_qword(v : qword;len : longint;var s : shortstring); compilerproc; procedure fpc_shortstr_int64(v : int64;len : longint;var s : shortstring); compilerproc; procedure fpc_ansistr_qword(v : qword;len : longint;var s : ansistring); compilerproc; procedure fpc_ansistr_int64(v : int64;len : longint;var s : ansistring); compilerproc; Function fpc_val_int64_shortstr(Const S: ShortString; var Code: ValSInt): Int64; compilerproc; Function fpc_val_qword_shortstr(Const S: ShortString; var Code: ValSInt): QWord; compilerproc; procedure fpc_widestr_qword(v : qword;len : longint;var s : widestring); compilerproc; procedure fpc_widestr_int64(v : int64;len : longint;var s : widestring); compilerproc; function fpc_div_qword(n,z : qword) : qword; compilerproc; function fpc_mod_qword(n,z : qword) : qword; compilerproc; function fpc_div_int64(n,z : int64) : int64; compilerproc; function fpc_mod_int64(n,z : int64) : int64; compilerproc; function fpc_mul_qword(f1,f2 : qword;checkoverflow : longbool) : qword; compilerproc; function fpc_mul_int64(f1,f2 : int64;checkoverflow : longbool) : int64; compilerproc; function fpc_round(d : Extended) : int64;compilerproc; function fpc_do_is(aclass : tclass;aobject : tobject) : boolean; compilerproc; function fpc_do_as(aclass : tclass;aobject : tobject): tobject; compilerproc; procedure fpc_intf_decr_ref(var i: pointer); compilerproc; procedure fpc_intf_incr_ref(i: pointer); compilerproc; procedure fpc_intf_assign(var D: pointer; const S: pointer); compilerproc; function fpc_intf_as(const S: pointer; const iid: TGUID): pointer; compilerproc; function fpc_class_as_intf(const S: pointer; const iid: TGUID): pointer; compilerproc; Function fpc_PushExceptAddr (Ft: Longint;_buf,_newaddr : pointer): PJmp_buf ; compilerproc; Procedure fpc_PushExceptObj (Obj : TObject; AnAddr,AFrame : Pointer); compilerproc; Function fpc_Raiseexception (Obj : TObject; AnAddr,AFrame : Pointer) : TObject; compilerproc; Procedure fpc_PopAddrStack; compilerproc; function fpc_PopObjectStack : TObject; compilerproc; function fpc_PopSecondObjectStack : TObject; compilerproc; Procedure fpc_ReRaise; compilerproc; Function fpc_Catches(Objtype : TClass) : TObject; compilerproc; function fpc_help_constructor(_self:pointer;var _vmt:pointer;_vmt_pos:cardinal):pointer;compilerproc; procedure fpc_help_destructor(_self,_vmt:pointer;vmt_pos:cardinal);compilerproc; procedure fpc_help_fail(_self:pointer;var _vmt:pointer;vmt_pos:cardinal);compilerproc; {$ifdef dummy} Procedure fpc_DestroyException(o : TObject); compilerproc; procedure fpc_check_object(obj:pointer); compilerproc; procedure fpc_check_object_ext(vmt,expvmt:pointer);compilerproc; {$endif dummy} Procedure fpc_Initialize (Data,TypeInfo : pointer); compilerproc; Procedure fpc_finalize (Data,TypeInfo: Pointer); compilerproc; Procedure fpc_Addref (Data,TypeInfo : Pointer); compilerproc; Procedure fpc_DecRef (Data,TypeInfo : Pointer); compilerproc; procedure fpc_finalize_array(data,typeinfo : pointer;count,size : longint); compilerproc; function fpc_set_load_small(l: fpc_small_set): fpc_normal_set; compilerproc; function fpc_set_create_element(b : byte): fpc_normal_set; compilerproc; function fpc_set_set_byte(const source: fpc_normal_set; b : byte): fpc_normal_set; compilerproc; function fpc_set_unset_byte(const source: fpc_normal_set; b : byte): fpc_normal_set; compilerproc; function fpc_set_set_range(const orgset: fpc_normal_set; l,h : byte): fpc_normal_set; compilerproc; function fpc_set_in_byte(const p: fpc_normal_set; b: byte): boolean; compilerproc; function fpc_set_add_sets(const set1,set2: fpc_normal_set): fpc_normal_set; compilerproc; function fpc_set_mul_sets(const set1,set2: fpc_normal_set): fpc_normal_set; compilerproc; function fpc_set_sub_sets(const set1,set2: fpc_normal_set): fpc_normal_set; compilerproc; function fpc_set_symdif_sets(const set1,set2: fpc_normal_set): fpc_normal_set; compilerproc; function fpc_set_comp_sets(const set1,set2: fpc_normal_set): boolean; compilerproc; function fpc_set_contains_sets(const set1,set2: fpc_normal_set): boolean; compilerproc; {$ifdef LARGESETS} procedure fpc_largeset_set_word(p : pointer;b : word); compilerproc; procedure fpc_largeset_in_word(p : pointer;b : word); compilerproc; procedure fpc_largeset_add_sets(set1,set2,dest : pointer;size : longint); compilerproc; procedure fpc_largeset_sets(set1,set2,dest : pointer;size : longint); compilerproc; procedure fpc_largeset_sub_sets(set1,set2,dest : pointer;size : longint); compilerproc; procedure fpc_largeset_symdif_sets(set1,set2,dest : pointer;size : longint); compilerproc; procedure fpc_largeset_comp_sets(set1,set2 : pointer;size : longint); compilerproc; procedure fpc_largeset_contains_sets(set1,set2 : pointer; size: longint); compilerproc; {$endif LARGESETS} procedure fpc_rangeerror; compilerproc; procedure fpc_overflow; compilerproc; //procedure fpc_iocheck(addr : longint); compilerproc; procedure fpc_iocheck; compilerproc; procedure fpc_InitializeUnits; compilerproc; // not generated by compiler, called directly in system unit // procedure fpc_FinalizeUnits; compilerproc; { Procedure fpc_do_exit; compilerproc; Procedure fpc_lib_exit; compilerproc; Procedure fpc_HandleErrorAddrFrame (Errno : longint;addr,frame : pointer); compilerproc; Procedure fpc_HandleError (Errno : longint); compilerproc; } procedure fpc_AbstractErrorIntern;compilerproc; procedure fpc_assert(Const Msg,FName:Shortstring;LineNo:Longint;ErrorAddr:Pointer); compilerproc; Procedure fpc_reset_typed(var f : TypedFile;Size : Longint); compilerproc; Procedure fpc_rewrite_typed(var f : TypedFile;Size : Longint); compilerproc; Procedure fpc_typed_write(TypeSize : Longint;var f : TypedFile;const Buf); compilerproc; Procedure fpc_typed_read(TypeSize : Longint;var f : TypedFile;var Buf); compilerproc; {$ifdef CPUPOWERPC} function fpc_int64_to_double(i: int64): double; compilerproc; function fpc_qword_to_double(q: qword): double; compilerproc; {$endif CPUPOWERPC} {$endif hascompilerproc} { $Log$ Revision 1.46 2003-08-21 22:07:43 olle - removed parameter from fpc_iocheck Revision 1.45 2003/06/17 19:24:08 jonas * fixed conversion of fpc_*str_unique to compilerproc Revision 1.44 2003/06/17 16:38:53 jonas * fpc_{ansistr|widestr}_unique is now a function so it can be used as compilerproc Revision 1.43 2003/05/26 19:36:46 peter * fpc_shortstr_concat is now the same for all targets * fpc_shortstr_append_shortstr added for optimized code generation Revision 1.42 2003/05/16 22:40:11 florian * fixed generic shortstr_compare Revision 1.41 2003/05/13 19:18:08 peter * fpc_help_fail compilerproc * fpc_new_class, fpc_dispose_class not needed by latest compiler Revision 1.40 2003/05/11 21:39:14 peter * constructor helper added Revision 1.39 2003/04/25 21:15:20 peter * fpc_big_array changed to 1k only. using maxlongint will crash gdb Revision 1.38 2003/04/23 21:28:21 peter * fpc_round added, needed for int64 currency Revision 1.37 2003/04/02 14:07:30 peter * class helpers compilerprocs are not needed yet, changed ifndef i386 to ifdef dummy Revision 1.36 2003/03/17 14:30:11 peter * changed address parameter/return values to pointer instead of longint Revision 1.35 2003/01/11 00:17:29 florian * uncommented the variant<->dyn. array stuff Revision 1.34 2003/01/09 20:14:20 florian * fixed helper declarations Revision 1.33 2003/01/06 23:04:21 mazen * functions headers modified in generic.inc to make it possible compiling sparc RTL based on generic code Revision 1.32 2003/01/06 08:25:47 michael + PAtch from peter fixing daily build Revision 1.31 2003/01/05 21:32:35 mazen * fixing several bugs compiling the RTL Revision 1.30 2002/12/29 16:59:17 peter * implemented some more conversions Revision 1.29 2002/11/26 23:02:07 peter * fixed dynarray copy Revision 1.28 2002/10/17 12:43:00 florian + ansistring_append* implemented Revision 1.27 2002/10/10 19:24:28 florian + write(ln) support for variants added Revision 1.26 2002/10/10 16:08:50 florian + several widestring/pwidechar related helpers added Revision 1.25 2002/10/05 14:20:16 peter * fpc_pchar_length compilerproc and strlen alias Revision 1.24 2002/10/02 18:21:51 peter * Copy() changed to internal function calling compilerprocs * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the new copy functions Revision 1.23 2002/09/27 21:10:40 carl * fix 2GB limit problem Revision 1.22 2002/09/07 21:12:04 carl * cardinal -> longword - remove some unused routines Revision 1.21 2002/09/07 15:07:45 peter * old logs removed and tabs fixed Revision 1.20 2002/09/02 19:24:41 peter * array of char support for Str() Revision 1.19 2002/08/20 18:24:05 jonas * interface "as" helpers converted from procedures to functions Revision 1.18 2002/07/31 16:58:12 jonas * fixed conversion from int64/qword to double errors Revision 1.17 2002/07/28 20:43:47 florian * several fixes for linux/powerpc * several fixes to MT Revision 1.16 2002/04/25 20:14:56 peter * updated compilerprocs * incr ref count has now a value argument instead of var Revision 1.15 2002/04/24 16:15:35 peter * fpc_finalize_array renamed Revision 1.14 2002/04/21 18:56:59 peter * fpc_freemem and fpc_getmem compilerproc Revision 1.13 2002/01/21 20:16:08 peter * updated for dynarr:=nil }