Re: [fpc-pascal] Question: Is there a global callback, when a thread gets terminated?

2019-02-05 Thread OBones
Hello, If you are targeting Windows, there is a special area in the PE structure for a DLL that contains addresses that will be jumped to whenever a thread gets created/destroyed. This has been used by libtcmalloc from gperftools: https://github.com/gperftools/gperftools/blob/master/src/windo

Re: [fpc-pascal] TThread.FreeOnTerminate

2018-12-14 Thread OBones
Michael Van Canneyt wrote: I think FreeOnTerminate should not even exist. IMO it should simply be 'True'. This is where I strongly disagree, to me it should always be False, because having things free up themselves at unpredictable times is a recipe for disaster which already hit me badly. For

Re: [fpc-pascal] TThread.FreeOnTerminate

2018-12-14 Thread OBones
Michael Van Canneyt wrote: On Fri, 14 Dec 2018, el es wrote: On 13/12/2018 22:23, Michael Van Canneyt wrote: On Thu, 13 Dec 2018, Martin Frb wrote: Besides, the documentation does not say that FreeOnTerminate is limited to be used in the thread construction. Especially since its ef

Re: [fpc-pascal] any free pascal standard function to compare a string against an array of string?

2018-10-10 Thread OBones
Hello, I would use IndexStr from StrUtils: https://www.freepascal.org/docs-html/rtl/strutils/indexstr.html   if IndexStr('subtext', ['abc','cde','fecg','hig']) >= 0  then Regards Dennis wrote: is there a function like   if    IsOneOf('subtext', ['abc','cde','fecg','hig'])   then begin ... e

[fpc-pascal] ExceptProc no longer gets Frames if DLL host uses a different memory manager

2018-05-18 Thread OBones
Hello, I have a Win64 DLL compiled with FreePascal 2.6.0 in which I install a ExceptProc handler which signature is as follows: procedure MyExceptProc(Obj: TObject; Addr: Pointer; FrameCount: LongInt; Frame: PPointer); Up until recently, FrameCount was greater than zero and I could walk the

Re: [fpc-pascal] LLVM Backend Support

2016-08-19 Thread OBones
Sven Barth wrote: Am 19.08.2016 09:55 schrieb "Jonas Maebe" >: > As alluded to above, LLVM support needs to be added/tested/maintained > separately for each supported architecture and to a lesser extent for > each supported OS. Right now, I only have plans for

[fpc-pascal] x64 compiler and Large Address Aware flag

2016-07-27 Thread OBones
Hello, We are using FPC (2.6.0) here to allow compiling our users ideas into runable code and while this has worked just fine until now, on one occasion we have reached a situation where the ppcrossx64 compiler ends with an EOutOfMemory exception. Looking at its memory consumption, sure enough

Re: [fpc-pascal] TFPList.Expand was: Maximum of memory which can be used by single program in 32 bit Windows

2016-05-20 Thread OBones
Lukasz Sokol wrote: On 20/05/16 09:40, Graeme Geldenhuys wrote: On 2016-05-20 09:36, Graeme Geldenhuys wrote: I think a “x percentage of capacity” increment is the way to go. eg: 5 or 10% Scrap that idea. In hind sight, % increments is what is causing the problem. Regards, Graeme And actu

Re: [fpc-pascal] FPC generated executables and digital signatures

2016-04-08 Thread OBones
If the exe is unsigned, then Windows will complain everytime it is run. If it is signed with a fully resolved certificate (not a self created one), then it will show the publisher in the dialog and depending on your security settings will either ask you if you want to be asked the next time or

Re: [fpc-pascal] IfThen() intrinsic removed

2016-02-05 Thread OBones
Michael Van Canneyt wrote: The only use case that would be gained is the non-evaluation of one of the arguments. Yes, and that's pretty much the only use that I could think of, but it would be very convenient when testing for a variable to be assigned and give a default value it if is not. S

Re: [fpc-pascal] Pascal Lexical Diagrams

2016-02-01 Thread OBones
Mark Morgan Lloyd wrote: So hopefully we can drop the nasty "railroad" Americanism, since it wasn't the original name. And hopefully we can use "syntax" in the name, since that's what they describe. Hence "syntax chart", "syntax diagram" or something similar. Please :-) Where I live, "synta

Re: [fpc-pascal] how to use procedure of object in C

2015-03-10 Thread OBones
Xiangrong Fang wrote: However, like in my first mail, if I define THandler a procedure of object, it makes easier to SetHandler(AMethod); but how can I use that "procedure of object" pointer in the so? It works the same, cast the data you receive to a TMethod and call the "code" member with t

Re: [fpc-pascal] how to use procedure of object in C

2015-03-09 Thread OBones
Michael Van Canneyt wrote: On Mon, 9 Mar 2015, Xiangrong Fang wrote: Hi all, I define a procedure like this: type TDataHandler = procedure(data: Pointer) of object; procedure SetHandler(h: TDataHandler); external cdecl; Now, can I implement SetHandler in a library written in C, then call

Re: [fpc-pascal] can someone please email me a zipped hello world binary program MIPS big endian for testing on my MIPS hardware?

2013-06-12 Thread OBones
Hello, Can't you just run that exe with the -h flag? Should run fast enough. Dennis Poon wrote: But Pierre, that looks more like a native MIPS compiler. My MIPS hardware is too slow to run a compiler. I need a cross compiler. If you have MIPS hardware, can you compile and send me a simple MIPS

Re: [fpc-pascal] Weird absence of compilation error

2013-03-21 Thread OBones
to warn my users to be more careful. Anyway, I have created a ticket for this, thanks for the response: http://bugs.freepascal.org/view.php?id=24104 Regards OBones ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.o

Re: [fpc-pascal] Weird absence of compilation error

2013-03-21 Thread OBones
be ignored by the compiler. A '-' (minus) would force some action, so it is absolutely wrong at this place. Thanks for the explanation on the behavior. ----- Original Message - From: "OBones" To: "FPC-Pascal users discussions" Sent: Thursday, March 21, 2013

[fpc-pascal] Weird absence of compilation error

2013-03-21 Thread OBones
le it successfully in Delphi mode! What's even weirder is that if I replace the Plus operator by a Minus operator, then the compilation fails. What I was expecting is that the compilation fails in all cases. Is there some flag that I failed to specify? Rega

Re: [fpc-pascal] SDF/Delimitedtext: Request for *Delphi* test :)

2012-09-20 Thread OBones
Reinier Olislagers wrote: 1. Could you please run this on other versions of Delphi and report back the results (presumably older versions will not run the test with commatext) I have run it with D2007, DXE, DXE2 Win32 and DXE2 Win64, all gave the following result: tw19610: sdf tests succeeded

Re: [fpc-pascal] EControlC instead of EZeroDivide when using SSE instructions

2012-08-22 Thread OBones
Jonas Maebe wrote: OBones wrote on Wed, 22 Aug 2012: Jonas Maebe wrote: You can try debugging syswin32_i386_exception_handler in rtl/win32/system.pp to see what exception Win32 reports instead. Thanks for the confirmation as I was heading that way when I posted the message, without much

Re: [fpc-pascal] EControlC instead of EZeroDivide when using SSE instructions

2012-08-22 Thread OBones
Jonas Maebe wrote: OBones wrote on Wed, 22 Aug 2012: Olivier SANNIER wrote: Does any of you have any suggestion as to explain this behavior, and best of all, how to fix it? I went further and changed the code this so that I can get better details as to where the exception is coming from

Re: [fpc-pascal] EControlC instead of EZeroDivide when using SSE instructions

2012-08-22 Thread OBones
Olivier SANNIER wrote: Does any of you have any suggestion as to explain this behavior, and best of all, how to fix it? I went further and changed the code this so that I can get better details as to where the exception is coming from: program test; uses sysutils, classes; function GetMX

Re: [fpc-pascal] Re: UnicodeString comparison performance

2012-07-24 Thread OBones
Thomas Schatzl wrote: This code is not thread safe at all. A thread switch after the while loop and before the increment will not prevent progress on other threads, so multiple threads can enter the "critical section". Well, yes, even if under Windows it's rare that a thread is preempted right i

Re: [fpc-pascal] Re: UnicodeString comparison performance

2012-07-23 Thread OBones
Jonas Maebe wrote: On 23 Jul 2012, at 10:58, OBones wrote: leledumbo wrote: I look at the generated code and in the direct one there's additional overhead of decrementing the reference counter on each iteration. I see it too now (I forgot about the -a option). I can understand why there

Re: [fpc-pascal] Re: UnicodeString comparison performance

2012-07-23 Thread OBones
leledumbo wrote: That one I cannot answer, please summon Florian/Jonas/Marco/Michael/whoever capable to answer Would you happen to know the magical words/rhunes that I should use? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lis

Re: [fpc-pascal] Re: UnicodeString comparison performance

2012-07-23 Thread OBones
leledumbo wrote: I look at the generated code and in the direct one there's additional overhead of decrementing the reference counter on each iteration. I see it too now (I forgot about the -a option). I can understand why there is a call to the decrementer outside the loop when using the varia

[fpc-pascal] UnicodeString comparison performance

2012-07-20 Thread OBones
Hello all, As I'm moving further into my experiments with FreePascal 2.6.0, I have run into a strange issue related to UnicodeString comparisons. Basically, I'm comparing the result of a function with a constant value and find that the comparison is faster if I first assign the result of the f

Re: [fpc-pascal] Floating point discrepancy in x64 mode

2012-07-20 Thread OBones
Jonas Maebe wrote: Possible solutions: a) typecast one of the operands of the division to double (not that this is Delphi-incompatible) b) Compile with -CF64 to force all floating point constants to become at least 64 bit in precision, even if they can be represented exactly using 32 bit I wen

[fpc-pascal] Floating point discrepancy in x64 mode

2012-07-20 Thread OBones
Hello all, Let's consider the following test program: program test; function DirectCompute: Double; var k: Integer; begin k := 0; Result := (k+0.5)/12; end; function IntermediateCompute: Double; var k: Integer; begin k := 0; Result := k+0.5; Result := Result / 12; end; begin W

Re: [fpc-pascal] Inter-process communication, a cautionary tale

2012-07-19 Thread OBones
Mark Morgan Lloyd wrote: OBones wrote: Mark Morgan Lloyd wrote: Basically, what I was trying to do was this. In the main thread: fIpcPipe:= CreateNamedPipe(PChar(fIpcName), PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE + PIPE_READMODE_MESSAGE

Re: [fpc-pascal] Inter-process communication, a cautionary tale

2012-07-18 Thread OBones
Mark Morgan Lloyd wrote: Basically, what I was trying to do was this. In the main thread: fIpcPipe:= CreateNamedPipe(PChar(fIpcName), PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE + PIPE_READMODE_MESSAGE, 1, 0, 0, 1000, NIL (* @sa *) ); That

Re: [fpc-pascal] Inter-process communication, a cautionary tale

2012-07-18 Thread OBones
Mark Morgan Lloyd wrote: A couple of weeks ago, out of curiosity rather than necessity, I started looking at whether the library could be ported to Windows using MS-style named pipes. However I seem to have hit a snag since it appears that Windows can't both create a named pipe (for reading) an

[fpc-pascal] StackTop and StackBottom are bogus in a Win32/64 Dll

2012-07-06 Thread OBones
Hello all, I'm writing Dlls here and am also doing low level analysis of the stack and its content. To do that, I use the StackTop and StackBottom global variables which used to work fine in an exe file. Problem is, when in a DLL, StackTop is always zero and StackBottom is the exact opposite o

[fpc-pascal] Manually handling all exceptions

2012-07-03 Thread OBones
think about that? Does it sound feasible? Do you have any advices on how best to proceed? Thanks in advance OBones. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Unhandled exception from library crashes host exe

2012-06-27 Thread OBones
Hello, Regular exceptions, those raised with the "raise" keyword are always trapped by try..except blocks but you have to make sure that EVERY method in the DLL that is called by the host exe has such a construct so as not to let the exception escape. However, there are exceptions that come fr

Re: [fpc-pascal] Converting from seconds to TTime: easiest way?

2012-06-20 Thread OBones
Reinier Olislagers wrote: Morning list, I'm trying to convert a large number of seconds to a TTime. To my surprise - without a Delphi background ;) - EncodeTime only takes up to 59 seconds... ;) Same for EncodeTimeInterval Considering that TTime is a float where the fractional part is the par

Re: [fpc-pascal] Error in x32 compiler when using SSE3

2012-05-29 Thread OBones
Jonas Maebe wrote: OBones wrote on Mon, 28 May 2012: Boy, I'm having a hard day and I'm very sorry to make you waste so much time. Frac was here to see the impact of some changes on the issue, but the original code that crashes is with Trunc instead of Frac so that the comparison

Re: [fpc-pascal] Error in x32 compiler when using SSE3

2012-05-28 Thread OBones
Jonas Maebe wrote: On 28 May 2012, at 15:19, OBones wrote: Bugger, why does this keep happening to me??? Anyway, this time it is at the end. I cannot reproduce the problem with 2.6.0/2.7.1 on Mac OS X/i386, nor with 2.7.1 on Linux/i386. I even don't see any comis* instructions in the

Re: [fpc-pascal] Error in x32 compiler when using SSE3

2012-05-28 Thread OBones
Jonas Maebe wrote: On 28 May 2012, at 14:41, OBones wrote: I'm compiling the program at the end of this message The program is missing. Bugger, why does this keep happening to me??? Anyway, this time it is at the end. I really need to have the same instruction set used for floating

[fpc-pascal] Error in x32 compiler when using SSE3

2012-05-28 Thread OBones
Hello all, I'm compiling the program at the end of this message in x86 and x64 mode using the following command lines: ppc386 -MDelphi -CfSSE3 testFPU.dpr ppcrossx64 -MDelphi -CfSSE3 testFPU.dpr while I get an exe file and no error in x64 mode, I get the following error message with ppc386:

Re: [fpc-pascal] Catching math exceptions in a DLL

2012-05-24 Thread OBones
Jonas Maebe wrote: OBones wrote on Wed, 16 May 2012: Using FPC, I'm writing a DLL that exports functions used by a given host process. In order to protect the host process, it is mandatory that all exceptions are trapped in the exported function You are probably running into

[fpc-pascal] Catching math exceptions in a DLL

2012-05-16 Thread OBones
Hello all, Using FPC, I'm writing a DLL that exports functions used by a given host process. In order to protect the host process, it is mandatory that all exceptions are trapped in the exported function and in order to achieve that, I have the following construct in all exported functions:

Re: [fpc-pascal] Setting string to be UnicodeString by default

2012-05-15 Thread OBones
Marcos Douglas wrote: On Tue, May 15, 2012 at 6:16 AM, Jonas Maebe wrote: Mattias Gaertner wrote on Tue, 15 May 2012: On Tue, 15 May 2012 10:43:19 +0200 Jonas Maebe wrote: It is not possible in FPC 2.6.x. Wth the svn trunk version, you can use {$modeswitch unicodestrings} (in combination

Re: [fpc-pascal] Compilation progress

2012-04-27 Thread OBones
Jonas Maebe wrote: On 26 Apr 2012, at 17:31, OBones wrote: Is there a way get progress information output by the compiler while building a project? I tried the -vt option, but I can't figure out a way to parse this and get something like current value and max while the lines are outp

[fpc-pascal] Compilation progress

2012-04-26 Thread OBones
Hello, Is there a way get progress information output by the compiler while building a project? I tried the -vt option, but I can't figure out a way to parse this and get something like current value and max while the lines are output. I also tried to look in the lazarus sources but could not f

Re: [fpc-pascal] Compiling from and to memory

2012-04-26 Thread OBones
Jonas Maebe wrote: OBones wrote on Mon, 23 Apr 2012: And because I have to split my generated files so that FPC does not hit the 2GB memory limit (which it does for a 15M source file) What is the structure of that source code? (a few giant routines, large constant arrays, ... ?) Thousands

Re: [fpc-pascal] Compiling from and to memory

2012-04-23 Thread OBones
Mattias Gaertner wrote: On Fri, 20 Apr 2012 18:26:28 +0200 Florian Klaempfl wrote: Am 19.04.2012 14:11, schrieb OBones: I looked around in the documentation for "standard input", "pipe", but apart from ways to access them from within a program, I was not able to find any

Re: [fpc-pascal] Inline assembly using absolute dword ptr

2012-04-23 Thread OBones
Jonas Maebe wrote: On 20 Apr 2012, at 17:50, OBones wrote: So there is a difference with Delphi's assembler where it defaults to relative indexing while FPC defaults to absolute in that context. What exactly do you mean by relative addressing in this context? RIP-relative? In FPC

Re: [fpc-pascal] Inline assembly using absolute dword ptr

2012-04-20 Thread OBones
OBones wrote: Jonas Maebe wrote: {$IFDEF WIN64} pushrcx mov rcx,gs:[abs qword ptr $30] And this: mov rcx,qword ptr gs:[$30] Thanks, but does this guarantee absolute indexing? I'm asking because the abs keyword is required when using the same code under Delphi XE2.

Re: [fpc-pascal] Inline assembly using absolute dword ptr

2012-04-20 Thread OBones
Jonas Maebe wrote: {$IFDEF WIN64} pushrcx mov rcx,gs:[abs qword ptr $30] And this: mov rcx,qword ptr gs:[$30] Thanks, but does this guarantee absolute indexing? I'm asking because the abs keyword is required when using the same code under Delphi XE2. If I don't use it, that

Re: [fpc-pascal] Compiling from and to memory

2012-04-20 Thread OBones
Mattias Gaertner wrote: Maybe you can create a ramdisk. Thank you for your answer. I have thought about that, but this would create deployment problems as there is no default ramdisk driver under Windows. Might be worth considering should performance become a really big issue. Regards ___

Re: [fpc-pascal] Compiling from and to memory

2012-04-20 Thread OBones
michael.vancann...@wisa.be wrote: It is currently not possible. FPC always reads from and writes to files. Fair enough, I'll have to deal with it then. Thank you for your answer ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists

Re: [fpc-pascal] Inline assembly using absolute dword ptr

2012-04-20 Thread OBones
OBones wrote: The function starts at line 26 so the errors are about "dword ptr" and "abs qword ptr" inside the fs and gs square brackets What is wrong with my syntax? Is there another way to write it and get it to work? Ok, answering myself here, the syntax accepted by

[fpc-pascal] Inline assembly using absolute dword ptr

2012-04-20 Thread OBones
Hello, I'm trying to compile the following code under FreePascal 2.6.0 : function MyGetCurrentThreadId: DWORD; assembler; asm {$IFDEF WIN32} pushecx mov ecx,fs:[dword ptr $18] mov eax,dword ptr [ecx + $24] pop ecx {$ENDIF WIN32} {$IFDEF WIN64} pushrcx mov

[fpc-pascal] Compiling from and to memory

2012-04-20 Thread OBones
to find any information. Is this possible? If yes, how should I proceed? Thank you for your answers OBones ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal