Re: [fpc-pascal] Re: Converting code from C++ to FP....

2011-03-20 Thread Micha Nelissen

Jorge Aldo G. de F. Junior wrote:

const has the same effect as fpc const before a parameter,


This is not true.


double* SX0
is the same as
double *SX0
or
double * SX0

so this becomes

const SX0 : pdouble (ugly pointer as array Cishism)


No! 'const double * X' in C makes the pointed-to data const, while 
'const X: PDouble' in pascal makes the parameter itself const. You 
cannot assign another address of a double to it, while you can in C.


In C terms, pascal can only do 'double * const X'. Pascal is not really 
useful this way, 'const' is generally only useful for structures and 
strings.


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


Re: [fpc-pascal] GetTempFileName in Linux

2010-10-07 Thread Micha Nelissen

Michael Van Canneyt wrote:

Yes, but if the administrator must update 20 PCs manually every 2 weeks,
he quickly complains that he has better things to do, so it must be done
when the 'ordinary' user uses the application.


Aren't there automation systems for this? Just like debian's 'apt-get 
update  upgrade' with a custom repository with your software? But then 
for windows I presume?


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


Re: [fpc-pascal] GetTempFileName in Linux

2010-10-07 Thread Micha Nelissen

Michael Van Canneyt wrote:

I haven't seen any yet. The main problem is that the update isn't
'optional' or 'to be scheduled at X every night'. It must be done when 
the server application says it is time to do so.


apt-proxy ... push to the proxy when it's time to update stuff ;)

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


Re: [fpc-pascal] FPC static linking of zlib

2010-04-14 Thread Micha Nelissen

Michael Van Canneyt wrote:

libz.so.1 = /lib/libz.so.1 (0x7f6de2801000)

As you can see, it uses libz (or zlib) but dynamically, probably through 
some library dependency.


I think this dynamic library dependency is caused by e.g. gtk, not 
directly by application or lcl or fcl directly.


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


Re: [fpc-pascal] FPC static linking of zlib

2010-04-13 Thread Micha Nelissen

Matthias Klumpp wrote:

If you build the package using lazbuild, lintian (the Debian policy checker
tool) throws an error described here:
 http://lintian.debian.org/tags/embedded-zlib.html


paszlib is a pascal implementation of compression. How is that check 
performed? Maybe it triggers on some specific function name?


I'm not sure if some version of zlib was translated to pascal; therefore 
having the same security issues, or if it was written from scratch, so 
that it won't have those security issues?


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


Re: [fpc-pascal] Pointers

2010-02-11 Thread Micha Nelissen

Rainer Stratmann wrote:

Ok, that makes some sense, but I did not know it before.
In the past with the turbopascal compiler and other always sizeof byte was 
added.


The behavior is dependent on the {$T+} (typed pointers) mode.

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


Re: [fpc-pascal] readonly variables

2009-11-29 Thread Micha Nelissen

Anthony Walter wrote:

Having said all that, Jonas, what is the actual implemented behaviour
of FPC? Does it 0 initialize heap memory at startup or not? If not,
what is the justification for not doing so when this has been a long
established behaviour of Delphi?


It's not the compiler or RTL that zeroes the memory, but the OS. 
Therefore, it cannot be guaranteed by the fpc documentation (except if 
it would contain code to explicitly initialise that memory).


Most OSes (Windows, Linux, BSDs, ...) do zero global memory though, to 
prevent leakage of (potentially security sensitive) information from one 
process to another.


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


Re: [fpc-pascal] Generic type declaration example versus manual.

2009-11-21 Thread Micha Nelissen

Jonas Maebe wrote:

tgeneric16.pp is not an example, it's a test. Moreover, it doesn't compile yet, 
not even with FPC 2.5.1. So documenting that syntax is not really a good idea.


His comment doesn't really apply to tgeneric16 specifically, but more to 
 generic syntax in general.


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


Re: [fpc-pascal] memory mapped file

2009-10-31 Thread Micha Nelissen

Alexey Voytsehovich wrote:

All the good days.
You can not tell what I need to read and/or study for solving
cross-platform (linux/windows) implementation of the memory mapped file?


On unix, it would be fpmmap.
On windows, it would be CreateFileMapping/MapViewOfFile if I'm not mistaken.

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


Re: [fpc-pascal] bzip2

2009-10-31 Thread Micha Nelissen

Juha Manninen wrote:

Oops, sorry. I will do that.
Where does the thread information come from? It looks good in my email client 
and I don't see any extra data.


Try to enable 'Threaded view'; usually somewhere in the View menu, Sort 
menu, etc. Depends on client used.


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


Re: [fpc-pascal] (no subject)

2009-10-17 Thread Micha Nelissen

ak za wrote:
i want to don't send mail to me from you but idn't know how do it. 
please guide me


Do you mean unsubscribe, see link at bottom of this email:


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


Then look at bottom of page, unsubscribe.

Micha


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


Re: [fpc-pascal] Illogical automatic dereferencing

2009-10-10 Thread Micha Nelissen

Henry Vermaak wrote:

One thing I think you don't understand is that an array _is_ a
pointer.  Look at this table to visualise:


In Pascal, an array is not a pointer; at least not at the language 
level. For a static array X (array[1..n] of T), you *can* write:


Move(Ptr^, X, sizeof(X));

because X *is* the array, representing the memory of the array.

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


Re: [fpc-pascal] FIONREAD FPC FpIOCtl for Cross platform Sockets

2009-10-09 Thread Micha Nelissen

Andrew Brunner wrote:

Sockets programming often requires a poll for how much data is
available on a particular socket descriptor.


AFAIK, it doesn't? If data is available, but less than you request, a 
'read' on the socket does not block, but returns the number of bytes 
read, which is less than you requested.


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


Re: [fpc-pascal] multiple inheritence

2009-10-03 Thread Micha Nelissen

David Emerson wrote:
lists containing the same elements: one sorted, one unsorted. The 
reason to have both: sorted - fast search; unsorted - sequential 
navigation through the list while elements are being added.


It's not as if combining those gives you the best of both worlds ... if 
the sorted list needs to keep its list sorted, having the sequential 
list won't make iterating faster ...


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


Re: [fpc-pascal] Re: getting started with threads

2009-09-19 Thread Micha Nelissen

Graeme Geldenhuys wrote:

So far I have single interface for create/destroy/lock/unlock of
semaphores for Windows, Linux, *BSD. The latter two is actually for all


A semaphore is not locked and unlocked, it is posted and waited for.

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


Re: [fpc-pascal] getting started with threads

2009-09-19 Thread Micha Nelissen

Jonas Maebe wrote:
on x86 too). Atomic operations are not memory barriers by themselves, 
and the fact that you perform an atomic operation does not mean that 
afterwards all cpu's will immediately see this new value.


Explain? Isn't the point of an atomic update that it doesn't matter 
whether the other CPU has seen the value yet? Or are we talking about 
different values?


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


Re: [fpc-pascal] Lazarus settings and roaming profiles in Windows

2009-07-16 Thread Micha Nelissen

Florian Klaempfl wrote:

Roaming profiles using auto copy/delete are not the best choice for that.


For me it works fine for years ;)


Then you must be the only one since everybody I know despises it. We use 
multiple times login sometimes and then the settings are always messed 
up. If the profile locally exists already it sometimes isn't updated but 
afterwards it does overwrite the server's! The only solution is not 
logging off, wow great engineering indeed!


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


Re: [fpc-pascal] Lazarus settings and roaming profiles in Windows

2009-07-16 Thread Micha Nelissen

Florian Klaempfl wrote:

Then you must be the only one since everybody I know despises it. We use
multiple times login sometimes and then the settings are always messed
up. 


Well, this causes a headache with fully networked home drives as well ;)


If configuration files are per application it's much less of a problem. 
And applications can implement a configuration file lock much easier if 
they want to detect multiple activity. It reduces the per-login problem 
to a per-application-start problem; which is much better already.



If the profile locally exists already it sometimes isn't updated but
afterwards it does overwrite the server's!


Hmm, I know only of this if the a machine starts up with a messed up
clock because e.g. of an empty mainboard battery.


Or a server that is not responding quickly enough or so ... Perhaps a 1k 
euro server isn't sufficient after all ;-P


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


Re: [fpc-pascal] Lazarus settings and roaming profiles in Windows

2009-07-16 Thread Micha Nelissen

Florian Klaempfl wrote:

My conclusion:
I agree with Jonas, you can use network shares for development machines..


Consider 10-50 people working and accessing a server this way :) Using
roaming profiles and local source checkouts, this can be handled easily
by a 1k Eur server which even doesn't requires high


We have like 150+ people accessing all project documents, designs, code 
on a single file server. Server runs Linux with Samba AFAIK. Some of 
Linux targeted development checkouts are on another Linux development 
server accessed by a small group of people though, but it still proves 
the occasional home drive configuration file on a networked drive 
could be handled easily.


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


Re: [fpc-pascal] Lazarus settings and roaming profiles in Windows

2009-07-16 Thread Micha Nelissen

Vincent Snijders wrote:
I am not sure having a 100 MB lazarus *roaming* profile by default would 
be a good idea.


Probably the choice to compile lazarus itself to its configuration 
directory is not such a good idea ;-).


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


Re: [fpc-pascal] Lazarus settings and roaming profiles in Windows

2009-07-16 Thread Micha Nelissen

Florian Klaempfl wrote:

Micha Nelissen schrieb:

Florian Klaempfl wrote:
And applications can implement a configuration file lock much easier if
they want to detect multiple activity.


Do they :)? Does lazarus?


IIRC OpenOffice (3.0) does detect it already and warn me.


Well, then you need two 1k Euro servers. Anyways, a server not
responding quickly enough to serve a profile will be a real pain serving
a fully networked home/profile dir :)


That's the difference between a Windows server and one with a proper OS 
:-P. Or it's the administration of it. Or ... don't know. I know there 
are little problems with the file server I described in another post but 
many problems with corrupted profiles.


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


Re: [fpc-pascal] DirectFB for FPC beta tarball

2009-05-31 Thread Micha Nelissen

Michael Van Canneyt wrote:

The known major bugs of previous SVN versions have beeen fixed. We're
now starting to actually use DFB in our project. Reports (bugs or
anything) are thus highly appreciated.


Do you think it would be feasible to use this as a basis for a Lazarus 
widgetset ?

Lazarus without X would be quite cool.


I already have it running, using gtk2 :P

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


Re: [fpc-pascal] Class procedure assigned to object's event

2009-05-27 Thread Micha Nelissen

Antonio Sanguigni wrote:

For the second one:
main.pas(261,19) Error: Incompatible types: got class method type of
procedure(TObject, Boolean,const AnsiString) of object;Register
expected procedure variable type of procedure(TObject, Boolean,const
AnsiString) of object;Register


Remove the 'class' keyword from your function. A class method is a 
different beast (with different signature) from a regular method.


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


Re: [fpc-pascal] re: thanks for major signal handling fix

2009-05-20 Thread Micha Nelissen

Jonas Maebe wrote:

On 20 May 2009, at 22:01, Jonas Maebe wrote:
The problem you have right now is that the program and each of your 
libraries each contain their own copy of the exception class, and 
therefore do not recognise (Pascal) exceptions raised by any of the 
others.


Well, that and the fact that moreover each library/program contains its 
own exception stack rather than a single shared one (although that could 


Aren't both problems solved by using the same RTL binary code (in 
library form)?


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


Re: [fpc-pascal] heap size growing

2009-05-11 Thread Micha Nelissen

Luca Olivetti wrote:
Seeing this thread, I used GetFPCHeapStatus and, effectively, 
CurrHeapSize is growing but CurrHeapUsed isn't, so apparently 
TJpegImage.LoadFromStream (that's what I'm using) causes heap 
fragmentation.


Can you reproduce this in a small test program? Perhaps there is a 
simple fix for TJpegImage's allocation pattern.


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


Re: [fpc-pascal] Dependencies of FPC_HAS_FEATURE_XXX

2009-05-05 Thread Micha Nelissen

Sven Barth wrote:
Hmm... if this speeds things up: shall I enclose the problematic places 
with ifdefs and send a patch along with the bug report?


Got response yet? If not then yes, please send patches per topic to 
ifdef the optional code away.


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


Re: [fpc-pascal] REQ: official FPC's FCGI framework

2009-02-12 Thread Micha Nelissen

Bee wrote:

Hi all,

FPC has pretty usable support for web based development. Currently FPC 
supports it through CGI and Apache module. IMO, there's one more support 
that should be added officially: FastCGI. The initial work has been done 


lNet has fastcgi support. Maybe it's interesting for you. It can connect 
to some server or spawn some itself. Implemented in lib/lfastcgi.pp.


It's used by lwebserver to provide a fastcgi connection to PHP backend. 
In lib/lwebserver.pp.


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


Re: [fpc-pascal] Using FPC MM in a C program

2009-01-06 Thread Micha Nelissen

leledumbo wrote:

Since it's possible to use libc's MM via cmem unit, would the opposite be
possible?


I have a crtl.pas which defines a few functions (malloc, calloc, free, 
memmove, memcpy) to help in using libraries written in C with fpc 
programs without needing external dependencies (msvcrt.dll on windows, 
for some reason that did not work for me).


However, it's a all-or-nothing situation. A program uses either this 
crtl unit, or it links a C library like msvcrt.dll or something similar; 
using both is asking for trouble.


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


Re: [fpc-pascal] fstat usage

2008-12-06 Thread Micha Nelissen

Francisco Reyes wrote:
Trying the fstat function and don't seem to be getting the right values 
for ctime, mtime and atime.


What OS and CPU ?

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


Re: [fpc-pascal] Lazarus: graphical interface using code only?

2008-12-04 Thread Micha Nelissen

Graeme Geldenhuys wrote:

I'm curious... How do you manage to create a GUI or use a GUI program
if you are blind? Sorry, I don't know how screen readers work?



Try http://en.wikipedia.org/wiki/Screen_reader for a start?

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


Re: [fpc-pascal] Make FPC closer to hardware

2008-11-15 Thread Micha Nelissen

leledumbo wrote:

Would it be a good idea to lower down (again) FPC so that it can be used
easier for systems programming?


example?

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


Re: [fpc-pascal] Speed difference between intel/ppc on intel Mac

2008-09-07 Thread Micha Nelissen

Jonas Maebe wrote:
You can use -vd to have the compiler print out all compiler options it 
interprets (both from configuration files and from the command line). In 
general, to get the best code for an Intel Core family processor, use 
something like


-O3ppentium4 -Cppentium4 -Cfsse2

i doubt it'll speed up your program by a factor of 2 in any case though.


Hmm there are weak spots in FPC. E.g. fannkuch in the shootout:

http://shootout.alioth.debian.org/u32/benchmark.php?test=fannkuchlang=fpascalid=5

FPC is 2.1 times slower than gcc here. Maybe this program is like it?

It's still quite unlikely that an assembly emulator would optimize it 
run so much better than the original compiler could.


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


Re: [fpc-pascal] Translate C to Pascal

2008-07-30 Thread Micha Nelissen
Mattias Gärtner wrote:
 How to translate this:
 
 struct a;

Isn't this a forward declaration? So sometime later it needs to declare
'struct a { ... };' ?

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


Re: [fpc-pascal] Enabling FPC_HAS_FEATURE_CONSOLEIO

2008-07-29 Thread Micha Nelissen
leledumbo wrote:
 This is very inconvenient. Moreover, assertions needs it. My first attempt,
 is to comment out {$undef FPC_HAS_FEATURE_CONSOLEIO} in my system.pas. But
 then, FPC argues about Unknown compilerproc fpc_write_text_shortstr. I
 found it in text.inc, but it's only included if FPC_HAS_FEATURE_TEXTIO is
 defined. Knowing that I don't yet have any file system driver, I guess it's
 impossible to reach my goal by defining it.
 What's the correct way?

Can you undefine FPC_HAS_FEATURE_TEXTIO as well?

In the end, you have nothing left :-). Or is this the point?

What's the goal?

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


Re: [fpc-pascal] Generics

2008-03-31 Thread Micha Nelissen
Damien Gerard wrote:
 Oki I understand.
 I tried to use an Interface but I had a nice Segementation fault :)

I'm not sure how FParent.ItemByDefault is going to work?

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


Re: [fpc-pascal] Generics

2008-03-31 Thread Micha Nelissen
Damien Gerard wrote:
 I tried to use an Interface but I had a nice Segementation fault :)

 Should I report it as a bug in the mantis ?

 foo.pas
 
 Actually there is the same error with an intermediate class :(

Segmentation faults in the compiler itself can/should always be
reported. Thanks.

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


Re: [fpc-pascal] AnsiDequotedStr not return empty for

2008-03-02 Thread Micha Nelissen
Peter Vreman wrote:
 In case always check Delphi documentation to see wether the behaviour
 you see is intentional.
 
 In case of  it is also ambigious what you want. Because  in the
 middle of the string is translated to a single . So you might also
 expect that it returns a single  instead of an empty string.

Wouldn't it be reasonable to expect the rules are similar to Pascal
itself, with  being a single quote, and '' an empty string ?

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


Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread Micha Nelissen
ik wrote:
 Actually the assembler is not that hard to understand :)
 My point is, that I don't like the idea of 7 or 20 or 100 amount of
 parameters to give answer to every need. I think we should find a
 better way to implement it, like var args in C or open array in
 pascal...

The linux kernel interface is always using registers, and since there
are a limited amount of registers, there is a max. number of arguments.
IIRC the maximum is 6, i386 limited: eax, ebx, ecx, edx, esi, edi, ebp.

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


Re: [fpc-pascal] syscalls and fpc

2008-02-14 Thread Micha Nelissen
ik wrote:
 Hi,
 
 I found that the Do_Syscalls are written in assembly and have only
 limited number of parameters (up to 6). Is there a way to write it
 using array of TSysParam instead of having 7 different functions ?

Maybe but it wouldn't make the assembler easier to read :-).

 Another question is, is there a way to use it witthout writing
 assembly, like using it in libc or some other way ?

Calling them doesn't require assembler, or what do you mean? You can try
to extend the compiler to support inlining of assembly functions ;-).

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


Re: [fpc-pascal] static class methods

2008-02-06 Thread Micha Nelissen
Jonathan Benedicto wrote:
 Jonas Maebe wrote:
 I'm not sure how Delphi could handle this without passing the VMT as 
 invisible parameter (and from a cursory look at the code generated by 
 Kylix, it does appear to pass the VMT).
 
 Delphi doesn't allow static class methods to be virtual.

What are static class methods?

Plain class methods are allowed to be virtual, surely.

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


Re: [fpc-pascal] Problems with generics

2007-12-30 Thread Micha Nelissen
bartek wrote:
 I am not quite sure whether my synatx is correct. IMHO explictly defining the 
 type feels more pascalish. Having more time at hand i have written a much 
 shorter example code which shows in what way such a type should be defined.

I think that it is the same type in a different namespace. Like using
unit.type syntax.

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


Re: [fpc-pascal] Problems with generics

2007-12-29 Thread Micha Nelissen
bartek wrote:
 function HashOf(const Key: ShortString): DWord;
 
 function BucketNodeOf(const Hash: DWord): TBucket.PNode;
 DataContainers.pp(104,66) Fatal: Syntax error, ; expected but . found

I'd say this is a bug, and your syntax is correct. Update the existing
bug report, perhaps?

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


Re: [fpc-pascal] CSV via PCRE

2007-11-10 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 OK, while we are busy with show-and-tell... Then have a look at my
 token library implementation.

You've implemented some kind of 'cut'. But grep is also very useful (and
more often used in a shell, at least by me).

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


Re: [fpc-pascal] fpnanosleep (again)

2007-11-08 Thread Micha Nelissen
John Coppens wrote:
 Just an extra note: delay(1) seems to delay 4.1 ms, so it _does_ seem to
 be possible to do less than 8.3?

You wait till the next tick that is after the requested delay. So it's
never a HZ multiple or so.

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


Re: [fpc-pascal] Re: Why this evaluates on if wrong ?

2007-10-29 Thread Micha Nelissen
Stephen Dickason wrote:
 In binary that is 0001 + 0.0110011001100 - 0.0110011001100 because
 we hit recurring decimals a lot more in binary than decimal.  I wonder why we
 don't have a standard format (maybe we do?) that factors in the remainder as
 part of the number also?

It's possible to create a type that stores the numerator and
denominator, but then you would need to simplify to extract common
factors on every calculation, otherwise it would quickly run out of
range (Integer or whatever you choose). Extracting common factors takes
exponential time, so it's quite slow. The range would be quite limited
as well, it's as wide as the numerator.

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


Re: [fpc-pascal] FPC and JAVA

2007-10-27 Thread Micha Nelissen
Jonas Maebe wrote:
 go for any Lazarus/Delphi app ported to the Mac, for that matter (unless
 Lazarus can do automatic button layouting, and if the current layout
 mismatch is simply due to some wrong default setting for the Carbon
 target).

Actually, we have a TButtonPanel exactly for this purpose. It's just
that (A) not all dialogs use it yet (B) it doesn't get the right default
setting from Carbon yet.

Perhaps not very easy fix, but the infrastructure exists.

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


Re: [fpc-pascal] random Disk Full exceptions

2007-10-20 Thread Micha Nelissen
Marc Santhoff wrote:
 writeln(stderr, '-- hit found: '+inttostr(fcnt) + ' - ' +
 inttostr(PInteger(longint(adr)-longint(fx))^) + ' - ' +
 floattostr(PSingle(adr)^));
 
 Very nasty thing:
 
 The output channel is temporarily blocked and gives back EAGAIN.

This means the output channel is opened non-blocking. Is that
intentional or a bug ?

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


Re: [fpc-pascal] Audio development and /dev/dsp

2007-09-28 Thread Micha Nelissen
ik wrote:
 lsof does not give me any open access to the device.
 
 I'm using Kubunto 7.04 amd64.

Buggy audio driver ? Does it work properly when using ALSA, aplay etc. ?

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


Re: [fpc-pascal] Problem with interfaces

2007-08-20 Thread Micha Nelissen
Joao Morais wrote:
 The first call that I make to DefaultObj from *another* unit recreate
 the object, because, I don't know why, the _holder var points again to nil.

Try to use a data watchpoint to watch when the variable is being
changed. Hopefully that will point to the root cause. Did you also try
printing the address of the variable (I assume global variables aren't
moving, but who knows?)

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


Re: [fpc-pascal] PowerPC crosscompiler on i386 Mac OS X looks for, wrong assembler and linker

2007-07-03 Thread Micha Nelissen
Adriaan van Os wrote:
 build and then the Makefile takes cares of the rest. If a configuration
 is not supported or if there is a problem, you get a clear error message.

You *must* be joking, right ? Usually it involves digging through a
messy config.log, where you sometimes can't really find the reason (just
one of those mysterious test compiles failed) and then have to decrypt
an enormously complex configure script that will give you nightmares for
years.

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


Re: [fpc-pascal] Starting new threads

2007-06-21 Thread Micha Nelissen
Tom York wrote:
 By the way is NNTP forbidden?  I would much rather use NNTP over a
 mailing list.

IIRC, these lists are mirrored in gmane, so perhaps you can use gmane ?
Have the mailing list subscription, but configure it to not send email.

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


Re: [fpc-pascal] Re: put data to stdout (fpc vs. gcc)

2007-06-15 Thread Micha Nelissen
Michael Van Canneyt wrote:
 You would have to test the speed of each of them separately to be able
 to say anything definitive. Like it is now, there is no indication
 that it is the float-to-text routine which is to blame.

So use sprintf in C, and the equivalent in fpc; and rerun the test.

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


Re: [fpc-pascal] PASCAL programming for Novice

2007-06-10 Thread Micha Nelissen
Francisco Reyes wrote:
 Pete Cervasio writes:
 
 Contents of $HOME/.vim/filetype.vim:
 
 Thanks. Found that it also works with .pas
 Changed the programs to that since that is one of the extensiosn the
 compiler also checks for. ___

If you google for vim delphi syntax you can easily find a delphi
syntax highlight file for vim. You can then connect .pas/.pp/.inc to
that one in a similar way.

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


Re: [fpc-pascal] Linux Linking Error solved

2007-06-04 Thread Micha Nelissen
Rick Seiden wrote:
 I emailed yesterday about an error when compiling in Linux.  The error I
 received was Error while linking.
 
 I figured out that the permissions on /usr/bin/ld is set to root, and
 I'm logged in as a different user.  When I sudo fp to start Free Pascal,
 I am able to compile without a problem.

What are the permissions exactly ? You should be able to execute ld as
normal user at least.

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


Re: [fpc-pascal] TThread.Suspend under Linux

2007-06-02 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 I got most of my Thread Manager demo written. While trying out a few
 features I noticed that every time as Suspend a thread, my app is
 killed.  Running it through gdb I get the following output.

I don't see it being killed from your output, or am I missing something ?

man 7 signal:

   SIGSTOP   17,19,23StopStop process

It stops ... and that's what you asked it to do.

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


Re: [fpc-pascal] problem with threads and backgrounding, fpc 2.1.3 arm native

2007-04-05 Thread Micha Nelissen
Luca Olivetti wrote:
 This is another test program that shows my problem with fork: as soon as
 I start the thread, the main program stops working (the thread *is*
 running, you can put a writeln in its loop to show it). Note that in
 this short example I don't close stdin,stdout,stderr, I don't block
 signals but it doesn't matter (I did it all and the result is the same).
 The same happens with the native compiler and the cross compiler.

I can reproduce this,

(gdb) bt
#0  0x401afd80 in __pthread_sigsuspend () from /lib/libpthread.so.0
#1  0x401aea7c in __pthread_wait_for_restart_signal () from
/lib/libpthread.so.0
#2  0x401afc40 in pthread_create@@GLIBC_2.1 () from /lib/libpthread.so.0

Seems like it's waiting for some signal to be passed to the process, but
it doesn't happen.

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


Re: [fpc-pascal] problem with threads and backgrounding, fpc 2.1.3 arm native

2007-04-03 Thread Micha Nelissen
Luca Olivetti wrote:
 synchronize and critical sections, c library with callbacks to pascal,
 etc.) is working flawlessly in the foreground, but it segfaults if I try
 to background it (or try to use fpFork), and this is a problem since I
 want to write a daemon (i can use screen though if that isn't possible).

Backgrounding is not the same as forking. Backgrounding is using the
shell's job control (and sends some signal(s) to the process), forking
is what the program does itself. Can you list an example that crashes
with fpfork, and give an strace with it ?

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


Re: [fpc-pascal] problem with threads and backgrounding, fpc 2.1.3 arm native

2007-04-03 Thread Micha Nelissen
Luca Olivetti wrote:
 [EMAIL PROTECTED]:~$ uname -a
 Linux lspro 2.6.12.6-arm1 #77 Tue Dec 5 22:23:46 CST 2006 armv5tejl
 GNU/Linux

I've gotten access to an arm-linux system, where I cannot reproduce the
crash. That system is using 2.6.18 kernel. Can you try a newer kernel as
well ?

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


Re: [fpc-pascal] problem with threads and backgrounding, fpc 2.1.3 arm native

2007-04-03 Thread Micha Nelissen
Luca Olivetti wrote:
 Backgrounding is not the same as forking. 
 
 I (vaguely) understand the difference, but I think (probably mistakenly)
 that the problems are related.

I'm not saying the problems are not related; they may be. It's just
important to know there is a difference.

 the example daemon.pp, for example, crashes right away, strace doesn't
 seem very useful to me:
 
 [EMAIL PROTECTED]:~/fork$ strace -f ./daemon
 execve(./daemon, [./daemon], [/* 22 vars */]) = 0
 syscall: unknown syscall trap 0x8000

There is a patch on the internet for strace, to skip this error. Google
for strace syscall trap.

 A simple program that just repeatedly sleeps after the fork, dies as
 soon as it receives any signal (e.h HUP, USR1).

Ok, this will be the same problem as with backgrounding in the shell.

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


Re: [fpc-pascal] Wikies

2007-02-24 Thread Micha Nelissen
Florian Klaempfl wrote:
 I am finished. It can be improved, but I'm out of ideas =)

 
 I'am not ;) The wiki is definitively not the FPC documentation.

I've changed it to 'documentation for developers'. Covers the content
better ?

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


Re: [fpc-pascal] fpc have problem with dynarray in ARM

2007-02-23 Thread Micha Nelissen
Jose Pascual wrote:
 Could it be resolved in 2.1.1?
 
 I'm compiling ppcrossarm 2.1.1 in order to be it's corrected in this
 version,

Open a (descriptive) bug report (in case there is none about this issue
yet) and attach a test case.

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


Re: [fpc-pascal] Wikies

2007-02-11 Thread Micha Nelissen
Felipe Monteiro de Carvalho wrote:
 Hello,
 
 Are the wikis being merged? Is it my impression, or is there a main
 page for compiler things missing?

The pages are there.

 When I go to fpc page and click on Wiki it shows lazarus-ccr wiki, and
 I can´t find what was the old free pascal main wiki page, and thus
 can´t find the compiler related articles.

Correct, somebody needs to rewrite the Main_Page to mention both
projects, content, and links.

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


Re: [fpc-pascal] GetEpochTime not found

2006-12-09 Thread Micha Nelissen
Marc Santhoff wrote:
 Hi,
 
 I've got some funny problem here. The program compiled well with fpc up
 to version 1.9.4. I haven't touched it for a while and now it fails with
 fpc 2.0.2.
 
 CommonTypes.pp(207,21) Error: Identifier not found GetEpochTime

http://www.freepascal.org/docs-html/rtl/oldlinux/getepochtime.html

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


Re: [fpc-pascal] GetEpochTime not found

2006-12-09 Thread Micha Nelissen
Marco van de Voort wrote:
 fpc 2.0.2.

 CommonTypes.pp(207,21) Error: Identifier not found GetEpochTime
 http://www.freepascal.org/docs-html/rtl/oldlinux/getepochtime.html
 
 He uses FreeBSD.

Ah right, this was apparent from the unit path.

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


Re: [fpc-pascal] Implementing a true Singleton - Can we decrease the visibility of a method?

2006-12-08 Thread Micha Nelissen
Daniël Mantione wrote:
 
 Op Fri, 8 Dec 2006, schreef Micha Nelissen:
 
 Btw, I think singletons are nonsense too. Why is a global variable evil,
 and a singleton class not ?
 
 Well, a singleton can hide and/or protect its private data.

Not more than a global variable of the same class type ?

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


Re: [fpc-pascal] even linus torvalds prefer pascal over c

2006-12-02 Thread Micha Nelissen
Daniël Mantione wrote:
 (1) I'm using the in English not so common informatics instead of 
 computer science, because Dijkstra greatly disliked the term).

How about computing science, or is that too Eindhovens ? ;-)

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


Re: [fpc-pascal] even linus torvalds prefer pascal over c

2006-12-02 Thread Micha Nelissen
Daniël Mantione wrote:
 
 Op Sat, 2 Dec 2006, schreef Micha Nelissen:
 
 Daniël Mantione wrote:
 (1) I'm using the in English not so common informatics instead of 
 computer science, because Dijkstra greatly disliked the term).
 How about computing science, or is that too Eindhovens ? ;-)
 
 Dijkstra disliked the term because informaticians/computer scientists 
 don't study how a computer works. Informatics is no more about computers 

Indeed, that's why I said comput*ing*, i.e. the working with
computers, but not the science of the computers themselves.

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


Re: [fpc-pascal] even linus torvalds prefer pascal over c

2006-12-02 Thread Micha Nelissen
John Coppens wrote:
 Mind, I don't want to remove gotos. I'm all for free choice. But I'm
 still very much a proponent to discourage its use for fledgling
 programmers.

Well, in fpc, you have to use a compiler option to be able to use them.
A good trade-off IMHO.

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


Re: [fpc-pascal] Compiling problems

2006-11-03 Thread Micha Nelissen
Jonas Maebe wrote:
 
 If it's later fixed people might think, it's still not fixed.
 
 That should only be changed after it's fixed I think, because if you
 write 5091 to 5114 and it's still not fixed in 5115, people may also
 be confused :)

It just says those revisions are unusable, not whether the others are or
are not.

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


Re: [fpc-pascal] Progress Bar in different widget sets

2006-11-02 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 GTK's progress bar has a feature where the progress bar moves left and
 right repeatedly, instead of the normal from Min to Max.
 
 What do you call that feature and what do you actually use it for?

It's used when the Max isn't known.

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


Re: [fpc-pascal] Linux Install: Is it me or the documentation? ;-)

2006-11-01 Thread Micha Nelissen
Lev Lafayette wrote:
 and like the TurboPascal critter from all those years ago, verdade? If

Yes.

 this is so, where does it live in the filesystem? Not that coding in
 vi(m)/emacs/pico etc is a problem as such...

/usr/bin/fp ? It's named 'fp' in any case.

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


Re: [fpc-pascal] ROPS and latest FPC compiler (svn)

2006-10-31 Thread Micha Nelissen
Alexandre Leclerc wrote:
 That are 1300+ revisions. Try doing a binary search. That will take 11
 tests.
 
 How do a do such a thing?

You know binary search right ? Use svn diff -r X, with X varying between
working and newest revision, until you found X-1 working, X not.

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


Re: [fpc-pascal] typed constants...

2006-10-23 Thread Micha Nelissen
Michael Van Canneyt wrote:
 Initialized constants are deprecated, and should be replaced by initialized
 variables, as in Delphi:

They are? Why?

They have the practical advantage of being able to share them with other
instances of this process. At least, if compiler+linker cooperate to put
them in the right section.

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


Re: [fpc-pascal] RE: Get Local IP using glib (eth0,eth1)

2006-10-06 Thread Micha Nelissen
Jeff Pohlmeyer wrote:
  function to read the local IP eth0/eth1 using glibc library.
 
 This one is a little cleaner...
 
 program ip_addr;
 {$MODE OBJFPC}
 
 uses libc;

It doesn't seem like you're using libc specific functions ? You can also
write a fpc 'native' one using fpsocket and fpioctl in baseunix/unix, I
think.

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


Re: [fpc-pascal] Threads executing in sequence instead of parallel

2006-09-30 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 Ah, finally some explanation that makes sence!  Thanks Micha, your
 modified demo does in fact make Linux switch between threads.  I also
 tried the Sleep(0) you mentiond in the Sort Demo.  Sleep() didn't do
 the trick, but using the BurnCPU() method from Demo1 did.

Ok, maybe Sleep(0) in sysutils has to use the sched_yield syscall for
linux. This may be a feature request to be reported in bug tracker IMHO.

 Where can I read more about the timeslices to threads under Linux. It
 obviously works vastly different to Windows (and FreeBSD as someone
 pointed out).  This sounds like an interesting topic and something
 work understanding.  After all, it gave me enough headaches and a
 false positive - thinking it is a bug.

http://kerneltrap.org/node/517/print is an interview with one of the
authors, Ingo Molnar. Search for 'timeslice length' if you don't want to
read it all :-).

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


Re: [fpc-pascal] Threads executing in sequence instead of parallel

2006-09-30 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 pointed out).  This sounds like an interesting topic and something
 work understanding.  After all, it gave me enough headaches and a
 false positive - thinking it is a bug.

Btw, here is a quote from the interview, default length seems to be
150ms: (it also explains the usefulness of longer timeslices: caches)

quote
another property of SCHED_BATCH scheduling is the use of much longer
timeslices. Eg. right now it's 3 seconds for a default priority
SCHED_BATCH task - while normal tasks have 150 msec timeslices. For
things like numeric calculations it's good to have as long timeslices as
possible, to minimize the effect of cache trashing. Eg. on a
sufficiently powerful CPU with a 2 MB L2 cache, the 'population time' of
the cache can be as high as 10 milliseconds. So if there are two numeric
calculation tasks that both fully utilize the L2 cache (in nonobvious
patterns), and which context-switch every 150 milliseconds, then they
will waste 10 milliseconds on cache-rebuilding in the first 6% of their
timeslice. This shows up as a direct 6% slowdown of the numeric
calculation jobs. Now, if SCHED_BATCH is used, and each task has a 3000
milliseconds timeslice, then the cache-rebuild overhead can be at most
0.3% - a far more acceptable number.
/quote

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


Re: [fpc-pascal] Threads executing in sequence instead of parallel

2006-09-30 Thread Micha Nelissen
Marco van de Voort wrote:
 Ok, maybe Sleep(0) in sysutils has to use the sched_yield syscall for
 linux. This may be a feature request to be reported in bug tracker IMHO.
 
 Ugly. Better define a procedure TryYieldTimeSlice() or so. No need to follow
 Windowisms with archaic reasons.

Yes agree, thought of this just after sending the email. The
implementation might/will call Sleep(0) on the windows platform.

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


Re: [fpc-pascal] Threads executing in sequence instead of parallel

2006-09-29 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 We have a problem!!!
 
 The test project /fcl/tests/threads.pp as well as a Sort Demo (Bubble,
 Section and Quick Sort) all execute the threads in sequence, waiting
 for the previous thread to complete, before the next one executes.
 Kind of defeats the point of using threads.

There is no bug. The time slice management is simply different. Try
attached demo (it's your demo modified). You will notice that output
will be mixed.

Linux simply gives longer timeslices to threads (for efficiency reasons).

Micha
program demo1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}
  Classes, SysUtils;
  
type
  // counts up till 1k
  TIncrementer = class(TThread)
  protected
procedure Execute; override;
  end;
  
  // counts down from 1k
  TDecrementer = class(TThread)
  protected
procedure Execute; override;
  end;
  
  
  TRunThreads = class(TObject)
procedure ThreadTerminated(Sender: TObject);
  private
t1, t2: TThread;
FThreadCount: integer;
  public
constructor Create;
procedure RunNow;
  end;


{ TRunThreads }

procedure TRunThreads.ThreadTerminated(Sender: TObject);
begin
  Dec(FThreadCount);
end;


constructor TRunThreads.Create;
begin
  FThreadCount := 2;
  
  t1 := TIncrementer.Create(True);
  t1.OnTerminate := @ThreadTerminated;
  t1.Priority := tpLower;
  t1.FreeOnTerminate := True;
  
  t2 := TDecrementer.Create(True);
  t2.OnTerminate := @ThreadTerminated;
  t2.Priority := tpLower;
  t2.FreeOnTerminate := True;
end;


procedure TRunThreads.RunNow;
begin
  writeln('RunNow');
  t1.Resume;
  t2.Resume;
  repeat
sleep(100);
  until FThreadCount = 0;
  WriteLn('All threads completed!');
end;

{ TIncrementer }

procedure BurnCPU(Multiplier: integer);
var
  i, k: integer;
begin
  k := 13;
  for i := 0 to Multiplier*50 do
k := k div 5 * 6;
end;

procedure TIncrementer.Execute;
var
  i: integer;
begin
  for i := 0 to 1000 do
  begin
Writeln(Classname + ': ' + IntToStr(i));
BurnCPU(3);
  end;
end;

{ TDecrementer }

procedure TDecrementer.Execute;
var
  i: integer;
begin
  for i := 1000 downto 0 do
  begin
Writeln(Classname + ': ' + IntToStr(i));
BurnCPU(4);
  end;
end;


var
  lRunThreads: TRunThreads;

begin
  lRunThreads := TRunThreads.Create;
  lRunThreads.RunNow;
  writeln('Done...');
end.

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

Re: [fpc-pascal] Threads executing in sequence instead of parallel

2006-09-29 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 The Sort Demo, which is a port of the Threads demo included with
 Delphi 7, shows this clearly.  I can archive and post the source, but

Try inserting some Sleep(0) to force the kernel to switch to another
thread ? In real worker threads you wouldn't do this of course, but here
just for the visual effect.

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


Re: [fpc-pascal] Please Help - Need ONE HINT - Trying to get

2006-09-16 Thread Micha Nelissen
Jason P Sage wrote:
 I was trying to avoid sysutils sleep(0) in linux platform due to the size of
 sysutils. The fact I don't know how to make dynamic linking work on linux
 yet - (use shared libs versus static) makes my exe's bigger than I would
 like. In most of my applications, size isn't an issue - but in one in
 particular - it is everything. Using shared linking in linux, which I think

It's better to help us increase effectiveness of smart linking ;-).

 timeslice, which was my impression. I THINK that sleep refers to releasing
 or yielding your entire application to other tasks the operating system is
 handling. Which means its use should be minimal, and strategic - like when
 you application true should release the CPU a bit... or is truly idle.

I think Sleep is per-thread, not sure though. Anyway, you should never
need Sleep; instead you should use mutexes or similar techniques to
sleep until you need to wake up for calculation or whatever.

 You see I have been playing with TThread - and I noticed that the most
 currently launched thread is the one who stays running - and everything else
 in my app stops until it finishes. This leads me to believe I am responsible

How did you arrive at this conclusion ? It should not be so, the OS will
do the scheduling for you, all threads will get their timeslice.

 or some sort of mechanism. I believe TThread.Syncronize and possibly TThread
 Critical Section are going to be my next area of experimentation.

Critical sections are a sort of mutex indeed, about which I was talking
above.

 Along this lines I have changed the entire main loop architecture of my
 bigger THREADING application - to work similar to how Lazarus makes its
 executables or how a windows program works in win32 - I've built a messaging
 system - that is a COMMON construct throughout all my classes, so that they
 can ALL communicate in a context-less way to the main program - allowing the
 main program to respond by suspending, resuming, terminating... etc any/all
 of the working threads as it deems correct.

Sounds like a good architecture.

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


Re: [fpc-pascal] Please Help - Need ONE HINT - Trying to get something like sched_yield with free pascal in linux

2006-09-15 Thread Micha Nelissen
Jason Sage wrote:
 Hi all – and thanks to who ever can respond in advance.
 
  
 
 I have a Server Like App – I need the equivalent of sched_yield

Tried sleep(0); yet ?

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


Re: [fpc-pascal] flag or exception?

2006-09-01 Thread Micha Nelissen
Bisma Jayadi wrote:
 Hi all...
 
 I've always been confused about this subject... flag or exception for
 error handling? Can anyone share knowledges and ideas about when and
 where and why a (pascal) developer should chose one over another?

Depends on taste, and they have both advantages and disadvantages.

For example, it's easy to see when flag-using code is coded correctly
(are the return values checked and handled?), while it's hard for
exception-using code. Exceptions are usually slower as well. Exceptions
are also not compatible to other languages, usually. OTOH, using
exceptions is lazier/easier. If an error should never occur, then using
exceptions will have more readable code, as not every function calling
this must handle the possible error flag.

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


Re: [fpc-pascal] DLL and Shared Libs in FPC

2006-08-07 Thread Micha Nelissen
Jason P Sage wrote:
 I have read some things here and there, but can anyone simply tell me if its
 now possible to write DLL's and Linux Shared Libraries with FPC now?
 
 The last time I approached this topic, it was unsupported, and was still not
 really something that was ready for prime time.

Do you mean import/export of classes, etc. as well ? Procedural 'C-like'
libraries have worked for a long time, as already stated.

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


Re: [fpc-pascal] Common OpenMP syntax?

2006-07-26 Thread Micha Nelissen
Vinzent Hoefler wrote:
 Well, I just added some stuff there, yesterday. It's far from being 
 complete yet (it just covers a basic parallel construct), nor is it 
 really thought through yet, but well, it might be a start; something to 
 begin with.
 
 Any suggestions are welcome, of course.

Does parallel mean all the statements in the block can be executed in
parallel, or that multiple copies of the block of statements can be
started in parallel ?

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


Re: [fpc-pascal] Common OpenMP syntax?

2006-07-26 Thread Micha Nelissen
Vinzent Hoefler wrote:
 On Wednesday 26 July 2006 08:17, Micha Nelissen wrote:
 Does parallel mean all the statements in the block can be executed in
 parallel, or that multiple copies of the block of statements can be
 started in parallel ?
 
 The latter.

Strange. How many copies ?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Common OpenMP syntax?

2006-07-26 Thread Micha Nelissen
Vinzent Hoefler wrote:
 On Wednesday 26 July 2006 09:07, Micha Nelissen wrote:
 How many copies ?
 
 Omp.Get_Num_Threads(), AFAICS.

Ah the number of threads is determined by the RTL, and any parallel
block must be written flexible, so that it can work for any given number
of threads ?

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


Re: [fpc-pascal] Common OpenMP syntax?

2006-07-26 Thread Micha Nelissen
Michael Van Canneyt wrote:
 The latter.
 
 Which is why I think that it's better to have them as local functions,
 instead of having to introduce a lot of new functions.

There is no real reason to restrict 'parallel' to local functions, is
there ?

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


Re: [fpc-pascal] CRT (Console Unit) Problems with Fedora 5

2006-07-26 Thread Micha Nelissen
Jason P Sage wrote:
 A good example is that FreeVision and the FPC IDE do not work on my Linux
 either.

Elaborate on do not work please ?

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


Re: [fpc-pascal] Semaphore problems

2006-07-25 Thread Micha Nelissen
Vinzent Höfler wrote:
 because we assume it's non-recursive, that was the whole point. So we
 should *first* check the count and then may lock/unlock the mutex
 accordingly.

Note that these two actions must be atomic. This is what the TryLock is for.

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


Re: [fpc-pascal] Semaphore problems

2006-07-25 Thread Micha Nelissen
Vinzent Hoefler wrote:
 On Tuesday 25 July 2006 06:40, Micha Nelissen wrote:
 Vinzent Höfler wrote:
 because we assume it's non-recursive, that was the whole point. So
 we should *first* check the count and then may lock/unlock the
 mutex accordingly.
 Note that these two actions must be atomic.
 
 Oh, really?

Ehm, no. Got confused a bit :-). Reread the thread, and think your
latest implementation as posted here is ok.

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


Re: [fpc-pascal] Semaphore problems

2006-07-25 Thread Micha Nelissen
Vinzent Hoefler wrote:
 Ehm, no.
 
 Ehm, yes. I was being ironic here. Of course, the action of checking the 
 counter and locking/unlocking the associated mutex must be atomic.

But here they are not associated, they're protected by owner_lock, as
you said.

 Got confused a bit :-). Reread the thread, and think your
 latest implementation as posted here is ok.
 
 No, it's not. As usually I should sit down with pencil, paper, a cup of 

I mean the idea for the recursive locking is ok. I was confused by the
whole 'owning' part. Locks don't own threads in my mind, so I assumed
you got that right. Alas, no :-). Also problematic is posting only
partly updates to a function. Then we forget the other, also critical part.

function Recursive_Mutex.Lock:...;
begin
   // Owned by current thread?
   if CurrentThreadId  self.ThreadId then
   begin
  result := pthread_mutex_lock (self...);
  if result  0 then exit;
  self.ThreadId := CurrentThreadId;
  self.Count := 1;
   end else begin
  Inc(self.Count);
   end;
   result := SUCCESS;
end {Mutex.Lock};

function Recursive_Mutex.Unlock: ...;
begin
  if CurrentThreadId  self.ThreadId then
exit(ENOTOWN);
  assert(self.Count  0);
  dec(self.Count);
  if self.Count = 0 then
  begin
self.ThreadId := 0; // a threadid that does not occur in system
pthread_mutex_unlock(self...);
  end;
  result := SUCCESS;
end;

I don't see the need for Owner_Check_Lock anymore ? :-)

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


Re: [fpc-pascal] Semaphore problems

2006-07-25 Thread Micha Nelissen
Burkhard Carstens wrote:
 I don't see the need for Owner_Check_Lock anymore ? :-)
 
 You have to prevent that 2 concurrent threads call lock simultanously, 

No, why?

 so you have to take an internal lock before touching internal vars like 
 self.ThreadID ?

No, why ? This is a common misconception I think. (Multi-threaded)
Programs are about state, not about touching internal variables.

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


Re: [fpc-pascal] enlarge or shrink a TRect by x pixels

2006-07-25 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 Hi,
 
 For the life of me I cant remember what the functions are called to
 enlarge or shrink a TRect by x pixels.  Can anybody help me out?  (I
 know there was such functions in Delphi)

InflateRect ?

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


Re: [fpc-pascal] Semaphore problems

2006-07-25 Thread Micha Nelissen
Vinzent Hoefler wrote:
 Ok, there's a glitch: The read and write of self.ThreadId is required to 
 be atomic, so that a thread entering may either see 0 or the owner's 
 thread id when checking, otherwise it could be possible, it sees its 
 own thread_id due to a partial update and *then* it goes really wrong.

It's not a glitch but an assumption I'd say. The compiler devels should
be able to answer whether we can assume this, or not ?

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


Re: [fpc-pascal] Semaphore problems

2006-07-24 Thread Micha Nelissen
Vinzent Höfler wrote:
 Currently all I see is a subtle semantic difference between Windows- and
 Unix-Event's implementation.

AFAICS, it's as close as it can get. You mean subtle as in, unimportant,
or as in, possibly fatal ? :-) If possibly fatal, describe when/how.

 So for now all I can say is that this should either
 
 a) be documented,

*Could* be a good idea, yes ;-).

 b) changed to a common semantic behaviour, or

They're both more or less 'transient' now.

I am not sure how to emulate windows behavior on unix, although that
behavior is easier to use I think, so would be desirable.

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


Re: [fpc-pascal] Pascal Compiler - Missing Messages etc.

2006-07-21 Thread Micha Nelissen
Rainer Stratmann wrote:
 Partly I agree, but, what has a good programmer to do with internals of any 
 os? That a programmer should be an intelligent person does not mean that it 
 could not be an advantage if fpc run out of the box.

What do you count as internals ? Surely the programmer should be
familiar with basic directory layout ? Just like windows has C:\Windows,
C:\Program Files, etc. unix has other conventions. I wouldn't count
these as internals of the OS.

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


Re: [fpc-pascal] RE: Nice website

2006-06-29 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 If you are using Mozilla Firefox, do the following...
  View - Page Style - Nav-Left

Do you also know a way for it to remember this choice for a website ? At
least, it doesn't remember for me.

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


Re: [fpc-pascal] RE: Nice website

2006-06-29 Thread Micha Nelissen
Graeme Geldenhuys wrote:
 It doesn't remember that setting for me as well.  The only thing I can
 think of, is if the website used cookies to store the pagestyle for
 the user.  I am no web programmer, so don't take my word for it.  :)

That's a hack IMHO, and can only work for dynamic websites. The main
freepascal page is static html.

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


Re: [fpc-pascal] RE: Nice website

2006-06-28 Thread Micha Nelissen
Jeff Pohlmeyer wrote:
 One suggestion: I think the sentence about the M680 should
 be moved to the end of the first paragraph. Finish telling
 me about what you do support first. I'm only on the second
 sentence of the entire website, and already they're telling
 me what the old compiler does that the new one doesn't.

Good point. Thanks, fixed.

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


Re: [fpc-pascal] porting fpIoctl() to windows

2006-05-29 Thread Micha Nelissen
Alain Michaud wrote:
 In the mean time, I calculate the function number by hand, knowing the
 device number, function number, IO_RW, etc... Or if I use a precedure do
 do this, then this will slow the program down.

AFAIK, these numbers are mostly constants, so you need to do this work
only once.

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


  1   2   >