Re: [fpc-pascal] Help building FPC on armhf

2015-06-30 Thread Andrew Brunner



On 06/29/2015 07:42 AM, Michael Ring wrote:
I think I now remember having the same problem before, can you please 
try to build with "-O-" instead of -O2 ?


I've had some success/progress with my Wandboard Quad Revision C.
Thanks for all your help however there are still some issues.

When compiling FPC 2.6.4 bootstrap  I determined that :
-OpARMV71 is not a supported option.
-cfVFPV3 is not a supported option.

On make sourceinstall I determined that there is something wrong with 
the make process because nothing I do can get make sourceinstall to stop 
overriding the source in /usr/share/src/fpc-2.6.4 with my 3.1.1 source :-(


/bin/rm -f build-stamp.*
/bin/rm -f base.build-stamp.*
/usr/bin/install -m 755 -d /usr/share/src/fpc-2.6.4/fpc
/bin/cp -Rfp /Developer/FPC/* /usr/share/src/fpc-2.6.4/fpc

The script should have shown /usr/share/src/fpc-3.1.1 etc...

This problem is only with building on Linux-arm.  I've never had this 
issue in any other linux device.



--
Andrew Brunner

Aurawin LLC
512.850.3117
https://aurawin.com/

Aurawin is a great new way to store, share and enjoy your photos, videos, 
music, and more.

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


Re: [fpc-pascal] Help building FPC on armhf

2015-06-29 Thread Andrew Brunner


On 6/28/2015 8:56 AM, Michael Ring wrote:

I am using parameters suggested on this page (modified for armv7a):

http://michellcomputing.co.uk/blog/2014/05/freepascal-2-7-1-on-raspberry-pi/ 



OPT="-dREVINC -dFPC_ARMHF -CX -CpARMV7A -CfVFPV3_D16 -OpARMV7A -O2 
-OoFASTMATH -XX -Xs"


as your error seems to be caused by some conditional parsing the extra 
defines above might help (or not .)


Michael


Hi Michael,

I tried to use the options above to no avail.  Thanks for the effort though.

--
Andrew Brunner

Aurawin LLC
512.850.3117
https://aurawin.com/

Aurawin is a great new way to store, share and enjoy your photos, videos, 
music, and more.

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


Re: [fpc-pascal] Help building FPC on armhf

2015-06-28 Thread Andrew Brunner



On 6/28/2015 4:47 AM, Jonas Maebe wrote:
1) the error you get means that the "fpc" binary is not in your path. 
Building FPC always has been and always will be only supported with an 
existing, complete installation of the latest FPC release in your path 
2) FPC 2.6.4 does not contain ARMHF support (except in an unofficial, 
and completely unsupported by us, Debian backport) 3) "ARM hard float" 
not a different kind of CPU compared to ARM. To build FPC for ARM 
hard-float using a non-ARMHF compiler, perform a make all for 
CPU_TARGET=ARM with OPT="-dARMHF"


Thanks Jonas,  I was able to get a bit further along in the build process.

make clean all OPT=-dARMHF DEBUG=1 OS_TARGET=linux CPU_TARGET=arm 
CPU_SOURCE=arm


Building crashes at compiling system.pp

as   -o /Developer/FPC/rtl/units/arm-linux/dllprt0.o arm/dllprt0.as
as  -o /Developer/FPC/rtl/units/arm-linux/cprt0.o arm/cprt0.as
as  -o /Developer/FPC/rtl/units/arm-linux/gprt0.o arm/gprt0.as
as  -o /Developer/FPC/rtl/units/arm-linux/ucprt0.o arm/ucprt0.as
/Developer/FPC/compiler/ppc1 -Ur -gl -Ur -Xs -O2 -n -Fi../inc -Fi../arm 
-Fi../unix -Fiarm -FE. -FU/Developer/FPC/rtl/units/arm-linux -dARMHF 
-darm -dDEBUG -dRELEASE -Us -Sg system.pp
flt_pack.inc(119,5) Error: Syntax error while parsing a conditional 
compiling expression
system.inc(1884,8) Warning: Implicit string type conversion from 
"RawByteString" to "UnicodeString"

system.pp(377) Fatal: There were 1 errors compiling module, stopping
Makefile:3573: recipe for target 'system.ppu' failed
make[7]: *** [system.ppu] Error 1
make[7]: Leaving directory '/Developer/FPC/rtl/linux'
Makefile:1950: recipe for target 'linux_all' failed
make[6]: *** [linux_all] Error 2
make[6]: Leaving directory '/Developer/FPC/rtl'
Makefile:4157: recipe for target 'rtl' failed
make[5]: *** [rtl] Error 2
make[5]: Leaving directory '/Developer/FPC/compiler'
Makefile:4046: recipe for target 'next' failed
make[4]: *** [next] Error 2
make[4]: Leaving directory '/Developer/FPC/compiler'
Makefile:4055: recipe for target 'ppc2' failed
make[3]: *** [ppc2] Error 2
make[3]: Leaving directory '/Developer/FPC/compiler'
Makefile:4063: recipe for target 'cycle' failed
make[2]: *** [cycle] Error 2
make[2]: Leaving directory '/Developer/FPC/compiler'
Makefile:2826: recipe for target 'compiler_cycle' failed
make[1]: *** [compiler_cycle] Error 2
make[1]: Leaving directory '/Developer/FPC'
Makefile:2858: recipe for target 'build-stamp.arm-linux' failed
make: *** [build-stamp.arm-linux] Error 2


--
Andrew Brunner

Aurawin LLC
512.850.3117
https://aurawin.com/

Aurawin is a great new way to store, share and enjoy your photos, videos, 
music, and more.

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


[fpc-pascal] Help building FPC on armhf

2015-06-27 Thread Andrew Brunner

Hi there,

I recently installed fpc-2.6.4 on my Wandboard-Quad for production. I 
have fpc from svn but I get an error when I try to build.


Compiling ARM Free Pascal Compiler...
make clean all OPT=-O- DEBUG=1 OS_TARGET=linux CPU_TARGET=armhf 
CPU_SOURCE=arm

make: -iVSPTPSOTO: Command not found
Makefile:215: *** The Makefile doesn't support target armhf-linux, 
please run fpcmake first.  Stop.


Can someone help?


--
Andrew Brunner

Aurawin LLC
512.850.3117
https://aurawin.com/

Aurawin is a great new way to store, share and enjoy your photos, videos, 
music, and more.

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


Re: [fpc-pascal] Looking for JavaScript component on FPC

2015-04-02 Thread Andrew Brunner

On 4/2/2015 11:46 AM, Michael Van Canneyt wrote:

Namespaces are available as dotted units ?
Namespace as dotted units?  I use 3.1.1 compiled here so there is no 
problem.   FPC since as far as I recall (svn) has had support for naming 
units with multiple dots.  I've had tons of units with includes and I 
dot them for quick functionality review in directory listings.


Hmmm... The only problem is it seems pretty cheap.   I love the advanced 
look of my complex units.  I would have to break out each unit and 
maintain a bunch of separate units.  I could see how this was a 
delphi-like feature but its not done in a modern fashion.


Just wondering how much work it's going to take to have nested class 
support.




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


Re: [fpc-pascal] Looking for JavaScript component on FPC

2015-04-02 Thread Andrew Brunner

On 4/2/2015 2:24 AM, Michael Van Canneyt wrote:

And already utterly unreadable for me...
IMHO goes to show that this is a very personal matter :-) 


Units that include hierarchy via class types are a supplement for 
namespaces in languages such as c#.  Since Namespaces are not *yet* 
available in FPC we have to use classes.


The dotted notation in libraries that use the organized unit makes for 
easy code readability as well as having global variables available 
within the namespace.   So things like naming conventions become standard.


I have attached a 3.4kb example unit that is the back-end db module.

CMS.XML "namespace" holds all my XML related types,vars,consts,etc.

Units that use this module declare things like

var PP:dbmCMS.CMS.TPagePoint;

I realize the similarities in having a unit results in the same code as 
above however, the real benefit comes when the database modules become 
more complex.


The single most important feature I absolutely love is having *.TItem 
and *.TItems where * is a hierarchy of nested classes (purposely 
namespace).  My most complex database module dbmSocial. There I have 
Files.TItem/TItems and Folder.TItem/TItems.


 I hope the attached unit brings some clarity to my motivation and need 
for having organized units with namespaces (currently as nested classes).



unit dbmCMS;

{$mode objfpc}{$H+}
{
  unit dbmCMS.pas

  CMS Storage Database Module

  DBMS facilities to handle Content Management System

  Copyright Aurawin LLC 2014
  Written by: Andrew Thomas Brunner

 This code is protected under the Aurawin Release License
 http://www.aurawin.com/aprl.html
}

interface

uses
  Classes, SysUtils, hDatabase, uXML, uStringArray, uQWordArray, uByteArray, 
XMLRead, DOM,
  uStreams, uDBModule, uDatabase, dbmContentTypes, hHTTP, uVarString;

type
  CMS = class
  type
XML=class
type
  Stanzas=class
  const
PagePoint  = 'pp';
  end;
  Fields=class
  const
FileID = 'fild';
FolderID   = 'fold';
URI= 'uri';
Space  = 'spc';
Data   = 'data';
  end;
end;
PPagePoint=^TPagePoint;
TPagePoint=record
  FileID   : QWord;
  FolderID : QWord;
  URI  : TVarString;
  Space: TVarString;
  Data : TVarString;
end;
class function  toXML(var Item:TPagePoint; Output:TMemoryStream; 
Header:boolean):boolean;
class function  fromXML(xDoc:TXMLDocument; var Item:TPagePoint):boolean; 
overload;

class procedure Empty(Var Item:TPagePoint); overload;
class procedure Init(Var Item:TPagePoint); overload;
class procedure Done(Var Item:TPagePoint); overload;
  end;

implementation
uses uStorage,uTimer,uImage,DB, sqldb,uBase64;

class function  CMS.fromXML(xDoc:TXMLDocument; var Item:TPagePoint):boolean;
var
  xItem:TDOMNode;
begin
  Result:=False;
  Empty(Item);
  xItem:=uXML.XML.getNode(xDoc,XML.Stanzas.PagePoint);
  if (xItem<>nil) then begin
with uXML.XML do begin
  Item.FileID:=toQword(xItem,XML.Fields.FileID);
  Item.FolderID:=toQword(xItem,XML.Fields.FolderID);
  Item.Space:=toString(xItem,XML.Fields.Space);
  Item.URI:=toString(xItem,XML.Fields.URI);
  Item.Data:=toString(xItem,XML.Fields.Data);
  Result:=True;
end;
  end;
end;

class function  CMS.toXML(var Item:TPagePoint; Output:TMemoryStream; 
Header:boolean):boolean;
begin
  Result:=False;
  if Header then
uXML.XML.Stamp(Main.Header.Encoding,Output);

  Output.Position:=Output.Size;
  uStreams.Write('<',1,Output);
  uStreams.Write(XML.Stanzas.PagePoint,Output);
  uStreams.Write('>',1,Output);

  with uXML.XML do begin
uStreams.Write(Print(XML.Fields.FileID,Item.FileID),Output);
uStreams.Write(Print(XML.Fields.FolderID,Item.FolderID),Output);
uStreams.Write(Print(XML.Fields.Space,Item.Space,CDATA_OFF),Output);
uStreams.Write(Print(XML.Fields.URI,Item.URI,CDATA_ON),Output);
uStreams.Write(Print(XML.Fields.Data,Item.Data,CDATA_OFF),Output);
  end;

  uStreams.Write('',1,Output);

  Result:=True;
end;

class procedure CMS.Empty(Var Item:TPagePoint);
begin
  Item.FileID:=0;
  Item.FolderID:=0;
  SetLength(Item.Space,0);
  SetLength(Item.URI,0);
  SetLength(Item.Data,0);
end;

class procedure CMS.Init(Var Item:TPagePoint);
begin
  Item.FileID:=0;
  Item.FolderID:=0;
  SetLength(Item.Space,0);
  SetLength(Item.URI,0);
  SetLength(Item.Data,0);
end;

class procedure CMS.Done(Var Item:TPagePoint);
begin
  Finalize(Item.Space);
  Finalize(Item.URI);
  Finalize(Item.Data);
  Finalize(Item);
end;

end.

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

Re: [fpc-pascal] Looking for JavaScript component on FPC

2015-04-01 Thread Andrew Brunner
I have Besen installed and I am in the process of evaluating it.  It 
does not handle nested classes.
I need a JIT compiler that provide access to heavily nested class 
information.  This PostInfo is a simple database module that I would 
want Script to have access to.

---
// sample interface with no implemenation
---
Type
  PostInfo= class
  type
IDs= class
const
  ID = 0;
  InsertID   = 1;
  DomainID   = 2;
  IP = 3;
  Created= 4;
  Form   = 5;
  Data   = 6;
end;
Keys=class
const
  ID = 'ITMID';
  InsertID   = 'ITMIID';
  DomainID   = 'ITMDID';
  IP = 'ITMIP';
  Created= 'IDTC';
  Form   = 'IFRM';
  Data   = 'IDAT';
end;
XML=class
type
  Stanzas=class
  const
Info   = 'pstinf';
  type
Fields=class
const
  ID   = 'id';
  Created  = 'ctd';
  IP   = 'ip';
  Form = 'frm';
  Data = 'dta';
end;
  end;
end;
Email=class
const
  Address  = 'au-eml-addr';
  NameSpace= 'au-eml-ns';
  Subject  = 'au-eml-sbj';
  Body = 'au-eml-bdy';
end;
const
  TableP: PDatabaseTable = nil;
  MonitorP: PDBMSMonitorItem = nil;
  Startup: TDBTableIni = (
AutoCreate: True;
AutoCommit   : True;
Group: 'Domains/Storage';
Name: 'Post Info';
Value: 'scs_pstinfo';
Hint: 'Table for accepting domain level form data from the web.';
PrimaryField: Keys.ID;
);
  Fields: array [0..6] of TDatabaseField = (
(PropertyID: IDs.ID; DataType: dftQWord; AutoCreate: True; 
Verified: False; Precision: 0; Flags: cfNotNull or cfPrimaryKey or 
cfIdentity; Name: Keys.ID; ),
(PropertyID: IDs.InsertID; DataType: dftQWord; AutoCreate: 
True; Verified: False; Precision: 0; Flags: cfNone; Name: Keys.InsertID; ),
(PropertyID: IDs.DomainID; DataType: dftQWord; AutoCreate: 
True; Verified: False; Precision: 0; Flags: cfNone; Name: Keys.DomainID; ),
(PropertyID: IDs.IP; DataType: dftQWord; AutoCreate: True; 
Verified: False; Precision: 0; Flags: cfNone; Name: Keys.IP; ),
(PropertyID: IDs.Created; DataType: dftDouble; AutoCreate: 
True; Verified: False; Precision: 0; Flags: cfNone; Name: Keys.Created; ),
(PropertyID: IDs.Form; DataType: dftShortString; AutoCreate: 
True; Verified: False; Precision: 255; Flags: cfNone; Name: Keys.Form; ),
(PropertyID: IDs.Data; DataType: dftMemo; AutoCreate: True; 
Verified: False; Precision: 0; Flags: cfNone; Name: Keys.Data; )

  );

  class function  Post(Var Module:TDBMSModule; Var Task:TDBMSTask; 
DomainID,IP:QWord; Form:TVarString; Data:TVarString): Boolean;

  end;

--

I need a JITC to provide access to native FPC code that looks like this 
on the compiled side, but would be implemented like so in the cloud.


Before BESEN.Execute, would need to have access to FPC runtime variables 
like Module,Task,IP

if (PostInfo.Post(Module,Task,DomainID,IP,Form,Data)==false){
  Log('FAILED to write');
} else {
  Log ('WooHoo');
};

Nested classes are a modern way to organize complex API and code into 
very easy to read code.  Most of the modules I have are extremely 
nested, the one I chose here is easy and strait forward.


I see PascalScript is part of the Lazarus project now.  I have not been 
able to get nested classes to work there either.  If I am to get my code 
accessible, I will need someone with knowledge in extending BESEN or 
PascalScript or both.  I would be ideal to offer developers a choice of 
which scripting language they want to write back-end code.


But if I am to provide developers with instant API to do complex code 
that is relevant to computing needs of today, I will need access to 
nested objects in either of these JITCs.


Anyone familiar with BESEN or PascalScript that could shed some light?

--
Andrew Brunner

Aurawin LLC
512.850.3117
https://aurawin.com/

Aurawin is a great new way to store, share and enjoy your photos, videos, 
music, and more.

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


[fpc-pascal] Looking for JavaScript component on FPC

2015-03-31 Thread Andrew Brunner
I am trying to integrate javascript for back-end support of cloud apps.  
I noticed the fcl-js package.  Does anyone have an idea when we can 
expect to have a component suite much like the PascalScript?


Thanks,

--
Andrew Brunner

Aurawin LLC
512.850.3117
https://aurawin.com/

Aurawin is a great new way to store, share and enjoy your photos, videos, 
music, and more.

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


Re: [fpc-pascal] Is Nested Procedure Types

2013-11-23 Thread Andrew Brunner
Ok, I had a test program that used a few other units.  Apparently this 
had to be placed at the top of my units that used and implemented the 
nested callback type.


{$mode objfpc}
{$modeswitch nestedprocvars}


The last question I have is when can I expect to use nested procedure 
variables system wide without compiler directives?  What's the hold-up 
or reason why the mode is even needed?


Thanks again,

On 11/23/2013 09:43 AM, Jonas Maebe wrote:

On 23 Nov 2013, at 15:47, Andrew Brunner wrote:


I'm wondering if the is nested procedure type is supposed to work

{$modeswitch nestedprocvars}

Type TMyCallback=procedure(Index:Integer) is nested;

I thought 2.6.0 was supposed to support this but I'm using FPC from svn/trunk 
and it does not.  Any ideas?

It does work, see e.g. 
http://svn.freepascal.org/svn/fpc/trunk/tests/test/tmaclocalprocparam2d.pp


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

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


[fpc-pascal] Is Nested Procedure Types

2013-11-23 Thread Andrew Brunner

I'm wondering if the is nested procedure type is supposed to work

{$modeswitch nestedprocvars}

Type TMyCallback=procedure(Index:Integer) is nested;

I thought 2.6.0 was supposed to support this but I'm using FPC from 
svn/trunk and it does not.  Any ideas?


see also:
http://wiki.freepascal.org/FPC_New_Features_2.6.0#Support_for_nested_procedure_variables


Thanks,

--
Andrew Brunner

Aurawin LLC
512.850.3117
https://aurawin.com/

Aurawin is a great new way to store, share and enjoy your photos, videos, 
music, and more.

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

Re: [fpc-pascal] Status of UTF8

2013-09-28 Thread Andrew Brunner


On 09/28/2013 07:51 AM, Jonas Maebe wrote:
You can read your data into a RawByteString and then call 
SetCodePage(rawbytestr,codepagenr,false) to set its code page to 
whatever the code page of the data in that string is (without 
attempting to convert the data, which is what the last "false" 
parameter indicates). 


Thanks Jonas, I'm relieved to see there is already mechanisms in place.


You can then convert it into UTF-8 by calling 
SetCodePage(rawbytestr,CP_UTF8), or the 
equivalent SetCodePage(rawbytestr,CP_UTF8,true) (the last parameter is 
a default parameter with value "true")


That looks exactly what is needed.

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


[fpc-pascal] Status of UTF8

2013-09-28 Thread Andrew Brunner
I wanted to get the status of WideString support.  Specifically 
Multi-lingual (Ansi/UTF8 strings) using Threads.


I noticed that FPC is now automatically converting (encoding/decoding) 
the contents of a string during various operations.  These conversions 
seem to be using system locale settings as a basis for selecting which 
code page it uses.


I did see that I can change the default code page, but that is not 
acceptable where incoming MIME data is concerned.  With MIME messages - 
the content type and character set are passed along with each section of 
text.  Blocks specifiy with which code page to employ.


The problem I have is that I process content of many different code 
pages in parallel.  String manipulation occurs at a mult-threaded level 
so switching global variables is going to expose the current way of 
processing as dangerous.


What are the best practices for taking a chunks of string data (of 
various code pages), and converting to UTF8 given a multi-threaded 
application?


Supporting thread-safe system-wide code page string manipulation is a 
basic requirement moving forward.


If interested, I can contribute a converter I wrote that offers 
encoding/decoding of strings as perhaps some inspiration that may lead 
to FPC internal support for such a mechanism.



Thanks,

Andrew Brunner
Aurawin LLC

512.574.6298

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


Re: [fpc-pascal] How to save a huge XML?

2013-06-19 Thread Andrew Brunner

On 06/19/2013 02:44 AM, Michael Schnell wrote:

On 06/18/2013 02:35 PM, Marcos Douglas wrote:
Today I call WriteXMLFile(Doc, AFileName) but I have XML with 5G, 
10G.. 30G...


What the best way to save "line by line"?


Why not push it through a stream compressor ?

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




In cases like the it is best practice for the reporter change their 
implementation.


Stream Compression, and other things won't help.  This is a limitation 
of strings and memory allocation w/r/t xml.


I would suggest that the reporter just implement function toXML() 
method(s) to construct XML data as a string and use 
T(File/Memory)Stream.  This method has worked well for me.


--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.

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


[fpc-pascal] ImageMagick and Static Linking

2013-05-08 Thread Andrew Brunner

Image Magick comes with static libraries and dynamic libraries.
Is there any way to make ImageMagick unit support the *.lib files?
I'm trying to avoid having to distribute the ImageMagick dlls.

Thanks,

--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Win64 release of FPC 2.6.2 missing

2013-05-06 Thread Andrew Brunner
I agree with what you are saying as long as the os matches the binary type.   
An x64 native package must  install a x64bit binary and utils. 

I would be understating if I said that a 32bit binary would be normal on a 
64bit distro.  

Andrew Brunner
Aurawin LLC
512.574.6298

A safe new way to store and share your files, pictures, videos and more. 

http://aurawin.com

On May 6, 2013, at 2:32 AM, Jonas Maebe  wrote:

> 
> On 04 May 2013, at 16:24, Andrew Brunner wrote:
> 
>> I agree that most of us first go to x64 downloads for binaries.  Thinking 32 
>> to 64 or reverse is onerous on typical end users.
> 
> The whole point is that the "typical end user" doesn't know nor should have 
> to care about whether the compiler is a 32 or 64 bit binary. It should not 
> make any difference whatsoever. If it does, then that's either a bug in FPC, 
> or in Lazarus, its fpmake files or Makefiles (or fpcmake).
> 
> 
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problems with ImageMagick Win64

2013-05-04 Thread Andrew Brunner

http://bugs.freepascal.org/view.php?id=24346

Can someone please apply patch?  Thanks.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Win64 release of FPC 2.6.2 missing

2013-05-04 Thread Andrew Brunner
I wanted to mention that Lazarus comes with a 64bit FPC 2.6.2 from binaries...

Guys, Graeme is well meaning here.  I agree that most of us first go to x64 
downloads for binaries.  Thinking 32 to 64 or reverse is onerous on typical end 
users.  

I need 64bit FPC binaries too.   Presently I install the Lazarus to get 64bit 
FPC, then checkout svn FPC/trunk and Lazarus/trunk.  I do this every time 
because of the fact that there is no 64bit FPC.

Others do this too.   You are looking at this too much from the internals.  
This is a case where the Customer is right I can assure you.

But the solution must conform to FPC standards with regards to builds/packaging.

Thanks for any help in offering a 64bit download of FPC.  

Andrew Brunner,

Aurawin LLC
512.574.6298
http://aurawin.com/

Aurawin is great new way to store and share your pictures, videos, and more, 
featuring our innovative Pure Cloud social computing platform. 

On May 3, 2013, at 4:21 PM, Graeme Geldenhuys  wrote:

> Hi,
> 
> John Lee made the suggestion that an "unofficial" 64-bit Windows
> compiler archive be made available - for those people like me.
> 
> You can now download it from the Free Pascal FTP site:
> 
>  ftp://ftp.freepascal.org/fpc/dist/2.6.2/x86_64-win/
> 
> 
> [ readme.txt ]--
> 64 bit win fpc 2.6.2
> 
> generated by Graeme Geldenhuys, uploaded by John Lee
> fpc.cfg is set up for Graeme's config
> 
> NB this version is not generated as part of the distribution
> by the fpc developers since it is not believed to offer any/many
> advantages cf the win32 version frunning on a win 64 bit target.
> 
> May 2013
> 
> 
> 
> Hope somebody finds it useful.
> 
> 
> Regards,
>  - Graeme -
> 
> -- 
> fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
> http://fpgui.sourceforge.net/
> 
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problems with ImageMagick Win64

2013-04-28 Thread Andrew Brunner

On 04/28/2013 02:49 PM, Andrew Brunner wrote:
I can't get ImageMagick unit to work under Windows XP 64. 
Also, I have confirmed that ImageMagick installed and the application 
does work.

Can someone please edit change the unit code for Windows instead of Win32?
The libraries are identical for x64 and 32.

Thanks,

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


[fpc-pascal] Problems with ImageMagick Win64

2013-04-28 Thread Andrew Brunner

Current FPC/Trunk running on Win64 XP

I can't get ImageMagick unit to work under Windows XP 64.

I changed Win32 to Windows

{$ifdef Windows}
  MagickExport = 'CORE_RL_magick_.dll';
  WandExport = 'CORE_RL_wand_.dll';
{$else}
  MagickExport = 'libMagickCore';
  WandExport = 'libMagickWand'; // Previous ImageMagick versions used 
'libWand'

{$endif}

  CORE_RL_magick_.dll
  CORE_RL_wand_.dll'

Apon running the app, libMagickWand.dll was not found.

Can someone please look into this?

Thanks,

--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Does FPC 2.8.0 can actually still be called Pascal ?

2013-02-28 Thread Andrew Brunner

On 02/28/2013 03:25 AM, Marco van de Voort wrote:

So "Sulphur" then? It is the next element in the same group of the periodic
table and twice as heavy as Oxygen? Moreover hints at being a bit evil and
vile.


Won't work.  The truth is:
 1.) most don't kown/know their current state.
 2.) those that do, are rightly wanting to align properly.
 3.) loss of naturally good talent (it only takes one bad idea to misguide)
 4.) draw of skilled talent that binds contention.
 5.) there is a measurable force that supports M$'s (project of the 
day).  The force involves collective conscientiousness.  And control 
over perception.  The social fabric is presently being shaped in their 
favor.  From our perspective, no-one ever lost their teeth buying 
Microsoft's Windows.  But from their perspective, no-one ever lost their 
job buying a M$ project.  Both perceptions are negative towards the 
truth. Proof to me that they have successfully adopted a viable strategy.
 6.) Collective conscientiousness demonstrates that Pascal is a dead 
language.  So either we overcome the notion that the language is dead 
(my favourite) or perhaps call it something else and try to ignite a 
spark and see what happens.



The idea behind hinting on that last bit is if we simply admit we are dirty, we 
won't
have any useless cleanness discussions anymore?



With strong acting/performance project, cleanliness is just inherent.  
So I would say sure.
With such a project, bad code would be limited to reflect on the code 
contributor/creator.
But to 1.) above, wrongly kowning up to bad code contributions is my 
largest genuine concern.




--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Does FPC 2.8.0 can actually still be called Pascal ?

2013-02-27 Thread Andrew Brunner

On 02/27/2013 05:50 PM, Graeme Geldenhuys wrote:
FPC now definitely finds itself in the Jascal.NET territory. ;-) 
Regards, - Graeme - 


That's probably needed here.  I think it's a great idea to embrace a new 
name for some future version that includes innovations.  Pascal has been 
forced into a bracket it ought-not-be.


Jascal DOES look cool ;-)

--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Performance problems with Image Conversions

2013-02-25 Thread Andrew Brunner

Ok,  This matter has been solved.

The updated code is so simple and many factors faster!

Thanks to all!


class function Image.Transform(Stream:TMemoryStream; var 
iX,iY:Integer):boolean;

var
  status : MagickBooleanType;
  wand   : PMagickWand;
  srcWidth,srcHeight : Cardinal;
  dstWidth,dstHeight : Cardinal;
  Factor : Double;
  img: Pimage;
  blob   : PByte;
  bSize  : QWord;
begin
  Result:=false;
  wand := NewMagickWand;
  Try
Stream.Position := 0;
status := MagickReadImageBlob(wand, Stream.Memory, Stream.Size);
if (status = MagickTrue) then begin

  img := GetImageFromMagickWand(wand);

  srcHeight := MagickGetImageHeight(wand);
  srcWidth := MagickGetImageWidth(wand);
  if (srcWidth>=srcHeight) then begin
Factor:=iX/srcWidth;
  end else begin
Factor:=iY/srcHeight;
  end;
  dstWidth:=Trunc(srcWidth*Factor);
  dstHeight:=Trunc(srcHeight*Factor);
  if (srcWidth>iX) or (srcHeight>iY) then begin
//MagickResizeImage(wand, 106, 80, LanczosFilter, 1.0);
MagickScaleImage(wand, dstWidth, dstHeight);
Stream.Size:=0;
blob:=MagickGetImageBlob(wand,@bSize);
Stream.Write(blob^,bSize);
Result:=true;
  end;
end;
  finally
DestroyMagickWand(wand);
  end;
end;


--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Performance problems with Image Conversions

2013-02-25 Thread Andrew Brunner

On 02/25/2013 04:51 AM, Graeme Geldenhuys wrote:
ImageMagick will probably be a good choice. Regards, - Graeme - 



Ok, I'm going to start tests with that.  Thanks
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Performance problems with Image Conversions

2013-02-24 Thread Andrew Brunner

On 02/24/2013 04:44 AM, Michael Van Canneyt wrote:


Try to get rid of the XML, it is always going to be slow.
Using XML can slow your applications with a factor 6.
If you are mime-encoding an image, it'll be even more.



I was just thinking about that.  I think JSON would be ok, especially if 
I can use the RTL to get the data into the fields. XML code takes about 
33% of my dbModules for each implementation. That would take a lot of 
work for each DBModule and CoreObject, both client (js) and server(pas).



Do a FreeAndNil(srcCanvas) here. 1. Free already checks if the pointer 
is not nil.

  You do not need to check again.
2. FreeAndNil will make sure the pointer is Nil



Done.

Do not use TFPMemoryImage. It is a catch-all memory format, not 
optimized at all, using 64 bits for the images.
Instead, use e.g. TFPCompactImgRGBA8Bit if you need alpha or 
TFPCompactImgRGB8Bit if you do not need Alpha.




Done.  I'm preparing to check for performance gains...


dstImg:=TFPMemoryImage.Create(iX,iY);
 dstImg.UsePalette:=false;
 dstCanvas:=TFPImageCanvas.create(dstImg);
 dstCanvas.StretchDraw(0,0,iX,iY,srcImg);


Phew, this is also a real killer.

Do not draw on a canvas with stretchdraw. That will be slow as well; 
Rather, attempt to manipulate the image in memory by doing a stretch 
directly.
Choose an algorithm which is fast. The default interpolation will 
result in quite a lot of calculations. 


Ok,  I noticed some units surrounding the graphic code.  Is this 
something that is illustrated on the wiki?  Where do I get the methods?  
Anyone else is welcome to comment on scaling methods here... I have a 
feeling this would yield the most performance gains.


Digital Photos scaled go from 3264x2448 down to 512x384 so the scaling 
is somewhat slow.  The streaming is slow too...


If not, does anyone have lightning fast scaling methods in C++ or Java 
that I can port/contribute?

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


[fpc-pascal] Performance problems with Image Conversions

2013-02-23 Thread Andrew Brunner

Hi guys,

I just finished (a beta) of a collage app for Aurawin.  I'm seeing a 
huge load on my servers when scaling images using the Image factory 
classes for JPEG, and PNG.


Prefix:
6 Core AMD 64 32GB RAM Ubuntu 12.10 x64
8 Core AMD 64 32GB RAM Ubuntu 12.10 x64
FPC/Lazarus daily svn/trunk

Overview:
1.) end-user grabs references to files (stored on my server)
2.) back-end core object scales camera photos to something more net 
friendly 512px max to scale.

3.) server streams photos back to client over the web and
4.) server assembles XML stream of Mime encoded file data for things like
https://aurawin.com/cb?3

Specifics

The pics in this sample take about 30 seconds to go from their originals 
to 512px.  The app waits for the collage to save to the cloud.  The 
problem gets worse for larger collages with more images.


iX,iY are no larger than 512

class function Image.Transform(Stream:TStream; var 
sContentType,srcKind,dstKind:string; var iX,iY:Integer):boolean;

var
  FReader  : TFPCustomImageReader;
  FWriter  : TFPCustomImageWriter;
  cReader  : TFPCustomImageReaderClass;
  cWriter  : TFPCustomImageWriterClass;
  Factor   : Double;
  FTransparent : boolean;
  dstImg   : TFPMemoryImage;
  srcImg   : TFPMemoryImage;
  srcCanvas: TFPImageCanvas;
  dstCanvas: TFPImageCanvas;


  procedure FreeImageData;
  begin
if (srcCanvas<>nil) then
  srcCanvas.Free();
if (dstCanvas<>nil) then
  dstCanvas.Free();
if (FReader<>nil) then
  FReader.Free();
if FWriter<>nil then
  FWriter.Free();
if srcImg<>nil then
  srcImg.Free();
if dstImg<>nil then
  dstImg.Free();
  end;
begin
  Result:=false;
  if SameText(srcKind,Image.Kind.GIF.Name) then begin
sContentType:=hHTTP.ctPNG;
dstKind:=Image.Kind.PNG.Name;
FTransparent:=true;
  end else if SameText(srcKind,Image.Kind.PNG.Name) then begin
dstKind:=Image.Kind.PNG.Name;
FTransparent:=true;
  end else begin
sContentType:=hHTTP.ctJPG;
dstKind:=Image.Kind.JPG.Name;
FTransparent:=false;
  end;
  cReader:=FPImage.ImageHandlers.ImageReader[srcKind];
  cWriter:=FPImage.ImageHandlers.ImageWriter[dstKind];
  dstCanvas:=nil; srcCanvas:=nil; FReader:=nil; FWriter:=nil; 
srcImg:=nil; dstImg:=nil;

  Result:=(cReader<>nil) and (cWriter<>nil);
  if Result then begin
Try
  FReader:=cReader.Create();
  FWriter:=cWriter.Create();

  if SameText(dstKind,Image.Kind.PNG.Name) then begin
TFPWriterPNG(FWriter).Indexed:=false;
TFPWriterPNG(FWriter).UseAlpha:=true;
  end;

  srcImg:=TFPMemoryImage.Create(0,0);
  srcImg.UsePalette:=false;
  Stream.Position:=0;
  Try
srcImg.LoadFromStream(Stream,FReader);
Stream.Position:=0;

if (srcImg.Width>=srcImg.Height) then begin
  Factor:=iX/srcImg.Width;
end else begin
  Factor:=iY/srcImg.Height;
end;

if (srcImg.Width>iX) or (srcImg.Height>iY) then begin
  if FTransparent then begin
if SameText(srcKind,Image.Kind.GIF.Name) then begin
  FTransparent:=TFPReaderGIF(FReader).Transparent;
  TFPWriterPNG(FWriter).UseAlpha:=true;
end;
  end;

  iX:= Round(srcImg.Width * Factor);
  iY:= Round(srcImg.Height * Factor);

  dstImg:=TFPMemoryImage.Create(iX,iY);
  dstImg.UsePalette:=false;
  dstCanvas:=TFPImageCanvas.create(dstImg);
  dstCanvas.StretchDraw(0,0,iX,iY,srcImg);

  Stream.Size:=0;
  dstImg.SaveToStream(Stream,FWriter);
  Stream.Position:=0;
  Result:=true;
end;
  Except
Stream.Size:=0;
Stream.Position:=0;
Result:=false;
  end;
Finally
  FreeImageData();
end;
  end;
end;

Further, when a user views images via my preview app, I don't send the 
originals, I scale those too using the same methods.  The speed is 
killing my server's performance.


Does anyone have any idea how to speed up the underlining code?

--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Configuration file handling

2013-02-16 Thread Andrew Brunner


On Feb 16, 2013, at 2:37 AM, Reinier Olislagers  
wrote:

> 
> Security problems with world-writable files? Yes, that problem applies
> to *nix as well but Mark has given no indication his config files are
> world-writable. (Even if the logins Mark speaks of run under different
> user accounts, there's such a thing as groups on *nix, too :) )
> 

My only concern for using Ini files is invalid data because the entire Ini will 
stream out and replace the file.  If one thread has data that differs from 
another the order of writing becomes important.  If all data refers to the same 
user, make sure your data is stored in an offshoot of the appropriate sandbox.  
I think the method getAppConfigDir might prove useful if this is they way you 
decide to go...___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Configuration file handling

2013-02-15 Thread Andrew Brunner
I would not use INI if the systems are writing data.  While I've had 
plenty of success reading INI files in parallel - I seem to recall that 
the file is just streamed out without regard to which version is on 
disk.  I think the file is completely refreshed.


I recommend using a DBMS system of some sort for read/write ops in parallel.

On 02/15/2013 04:54 PM, Mark Morgan Lloyd wrote:
If multiple, related, programs running on unix (Linux, Solaris etc.) 
refer to the same configuration file accessed via a TIniFile, is there 
any recommended "good practice" to ensure that they don't try to 
update it simultaneously?


In the case that I'm thinking of, I don't anticipate e.g. multiple 
logins trying to write setup information at the same time. The more 
risky case is if there are e.g. multiple daemons or apps trying to 
save state when a UPS signals imminent shutdown.





--
Andrew Brunner

Aurawin LLC
15843 Garrison Circle
Austin, TX 78717

https://aurawin.com

Aurawin is a great new way to store, share, and explore all your content
featuring our innovative cloud social computing platform.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] fcl-db components missing from 2.6.0 (Lazarus winx64 bin inst)

2012-10-29 Thread Andrew Brunner

Hi,

I'm trying to setup a build box on Win8 x64.  I can't get Lazarus to 
compile my project.  It fails because it uses postgresql, mysql and 
oracle units.


The postgresql compiles units are missing from compiled units folder.  
The actual source is listed in the source.  Their code-tools system does 
find the unit when I hot-click the unit.


I'm going to FPC/Laz build from svn/source but I just wanted to post 
here to see what was the cause...


--
Andrew Brunner

Aurawin LLC
512.574.6298
http://aurawin.com/

Aurawin is a great new way to store, share, and enjoy your
photos, videos, music and more.

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


Re: [fpc-pascal] Subversion Client/Server Source

2012-10-24 Thread Andrew Brunner

On 10/24/2012 09:01 AM, michael.vancann...@wisa.be wrote:
Well, the http transport uses WEBDAV. So search for the WEBDAV 
protocol, and

you're set ?

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



Ok,  looking at WEBDAV and svn.  I assume svn is just file based. 
Implementing WEBDAV will enable svn client to do locking/read/write as 
needed to the actual repository on disk.


Without SVN protocol - I would have to require server distros to have 
subversion installed.


It looks like heavy XML.  It will require use the fpc-xml.  Are the DOM 
components proven to be memory leak free at this point?


--
Andrew Brunner
Aurawin LLC
512.574.6298

A safe new way to store and share your files, pictures, videos, and more.

http://aurawin.com/

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


Re: [fpc-pascal] Subversion Client/Server Source

2012-10-24 Thread Andrew Brunner

On 10/24/2012 08:36 AM, michael.vancann...@wisa.be wrote:


Why not use the library version of SVN ? This is how Tortoise does it, as
far as I know.



I think the focus then would shift to wrapping a library to hook into 
server over HTTP.  I would still need svn protocol or even maybe I could 
look at Apache svn source (C++) to port to Aurawin's HTTP server.


But where is the "Official" svn documentation for implementing svn over 
http?


--
Andrew Brunner
Aurawin LLC
512.574.6298

A safe new way to store and share your files, pictures, videos, and more.

http://aurawin.com/

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


[fpc-pascal] Subversion Client/Server Source

2012-10-24 Thread Andrew Brunner

Hi there,

I'm exploring the possibility adding support for version control in the 
Aurawin project.


I'm needing resources to subversion client/server source to estimate how 
much time it will take.


Does anyone know of official protocol for implementing SVN?

Does anyone have any contributions of SVN client/server code in pascal?

Any help is greatly appreciated,

Andrew Brunner
Aurawin LLC
512.574.6298

A safe new way to store and share your files, pictures, videos, and more.

http://aurawin.com/

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


Re: [fpc-pascal] Problems with Postgresql Character Encoding

2012-09-26 Thread Andrew Brunner

This did the trick!

I added a comment on reporting too.  I say this one is good to go.


On 09/26/2012 07:41 AM, LacaK wrote:




May be that better would be add support for PQsetClientEncoding into 
TPQConnection ... I can look at it if you want.

Patch is here http://bugs.freepascal.org/view.php?id=22985
(I did only basic testing)


-Laco.


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




--
Andrew Brunner

Aurawin LLC
512.574.6298
http://aurawin.com/

Aurawin is a great new place to store, share, and enjoy your
photos, videos, music and more.

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


Re: [fpc-pascal] Problems with Postgresql Character Encoding

2012-09-26 Thread Andrew Brunner

On 09/26/2012 04:30 AM, LacaK wrote:

Do you have tried SQL:  SET CLIENT_ENCODING TO 'LATIN1' ?
May be that better would be add support for PQsetClientEncoding into 
TPQConnection ... I can look at it if you want.

-Laco.


Hi Laco,

Thanks for the help.  Yes I did on connection I tried 
Connection.onConnected... ExecuteDirect ('SET CLIENT_ENCODING TO 
LATIN1).  It didn't help.


Failed to insert UTF8 database with a string like ' the © character test.'

Postgres wants the data to be converted... ie.) AnsiToUTF8 would get the 
data to post.


Thanks for the patch - I'm updating my FPC /Lazarus and building now...



--
Andrew Brunner

Aurawin LLC
512.574.6298
http://aurawin.com/

Aurawin is a great new place to store, share, and enjoy your
photos, videos, music and more.

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


[fpc-pascal] Problems with Postgresql Character Encoding

2012-09-26 Thread Andrew Brunner
My cloud file/folder sync client desktop app builds and maintains a 
manifest of all files and folders from a specified starting point. I use 
this manifest to synchronize disk entries across devices.  It uses HTTP 
requests and XML to carry out all transactions.  Meaning there is no 
TSQLConnection.  The problem is that the HTTP server receives the data 
as XML and refuses to post changes.  If data (in updates or inserts) 
contains non-supported UTF8 characters postgresql rejects with character 
encoding notices.


I've tried with using AnsiToUTF8 and UTF8toAnsi.  That works for email 
messages.  However, since sync code has to scan tens of thousands of 
disk files/folders I don't think it's good for battery and memory 
consumption for a background app to consume cpu resources in this case 
going between 2 forms of the same file/folder name.


I need to be able to take advantage of Postgresql's client encoding 
method.  I know postgresql allows me to tell the server that the 
connection is presently character set "LATIN1".  And presumably 
postgresql server will convert what it needs to my database encoding of 
UTF8.



SystemP^.Connection.Charset:='LATIN1';

This does nothing for me when Connection is a postgresql connection.

Anyone have any experience with postgresql character sets / encoding???

I can't hard-code any one character set because users from 1 region will 
have different encoding needs than another.


Any help, or comments is greatly needed.

--
Andrew Brunner

Aurawin LLC
512.574.6298
http://aurawin.com/

Aurawin is a great new place to store, share, and enjoy your
photos, videos, music and more.

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


[fpc-pascal] Postgresql Concurrent Transactions

2012-06-21 Thread Andrew Brunner
Hi there,

I'm seeking help to address an issue I presently have with a Server
application that uses TPostgres components.

Each manager thread has its own Connection, Transaction, and TQuery.
Each manager can handle potentially thousands of sockets
Each server instance (1 process) can have up to ~100 manager threads.

Each Manager executes socket "commands" that translate at some point, into
a Database, Select, Update, or Delete.

My current problem:
If a user updates a table by uploading large a video (say about 200+MB)
 the sql server locks pretty much every table and prevents other sockets
which during the SQL execution.  This is true for Delete and Update as of
v9.1.

Implications.  Parallel commands executed on other threads aren't able to
execute b/c the postgresql server just sits there waiting for the update
transaction to complete.   PostgreSQL is locking all subsequent calls to
even other tables.

Remediation: Memory barriers are already in place to ensure that other
threads don't access the TConnection,TQuery or other things during the
problematic transaction.  Is there a way to use specify a SHARE mode in
transactions for TPostgres component?

How have anyone who've encountered this problem solved this issue?  Any
feedback is welcome.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Darwin i386

2012-05-20 Thread Andrew Brunner
On Sun, May 20, 2012 at 8:52 AM, Jonas Maebe  The
above was a question relating to "... with the exception of threads calling
methods via synchronize (so I can debug)." I.e., what are the exact things
you are doing, what is happening, and what are the expected results
regarding trying to debug threads calling methods via synchronize (which, I
assume, works on other platforms but not on Mac OS X).

Sorry.  Kinda missed that.  Debugging heavily threaded code under linux has
proved to be difficult.  So I have developed a directive that triggers
threaded code to execute via synchronize.

I recently cleared all linux issues with a core networking engine (both
client and server) and moved to Apple to test.  On Apple I needed to step
into code that normally runs reentrant from the main thread, from other
threads, and from other threads via synchronize.

On Linux all was fine.  On Apple - I was seeing thread locking to my
network engine in client mode.  Same code, different operation system.  I
traced all the way to the signaling mechanisms in the classes unit.  The
thread went into wait infinite and never executed the method.

So instead of complaining about it here - I decided to method scheduling
system for the engine.  This way when the engine is idle it can execute
methods in its own thread space.  During debug mode I run engine
callbacks via synchronize.  On linux I get no problems.  On Apple I had
gotten tons of timeout errors and weird behavior that takes 5-10 seconds to
step over or into each line!

So I have gdb 7.4.1 from source installed and I can't test.  I may have to
revert back to gdb stock just to get back to work :)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Darwin i386

2012-05-20 Thread Andrew Brunner
>
>
> What are you doing exactly, what happens, and what is the expected result
> instead?
>

I'm upgrading my gdb from shipping version with darwin to gdb version from
download.  I downloaded and ran /configure make make install 7.1.  It
doesn't work with fpc.  I'm going to have to switch back.  The newer
versions require code signing...

warning: dsym file UUID doesn't match the one in
/Developer/Source/Builds/Aurawin/AuCloud/Apple/32/AuCloud
(no debugging symbols found)...done.
(gdb) run
Starting program: /Developer/Source/Builds/Aurawin/AuCloud/Apple/32/AuCloud
Unable to find Mach task port for process-id 62916: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb)

(gdb) run
Starting program: /Developer/Source/Builds/Aurawin/AuCloud/Apple/32/AuCloud
Unable to find Mach task port for process-id 62916: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
(gdb)

BUT: sudo gdb bypasses this problem, and the program can get past this
error but when the program launches, gdb gives

(gdb) run
Starting program: /Developer/Source/Builds/Aurawin/AuCloud/Apple/32/AuCloud
[New Thread 0x2003 of process 62922]
[New Thread 0x2103 of process 62922]
[New Thread 0x2203 of process 62922]
[New Thread 0x2303 of process 62922]
[New Thread 0x2403 of process 62922]
[New Thread 0x2503 of process 62922]
[New Thread 0x2603 of process 62922]
[New Thread 0x2703 of process 62922]
TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result
-30585
warning: dsym file UUID doesn't match the one in
/Developer/Source/Builds/Aurawin/AuCloud/Apple/32/AuCloud
(no debugging symbols found)...done.

BUT notice TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with
result -30585.  Now the main screen has no focus.  I can only close the
window :-)

Progress but I need to get gdb 7.1 to run properly on darwin.  Either that
or I gotta restore the old gdb :-(

Google "gdb" together the exact error message you are getting, and you will
> probably find instructions about what you have to do. Or more easily: just
> use fink or macports to compile/install a different gdb (macports is more
> likely to have the most recent one available), then everything will be
> taken care of for you. It's unlikely that it will help with the problem you
> are having though, because I've never heard of any problems particularly
> related to debugging multithreaded applications with the stock gdb on Mac
> OS X.
>
>
I've been.  I didn't have a problem with GCC or GDB.  I've got the latest
and greatest of both.  This is a darwin thing.  gdb can't operate properly
without root access.

I've built a system cert.  I've used codesign -s  gdb-cert ./gdb and darwin
asked for my admin creds.  So I know gdb has been signed.
I used which gdb to make sure I was in the right place to codesign.

Can you tell me how to compile fpc to make 64bit lazarus?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Darwin i386

2012-05-19 Thread Andrew Brunner
I'm having a hard time with GDB and debugging threads on a OSX 10.7.4 with
fpc/trunk

The shipped gdb worked great with the exception of threads calling methods
via synchronize (so I can debug).

I'm in the process of building GDB from download and configure set gdb to
x64 darwin.  Configure detected correctly but my gdb 7.4.1 app fails to
load with some ioctl error.  I'm assuming fpc can't compile darwin x64 yet.


I tried # gdb ./configure --target=i386-apple-darwin but I think it needs
i386 gcc compiler.

I downloaded gcc from subversion and tried to configure and it too
configures make files to x64 darwin :-(

Has anyone got the latest GDB running on darwin?  Any instructions or tips
for getting gdb 7.4 working properly?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Unicode support

2012-05-16 Thread Andrew Brunner
I wanted to ask what the present state of unicode support is now.

I'm running into problems with some various strings.  Sometimes when a
string contains a unicode character postgresql won't allow the
insert/update.  Also, some MP3 tags contain UTF16, UTF16BE and I really
don't know of the best practice on how to handle multi-byte characters in
code.

I have 3 representations of the same string for all ID3 frames for my MP3
tag reader.  I have to say - this has become an issue.

Anyone want to comment on direction of FPC for Unicode... Ie I think the
string field should be able to re-map to UTF8.  Is that something that can
be done?

What can I do to support unicode in the serving of
pages/files/documents/music without having to have encoding aware code.

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

Re: [fpc-pascal] Darwin i386 socket polling

2011-12-23 Thread Andrew Brunner
> Windows supports epoll?

No, windows doesn't offer polling socket mechanisms.  They send
messages to windows with the socket number - it's event driven.
Kernel polling is different, but I assumed that Darwin would support
it via e-Poll.  I searched and found a few references to
kQueue/kEvent.

Thanks for the help guys.

I'll check the iNet code to see the supporting units.  Anyone have a
write-up on the website for sockets and the different nuances for each
of the major oses?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Darwin i386 socket polling

2011-12-22 Thread Andrew Brunner
I'm needing to figure out how socket signaling mechanisms work under darwin.

Windows and Linux work, Darwin however does not support ePoll.

Anyone have any experience with Sockets events under OSX i386?

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


[fpc-pascal] Distributing unit object files

2011-12-15 Thread Andrew Brunner
I'm needing to figure out how best to "close" or "seal" units so that
I can use the compiled unit object files instead of the actual unit
files.

The problem is that the compiled unit files call a few units that the
project has the source to.  And FPC is looking to recompile the
compiled object file because a CRC has changed for a contributing unit
that was used when the unit object file was created.

How do I make FPC not rebuild the unit object file when contributing
units to the compiled unit have been modified? What is the best
strategy - if at all?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] web app and application persistency

2011-08-01 Thread Andrew Brunner
The only thing I can think of would be packet inspection.  Firewalls
included with Linux and Windows do not perform "deep" packet
inspection.  They only allow/deny packets with specific ports over
either TCP or UDP.

Am I missing something?

On Mon, Aug 1, 2011 at 12:31 PM, Michael Van Canneyt
 wrote:
> Any reason why it should not detect it ?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] web app and application persistency

2011-08-01 Thread Andrew Brunner
On Mon, Aug 1, 2011 at 12:05 PM, Michael Van Canneyt
 wrote:
> ..But it is not always supported by the browser (as Marco indicated)
> and many firewalls simply don't agree with websockets.
>

Can  firewalls detect websockets over port 80?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] web app and application persistency

2011-08-01 Thread Andrew Brunner
On Mon, Aug 1, 2011 at 10:43 AM, Felipe Monteiro de Carvalho
 wrote:
> On Mon, Aug 1, 2011 at 5:23 PM, Andrew Brunner
>  wrote:
>> I agree with this one.  The only thing I could add would be AJAX &
>> WebSockets for really advanced applications.
>
> Do WebSockets allow to use TCP sockets in JavaScript or is it something else?

WebSockets are persistent connections that never close unless
directed.  Plus the server can push data over the socket and the
client can process data on an event basis.

HTTPRequest is query response.   WebSockets is asynchronous and
perfect for event driven programming over the web.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] web app and application persistency

2011-08-01 Thread Andrew Brunner
On Mon, Aug 1, 2011 at 10:07 AM, Gustavo Enrique Jimenez
 wrote:
> Hi:
>
>  I send cookies to the client. One of those cookies is a "sessionID",
> a random number generated at login.
>  My sequence is something like
>
> Login
> Client: username/password ->Login html button
> Server: run cgi app with username/password parameters -> ¿Valid user?
> ->  generate sessionID, store in DB. Send sessionID to the client as a
> cookie.
>
> Transaction
> Client: Product -> Search product html button (sessionID is also sent
> to the server)
> Server: run cgi app with product/username parameter. sessionID is
> implicit, as any cookie. if username/sessionID from the client is the
> same as in the DB, send data to the client.
>
> The sessionID cookie will remain until logout or expire time. This
> way, you don't have to store password in html. The sessionID cookie
> must be random+hash, unique to every session. sessionID is sort of
> temporal password.
>
> Cliente: username  -> Logout html button
> Server: run cgi app with username/sessionID. Verify
> username/sessionID, then send an empty sessionID cookie (this will
> delete the sessionID cookie in client)

I agree with this one.  The only thing I could add would be AJAX &
WebSockets for really advanced applications.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Javascript in Desktop Applications

2011-02-07 Thread Andrew Brunner
Hmmm...  Mozilla is open source... :-)  We are free to port the
Scripting Engine to Pascal as long as we have the source? no?

On Mon, Feb 7, 2011 at 11:31 AM, Michael Van Canneyt
 wrote:
> No, that project embeds mozilla in FPC.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Javascript in Desktop Applications

2011-02-07 Thread Andrew Brunner
On Mon, Feb 7, 2011 at 10:39 AM, Brian Winfrey  wrote:
>
> I have some interest in exploring javascript implementations for fpc.
> http://code.google.com/p/fpcjs/  -- Is this comparable to what you have noted?

Actually fpcjs is the first project that I, (myself), have seen that
addresses the gateway issue of accessing application level methods.
Granted fcpjs (currently) only supports one type of callback(variant
array):variant.  The only issue I see is having a quasi fpc/js design
restriction in developing apps with no OOP - coding low-level linear
methods(for register) with maps to JS object counterparts.  The other
MAJOR issue is that callbacks via Register are not working on Linux
!?!.   Docs said they needed something about native registration.  But
this project looks lightweight enough on its face.

I'm at a point in my project where I think I am needing something like
this.  In an ideal world, any application level scripting engine
should know how to interface with FPC objects @ runtime w/o variants.

Currently, my largest problem is  because without things like scripting :
  * Admins must rebuild the service exe every time back-end objects
are modified.
  * Production environments where each binary is installed on a
different device across the network cluster(s)/node(s) will have
different versions.
  * Auto-build or auto-updates via distribution system will most
likely lead to problems for either us or for Admins during deployment.

The use of a scripting engine would resolve these problems.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Javascript in Desktop Applications

2011-02-07 Thread Andrew Brunner
On Mon, Feb 7, 2011 at 7:35 AM,   wrote:
> A cross-platform solution is to use one of libsee or BESEN.
>
> The latter is implemented in 100% native Object Pascal.
>
> Michael.

BESEN is very, very, very  well written but I can't seem to get any
indication how to use it in my project.  I would love FPC to include a
JIT system for JS or Pascal.  IMO, FPC absolutely needs a scripting
FCL going forward.  BESEN seems like the right guy for the job, but I
suspect he's burned out :-(  I think he had memory concerns too.

Does anyone have any BESEN examples that integrated actual FPC units?
It seems like all the samle js units are self contained with no
interface to system or GUI units.

Including JS support on my project would enable people to leverage
exiting "proven" technologies which would make for easier/allowable
for adoption in working groups / houses where selection of language is
restricted to language of the day :-)  Taking this statment and
applying this across the board, it would be an easier sell for
adoption of FPC/Lazarus with JIT support.  Personally, I'm thinking
along the lines of Web RAD down the road...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Pascal Scripting Engines

2010-12-10 Thread Andrew Brunner
I think FPC in general could benefit from a native FPC script.  They have a
link to a port of REM objects but the website said it was with flaws and
tests were needed under linux.

A light-weight scripting engine would need to be restricted to methods and
object code.  And perhaps some level of access to the networking engine each
script would be called from.

IMO, the scripting engine would either be completely thread safe or would
have to have multiple instances one per thread.

Do you still have your code?  I wonder if the FPC memory manager could
handle such an engine running over and over again without losing memory.


On Fri, Dec 10, 2010 at 1:27 PM, Jorge Aldo G. de F. Junior <
jagf...@gmail.com> wrote:

> I once wrote a script engine that generated bytecodes.
>
> At the time it was harder due to defective variants support (something
> like that).
>
> Now it would be easier.
>
> 2010/12/10 Andrew Brunner :
> > Hi there,
> >
> > I'm considering pascal scripting engines in stead of hot-swaped compiled
> > stored objects/dlls for server back-end development for clients (namely
> > WebSocket/JS).  I came across a few relatively recent solutions and
> wanted
> > to know if there are any obscure "light weight" scripting engines but yet
> > leverage byte code.  My largest problem would be security though.  I
> would
> > want to limit script engine access to OS level calls.  I need to be able
> to
> > "sandbox" these back-end apps so they don't interfere with the server
> > process.
> >
> > Any thoughts/recommendations?  Thanks.
> >
> > ___
> > fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> >
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Pascal Scripting Engines

2010-12-10 Thread Andrew Brunner
Hi there,

I'm considering pascal scripting engines in stead of hot-swaped compiled
stored objects/dlls for server back-end development for clients (namely
WebSocket/JS).  I came across a few relatively recent solutions and wanted
to know if there are any obscure "light weight" scripting engines but yet
leverage byte code.  My largest problem would be security though.  I would
want to limit script engine access to OS level calls.  I need to be able to
"sandbox" these back-end apps so they don't interfere with the server
process.

Any thoughts/recommendations?  Thanks.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Cannot build FPC from SVN

2010-11-29 Thread Andrew Brunner
Bootstrapping from Ubuntu 10.10 and rebuilding from SVN got past the
problem.  I guess that an evolutionary dead end with some bad revision
caused this problem...

Anyways.  I'm back up and running.

On Mon, Nov 29, 2010 at 8:15 AM, Jonas Maebe wrote:

>
> On 29 Nov 2010, at 15:09, Andrew Brunner wrote:
>
>  FE. -FU/Developer/Source/Compilers/FPC/rtl/units/x86_64-linux -Cg -dx86_64
>> -dRELEASE ../objpas/fgl.pp
>> fgl.pp(128,38) Error: Generics without specialization cannot be used as a
>> type for a variable
>>
>
> http://lists.freepascal.org/lists/fpc-devel/2010-November/023155.html (and
> the rest of the thread).
>
>
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Cannot build FPC from SVN

2010-11-29 Thread Andrew Brunner
Hi Jonas,

I use svn/trunk to build FPC.  I bootstrapped  a a few months ago Ubuntu
10.10 betas/release  but I've been using 2.5.1 for over a year now seeded
with what ever came with Ubuntu 10.10 distro (But that was months ago).

Presently I don't  how I'm not using 2.5.1 to build current FPC but there
maybe remnants of Ubuntu's deb install somewhere in links, but why all of a
sudden this problem?

When I type fpc from any path I get

Free Pascal Compiler version 2.5.1 [2010/11/29] for x86_64
Copyright (c) 1993-2010 by Florian Klaempfl
/usr/lib/fpc/2.5.1/ppcx64 [options]  [options]

I'll go read that thread...

On Mon, Nov 29, 2010 at 8:15 AM, Jonas Maebe wrote:

>
> On 29 Nov 2010, at 15:09, Andrew Brunner wrote:
>
>  FE. -FU/Developer/Source/Compilers/FPC/rtl/units/x86_64-linux -Cg -dx86_64
>> -dRELEASE ../objpas/fgl.pp
>> fgl.pp(128,38) Error: Generics without specialization cannot be used as a
>> type for a variable
>>
>
> http://lists.freepascal.org/lists/fpc-devel/2010-November/023155.html (and
> the rest of the thread).
>
>
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] Cannot build FPC from SVN

2010-11-29 Thread Andrew Brunner
svn 1645

FE. -FU/Developer/Source/Compilers/FPC/rtl/units/x86_64-linux -Cg -dx86_64
-dRELEASE ../objpas/fgl.pp
fgl.pp(128,38) Error: Generics without specialization cannot be used as a
type for a variable

This has been stopping the build process for a few days now.  Anyone know
about it or is this my problem?  I tried deleting all FPC units and
re-checked out from SVN but still same error.

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

Re: [fpc-pascal] Leak narrowed down

2010-10-28 Thread Andrew Brunner
>> Then, once the program is running and has leaked memory, run
>> leaks nameofyourprogram
>
> Thanks for this tip! It is very interesting, however in this situation
> it does not detect the lost memory.
>
> At this point I have to give up on GetTextWidth - I will avoid it for
> now. Maybe next year the problem can be solved. I will send a note to
> the Lazarus list and submit a bug report, provided I can confirm the
> issue with a minimal testing program.

There are two instances in the past that I had with working with
GetTextWidth to the point where I started with Delphi's canvas and
traced into their code and derived my own from theirs.  If you are
needing the feature then compile FPC with DEBUG=1, recompile Lazarus
with DEBUG=1 (I think), then trace into the LCL/FPC code and take a
look around.

It could be with the string it could be with the Device Context used
to draw the text and see its width.  It could be the Handle to the
font object not being de-allocated.  Do you use try handling with
finally SetLength(Str,0)?

If you place a counter inside that routine, how many times is it
called?  That may help too.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: PostgreSQL 8.4 Ubuntu 10.10 x64

2010-10-22 Thread Andrew Brunner
On Fri, Oct 22, 2010 at 2:44 AM, Martin Schreiber  wrote:
> The problem is in TypeStrings, ftLargeInt should return 'bigint' instead
> of 'int'. Fixed in MSEide+MSEgui trunk 4028.
> http://developer.berlios.de/svn/?group_id=11520

Thanks Martin!

> Interresting, MSEgui is used in production since years with PostgreSQL,
> Firebird, MySQL and Sqlite3, nobody ever reported the bug...

Well the only way to reveal the flaw was to exceed integer range, for
most smaller that would be improbable.  The project I have here uses
large indexes and many identifiers.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] PostgreSQL 8.4 Ubuntu 10.10 x64

2010-10-21 Thread Andrew Brunner
I've got a problem with the PostgreSQL component.  I've got an insert
statement with int64 values.  The prepare command goes through but the
server denies the entire packet with the string value of the int64 is
too large for integer type error.

The fields were all declared as bigint and the parameter binding
happened as LargeInt.  This worked on MySQL but I'm sure everything is
working on my end.  Anyone have problems with using Int64 types and
insert?

Report as bug?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Building FPC with debug information

2010-10-20 Thread Andrew Brunner
Yes.  It's what I saw. I was still able to trace database components
line by line using Lazarus and GDB though.

On Wed, Oct 20, 2010 at 12:54 PM, Brian Winfrey  wrote:
>> make OPT="-O-" DEBUG=1 all
>
> When I ran this I see that both -dDEBUG and -dRELEASE are passed on
> the fpc command line.  Is that correct?
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem accessing Class Method with abstraction

2010-10-17 Thread Andrew Brunner
procedure VerifyIDs(Var Module:TDBMSModule);
var
  iLcv:integer;
  ItemP:PCoreObjectItem;
  coGeneric:TPersistentClass;
  coItem:TCoreObject;
begin
  for iLcv:=0 to High(CoreObjectItems) do begin
ItemP:=CoreObjectItems[iLcv];
coGeneric:=GetClass(ItemP^.ClassName);
if (coGeneric<>nil) and coGeneric.InheritsFrom(TCoreObject) then begin
  coItem:=coGeneric.Create as TCoreObject;
  Try
coItem.VerifyIDs(Module);
  finally
FreeAndNil(coItem);
  end;
end;
  end;
end;

This code works as expected but why do I need to create an instance of
the object if I just want to reference it's class procedure of
VerifyIDs?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problem accessing Class Method with abstraction

2010-10-17 Thread Andrew Brunner
On Sun, Oct 17, 2010 at 3:33 AM, Michael Van Canneyt
 wrote:


// Revised code

CCoreObject=Class(TCoreObject);
TCoreObjects=class;
TCoreObject=Class (TPersistent)
 protected
   class procedure VerifyIDs(var Module:TDBMSModule); Virtual; abstract;
 end;
 TAdminCore=Class(TCoreObject)
 protected
   class procedure VerifiyIDs(var Module:TDBMSModule); override;
 end;

procedure TCoreObjects.Load;
var
  iLcv:integer;
  coGeneric:TPersistentClass;
  ItemP:PCoreObjectItem;
  coItem:TCoreObject;
  id:IStringsAdapter;
begin
  if FInfo.Loaded then exit;
  for iLcv:=0 to High(CoreObjectItems) do begin
ItemP:=CoreObjectItems[iLcv];
coGeneric:=GetClass(ItemP^.ClassName);
if (coGeneric<>nil) then
  Add(iLcv,coGeneric);
  end;
  FInfo.Loaded:=True;
end;

procedure TCoreObjects.Add(iCoreItemIndex:integer; Item:TPersistentClass);
var
  iIndex:integer;
  coItem:TCoreObject;
begin
  if Item.InheritsFrom(TCoreObject) then begin
coItem:=Item.Create as TCoreObject;
iIndex:=Add(coItem);
Copy(CoreObjectItems[iCoreItemIndex]^,coItem.Header);
coItem.OwnerP:=...@finfo;
coItem.Initialize;
  end;
end;



procedure VerifyIDs(Var Module:TDBMSModule);
var
  iLcv:integer;
  ItemP:PCoreObjectItem;
  coGeneric:TPersistentClass;
  coItem:CCoreObject;
begin
  for iLcv:=0 to High(CoreObjectItems) do begin
ItemP:=CoreObjectItems[iLcv];
coGeneric:=GetClass(ItemP^.ClassName);
if (coGeneric<>nil) and coGeneric.InheritsFrom(TCoreObject) then begin
  // coItem:=coGeneric as CCoreObject; // did not compile
  coItem:=TCoreObjectClass(coGeneric); // Compiles
  coItem.VerifyIDs(Module); // SIGEV
end;
  end;
end;

It's crashing with SIGEV error.  I think b/c at that point the class
reference becomes a TCoreObjectClass with pointer to abstracted method
not the TAdminCore.VerifyIDs method.

Take TCoreObjects.Add(iCoreItemIndex:integer; Item:TPersistentClass);
for a point of discussion...  It has no problems loading and creating
instances of descendant core objects as they are presently running and
referenced throughout the project.  So while this method accepts the
as TCoreObject the as keyword does not work for class references.  How
can I leave these class references as generic but yet still access the
implmented method of the descendant class?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Problem accessing Class Method with abstraction

2010-10-16 Thread Andrew Brunner
I've got a class factory problem I'm trying to resolve and it appears
I'm at a point where it's probably better to ask for help.

  TCoreObjects=class;
  TCoreObject=Class (TPersistent)
  protected
class procedure VerifyIDs(var Module:TDBMSModule); Virtual; abstract;
  end;
  TAdminCore=Class(TCoreObject)
  protected
class procedure VerifiyIDs(var Module:TDBMSModule); override;
  end;



procedure VerifyIDs(Var Module:TDBMSModule);
var
  iLcv:integer;
  ItemP:PCoreObjectItem; // Just record storing classname to load and
(each core object implment is loaded just not detailed here for
simplicity)
  coGeneric:TPersistentClass;
  coItem:TCoreObject;
begin
  for iLcv:=0 to High(CoreObjectItems) do begin
ItemP:=CoreObjectItems[iLcv];
coGeneric:=GetClass(ItemP^.ClassName);
if (coGeneric<>nil) and coGeneric.InheritsFrom(TCoreObject) then begin
  coItem:=coGeneric as TCoreObject << COMPILER ERROR :-(
  TPersistentClass(coItem):=coGeneric; << Compiles but get Runtime Error
  coItem.VerifyIDs(Module); < CRASH @ RUNTIME
end;
  end;
end;

How can I get each class's implement of VerifyIDs to get called as
each one is different but yet single.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-16 Thread Andrew Brunner
On Sat, Oct 16, 2010 at 2:16 PM, Michael Van Canneyt
 wrote:

> It would allow me to write programs that are multithreaded and don't use
> external libs.

Right.  Every interface between the kernel space and user space add at
least one degree of inefficiency.  So every FPC program would be
carrying at least one extra point of interface into the kernel.  And
when you scale these systems out they are clearly noticeable.

> And yes, they do exist. Not GUI, but server apps. Now, the only dependency
> is often libc for the threads.

GUI apps would for realtime reporting and analysis.  GUI apps using
graphical representations would most likely use OpenGL or DirectX to
represent that much data in a way that is intelligible.  Otherwise the
calculations would need to be pushed off to another process or
hardware device using IPC or something internal.

> There is a clear target: FPC programs without external libs, capable of
> multi-threading and thread synchronization, which basically means:
> - Ability to create threads.
> - Ability to use mutexes across threads.
> - Ability to use semaphores.

Exactly +3.  Desktop computing and dashboards are big.  Getting people
to use Lazarus and FPC should be easy with some SEO with links to
sample "engines".

> It's not because you don't see the value, that other people don't. So at
> least, please don't stop them from trying to go somewhere, even if you don't
> want to go there.

Exactly.  Important point.  It's real easy to get discouraged.
Especially when most of this work is contributed.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC for High Performance Computing (HPC) Components with Application API

2010-10-16 Thread Andrew Brunner
On Sat, Oct 16, 2010 at 2:16 PM, Henry Vermaak  wrote:

> libpthread.so is the name of the library, not the name of the implementation.

I updated FPC from SVN and it is pointing to this library now :-).
Only problem is someone took some changes I made to remove semaphore
on thread creation... If I would have known someone was going to
commit those changes I would have taken the time to move FSEM into a
block where createsuspended was true this way it wouldn't have event
effected others who need that barrier :-)

>> Ok. You mentioned NPTL.  What can you tell me about that?  Is that the
>> project that makes pthreads?
> http://en.wikipedia.org/wiki/Native_POSIX_Thread_Library

This was interesting "There exists a tracing tool for NPTL, called
POSIX Thread Trace Tool (PTT). And an Open POSIX Test Suite (OPTS) was
written for testing the NPTL library against the POSIX standard. "

^^^ Could this possibly be a solution or a lead in to getting GDM-GDB
to stop locking up on entry to breakpoint?!?  I know debugging threads
is nearly impossible under Linux (at least with GDB and Ubuntu)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC for High Performance Computing (HPC) Components with Application API

2010-10-16 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 5:10 PM, Henry Vermaak  wrote:

> I've told you before: NPTL is part of the glibc sources.  Download the
> latest glibc sources and look in the nptl directory.  The latest glibc
> release is 2.11.2.

FPC source to cThreads unit and the thread manager associated with
threading under linux presently calls a pthreads.so object.  When I
did my research I thought I was correct in making an assumption that
pthreads.so would require a pthreads project with it's own make file
;-) That is the latest and greatest pthreads project which is now
associated with glibc.

> pthreads is the standard, not the implementation.  The current most
> widely used implementation is called NPTL.  Your link points to
> LinuxThreads (judging by the name, I didn't download):

pthreads is not the standard.  pthreads.so is the implementation of
POSIX thread specification to be precise :-)

Ok. You mentioned NPTL.  What can you tell me about that?  Is that the
project that makes pthreads?

I'm looking to get the latest and greatest source of posix threads so
I draw upon that code and perhaps even come up with a native version
for FPC.  Any help would be greatly appreciated.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-16 Thread Andrew Brunner
On Sat, Oct 16, 2010 at 7:04 AM, Jonas Maebe  wrote:

> He cannot. If freeonterminate=true, then even if you call "inherited
> create(false)" as the very last statement of your constructor, the thread
> may already have finished running and freed itself before AfterConstruction
> is called. The AfterConstruction call will then crash.


Right.  I think that it would have been totally acceptable due to the
nature of threads especially on differing os(es) to not have
AfterConstruction because of this very issue.

The fact that threads can zip through their execute event and self
terminate before the AfterConstruction is even called is definitely an
issue that can only be solved with synchronization of some sort.
Threads are a special case where these objects themselves represent a
kernel process with its own distinct timeline.  Logically, performance
cannot be a priority when requiring synchronization of differing
timelines.

But for small projects where Delphi offers TThread with these
features, it is good for FPC to accommodate Delphi source.  There is
always going to be a demographic  who will never need performance and
performance is not much of an issue for projects with < 1000 threads
to the observer.

IMO, it would be better to leverage the present performance condition
to muster support for a high performance thread component set.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC for High Performance Computing (HPC) Components with Application API

2010-10-15 Thread Andrew Brunner
Do you have a link to the latest version of pthreads?

It was my understanding that libc took over the pthreads project.  I
just took up this issue a few days ago so I recognize my info may be
stale or even wrong.


On Fri, Oct 15, 2010 at 4:19 PM, Henry Vermaak  wrote:
> On 15 October 2010 21:24, Andrew Brunner  wrote:
>> Suggested Reading:
>>   http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.3.6.tar.gz
>
> Why would you want to look at this?  It's not used any more (except
> for really old kernels).
>
> Henry
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] FPC for High Performance Computing (HPC) Components with Application API

2010-10-15 Thread Andrew Brunner
I wanted to start a discussion based on current state of FPC and High
Performance Computing (HPC).

The premise of the thread is to discuss high scale threads.  Currently
FPC has matured to the point where it might be beneficial to start
targeting a particular market for users.  The first thing that comes
to mind is the university community where coding is second to theory.
Pascal offers ease of code readability and in turn brings the ability
to easily organize scientific formulas into computer code that when
arranged properly can be executed in a high scale environment,
delivering faster, near instant or instant results.

After reading a few responses in a separate discussion regarding
threading I came to realize that some work remains to FPC with regard
to High Performance Threading.  FPC is advanced in that it offers
native cross platform access to kernel threads.  FPC however, on
Linux, relies on a libc Posix Threads (pthreads) library that is a
widely adopted implement of the POSIX specification.

Microsoft has spent a lot of resources on parallel computing and it
may be beneficial for the FPC project to at least begin to explore the
possibility of FPC to be used in a professional high performance
environment.

IMO - it may be smarter to develop of a new threading paradigm.  A HPC
threading system that addresses issues with waitfor/suspend/resume and
resolve them for *nix/windows/mac but do so knowing that there are
most likely tens of thousands of threads running.

I would like to offer my commitment to this issue since FPC is ideal
for real-time computational engines.  With regard to HPC, the native
TThread object has been implemented (under *nix) with redundant
barriers in creation, suspend, and resume features.  This redundancy
makes for slow thread creation times and as such is not ideal as is.

Re-writing the current TThread implement may not prove nearly
impossible as is, because under windows Resume/Suspend Thread is
merely an API kernel call and *nix has no such API.  Even if we were
to re-write the TThreads unit to remove dependency on the pThreads
library, we would still be stuck with creating a semaphore under
linux, one per thread instance to gain Suspend/Resume functionality.

Suggested Reading:
   http://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.3.6.tar.gz
   http://openmp.org/wp/openmp-specifications/
   http://www.gnu.org/software/libc/
   http://msdn.microsoft.com/en-us/concurrency/default.aspx

Anyone interested in consulting or helping?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 12:01 PM, Vinzent Höfler
 wrote:

>> Exactly.  It was poor implementation.  You should have had a global
>> barrier onExecute.  That would unlock the thread after everything you
>> needed was readable.
>
> If it's global, it would unlock *any* thread at that time.

Yes, belonging to a system with of collection of said threads where
"managing" system oversees
any worker threads.

> Sure, it's not the optimum design. But using one global barrier each
> thread could block each other on creation, potentially introducing
> excessive context switches. Which is not optimal, neither.

Ok.  Say a project manager is looking to give FPC a try for a highly
scale system that requires managing
1 million concurrent operations across say 30,000 threads.  Say it's a
10 core system with 32Gigs ram.  The first thing they are going to do
is compare a general case with TThreads.  As is - it's slow as crap.
They aren't going to want to re-implement the threading system.  They
aren't going to take FPC seriously as a viable compiler for parallel
computing.

Pascal offers people the ability to quickly read what they are seeing.
 IMO, FPC would be a great solution.  But with so many competing
platforms and with M$ literally pumping millions into their parallel
computing platform... Hey... It's probably worth just going with the
compiler du jour ;-)

> Maybe it's less expensive, yet this blocking is actually required.

It is not required if threading is implemented that ALREADY has a
barrier in this case see pthreads source. It does.

>IMO, the problem is neither FPC nor pthreads,
> the problem is the required semantics of TThread.

The problem is not with TThread.  The problem is with Suspend and
Resume features.

> The faster alternative is bound to fail with "FreeOnTerminate := True".

How did you draw this conclusion?

> Perhaps - instead of looking into the pthreads library - you should
> better take a look at the TThreads implementation and try to understand
> *why* all the code there actually *is* there.

I'm going to look at severe linear inefficiencies.  That is my nature. :-)

> Yeah, right. Creating the semaphore to wait in the execute method is
> bound to be faster than creating it before thread creation. Sure.

LOL.  Again, how in the world did you make the assumption, especially
given all the code I put out there regarding a manager overseeing all
the threads, that I would create a semaphore inside a worker thread's
execute body?  Did you read the uThreads.pas unit for this discussion?

> Yes. But if you prefer crashing the application in favor of speed just
> use C. :->

I would most likely prefer objective-c.

>> IMO, cThreads has a lot of RFI. (Room for improvement).
>
> No. TThread has. Last time I looked into CThreads it was a more or
> less thin binding to the pthreads API.

TThread has RFI.  But are you then suggesting you want to improve w/o
using libc !?!
IMO, using whatever we can would be great.

 There is no need to block the thread from execution.
>>> Actually there currently is. Otherwise you ask for trouble.

We're going to disagree here.  It's just that simple.  If you found
yourself in the ranks with developers saying "What would anyone need
30,000 threads" camp, please ignore this entire discussion.  I beg
this with authority :-)

> Try calling pthread_destroy() with an uninitialized handle. Maybe
> that changes your way of thinking.

No, I pretty much question EVERYTHING.

> Oh, great. That probably was never done before. Sorry for my sarcasm.

My question is... Sorry to whom?

> *What* barrier?

Seriously?  There are four possibly five (depending on prospective)
barriers mentioned in the course of this entire discussion.  List them
and I will be able to oblige.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 11:03 AM,   wrote:
> On Fri, 15 Oct 2010 17:24:03 +0200, Sven Barth
>  wrote:
>
>> The problem isn't the pthreads library. The problem is the POSIX threading
>> specification of which pthreads is an implementation (look at the comment in
>> CSuspendThread again).
>
> Actually, it's not even a problem. Externally suspending a thread is
> inherently unsafe and should not be done at all.
>
> If you'd do *that* would be the problem (yes, I know that there are
> possible use cases, but these are negligible).
>

Externally suspending a thread *IS* absolutely unsafe.  But the notion
of suspending an ENGINE at runtime externally is totally expected.
The thread itself MUST put itself in a suspended state.

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


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 10:57 AM, Vinzent Höfler
 wrote:
>
> Huh? Why should the pthreads library have a semaphore or similar on each
> thread?

Good question.  And according to pThreads source comments they
themselves did unwillingly.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 10:57 AM, Vinzent Höfler
 wrote:

> If you access it inside the execute method, you more or
> less crash (or at least leak memory).

You obviously had a problem with access ThreadID before it was assigned.
Accessing it should not arrive at a RAV.  I'm not sure this is on topic...

> It took me a couple of days to find the reason for our application
> crashing and I believe that was fixed quite a while ago. (Somewhere
> around 2.0.4, IIRC). Jonas may remember.

> Excerpt from the workaround I had written then:

>      //-- Overwritten to ensure it starts in suspended state,  woken up
>      //-- by @link(AfterConstruction) a little moment later.
>      constructor Create;

Exactly.  It was poor implementation.  You should have had a global
barrier onExecute.  That would unlock the thread after everything you
needed was readable.  See my project attached a few emails back.  It
demonstrates how things should be done with threads.  Now - fpc
carries one private barrier per thread instance.

Developers of FPC should not always blame the development platform.
They are sometimes going to need to redirect an issue back onto the
developer.  But I do recognize this is a delicate issue.  But slowing
us all down for issues such as these...

Perhaps a wiki article on how to get threads to wait during execute
would have an easier fix.  And I'm sure a 100 people too would have
problems.

But I make a case, that slowing down the entire platform for those who
need help getting threads to synchronize makes for a poor movement
collectively.  Perhaps a plethora of examples could help.


> A similar workaround got into FPC a while later and it *was* for a
> good reason: Safety.

Anyone can make safety an issue.  IMO, cThreads has a lot of RFI.
(Room for improvement).

>> There is no need to block the thread from execution.
>
> Actually there currently is. Otherwise you ask for trouble.

I disagree.  Completely.  But that's just because I'm not tied to any
one way of thinking.

>> That is unless they are asking to have it
>> suspended on creation.  And if that is the case... We need to tie into
>> PThread's Semaphore or Event or CriticalSection and exploit that.
>
> What do you want to tie into there?

I reviewed the pthreads code.  BTW: pthreads is what FPC uses to
implement threading.  The barrier may be accessible therby eliminating
the need for an additional instance being created inside TThread.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 10:24 AM, Sven Barth
 wrote:
> The problem isn't the pthreads library. The problem is the POSIX threading
> specification of which pthreads is an implementation (look at the comment in
> CSuspendThread again).

POSIX is just like you say a specification.  Suspend and Resume is a
feature.  There are many ways to implement a feature such as suspend
and resume.  A semaphore is one way.  Unfortunately, because FPC uses
PThreads and PThreads uses libc FPC apps get slow during a high scale
thread creation process where a barrier is required.

I was able to work around not having an RTLEvent per thread to bybass
in this case, but other cases will come where I need to have events or
signals going to each thread.  And if a semaphore is created for each
thread object over each "layer" to implement you can see these
inefficiencies compound.

If we go native, at lease we can share the 1 semaphore that is needed
to introduce suspend and resume features.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 10:06 AM, Jonas Maebe  wrote:

> First of all, if you use tthread.create(true) (i.e., create a suspended
> thread), then the "execute" method will never be called:

BTW: I did notice that the semaphore was being used to suspend the
thread.  And I also know that that was it's only function... Suspend
and Resume.  At this point I would suggest we can do one of two
things:

1.) take pthreads and re-build with access to a semaphore that it
probably has (again I assume) or call method to trigger same
functionality to suspend thread via pThreads.

or

2.) take pthreads and port line by line into FPC so we make calls to
either kernel or libc.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 9:55 AM, Sven Barth  wrote:
> Am 15.10.2010 16:31, schrieb Andrew Brunner:
>>
>> On Fri, Oct 15, 2010 at 9:24 AM, Jonas Maebe
>>  wrote:
>>>
>>> You replaced a bunch of semaphore create/lock/unlock/destroy operations
>>> with
>>> calls to a function that does not do anything.
>>
>> I did not.  I REMOVED create/destroy/lock/unlock.  I ADDED calls to
>> the ThreadManager's own functions for thread Resume and Suspend.  Did
>> you try executing the suspend command?  What happened?
>
> What do you believe happens with a thread when you execute a function that
> only returns "dword(-1)" and does nothing else? :)
>
> Take a look at Jonas code excerpt from "rtl/unix/cthreads.pp" again and
> you'll see that the call to "pthread_kill" in CSuspendThread is disabled and
> has a big comment before it.
>
> Regards,
> Sven

Now that is funny.  I guess I made the assumption that the call the
Pthreads Suspend thread would actually do what is advertised, at lease
on good faith...

Who else has the source to PThreads?  Anyone care to read it over?  I have it.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 9:24 AM, Michael Van Canneyt
 wrote:
>
> Thank you,
>
> I'll study it to see if/how we can do something to increase speed of
> creating threads
> in FPC.
>
> But if I understand you correctly, the WRITE_MEMORY_BARRIER() call is
> beyond our reach, so there's little we can do about that.
>
> Michael.
>

Thanks for all your help too!  I'm just wanting a really stable
program executable.  My goal is to make sure FPC is stable and fast as
possible under Linux.  So any "tire kicking" I do is for the benefit
of FPC - nothing else.

It was also suggested that PThread's Suspend and Resume may not do
anything.  What I would do (if that is the case), is try to find where
PThread has access to the Semaphore  or CriticalSection it has on that
thread... If you could tie into that system, you would be able to not
have that extra inefficiency of the FPC Semaphore (and any the creator
of TThread may have).  All these barriers add serious inline time.

IMO. You must assume that all variables of the TThread descendant have
already been assigned and are valid.  There is no need to block the
thread from execution.  That is unless they are asking to have it
suspended on creation.  And if that is the case... We need to tie into
PThread's Semaphore or Event or CriticalSection and exploit that.
It's going to lead to a really significant gain for TThread.Create.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 9:24 AM, Jonas Maebe  wrote:
> You replaced a bunch of semaphore create/lock/unlock/destroy operations with
> calls to a function that does not do anything.

I did not.  I REMOVED create/destroy/lock/unlock.  I ADDED calls to
the ThreadManager's own functions for thread Resume and Suspend.  Did
you try executing the suspend command?  What happened?

> That barrier has nothing to do with "set values of variables before calling
> the inherited create method to their own creation" (although it's not
> entirely clear to me you mean by that). If you set values that the child
> thread will read after that thread has already been created, this memory
> barrier will not help either. That barrier is again about memory write
> ordering, which could cause the newly started thread to not see all writes
> performed by the parent thread *before* creating the child thread.

Other than waiting for the values to be committed, I just don't see it's value.

> And the reason that's it's probably not required, is because there's so much
> code in between that it's unlikely that any of those writes would still be
> outstanding at that point. It's not "for the few that don't understand how
> to create a thread".

Exactly.  The other code being what?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] What are the issues involved in threads sharing variables?

2010-10-15 Thread Andrew Brunner
On Fri, Oct 15, 2010 at 5:20 AM, Frank Church  wrote:
>
> I am writing an app involving 2 threads, and a timer loop in the UI.
>
> The first thread monitors network events, logs them into a database, appends
> them to a list.
>

Any time I see append to a list I always think "RTLCriticalSection"

> The second thread monitors the list, checks the events and updates a data
> structure, which is used by a timer loop in the main application to update
> the UI.
>
> What are the issues involved in making sure that the 2 threads don't
> conflicted over access to the list?
> This is my first foray into using threads that share memory structures.
>

You have to protect the list from access by other threads.  CritcialSection
is the only way
InitCriticalSection - Creates it
DoneCriticalSection  - Frees it
EnterCriticalSection - Locks list
DoneCritiicalSection - Unlocks list

Example

EnterCriticalSection(FLock);
Try
  FList.Add(EntryP);
Finally
  LeaveCriticalSection(FLock);
end;

Polling where the list size is highly dynamic you will need protect
it.  I think FPC has thread safe list objects too.

See the FPC rtl.pdf documentation on TThreadList
2.63.1
TThreadList
Description
TThreadList is a thread-safe Tlist (307) implementation. Unlike TList,
it can be accessed read-
write by multiple threads: the list implementation will take care of
locking the list when adding or
removing items from the list.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-14 Thread Andrew Brunner
> What are the exact differences from this test to your last one? Would be
> nice to know that... :)

Every barrier causes a significant increase in time.  In high
performance parallel computing time is something we minimize.  Big
reductions in linear execution yield massive performance gains in the
parallel environments.  So when I removed the FPC barrier that gave me
a significant increase in performance.  I also used the parent's
RTLEvent instead of creating one for each thread which added another
boost.  Then i removed another barrier for adding elements to the
watch list.  All together, that solved my problem.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Building FPC with debug information

2010-10-14 Thread Andrew Brunner
Thanks, Jonas.

On Thu, Oct 14, 2010 at 6:43 AM, Jonas Maebe  wrote:
>
> On 14 Oct 2010, at 02:58, Andrew Brunner wrote:
>
>> I was reading on building FPC with debug enabled so I can trace into a
>> unit
>
> make OPT="-O-" DEBUG=1 all
>
>
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-14 Thread Andrew Brunner
On Thu, Oct 14, 2010 at 4:29 AM, Michael Van Canneyt
 wrote:

> Impressive. So the FPC implementation on top of this obviously does
> something on top of this which causes it to slow down.
>
> Possible culprits would then be the semaphores and TLS allocation.

I obtained the source to pThreads system late last night.  It does use
a barrier using which is not necessary.  And FPC (trunk) has another
barrier on top of that.  I may re-compile pthreads library and update
on my machine but I think I already have it running up to speed!
Debugger slows things down too.

Present version of ThreadMemTest running outside debugger:

10500 threads create in 1.5 seconds :-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-13 Thread Andrew Brunner
On Wed, Oct 13, 2010 at 3:24 PM, Michael Van Canneyt
 wrote:

>> Is it possible I have the pthread library in some sort of debug mode
>> that is slowing down the process of thread creation?
>
> I seriously doubt it.
> What you could do to test, is write your program using direct Pthread calls.
> This way we can ascertain whether it is the FPC or Pthread code which is the
> bottleneck.

Right.  I'm going to do more reading on the POSIX threading system.  I
did get to trace into the threading unit under linux and the first
thing I noticed was that a mutex was used to suspend and create the
thread instead of using the ThreadManager.Suspend and Resume features.
 My local copy has removed the semaphore and I instantly noticed a
speed increase in thread creation due to the lack of the extra
semaphore per thread.

Based on what I see as far as performance goes, the current version of
threading under Unix takes 2 semaphores per thread. One by use in the
threads.inc file and at least one by the pthreads.so !

> If need be, I can dig up my texts for the Kylix book, it describes how to do
> this in Object Pascal. I suspect the code would still be pretty much the
> same.

I would say let's try to obtain source to pthreads or something.  I'd
bet we can just do a straight shoot into something from there.  If
it's open source i'd bet we can bother them perhaps for a newer
version more high-scale friendly.

> Yes, write an object pascal version of it, which accesses the kernel
> directly and bypasses the C library.

That's exactly what I'm thinking.  There are only like 36 methods to
implement.  Depending on how hard will be to hook into the kernel...
The only thing is we're going not going to have diversity as found in
the pthreads.so.  I'd bet they have tons of code for Darwin, Debian,
Redhat, etc.  I guess it's unknown at this point but well worth the
time to explore.

> It has been on many people's wish list for ages.

I presently can create 1,500 threads in 2 min 27seconds. That's 2 1/2
threads per second... 25min! Pathetic...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Building FPC with debug information

2010-10-13 Thread Andrew Brunner
I was reading on building FPC with debug enabled so I can trace into a
unit and found that it was way too difficult to find the parameters.
I know I had at one time edited the wiki page once I learned how to do
it but to my surprise that info was either lost/moved or too hard to
navigate and the search engines came up with too much information.

The build faq as a PDF on building FPC with the options and it never
mentioned anything about adding DEBUG=1 to the make command.
Presently I see -dDEBUG and -dRELEASE messages as fpc compiles itself.
 What is the propper way to take out the RELEASE directive?

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


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-13 Thread Andrew Brunner
On Wed, Oct 13, 2010 at 2:12 PM, Michael Van Canneyt
 wrote:

> FPC doesn't have anything to say about CPU allocation. The threads are
> created by the C pthread library and Linux kernel.
> They do the heavy work.

Is it possible I have the pthread library in some sort of debug mode
that is slowing down the process of thread creation?

What is needed to get directly to kernel api to /queue
events/create/destroy/suspend/resume threads?

Are there any alternatives to the cthreads unit?

Thank for the help Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-13 Thread Andrew Brunner
On Wed, Oct 13, 2010 at 8:28 AM, Michael Van Canneyt
 wrote:
> Probably because it uses a heap manager per thread.
>
> You may try to use 'cmem', which will replace the heap manager with the C
> memory manager (one for the whole app, not per thread). That will allow you
> to test this hypothesis.

Ok.  Trying to speed up the creating of threads I have enabled cmem by
putting it as the first unit in the project.  cmem,cthreads, are the
first two units to be exact.

looking at the status of the process using the system monitor it shows
me that process switches from ptrace_stop to futex_wait_queue_me
(cycling).  None of my CPUs look to be all consumed so this is clearly
an inefficiency with the way threads are created and added internally
to the fpc rtl.  I tried upping the nice level to -15 and it does
speed up a little, it still takes minutes to create anything over
1,500 threads. Futexs can be avoided with interlocked calls to assign
pointer values. I really hate to see the application thread slowed
down to a crawl just because of memory or class creation.

Please (anyone is welcome) help me speed fpc thread creation up.  I
might be able to suggest improvements to the threading system.  Anyone
intimately know FPC and it's linux guts w/r/t/ TThread that is willing
to take a look at this with me?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-13 Thread Andrew Brunner
On Wed, Oct 13, 2010 at 8:27 AM, Jonas Maebe  wrote:
>
> 1) on entry of the "critical section" protected by this variable, you can
> have problems, because this sequence:
>
> locked:=true;
> local:=shared_global_var;
>
> may actually be executed in this order:
>
> local:=shared_global_var;
> locked:=true;

Thanks btw... Yes, I didn't know that fact until you posted a link in
another thread.  I had a curios problem with pointers and a link list
that a manager thread managed but another server thread had access to
read/write.  Once in a while the order of ops would change and cause
read access violations.

> So you can get speculative reads into the "critical section"
>
> 2) when exiting the "critical section", there are no problems, because none
> of the loads or stores before the one that sets the boolean "lock" variable
> to false, can be moved past that store.

Into meaning inside or outside the section?  I was under the
assumption that inside the section - ops were thread safe from reads.
But multi-core systems - I'd bet that order can be executed
differently.

> In summary, the fact that a particular program runs fine on your particular
> machine does not mean anything:
> a) your particular machine may not perform any kind of reordering that
> results in problems
> b) your particular program may not expose any kind of reordering that
> results in problems

After reading the wikipedia article, and AMD's engineer's blog
postings with suggested code, and considering I'm exclusively using
AMD cpus, I would say this is true.  Problems could certainly prove
difficult to resolve in cases involving for worker objects waiting for
other workers to solve (recursion or so) acting as a logic gate -
potentially a serious issue.

> That does not mean that automatically the program "can be used without
> memory barriers". It is virtually impossible to prove correctness of
> multi-threaded code running on multi-cores through testing, and it is
> literally impossible to prove it for all possible machines by testing on a
> single machine (even if that machine has 4096 cores and runs 16000 threads),
> simply because other machines may use different memory consistency models.

After reading up I would say that only under certain circumstances
memory barriers can be avoided by engineering via thread isolation
(see my commands in uThreads.pas) and limited access (indexed boolean
arrays in uThreads.pas with no order necessary due to polling); and a
good understanding of challenges is required when coding
multi-threaded apps for multi-core systems.  Sometimes memory barriers
aren't even needed or germane to a particular aspect of an application
feature or functionality.   Knowing which aspects go with what method
is what makes for stable and fast applications.  Lastly, because the
polling concept was already established, I would say that order of
execution with regard to the architecture set forth in my test case,
proves just that.  Polling for all true or false, does not require
concern for pre-emptive positives, or false positives.  As designed it
proves true IFF all threads are complete.  And these facts will remain
true on all cpus.

Thanks for the info, help, and discussion.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-13 Thread Andrew Brunner
On Tue, Oct 12, 2010 at 5:51 PM, Andrew Brunner
 wrote:

Another problem demonstrated with this application is the limiting
factor of thread creation.  I'd like to make a complaint using this
code as well.  Change the number of threads to 3000.  The system gets
to about 1,000 and starts to "bog down".  I have a significantly fast
computer here and I can tell that thread creation is not supposed to
be this slow.

Under delphi 2006 (windows) I was able to create up to 3000 threads.
I recall stories of other programs in Java running well past that
3000.  Why does fpc handle threads in a way that causes creation to
slow down the more you have (as they approach 1,000) things slow to a
stall.

Can someone explain the difference?  It seems to me like there is a
list of threads being tracked by FPC or the memory manager is using
locks and the other threads are borrowing the locks causing a
sigificant reduction in performance over competing development
platforms (such as C# or Java or Delphi).

I'd like to get this resolved b/c my main system will potentially have
tens of thousands of threads on serious hardware.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Multi-threaded project with few locks (no Thread.waitfor). Memory consumption keeps increasing on Ubuntu 10.10 x64

2010-10-13 Thread Andrew Brunner
Since the number of threads is set at compile time, I didn't expect to
see the much memory creep.  The resource monitor for the process shows
about 15Mb of memory used.  When the first group of 50 threads was
created and ran that climbed another 5 to about 20MB.  Then every time
the system created / destroyed / created itself it added an additional
100kb.

So I ran an automation of this last night.  I was expecting to see the
system to be well into 100s of MB of RAM and the virtual memory way
past the 3gigs as reported.  That was not the case.  Physical memory
stopped creaping up at 45mb and the virtual memory peaked out at 4gigs
over the course of the entire night.  Meaning threads were
created/destroyed/ and new ones were created over and over again.  The
program exited gracefully as well this morning.

>> This test case illustrates a FPC memory leak.

I realised when I wrote that, that it may not be entirely accurate so
that's why I did the automation all night to see how bad things might
be.  It turns out that things remained stable and creep levelled out
but it was very strange to see.

On Wed, Oct 13, 2010 at 1:58 AM, Florian Klaempfl
 wrote:
> Am 13.10.2010 00:51, schrieb Andrew Brunner:
>>
>> This test case illustrates a FPC memory leak.
>
> What makes you think so? Internally freed memory is not immediatly
> released to the OS as well.

On windows I know there is a call to flush all virtual memory out.  Is
there a wrapper in fpc for *nix and windows?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Help getting Lazarus app in Ubuntu to elevate to root and back again

2010-10-11 Thread Andrew Brunner
On Sun, Oct 10, 2010 at 1:09 PM, Mark Morgan Lloyd
 wrote:
> Could you suid it to root or to an appropriate group? I've not tried this
> for a Pascal/Lazarus program and don't know what the precise rules are for
> port usage (i.e. whether the user has to be root or using the root group is
> sufficient), but for a C program accessing a video capture device I use
>
>  chown root:video v4lgrab
>  chmod g+s v4lgrab
>
> That then allows the program to be run as part of an unprivileged CGI
> script.

I'm presently using gksu ./startlazarus.  Though it would be nice if I could use
gksu -u myusername ./startlazarus and then have the fpSetUID(0) not
fail on me.  I made the assumption that gksu would startup lazarus
under myusername and not fail any attempts for me to use the setgid or
uid to root (because I did use gksu to launch the app).  This would
have been an ideal solution.  But there needs to be one library out
there that solves this.

Presently I am just using root :-(  Which means it's working but I'm
forced to use the root account for my Lazarus instance.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
Guys,  this is simply a semantic problem.  I've got a six core system
here.  The boolean array initialised all false.  thdArray[0..9]
threads executing simultaneously.  Corresponding values in
baArray[0..9]=false.  baArray[n] = true iff thdArray[n] Terminated
(method assigned to each member of thdArray

ObserverThread.Execute
repeat
  AllTrue:=CHECK_IF_ALL_IN_baArray_IS_TRUE;
  WaitForSingleObject(Handle,300);
until AllTrue or Terminated

ObserverThread WILL ALWAYS terminate AFTER each and every thread has
completed.  There is no worry about order of completion with this
method.


On Fri, Oct 8, 2010 at 3:52 PM, Jonas Maebe  wrote:
>
> On 08 Oct 2010, at 22:45, Andrew Brunner wrote:
>
> On Fri, Oct 8, 2010 at 3:37 PM, Marco van de Voort  wrote:
>
> No, but the last one might be set before the condition coupled to that last
>
> one might be carried out. See Jonas' example.
>
> The ONLY way that could happen is if the boolean happens to be set in
> a worker thread's method that still has more work to do.
>
> That is incorrect. Even if you set the boolean only to true at the very end,
> problems can still occur. See
> e.g. http://en.wikipedia.org/wiki/Memory_barrier#An_illustrative_example for
> an example and explanation.
>
> Jonas
>
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
On Fri, Oct 8, 2010 at 3:37 PM, Marco van de Voort  wrote:
> No, but the last one might be set before the condition coupled to that last
> one might be carried out. See Jonas' example.

The ONLY way that could happen is if the boolean happens to be set in
a worker thread's method that still has more work to do.  It is
understood that a thread would complete it's work before tripping the
Complete flag :-)

Threads aren't really that difficult to manage.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
Right.  But in the case of an array of booleans that will be polled
and an exit condition will only be met if all booleans are set to
true.  The order in which a polling thread sees them as being true has
no bearing on the functionality.


On Fri, Oct 8, 2010 at 3:07 PM, Paulo Costa  wrote:
> On 08/10/2010 18:35, Henry Vermaak wrote:
>
>> I think Jonas was talking about out of order execution in the cpu, not
>> disk i/o.
>
> No, it was out of order writing to memory (RAM), modern CPUs/Memory
> controllers can do strange things reordering writes to RAM.
>
> Paulo Costa
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Help getting Lazarus app in Ubuntu to elevate to root and back again

2010-10-08 Thread Andrew Brunner
I'm needing help to take my Lazarus app, elevate process to root
(using GUI prompt like GKSU) and I want to drop back down to the
user's level after port binding and listening.

Ubuntu has port restrictions for low port numbers.  I'm developing a
platform that happens to use ports for HTTP, XMPP, etc.  Unfortunately
I find myself running Lazarus as root and that is messing up my units
as they are saved.

I need Lazarus to run my app with debugger, and have the desktop
system ask me for my password, attach that elevated id by way of that
security mechanism to my debugged app, so I can execute my Bind and
Listen socket calls, then detach/remove that elevated status to
normal.

Anyone with code to do this very thing?  I this to be cross-platform
so ppl with KDE instead of Gnome need to be considered.
Example Code:
procedure DebugServices;
begin
   ElevateToRootStatus; // << Gets Ubuntu to prompt for Desktop system
to elevate CurrentProcess
   StartServices;
   DropRootStatus;
end;

Under normal circumstances I could just launch gksu in front of my
app.  But I'm under Lazarus with debugger so I need this badly.

Developing ElevateToRootStatus and DropRootStatus is totally unknown
how to do this.

Any help would be greatly appreciated.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
On Fri, Oct 8, 2010 at 9:52 AM, Jonas Maebe  wrote:
>> So are you referring to the topic of this conversation regarding data
>> flushing?  The notion of creating an index of completions to poll and
>> waiting for all the values to turn true as a means to determine actual
>> job completion without using locking mechanisms is just one viable
>> solution.  Are you implying that the log data (which is the purpose
>> for this/these worker threads) needs to be flushed prior to tripping
>> the boolean
>
> Yes.
>
>> or are you saying that the boolean array needs to be
>> flushed?
>
> That's not necessary if all the various threads do is setting the values to
> true. If you reset them to false inside newly started/resumed threads
> (although that would be strange), then you may have to flush it.

Right.  So you *were* talking about the actual log data being flushed

>> As a solution I just don't see any problems with boolean
>> values coming back as being true *before* they were assigned as
>> complete.  Pre-emptive completion - I just don't see that.
>
> If you have in a thread:
>
> buffer:=nil;
> finishedarray[threadnr]:=true;
>
> Then another thread (including the main program) running on a different core
> can see both (finishedarray[threadnr]=true) and (buffer<>nil) at the same
> time, except probably on x86. This can be prevented by adding memory barrier
> between those statements. A memory barrier orders whatever memory operations
> come before it with respect to those that come after it.

> Depending on the internal state that these logging threads use and whether
> or not its reused or read later on, that may or may not be important.

That may be true with regard to actual disk writing, but when polling
occurs and the value is read as true, any thread can assume it was
already tripped.  And I agree that other attributes' values may or may
not be accurate to observing threads, but I (assume you agree as well)
false positives are impossible for the purpose of polling as stated.
If not, I missed your point :-(
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
On Fri, Oct 8, 2010 at 9:21 AM, Jonas Maebe  wrote:
> No, the main source of problems is that the cpu may reordering memory
> operations resulting in those booleans in the arrays becoming true before
> all memory locations written in the thread are visible. The result is that
> you may try to use data that the thread should have written earlier, but
> that in fact is not yet available even though the boolean is already true.
>
> In fact, using atomic operations won't help to solve that problem, you do
> need memory barriers to flush the memory writes (most pthread functions and
> ending a pthread guarantee memory barrier behaviour, which is why WaitFor()
> itself is safe).
>
> On x86 you're unlikely to encounter many problems because of the strongly
> consistent memory model, but at least x86-64 now also has read and write
> barrier instructions. On non-x86 architectures, you definitely need memory
> barriers in such cases.
>

So are you referring to the topic of this conversation regarding data
flushing?  The notion of creating an index of completions to poll and
waiting for all the values to turn true as a means to determine actual
job completion without using locking mechanisms is just one viable
solution.  Are you implying that the log data (which is the purpose
for this/these worker threads) needs to be flushed prior to tripping
the boolean or are you saying that the boolean array needs to be
flushed?  As a solution I just don't see any problems with boolean
values coming back as being true *before* they were assigned as
complete.  Pre-emptive completion - I just don't see that.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
I disagree.  I've never had problems with setting values inside
boolean arrays in multi-threaded environments.  The memory is already
allocated.  Setting the value does not cause memory re-allocation,
which would be the only source of problems.  But of course just
because I didn't experience problems in the past with this does not
mean I won't with a future. ;-)

On Fri, Oct 8, 2010 at 9:04 AM, Jonas Maebe  wrote:
>
> On 08 Oct 2010, at 15:57, Andrew Brunner wrote:
>
>> A better way of achieving this is looking at the collection of threads
>> you have.  Set your own booleans for Finished or if they
>> freeonterminate you will need to create an
>> TCompletes=Array[0..threadcount] of boolean.  And as the threads free
>> set the variable of TCompletes to true.  Then you can poll the
>> Completes to see if they are all true.
>>
>> There are a million ways to accomplish safe thread usage without
>> waitfor...
>
> Yes, but the alternatives above are only safe if you only use atomic
> operations (which could be quite slow in case of an array of booleans due to
> the atomic reservation granularity), or if you add proper memory barriers
> everywhere.
>
>
> Jonas
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
A better way of achieving this is looking at the collection of threads
you have.  Set your own booleans for Finished or if they
freeonterminate you will need to create an
TCompletes=Array[0..threadcount] of boolean.  And as the threads free
set the variable of TCompletes to true.  Then you can poll the
Completes to see if they are all true.

There are a million ways to accomplish safe thread usage without waitfor...


On Fri, Oct 8, 2010 at 8:49 AM, Graeme Geldenhuys
 wrote:
> On 8 October 2010 15:32, Andrew Brunner wrote:
>> This seems like a discussion of semantics more than anything.  In an
>> application thread if you say WAITFOR something then the app cannot
>> process messages b/c the execution is put on hold until WAITFOR
>> returns.  This is normal behaviour, IMO.
>>
>> So if this is just an exercise, I really don't see a problem.  What's
>> the issue you're trying to solve?
>
> OK, my example just just that... to highlight the problem of using
> TThread.WaitFor.
>
> My real usage is in tiOPF. tiOPF has various cached logging classes,
> all done via threads. It's cached
> because we don't want to slow down the main application while output
> is written to a file or log window. So logging is written out to disk (or
> a GUI screen) when the thread gets time slices.  Now say you instantly
> generated 1 million log entries (so the thread has a huge backlog, and
> because you have a slow hard drive...in the case of logging to a
> file), and now you quit your application.
> The application needs to wait for the logging threads to complete
> before it can terminate.
> This is where the problem comes in. As soon as I call
> SomeThread.WaitFor, the application is frozen - it never gets to
> terminate completely because WaitFor never returns. All our apps are
> database GUI apps, but strangely enough, it is not only limited to GUI
> apps. The unit testing framework of tiOPF is Text or GUI. I run the
> daily build under our Linux server and it is non-gui based. The test
> runs never complete/terminate because there are five logging threads
> frozen which never returned from WaitFor. So I had to implement that
> boolean field and a while loop hack, instead of calling WaitFor [when
> I use FPC and Linux].
>
>
> --
> Regards,
>   - Graeme -
>
>
> ___
> fpGUI - a cross-platform Free Pascal GUI toolkit
> http://opensoft.homeip.net:8080/fpgui/
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
This seems like a discussion of semantics more than anything.  In an
application thread if you say WAITFOR something then the app cannot
process messages b/c the execution is put on hold until WAITFOR
returns.  This is normal behaviour, IMO.

So if this is just an exercise, I really don't see a problem.  What's
the issue you're trying to solve?  Create a two thread system and have
the second thread WAITFOR the third thread to complete.  Don't do this
with the main application thread for GUI apps.  Service apps aren't
even an issue b/c it would just create a blocking condition - again
normal.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Where is IsMultiThreaded set under Linux?

2010-10-08 Thread Andrew Brunner
> procedure TBarThread.Execute;
> begin
>  FFinished := False;    // work-around variable
>  while not Terminated do
>  begin
>    Synchronize(@UpdateProgressBar);
>  end;
>  FFinished := True;     // work-around variable
> end;
>
What about dropping that loop and put it in UpdateProgressBar

TForm1.UpdateProgressBar;
begin
  Something here
  Application.ProcessMessages
end;

And drop the waitfor all together?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Andrew Brunner
On Wed, Oct 6, 2010 at 7:55 AM, Sven Barth  wrote:
> You'll only find "127.0.0.1" for my computer there... I don't think that
> this is a very good solution.

Oh well.  That makes sense b/c these are servers that I have obtaining
the same IP over DHCP.
On clients when DHCP is being used with dynamic IPs the host file may
not be of much use or may require more parsing for the host name.

But from a file based solution you just need to read in the
/etc/hostname file.  That is the name of the box.
With the host name, ust search the /etc/hosts file for the IP matching
that name.
 It's similar to the ifconfig command with parsing of eth0 which by
the way if there are more than 1 nick, could be problematic.

Is there an Gnome or KDE API we could use to officially get NIC
related info like iphlpapi.dll API under Windows?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] lNet getting the local IP

2010-10-06 Thread Andrew Brunner
I just read the first line in /etc/hosts file.  The first entry is the IPv4.

On Tue, Oct 5, 2010 at 3:04 PM, Felipe Monteiro de Carvalho
 wrote:
> hello,
>
> I am searching for a way to get the local IP. I already found examples
> with winsock, synapse and indy. Does anyone know how to do that with
> lNet?
>
> thanks,
> --
> Felipe Monteiro de Carvalho
> ___
> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


  1   2   >