Re: [fpc-pascal] Coroutines and VirtualAlloc

2017-04-18 Thread Ryan Joseph

> On Apr 19, 2017, at 2:34 AM, Daniel Gaspary  wrote:
> 
> Using  SetJmp and LongJmp?
> 
> I believe some months ago it was a discussion on the list on why this
> was not really the way to implement coroutines.
> 
> Searching for longjmp/setjmp you can find the thread, I guess.

I never heard of those functions and I did find a thread about them but it 
seemed inconslusive. 

Here’s a little test I made not knowing exactly how those functions work. I 
expected the stack to be restored and “i” incremented but that’s not what 
happens. The program jumps in and out of the loop but “i” remains the same each 
time. Is this not how to use those functions?

type
TCoroutine = class (TObject)
public
procedure Start;
procedure Yield;
procedure Resume;
private
entry: jmp_buf;
env: jmp_buf;
passes: longint;
yieldNext: boolean;
end;

procedure TCoroutine.Start;
var
i: integer = 0;
begin
Setjmp(entry);
if passes > 0 then
exit;
writeln('start');
while i < 10 do
begin
writeln('loop ', i);
i += 1;
Setjmp(env);
if not yieldNext then
Yield;
yieldNext := false;
end;
end;

procedure TCoroutine.Yield;
begin
writeln('yield');
passes += 1;
yieldNext := false;
Longjmp(entry, 1);
end;

procedure TCoroutine.Resume;
begin
writeln('resume');
yieldNext := true;
Longjmp(env, 1);
end;

procedure CoroutineTest; 
var
co: TCoroutine;
i: integer;
begin
co := TCoroutine.Create;
co.Start;
writeln('stepped out');
for i := 0 to 4 do
co.Resume;
writeln('finished');
end;




start
loop 0
yield
stepped out
resume
loop 1
yield
resume
loop 1
yield
resume
loop 1
yield
resume
loop 1
yield
resume
loop 1
yield
finished


Regards,
Ryan Joseph

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

Re: [fpc-pascal] fpc code for Java class and Android.

2017-04-18 Thread Paul Breneman

On 04/18/2017 01:27 PM, Jon Foster wrote:

On 04/18/2017 10:13 AM, Jon Foster wrote:

On 04/18/2017 04:38 AM, Paul Breneman wrote:

On 04/17/2017 08:42 PM, Jon Foster wrote:
...

You have to copy the app to "/data/tmp" as that is usually the only
place on Android with a Linux file system that all users have access
to.
You can't look in there so you kind of have to fly blind. :-) "Terminal
IDE" makes this easier, assuming you have a compatible Android version,
since it provides the Linux file system space, term emulator and easy
access.

This was what I thought Paul was looking to do. FreeVision might work
depending on a number of variables... but I'm not familiar with it.
Most
Android terminal apps would provide some kind of VT100 like
emulation so
you may have to force FreeVision to output for that emulation. If it
tries to use a "termcap" through normal means it probably will crash.



Thanks Jon *very* much for the details that you shared!  I hope to get
time to get back into this soon and I'm sure that your notes will help.

The last problem that I had *three years* ago was that I failed to get
the mouse to work in the text mode IDE (I did have a keyboard and mouse
that worked in Android).  The mouse is not absolutely required for the
simple programs I'd like to do.

Regards,
Paul

The "mouse" will more than likely be unavailable. Most people don't
think "terminal" and "mouse". Still if you can find an Android
terminal app with "gpm" or xterm style mouse support it could work.
I've never used a "text mode" mouse in Linux. I can't think of any
terminal based programs I use that offer mouse support. :-) And then
you could always download an OpenSource terminal app and hack it to
provide that support. The "xterm" man page documents its mouse
protocol, which is probably the defacto standard.

THX - Jon


I should also mention that PascalGUI is probably the most mature
FPC+term+editor app that I know of. Its been a while but it seems
they've added some nice touches. I had been using "Pascal Develop" since
I could download the source and alter its compile target. But it doesn't
provide proper terminal emulation and came packaged with FPC 2.6 pre v3
beta, which was good at the time since 3 hadn't been out yet. :-D I
patched and added many FPC units to his original set, which I think he
released.



I'm pretty sure that the Turbo Pascal text mode IDE offered mouse 
support (under MS-DOS), and also the Free Pascal IDE (which you can try 
under Linux).


Thanks again Jon for your notes.  I've know about PascalGUI for a while 
and have a little doc about it near the bottom of this page:

  http://turbocontrol.com/helloworld.htm

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

Re: [fpc-pascal] AArch64 / Linux

2017-04-18 Thread Tobias Giesen
Wow, fantastic, many thanks! Will try to build it :=)


-

Please excuse the shortness of this mail which was sent from my mobile phone. 
If necessary, I will send more information later.

Cheers,
Tobias Giesen

> Am 18.04.2017 um 23:34 schrieb Jonas Maebe :
> 
> 
> Tobias Giesen wrote:
>> I now have two machines running Linux on 64-bit ARM. So I wonder, what's the 
>> best
>> way to get FPC 3.0.2 running natively on AArch64 and producing AArch64 
>> programs?
> 
> FPC 3.0.2 does not support AArch64. AArch64 is only supported in trunk,
> and in a separate 3.0.x backport branch
> (view-source:http://svn.freepascal.org/svn/fpc/branches/fixes_3_0_ios/
> -- this branch includes Linux/AArch64 support as well)
> 
> 
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] AArch64 / Linux

2017-04-18 Thread Jonas Maebe

Tobias Giesen wrote:
> I now have two machines running Linux on 64-bit ARM. So I wonder, what's the 
> best
> way to get FPC 3.0.2 running natively on AArch64 and producing AArch64 
> programs?

FPC 3.0.2 does not support AArch64. AArch64 is only supported in trunk,
and in a separate 3.0.x backport branch
(view-source:http://svn.freepascal.org/svn/fpc/branches/fixes_3_0_ios/
-- this branch includes Linux/AArch64 support as well)


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

[fpc-pascal] AArch64 / Linux

2017-04-18 Thread Tobias Giesen
Hello,

me again trying new platforms :=)

I now have two machines running Linux on 64-bit ARM. So I wonder, what's the 
best
way to get FPC 3.0.2 running natively on AArch64 and producing AArch64 programs?

Thanks for any tips.

Cheers,
Tobias


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

Re: [fpc-pascal] Coroutines and VirtualAlloc

2017-04-18 Thread Daniel Gaspary
On Sat, Apr 15, 2017 at 6:20 AM, Ryan Joseph  wrote:
> I was curious about possible ways coroutines could work in FPC and found this 
> example that claims to implement just that. It appears to be designed for 
> Windows though and makes use of a function called VirtualAlloc which I don’t 
> understand. Is there a non platform specific version of this function? I’d 
> like to test the code but I have no idea what that function does or how to 
> replace it.


Using  SetJmp and LongJmp?

I believe some months ago it was a discussion on the list on why this
was not really the way to implement coroutines.

Searching for longjmp/setjmp you can find the thread, I guess.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc code for Java class and Android.

2017-04-18 Thread Jon Foster

On 04/18/2017 10:13 AM, Jon Foster wrote:

On 04/18/2017 04:38 AM, Paul Breneman wrote:

On 04/17/2017 08:42 PM, Jon Foster wrote:
...

You have to copy the app to "/data/tmp" as that is usually the only
place on Android with a Linux file system that all users have access to.
You can't look in there so you kind of have to fly blind. :-) "Terminal
IDE" makes this easier, assuming you have a compatible Android version,
since it provides the Linux file system space, term emulator and easy
access.

This was what I thought Paul was looking to do. FreeVision might work
depending on a number of variables... but I'm not familiar with it. Most
Android terminal apps would provide some kind of VT100 like emulation so
you may have to force FreeVision to output for that emulation. If it
tries to use a "termcap" through normal means it probably will crash.



Thanks Jon *very* much for the details that you shared!  I hope to get
time to get back into this soon and I'm sure that your notes will help.

The last problem that I had *three years* ago was that I failed to get
the mouse to work in the text mode IDE (I did have a keyboard and mouse
that worked in Android).  The mouse is not absolutely required for the
simple programs I'd like to do.

Regards,
Paul
The "mouse" will more than likely be unavailable. Most people don't think 
"terminal" and "mouse". Still if you can find an Android terminal app 
with "gpm" or xterm style mouse support it could work. I've never used a 
"text mode" mouse in Linux. I can't think of any terminal based programs 
I use that offer mouse support. :-) And then you could always download an 
OpenSource terminal app and hack it to provide that support. The "xterm" 
man page documents its mouse protocol, which is probably the defacto 
standard.


THX - Jon

I should also mention that PascalGUI is probably the most mature 
FPC+term+editor app that I know of. Its been a while but it seems they've 
added some nice touches. I had been using "Pascal Develop" since I could 
download the source and alter its compile target. But it doesn't provide 
proper terminal emulation and came packaged with FPC 2.6 pre v3 beta, which 
was good at the time since 3 hadn't been out yet. :-D I patched and added 
many FPC units to his original set, which I think he released.


--
Jon Foster
JF Possibilities, Inc.
j...@jfpossibilities.com

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

Re: [fpc-pascal] fpc code for Java class and Android.

2017-04-18 Thread Jon Foster

On 04/18/2017 04:38 AM, Paul Breneman wrote:

On 04/17/2017 08:42 PM, Jon Foster wrote:
...

You have to copy the app to "/data/tmp" as that is usually the only
place on Android with a Linux file system that all users have access to.
You can't look in there so you kind of have to fly blind. :-) "Terminal
IDE" makes this easier, assuming you have a compatible Android version,
since it provides the Linux file system space, term emulator and easy
access.

This was what I thought Paul was looking to do. FreeVision might work
depending on a number of variables... but I'm not familiar with it. Most
Android terminal apps would provide some kind of VT100 like emulation so
you may have to force FreeVision to output for that emulation. If it
tries to use a "termcap" through normal means it probably will crash.



Thanks Jon *very* much for the details that you shared!  I hope to get
time to get back into this soon and I'm sure that your notes will help.

The last problem that I had *three years* ago was that I failed to get
the mouse to work in the text mode IDE (I did have a keyboard and mouse
that worked in Android).  The mouse is not absolutely required for the
simple programs I'd like to do.

Regards,
Paul
The "mouse" will more than likely be unavailable. Most people don't think 
"terminal" and "mouse". Still if you can find an Android terminal app with 
"gpm" or xterm style mouse support it could work. I've never used a "text 
mode" mouse in Linux. I can't think of any terminal based programs I use 
that offer mouse support. :-) And then you could always download an 
OpenSource terminal app and hack it to provide that support. The "xterm" 
man page documents its mouse protocol, which is probably the defacto standard.


THX - Jon

--
Jon Foster
JF Possibilities, Inc.
j...@jfpossibilities.com


--
Sent from my Debian Linux workstation -- http://www.debian.org/intro/about

Jon Foster
JF Possibilities, Inc.
j...@jfpossibilities.com
541-410-2760
Making computers work for you!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] GUI multithreaded Win32 program sometimes freeze when quitting

2017-04-18 Thread Henry Vermaak
On Tue, Apr 18, 2017 at 07:32:21PM +0800, Dennis wrote:
> Since this freezing behavour does not happen during debugging, I have spent
> months trying to fix it but failed.
> 
> Any suggestions are welcome.

Try using a data race detector to see if it's a deadlock.  I don't know
about Windows, but I've used the helgrind tool in valgrind to
successfully fix thread errors in a lazarus program.  If you're lucky,
the problem will manifest itself on a platform that valgrind is
available on.

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

Re: [fpc-pascal] GUI multithreaded Win32 program sometimes freeze when quitting

2017-04-18 Thread Mark Morgan Lloyd

On 18/04/17 12:00, Dennis wrote:

I have an win32 multithreaded program written in lazarus 1.7, FPC 3.1.1
From time to time, when it quits, it will freezes and from the task
manager, the program will occupies the entire CPU core.
I noticed that it will happen more often if:


This might be better on the Lazarus ML since it's likely to be a 
subtlety of the LCL.


My experience is that it pays to be absolutely paranoid during 
termination regarding the continued availability of anything associated 
with a form, and also about termination flags themselves particularly 
the application terminate flag.


Granted that most of my unhappy experience in this area was in Delphi, 
but like yourself I found the culprit elusive.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] fpc code for Java class and Android.

2017-04-18 Thread Paul Breneman

On 04/17/2017 08:42 PM, Jon Foster wrote:
...

You have to copy the app to "/data/tmp" as that is usually the only
place on Android with a Linux file system that all users have access to.
You can't look in there so you kind of have to fly blind. :-) "Terminal
IDE" makes this easier, assuming you have a compatible Android version,
since it provides the Linux file system space, term emulator and easy
access.

This was what I thought Paul was looking to do. FreeVision might work
depending on a number of variables... but I'm not familiar with it. Most
Android terminal apps would provide some kind of VT100 like emulation so
you may have to force FreeVision to output for that emulation. If it
tries to use a "termcap" through normal means it probably will crash.



Thanks Jon *very* much for the details that you shared!  I hope to get 
time to get back into this soon and I'm sure that your notes will help.


The last problem that I had *three years* ago was that I failed to get 
the mouse to work in the text mode IDE (I did have a keyboard and mouse 
that worked in Android).  The mouse is not absolutely required for the 
simple programs I'd like to do.


Regards,
Paul
www.ControlPascal.com

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

[fpc-pascal] GUI multithreaded Win32 program sometimes freeze when quitting

2017-04-18 Thread Dennis

I have an win32 multithreaded program written in lazarus 1.7, FPC 3.1.1

From time to time, when it quits, it will freezes and from the task 
manager, the program will occupies the entire CPU core.


I noticed that it will happen more often if:
1)
constructor TMyComponent.Create(TheOwner : TComponent);
begin

   self.some_component := TSomeComponent.Create(TheOwner);
end;


instead of

constructor TMyComponent.Create(TheOwner : TComponent);
begin

   self.some_component := TSomeComponent.Create(self);
end;


2) if the program executes some methods of a nil object



3) if I don't do a build all when some common units are changed by 
another project.




Since this freezing behavour does not happen during debugging, I have 
spent months trying to fix it but failed.


Any suggestions are welcome.

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