[fpc-pascal] fpGetTimeOfDay

2015-03-09 Thread Mark Morgan Lloyd
Are there any known issues with this sort of thing  fpGetTimeOfDay 
(@TimeVal, nil)  on various platforms? FPC 2.6.4 and 2.7.1 seem to be OK 
on x86, but on x64 (and FWIW SPARC, haven't tested others) it appears to 
be returning a fixed TimeVal plus a result of zero even if there are 
several seconds between calls.


--
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] fpGetTimeOfDay

2015-03-09 Thread Mark Morgan Lloyd

Marco van de Voort wrote:

In our previous episode, Mark Morgan Lloyd said:
Are there any known issues with this sort of thing  fpGetTimeOfDay 
(@TimeVal, nil)  on various platforms? FPC 2.6.4 and 2.7.1 seem to be OK 
on x86, but on x64 (and FWIW SPARC, haven't tested others) it appears to 
be returning a fixed TimeVal plus a result of zero even if there are 
several seconds between calls.


My FreeBSD manpage says:

... If tp or tzp is NULL, the associated time
 information will not be returned or set.

The Linux manpage words it differently:

  If either tv or tz is NULL, the corresponding structure is not  set  or
   returned.  (However, compilation warnings will result if tv is NULL.)


The funny thing is that the snippet of code that I'm using was 
contributed by you, and that it works fine on multiple versions of x86 
kernel.


http://lists.freepascal.org/pipermail/fpc-pascal/2007-February/013356.html

--
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] License terms for FastHTMLParser

2015-03-09 Thread Andrew Haines

On 03/08/2015 11:23 AM, Christo wrote:

While reading up on the history of FastHTMLParser (to find out who/where
the root owner of this unit is) I noticed that the last release (0.4)
from Jazarsoft
(http://web.archive.org/web/20050112010608/http://www.jazarsoft.com/download/fasthtmlparser-0.4-delphi.zip)
 has a permissive license, while the file in the FPC source tree has the GPL 
pasted at the top.  I also see that Andrew Haines is listed as the copyright 
holder in the FPC source, while the original file listed Jazarsoft.  I know 
Andrew developed the chm support in FPC/Lazarus, but it seems as if he isn't 
the original author of this unit.

I think the original license  copyright should be restored for this
unit, any comments?

Best wishes,
Christo

I probably pasted the license by mistake when I was adding it to the 
rest of the files. I submitted a bug report that removes it.


Regards,

Andrew Haines


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


Re: [fpc-pascal] fpGetTimeOfDay

2015-03-09 Thread Marco van de Voort
In our previous episode, Mark Morgan Lloyd said:
 Are there any known issues with this sort of thing  fpGetTimeOfDay 
 (@TimeVal, nil)  on various platforms? FPC 2.6.4 and 2.7.1 seem to be OK 
 on x86, but on x64 (and FWIW SPARC, haven't tested others) it appears to 
 be returning a fixed TimeVal plus a result of zero even if there are 
 several seconds between calls.

My FreeBSD manpage says:

... If tp or tzp is NULL, the associated time
 information will not be returned or set.

The Linux manpage words it differently:

  If either tv or tz is NULL, the corresponding structure is not  set  or
   returned.  (However, compilation warnings will result if tv is NULL.)

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


Re: [fpc-pascal] fpGetTimeOfDay

2015-03-09 Thread Henry Vermaak
On Mon, Mar 09, 2015 at 01:30:28PM +0100, Marco van de Voort wrote:
 In our previous episode, Mark Morgan Lloyd said:
  Are there any known issues with this sort of thing  fpGetTimeOfDay 
  (@TimeVal, nil)  on various platforms? FPC 2.6.4 and 2.7.1 seem to be OK 
  on x86, but on x64 (and FWIW SPARC, haven't tested others) it appears to 
  be returning a fixed TimeVal plus a result of zero even if there are 
  several seconds between calls.
 
 My FreeBSD manpage says:
 
 ... If tp or tzp is NULL, the associated time
  information will not be returned or set.
 
 The Linux manpage words it differently:
 
   If either tv or tz is NULL, the corresponding structure is not  set  or
returned.  (However, compilation warnings will result if tv is NULL.)

Well that's obvious, you can't dereference a NULL so there's nothing to
set.  The tz parameter is obsolete, it should normally be NULL.

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


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

2015-03-09 Thread Xiangrong Fang
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 h in C?

Thankyou.



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

Re: [fpc-pascal] fpGetTimeOfDay

2015-03-09 Thread Marco van de Voort
In our previous episode, Mark Morgan Lloyd said:
If either tv or tz is NULL, the corresponding structure is not  set  or
 returned.  (However, compilation warnings will result if tv is NULL.)
 
 The funny thing is that the snippet of code that I'm using was 
 contributed by you, and that it works fine on multiple versions of x86 
 kernel.
 
 http://lists.freepascal.org/pipermail/fpc-pascal/2007-February/013356.html

Yes, I read wrong. Only the corresponding structure is not updated apparently,
not both.

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


Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-09 Thread Jürgen Hestermann


Am 2015-03-09 um 18:31 schrieb Jonas Maebe:


On 09 Mar 2015, at 17:49, Jürgen Hestermann juergen.hesterm...@gmx.de wrote:


Am 2015-03-09 um 17:40 schrieb Jonas Maebe:

http://bugs.freepascal.org/view.php?id=24601#c75617 (and the comment below + 
use -vq to see warning numbers, and -vm to block a particular warning 
number).

Thanks for the answer.
But still: Why is there such a warning for managed types at all?

That is the same question you asked in your original mail and which is answered 
in the bug report comment I linked in reply.



Not quite. In the bug comment you wrote:

The warning is by design for all kinds of variables and regardless of their 
storage location (as noted by the original submitter, global/static variables 
of any kind are always initialised by 0/nil/...). The warning means that no 
value has been explicitly assigned to these variables (which may indicate a 
logic error in the code), not necessarily that they contain an unpredictable 
value.

But still there is the question *why* this design exists?
I think it is a bad design.
It should know that managed types *are* initialized and not raise a warning in 
this case.
Why generate a warning with an incorrect statement?
Am I forced to add (superfluous) initialization code or somehow suppress this 
kind of
warning just to get rid of this false warnings which are useless from the 
beginning?

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

Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-09 Thread Jürgen Hestermann


Am 2015-03-09 um 17:40 schrieb Jonas Maebe:


On 09 Mar 2015, at 17:25, Jürgen Hestermann wrote:


I get a warning that a local dynamic array variable is not initialized.
Aren't such managed types initialized by default?
On http://wiki.freepascal.org/Dynamic_array it says:

Actually, dynamic arrays are pointers with automatic dereferencing. They are 
initialized to *nil* automatically.

So why the warning?


http://bugs.freepascal.org/view.php?id=24601#c75617 (and the comment below + 
use -vq to see warning numbers, and -vm to block a particular warning 
number).




Thanks for the answer.
But still: Why is there such a warning for managed types at all?
Dynamic arrays are initialized by default so the warning text is simply wrong.
It IS initialized and the compiler knows this.

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


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

2015-03-09 Thread Ewald

On 09 Mar 2015, at 18:43, Michael Van Canneyt wrote:

 
 You must be sure that self is passed in the correct register.
 I am not sure this is the case if you declare it as an extra argument.

It is, as long as the `self` is the first parameter. Same goes for `Class 
Procedure XXX;` kind of declarations (in constrast to `Class procedure XXX; 
static;`).

I don't know how long that is going to last however (since this hidden 
parameter thingy is an implementation detail of the compiler I think). So I 
fully agree: it would be a kindness of the compiler people to confirm this :-)

--
Ewald

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


Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-09 Thread Jonas Maebe


On 09 Mar 2015, at 17:49, Jürgen Hestermann juergen.hesterm...@gmx.de wrote:

 Am 2015-03-09 um 17:40 schrieb Jonas Maebe:
 
 http://bugs.freepascal.org/view.php?id=24601#c75617 (and the comment below + 
 use -vq to see warning numbers, and -vm to block a particular warning 
 number).
 
 Thanks for the answer.
 But still: Why is there such a warning for managed types at all?

That is the same question you asked in your original mail and which is answered 
in the bug report comment I linked in reply.


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

Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-09 Thread DaWorm
I would think this part answers that question:  The warning means that no
value has been *explicitly* assigned to these variables (which *may
indicate a logic error* in the code), not necessarily that they contain an
unpredictable value. (emphasis mine)

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

Re: [fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-09 Thread Jonas Maebe


On 09 Mar 2015, at 17:25, Jürgen Hestermann wrote:

I get a warning that a local dynamic array variable is not  
initialized.

Aren't such managed types initialized by default?
On http://wiki.freepascal.org/Dynamic_array it says:

Actually, dynamic arrays are pointers with automatic dereferencing.  
They are initialized to *nil* automatically.


So why the warning?


http://bugs.freepascal.org/view.php?id=24601#c75617 (and the comment  
below + use -vq to see warning numbers, and -vm to block a  
particular warning number).



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


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

2015-03-09 Thread Michael Van Canneyt



On Mon, 9 Mar 2015, OBones wrote:


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 h in 
C?


IMHO Not without separate assembler code for each CPU.

Michael.

How about using TMethod?

procedure DataHandler(DummySelf: Pointer; data: Pointer);
begin
 // do what you want to do, DummySelf is always nil.
end;

var
 Method: TMethod;
begin
 Method.Data := nil;
 Method.Code := @DataHandler;

 SetHandler(TDataHandler(Method));
end;


You must be sure that self is passed in the correct register.
I am not sure this is the case if you declare it as an extra argument.
It may be so, but compiler people should confirm this. 
I don't think you can take it for granted.


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


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

2015-03-09 Thread Michael Van Canneyt



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 h in C?


IMHO Not without separate assembler code for each CPU.

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

[fpc-pascal] Warning Local variable seems to be not initialized on dyn array

2015-03-09 Thread Jürgen Hestermann

I get a warning that a local dynamic array variable is not initialized.
Aren't such managed types initialized by default?
On http://wiki.freepascal.org/Dynamic_array it says:

Actually, dynamic arrays are pointers with automatic dereferencing. They are 
initialized to *nil* automatically.

So why the warning?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

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 
h in C?


IMHO Not without separate assembler code for each CPU.

Michael.

How about using TMethod?

procedure DataHandler(DummySelf: Pointer; data: Pointer);
begin
  // do what you want to do, DummySelf is always nil.
end;

var
  Method: TMethod;
begin
  Method.Data := nil;
  Method.Code := @DataHandler;

  SetHandler(TDataHandler(Method));
end;

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


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

2015-03-09 Thread Xiangrong Fang
2015-03-10 0:33 GMT+08:00 OBones obo...@free.fr:


 How about using TMethod?

 procedure DataHandler(DummySelf: Pointer; data: Pointer);
 begin
   // do what you want to do, DummySelf is always nil.
 end;

 var
   Method: TMethod;
 begin
   Method.Data := nil;
   Method.Code := @DataHandler;

   SetHandler(TDataHandler(Method));
 end;


​I'm not sure how this works, but it seems that you are deliberately
converting a normal procedure to a method. What I want is exactly opposite
- I want to convert a method to a normal procedure.

If I define the interfact of DataHandler like this:

​TDataHandler = procedure(data: Pointer); cdecl;

It is very easy to use in an so, no matter it is written in C or pascal.

But the problem is, I want to do this:

SetHandler(h);

where h is a METHOD, not a normal procedure​.

Because I want to use the handler wrapped in my Class.

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?

Thanks!


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

Re: [fpc-pascal] FPC embedded ?

2015-03-09 Thread Michael Schnell

On 03/07/2015 05:20 PM, Adriaan van Os wrote:
Also for low-power battery-powered devices ? 


PIC32MX5XX/6XX/7XX Datasheet:

Power Management:
Low-power management modes (Sleep and Idle)
Integrated Power-on Reset, Brown-out Reset
0.5 mA/MHz dynamic current (typical)
41 μA IPD current (typical) 

-Michael

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