Re: [fpc-pascal] Stack problem in externally called callback function

2009-08-03 Thread Jonas Maebe


On 03 Aug 2009, at 08:49, Wimpie Nortje wrote:

The FPC thread setup code (CAllocateThreadVars, InitThread) happens  
inside the newly created thread before the user's thread function  
starts.


The only viable way I see to get support from the C library is for  
it to inform FPC about a new thread after creation, but this means  
that the C user's thread function has already started executing when  
FPC gets the new ID. Is it possible to do the FPC thread setup from  
outside the new thread?


No, because those functions need the thread ID. And e.g.  
CAllocateThreadVars calls pthread_setspecific(), which is defined as  
associating a value with the current thread.


I think the "easiest" way for you to do this would be to do something  
similar to what the FPC rtl does: write your own function that does  
all of this initialisation, and pass that one to pthread_create as the  
function to run in the new thread. Then from this function perform all  
initialisation, and finally call the original function.


Suppose this setup can be completed before the library starts  
calling FPC callbacks, would all the current memory problems then be  
solved?


Only if you can also guarantee that all thread exits can be hooked by  
your library (so no direct pthread_exit() calls from the user  
function) and that you then call FPC's DoneThread.



Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] More WideString routines

2009-08-03 Thread Felipe Monteiro de Carvalho
Hello,

>From time to time when I use widestring I miss equivalent functions to
those available for ansistrings.

At the moment I need a widestring replacement for StrPos. I searched
for WideStrPos in my FPC 2.2.2 but nothing came. Any ideas?

And if we really lack more widestring routines, where should they be placed?

thanks,
-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] More WideString routines

2009-08-03 Thread theo

Felipe Monteiro de Carvalho schrieb:

Hello,


At the moment I need a widestring replacement for StrPos. I searched
for WideStrPos in my FPC 2.2.2 but nothing came. Any ideas?

  

StrPos is for PChar. Do you mean Pos? There are lots of versions of Pos.
One of them is
Function Pos (Const Substr : WideString; Const Source : WideString) : 
SizeInt;


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal