[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

[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

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

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

[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

[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


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


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


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


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


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


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


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


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


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


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


[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] 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] 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] 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] 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] 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] Problems with Dynlibs.UnloadLibrary on Linux

2008-12-16 Thread Andrew Brunner
I've been experiencing problems with SOs under Linux and am trying to
develop a "Plugin" system for my Server I'm porting to Lazarus.  I'm
confident can get these Plug-ins to Load and Operate just fine at
least in (Ubuntu).

I can't however, Unload them.  I want to be able to use the
DynLibs.UnloadLibrary to unload a library.  I can't because I keep
getting a Segmentation Fault and the Application Crashes just by
calling the Unload Library.

This problem makes using SOs/DLLs pointless because if one plugin is
unloaded and the main service application closes due to a crash, all
plugins running under that process will go down with it.

Here's my extensive thread so far.  I'm hoping to find a good solution
shortly as this is slowing me down.

http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=viewtopic&t=6033&start=0&postdays=0&postorder=asc&highlight=

Are there a few tricks involved in getting FPC to compile these SOs
properly?  The minute I include Classes in my project's uses I can't
Unload the library.  If I just have straight forewared simple data
types with no other uses I can get these to unload.  Do you have any
ideas?

I'm using all the latest and greatest FPC and Lazarus sources from
subversion as of 2008.12.15.

Thanks for you input, if any,  Andy.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problems with Dynlibs.UnloadLibrary on Linux

2008-12-16 Thread Andrew Brunner
On Tue, Dec 16, 2008 at 3:29 PM, Jonas Maebe  wrote:

> In what code does it crash? Inside unloadlibrary, or (shortly) afterwards?
> What is the backtrace at the point of the crash?

It blows out right during the DynLibs.UnloadLibrary(FLibHandle)

There is only a read access violation that is raised.  Presumably by
the MM of the SO.

>> Are there a few tricks involved in getting FPC to compile these SOs
>> properly?  The minute I include Classes in my project's uses I can't
>> Unload the library.
>
> Even if you don't call any routines from that unit?
>

Yes,  If I compile with no uses clause the Lib loads and unloads as I
want.  As many times as I want with no issues.  But if I re-build the
SAME Library project with the uses Classes; The Main Application
crashes on the UnloadLibrary call.  I repeat, all I have to do to
reproduce this bug is to use Classes; unit inside a Library under
Ubuntu.

I have smart linking options enabled or else the Compiler can't link
the project during build.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Problems with Dynlibs.UnloadLibrary on Linux

2008-12-17 Thread Andrew Brunner
Thanks for that tip!  So running under GDB I get the following info...

This GDB was configured as "x86_64-linux-gnu"...
(gdb) run

Starting program: /mnt/Raid/Developer/Source/Lazarus/Test/TestApplication
[Thread debugging using libthread_db enabled]
[New Thread 0x7f9e79102770 (LWP 7388)]
[WARNING] Out of OEM specific VK codes, changing to unassigned
[WARNING] Out of unassigned VK codes, assigning $FF

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f9e79102770 (LWP 7388)]
0x7f9e71a38d68 in fpc_finalize ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
(gdb)


#1  0x7f9e719f6170 in ?? ()
#2  0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#3  0x7fff8092e038 in ?? ()
#4  0x7f9e719f6170 in ?? ()
#5  0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#6  0x7fff8092e050 in ?? ()
#7  0x7f9e719f6170 in ?? ()
#8  0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#9  0x7fff8092e068 in ?? ()
#10 0x7f9e719f6170 in ?? ()
#11 0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#12 0x7fff8092e080 in ?? ()
#13 0x7f9e719f6170 in ?? ()
#14 0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#15 0x7fff8092e098 in ?? ()
#16 0x7f9e719f6170 in ?? ()
#17 0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#18 0x7fff8092e0b0 in ?? ()
#19 0x7f9e719f6170 in ?? ()
#20 0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#21 0x7fff8092e0c8 in ?? ()
#22 0x7f9e719f6170 in ?? ()
#23 0x7f9e71c40060 in _$CLASSES$_Ld233 ()
   from 
/home/atbrunner/Source/Lazarus/Libraries/MatrixMemory/MatrixMemoryManager.so
#24 0x7fff8092e0e0 in ?? ()
#25 0x7f9e719f6170 in ?? ()
#26 0x7f9e71c40060 in _$CLASSES$_Ld233 ()




It appears that something is wrong with the classes unit or something.
 Keep in mind, the compiled library is nothing more than 2 functions
declared as exported booleans that don't have any parameters.



On Wed, Dec 17, 2008 at 8:03 AM, Felipe Monteiro de Carvalho
 wrote:
> Read this to create a backtrace:
>
> http://wiki.lazarus.freepascal.org/Creating_a_Backtrace_with_GDB
>
> --
> Felipe Monteiro de Carvalho
> ___
> 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 Dynlibs.UnloadLibrary on Linux

2008-12-18 Thread Andrew Brunner
On Thu, Dec 18, 2008 at 2:04 AM, Michael Van Canneyt
 wrote:

> Are you using threads ?
>
> Michael.


Hi Michael,

Not in the library project.  Although I do plan on having threads in
the Main Application.  Many pooled threads will be running in the main
application.

Just the "application" thread will be running in the "Matrix Modules" Libraries.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FreePascal/Lazarus plug-in's for Delphi.

2008-12-19 Thread Andrew Brunner
I think all efforts should the concentrated on providing mainstream
features that are common in newer development platforms (Java/C#) .  I
feel that spending time on making Delphi code more readable is a waste
since there are SO many other issues that need to be dealt with.

C# has a lot of ideas FPC can take on.  I say contributors should
think about bringing in new functionality and Expanding FPC to include
such features rather than deal with Delphi issues.  The benefits of
using FPC (write 1 compile X OSs) far outweigh any issues an
individual will have at learning which Library replaces Win32 or what
not.

FPC/Lazarus has come a long way in the 2 years I've been following the
project.  Keep up the good work and push forward...  Don't get side
tracked by all these compatibility issues.  Infact, add more features
that are currently not present in Pascal - Lamda Expressions etc...
A.I. in Code Insight... There are hundreds of new issues to pioneer -
let's not get caught up in a quagmire.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Schema Types

2008-12-22 Thread Andrew Brunner
I would also add that it's wise to employ overloaded commands for each
data structure that contains dynamic arrays.  There may be nested
dynamic arrays, and Delphi at least would not respect copying over
nested data structures that contained Dynamic Arrays, so I write Copy,
Empty, SetSize routines for all my data types that contain dynamic
arrays.

I would like to point out that it would be nice if we could have lamda
expressions.  Does FPC already have this or is it planned?



On Mon, Dec 22, 2008 at 9:38 AM, Florian Klaempfl
 wrote:
> Jonas Maebe schrieb:
>>
>> One important different to keep in mind between dynamic arrays and regular
>> arrays (including those defined using schema types): dynamic arrays are
>> reference counted and copies are always shallow copies. This means that in
>> this code:
>>
>> var
>>  a, b: array of real;
>> begin
>>  setlength(a,10);
>>  b:=a;
>
> The proper way to do a copy is
> b:=copy(a);
> :)
>
> It's only a one level deep copy though.
>
> ___
> 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] Dynlibs.LoadLibrary on 64bit Debian (Ubuntu)

2008-12-23 Thread Andrew Brunner
I'm running into another issue where I create all classes from scratch
to avoid using Classes unit inside library and now my library won't
load.  The only FPC related unit I use is SysUtils.

If I strip out my all my units as uses then the Application
LoadLibrary will return a handle.

I tried to use DGB and backtrace right after the call to LoadLibrary
but it got nothing.  I use Lazarus to build my projects and the
compiler options for extra Debug Info is set for both SO and App.

I want to write a bunch of libraries this Holiday break.  And I don't
see how I can get these working if something as simple as LoadLibrary
won't work.  Is there a GetLastError that Linux stores that I can read
and determine what's going wrong?  What are my options?  Are there any
tricks to get this to work?

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


Re: [fpc-pascal] Dynlibs.LoadLibrary on 64bit Debian (Ubuntu)

2008-12-23 Thread Andrew Brunner
> This is on Scientific Linux 5.2 (free distro based on Red Hat Enterprise
> Linux 5.2). Are you sure that you are using 2.2.3 and not 2.3.1?

Hi Jonas,

Yes, I did use build 2.3.1 from SVN.  I'll try 2.2.3 build b/c I'm
having so many different Issues with this one and re-post back.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Dynlibs.LoadLibrary on 64bit Debian (Ubuntu)

2008-12-23 Thread Andrew Brunner
I just installed fpc 2.2.3 and updated my links and re-built the so
and test app. And still had a problem with LoadLibrary returning 0.

So I went and downloaded the latest version of binutils (2.19) and compiled it.

Next, I rebuilt-Lazarus.

Then, I re opened the existing projects and built-all and still...
loadlibrary returned 0.

Next, I created a brand new Library Project and it worked perfectly
with the Classes and other things.

So, I'm up and running with an entirely different problem.  The 2.2.3
(2.2.2 fixes) edition seems to have a problem with arrays... I've got
a memory map of pointers based on the current processID.

TMemoryMap=Array[THandle] of Pointer.  This does work on Delphi.  But
it does not work on FPC.



On Tue, Dec 23, 2008 at 1:26 PM, Andrew Brunner
 wrote:
>> This is on Scientific Linux 5.2 (free distro based on Red Hat Enterprise
>> Linux 5.2). Are you sure that you are using 2.2.3 and not 2.3.1?
>
> Hi Jonas,
>
> Yes, I did use build 2.3.1 from SVN.  I'll try 2.2.3 build b/c I'm
> having so many different Issues with this one and re-post back.
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Array [THandle] of pointer

2008-12-23 Thread Andrew Brunner
Following Setup:
  Ubuntu 8.10 x64
  FPC 2.2.3 (latest and greatest)
  Lazarus (Latest and greatest)

I'm seeing an anomaly with reading/writing to an Array[THandle] of Pointers.

TMyStruct=record
  Index:integer;
end;
PMyStruct=^TMyStruct;
TMyList = Array[THandle] of PMyStruct;


If I declare a localized variable
procedure Test();
var
  MyTest:TMyList;
  hThread:THandle;
begin
  hThread:=getCurrentThreadID;
  if (MyTest[hThread])=nil then begin // < CRASH HERE EXTERNAL SIGBUS
  end;
end;


This should not crash here.  It should have been nil.

Any work being done in this area or should I report another bug?
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Array [THandle] of pointer

2008-12-23 Thread Andrew Brunner
Hehehehe

I know.  I didn't realize that the map was that large. It's for
Indexing memory objects to threads.  I did something similar under
Delphi but now recall limiting the size from [-1..9] or something
like that.  But that's in a 32 bit OS.  Doing it that way isn't going
to work.

I've got another way already.  I just didn't relate the size of the
actual structure.

On Tue, Dec 23, 2008 at 5:23 PM, Marc Weustink  wrote:
>
> I'm surprised it crashes there. A THandle is IIRC a Cardinal on unix, so by
> defining a variable MyTest:TMyList, you allocate 4GB * SizeOf(TMyStruct) =
> 16GB on your stack. Usually a process doens't have that much space and I
> wonder if you wanted this.
>
> (You may want to look at the lcl Maps unit)
>
> Marc
>
> ___
> 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] Dynlibs.LoadLibrary on 64bit Debian (Ubuntu)

2008-12-23 Thread Andrew Brunner
On Tue, Dec 23, 2008 at 1:36 PM, Jonas Maebe  wrote:

> Your bug report indicates version "2.2.3" in the details view.

I noticed that.  I don't recall paying much attention to the version
or perhaps it wasn't available in the combobox.
It was listed in the more detailed version.

> 2.2.x is the fixes branch, 2.3.x is trunk. It is unadvisable to use trunk
> unless you really want to be bleeding edge (with the emphasis on "bleeding"
> in case of dynamic libraries on linux/x86_64)

I had explored the SVN today using a browser... I checked out a number
of revisions.  2.2.2 and fixes.  I'm assuming fixes is an entire
distribution of FPC although I did a 2.2.2 install and then did a
fixes2.2.2 install.  I had to go down from 2.3.1 so some symbolic
links and Lazarus had to be tweaked.

But thanks for that hint on the Ubuntu problem.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Dynlibs.LoadLibrary on 64bit Debian (Ubuntu)

2008-12-24 Thread Andrew Brunner
I've been struggling with an issue of
Dynlibs.LoadLibrary(completepath/something.so) always returning zero
for libraries in subfolders that are traced back to samba shares.

Example Library Project is built on

/home/atbrunner/Source/Libraries/Test/project1.so

but /home/atbrunner/Source is a smbfs mount in fstab pointing to
\\fileserver\raid\developer\source\lazarus\ share on my network.

So what's with Dynlibs or Linux for that matter, not able to load
libraries from sub folders inside mounts?  Is *this a known issue?

If I copy the project1.so into my home folder, update the Application
to load the lib from that path, all is good.  Any ideas?  Is there a
config setting for binutils to "resolve" mounts?

I want to close out this issue and report in bug track what's up with
the entire matter...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Initializing Arrays?

2008-12-25 Thread Andrew Brunner
I typically use Empty, SetSize, Copy, and IndexOf etc. Methods for all
my DataTyped Arrays.  The SetSize method sets the size and for each
Item in the Array I call empty.

Empty(Var Item:TJSMContact); overload;
Empty(Var Items:TJSMContacts); overload;
var
  iLcv:integer;
begin
  For iLcv:=0 to High(Items) do
Empty(Items[iLcv]);
  SetLength(Items,0);
end;

function SetSize(Var Items:TJSMContacts, Size:Integer):integer; overload;
var
  iLength:Integer;
  iLcv:integer;
begin
  iLength:=Length(Items);
  SetLength(Items,Size);
  for iLcv:=iLength to Size do
Empty(Items[iLcv]);
end;

procedure Copy(Var Source,Destination:TJSMContact); overload;
begin
  Desintation.Name:=Source.Name;
  // etc
end;

On Thu, Dec 25, 2008 at 1:06 AM, Joseph Montanez
 wrote:
> I've already read that its not built into pascal but how do I get around
> this? If I have:
>
> contacts : array [1 .. 256] of JSMContact;
>
> the only way to initialize it is?
>
> with contacts[1] do
> begin
> Name := '';
> PhoneNo := '';
> end;
>
> Also if I am passing a var to a procedure how would use a pointer as
> parameter?
>
> { Wont compile :( }
>
> procedure JSMContactAdd(contact : ^JSMContact);
>
> JSMContactAdd(@contacts[1]);
>
> ___
> 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] Dynlibs.LoadLibrary on 64bit Debian (Ubuntu)

2008-12-27 Thread Andrew Brunner
Hi Joost,

The the problem was a Linux problem.  I'm running debian, Ubuntu 8.10,
but the problem was with the entries in FSTab not having the propper
case for the remote shares.  I matched the cases in the complete paths
(server side) and Rebooted.  Now at least I could test for crashes.

Unfortunately, I had already upgraded my binutils before I could test
so I need to re-install from scratch to revert back to my old bin
utils?

I don't have issues with loading/unloading at the present.



On Sat, Dec 27, 2008 at 4:14 AM, Joost van der Sluis  wrote:
> Op woensdag 24-12-2008 om 13:42 uur [tijdzone -0600], schreef Andrew
> Brunner:
>> I've been struggling with an issue of
>> Dynlibs.LoadLibrary(completepath/something.so) always returning zero
>> for libraries in subfolders that are traced back to samba shares.
>
> This sounds as if you have SE linux enabled and the option set to
> disallow execution from files from samba-shares.
>
> Try is 'setenforce off' solves the problem.
>
> Joost.
>
> ___
> 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] Library Project raises Linker Error Hints at -fPIC option

2009-01-06 Thread Andrew Brunner
I'm looking for a reason why I get this error while linking a compile
of a Shared Object I'm building under x64 (Ubuntu).

BinUtils 2.19 (Started with 2.18) but 2.19 did not fix problem.
FPC 2.2.3 (1/6/2009)
Lazarus SVN RVN :17967 0.9.27 beta

Error while building.

/usr/local/bin/ld:
libpuMatrixMemoryThread.a(uMatrixMemoryThread0s8.o): relocation
R_X86_64_32S against `TC_UMATRIXMEMORYTHREAD_EVENT_ITEM_NUMBER' can
not be used when making a shared object; recompile with -fPIC


-

The assignable typed constant is declared inside the localized unit
file.  It's not global but it's right after the implementation
declaration

implementation

Const
  Event_Item_Number  : DWORD   = 1;


-

Can anyone tell me why this would be a problem or what I need to do to
get FPC to build or LD to link properly?  I've added the -fPIC option
to pass to the linker in Lazarus but to no avail  Please help...

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


Re: [fpc-pascal] Library Project raises Linker Error Hints at -fPIC option

2009-01-07 Thread Andrew Brunner
Hi Jonas,

I posted bug with source.  Here is a link
http://bugs.freepascal.org/view.php?id=12940

Thanks, -Andy


On Wed, Jan 7, 2009 at 6:09 AM, Jonas Maebe  wrote:
>
> On 07 Jan 2009, at 03:46, Andrew Brunner wrote:
>
>> Can anyone tell me why this would be a problem or what I need to do to
>> get FPC to build or LD to link properly?
>
> It sounds like a bug in the code generator. Please submit a bug report with
> a compilable library that demonstrates the program.
>
>
> 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] Re: Library Project raises Linker Error Hints at -fPIC option

2009-01-12 Thread Andrew Brunner
I'm still unable to build my libraries.  Can I get anyone to help?  :-)

On Tue, Jan 6, 2009 at 8:46 PM, Andrew Brunner
 wrote:
> I'm looking for a reason why I get this error while linking a compile
> of a Shared Object I'm building under x64 (Ubuntu).
>
> BinUtils 2.19 (Started with 2.18) but 2.19 did not fix problem.
> FPC 2.2.3 (1/6/2009)
> Lazarus SVN RVN :17967 0.9.27 beta
>
> Error while building.
>
> /usr/local/bin/ld:
> libpuMatrixMemoryThread.a(uMatrixMemoryThread0s8.o): relocation
> R_X86_64_32S against `TC_UMATRIXMEMORYTHREAD_EVENT_ITEM_NUMBER' can
> not be used when making a shared object; recompile with -fPIC
>
>
> -
>
> The assignable typed constant is declared inside the localized unit
> file.  It's not global but it's right after the implementation
> declaration
>
> implementation
>
> Const
>  Event_Item_Number  : DWORD   = 1;
>
>
> -
>
> Can anyone tell me why this would be a problem or what I need to do to
> get FPC to build or LD to link properly?  I've added the -fPIC option
> to pass to the linker in Lazarus but to no avail  Please help...
>
> Thanks.
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Debian Linux, BinUtils, FPC question

2009-01-14 Thread Andrew Brunner
Hi there,

I'm trying to get more information on how FPC uses BinUtils under
Debian flavored linux.  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] Creating FPC enabled websites

2009-03-03 Thread Andrew Brunner
On Tue, Mar 3, 2009 at 2:44 PM, Joost van der Sluis  wrote:
>
> If users use the application constantly, don't use a web-application.
>
> So the things explained in this document from IBM is usefull for very
> large systems which a lot of users (Like Amazon, but they also don't
> like the idea of a full-blown javascript application) or some idiots who
> do things in a web-application while they shoudn't.
>
> Joost.
>

I disagree. I think a migration to web based software development
offers many benefits over desktop software.  Instant deployment, and
Object Orientated JS via ProtoType is completely doable.  And if you
find bugs or memory leaks I'm sure they'll get worked out in the next
revision.

I've done some awesome Realtime Apps with my custom Information Server
(built in Dephi) for the backend, and HTML/CSS/JS for the front.

Let's not forget the promise of Cloud Computing and its benefits as well.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Creating FPC enabled websites

2009-03-03 Thread Andrew Brunner
On Tue, Mar 3, 2009 at 3:04 PM, Michael Van Canneyt
 wrote:

> To prove my point I once did performance tests with AJAX, SOAP and whatnot
> technologies when compared to a specialized C/S protocol. In general the
> conclusion was that SOAP and standards-based applications worked 6 times
> slower. Also something to take into consideration, because it meant that
> 6 times more people could work on a single server simultaneously.
>
> Michael.

That might be true using conventional servers for the back-end but the
apps I did and tested were developed on MY back-end.  When tested - I
was pushing about 35k simultaneous connections (sustained) with jumps
up to 45k per network node.  Each connection was spanned across
HTTP,POP3, and SMTP :-)  All protocols mentioned were running on the
SAME machine.  Each connection had access to MySQL connectivity via my
own n-Tier Database API that could handle the thread pooling required
to handle such transactions.

This technology is something I am looking to bring to Lazarus and open
up for Cloud computing sometime soon.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Array initialization

2009-03-17 Thread Andrew Brunner
var
  c1 : array[1..10]  of char;
begin
  fillchar(c1[1],5,0);
  fillchar(c1[5],5,#32);

You might need @ sign in front of c1 though...
...or...

const
  c1:array[1..10] of char = '123456789a';



On Tue, Mar 17, 2009 at 5:50 PM, Francisco Reyes  wrote:
> On the following URL,
> http://web.mit.edu/sunsoft_v5.1/www/pascal/lang_ref/ref_data.doc.html#1212,
> I found some different syntax to initialize an array.
>
> Examples there..
> var
> c1 :  array[1..10] of char := '123456';
> int2 : array[1..100] of integer := [50 of 1, 50 of 2];
>
> Tried those, but didn't seem to to work.
>
> Is a loop the only way to initialize all the values in an array other than
> Values: array[1..2] of integer = (0,0);
>
> In the program I am working on, Values will be an array of 128 integers and
> I would like to initialize them to 0.
>
> Right now I just using:
> for InitialLoop := 1 to 128 do
>        Values[InitialLoop] :=0;
>
> ___
> 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: Servlet server for Fpc apps

2009-03-30 Thread Andrew Brunner
I've been reading this thread for a while and wanted to ask something...

What if someone had a cluster based cloud computing server written
entirely from the ground up in Delphi?  Including hot-swappable core
object for backend AJAX calls and all the major Web2.0 protocol
implements (XMPP/HTTP/SMTP/POP3)...

Would there be anyone or a group of people reading this who would be
willing to help port it from Delphi into a FPC/Lazarus xPlatform
build?

Would there be anyone or a group of people reading this who know where
one could procure funding for an open source Social Media Server?

If you are interested in contributing code or can help in any way
please let me hear from you...

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


Re: [fpc-pascal] Re: Servlet server for Fpc apps

2009-03-30 Thread Andrew Brunner
On Mon, Mar 30, 2009 at 2:26 PM, Dariusz Mazur  wrote:
> Andrew Brunner pisze:
>>
>> I've been reading this thread for a while and wanted to ask something...
>>
>> What if someone had a cluster based cloud computing server written
>> entirely from the ground up in Delphi?  Including hot-swappable core
>> object for backend AJAX calls and all the major Web2.0 protocol
>> implements (XMPP/HTTP/SMTP/POP3)...
>>
>
> Sound impressive. May i ask for more details.

Sure.  I'm really trying hard to get this project out the door.  It's
ODBC Database driven with connection pooling happening on the thread
manager level.  The sockets implementation is where all the packets
are routed via their assigned protocol via a mapping technology I've
implemented with the capacity to handle tens of thousands of
simultaneous connections per node.

When I get home I'll send out screen shots of the Server Management
System.  I tried porting the ItemListView component myself using LCL's
Scrollbox component but ran into problems with Gnome and scrolling the
box.  But moving forward I think a Console Application via AJAX would
be better suited than building native flavors.

>>
>> Would there be anyone or a group of people reading this who would be
>> willing to help port it from Delphi into a FPC/Lazarus xPlatform
>> build?
>>
>
> Why not. Fell free to ask.
>
>
> --
>  Darek
>
>
>
> ___
> 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: Servlet server for Fpc apps

2009-03-30 Thread Andrew Brunner
I don't know if I want to let the "cat out of the bag" sort to speak.
Once  I release the server out in the open there's not going back.
This is more of a "feeler" message to see if there are motivated (or
wealthy/influential) people out here - that are wanting to help
delivering an affordable open sourced alternative.

On Mon, Mar 30, 2009 at 2:40 PM, Leonardo M. Ramé  wrote:
>
> Andrew, do you have an example, or web page where we can read more about the 
> project?
>
>
> Leonardo M. Ramé
>
>
> --- On Mon, 3/30/09, Andrew Brunner  wrote:
>
>> From: Andrew Brunner 
>> Subject: Re: [fpc-pascal] Re: Servlet server for Fpc apps
>> To: "FPC-Pascal users discussions" 
>> Date: Monday, March 30, 2009, 2:51 PM
>> I've been reading this thread for a
>> while and wanted to ask something...
>>
>> What if someone had a cluster based cloud computing server
>> written
>> entirely from the ground up in Delphi?  Including
>> hot-swappable core
>> object for backend AJAX calls and all the major Web2.0
>> protocol
>> implements (XMPP/HTTP/SMTP/POP3)...
>>
>> Would there be anyone or a group of people reading this who
>> would be
>> willing to help port it from Delphi into a FPC/Lazarus
>> xPlatform
>> build?
>>
>> Would there be anyone or a group of people reading this who
>> know where
>> one could procure funding for an open source Social Media
>> Server?
>>
>> If you are interested in contributing code or can help in
>> any way
>> please let me hear from you...
>>
>> Thanks.
>> ___
>> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
>
> ___
> 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] SQL Administration Component for MySQL, PostgreSQL, and Oracle

2009-07-20 Thread Andrew Brunner
I wanted to draw attention to a recently added component project I
placed in the Bounties section of the Lazarus website.

URL: http://wiki.lazarus.freepascal.org/Bounties
"SQL Database Administration Components $500 US"

I am needing this component set quickly and have cash in hand.  Please
let me know if you would like to help add Administration functionality
to the SQLDB components for Lazarus.

If you are wanting these components and want to help increase this
bounty let me know.

If you want to be part of the team and share in the development let me
know as well.  I have a model of existing Delphi code.  Components
must be complete for Linux, MAC, & Windows.

Thanks,

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


[fpc-pascal] Environment Variables with Include Directive

2009-07-26 Thread Andrew Brunner
I've got a situation where I'm wanting to concatenate a path from the
environment with a string to specify the path to the actual file to
include when building.

PATH_TO_DATA_INCLUDES = '/mnt/Source/Includes/Data/

{$i %PATH_TO_DATA_INCLUDES%+definitions.inc}

Is there any way to get FPC to join the two entries together to create
a single include reference?

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


[fpc-pascal] DB unit and Parameter Binding with Variants

2009-08-04 Thread Andrew Brunner
I am very pleased with the core features of the DB components and more
specially the SQL components.  Many thanks for your efforts.
Development of these components for Linux, MAC, and Windows will make
this platform more palatable.

After reviewing the code for the TParams and TParam components, have
encountered an issue that needs attention.  The issue at hand is with
regard to the usage of FValue (Variant) for data storage values that
get processed during a bind operation.

I have had many issues with Delphi and variants and feel that variants
are completely unreliable when it comes to highly efficient
transactional systems.  Looking at the existing code - I see the Param
system making  copies of copies of memory and assigning them to the
variant.  This is totaly acceptable for client applications but in
server applications where scale is an issue, this will lead to major
performance issues.

I've given it some thought, and think it would be best if TParam had
an additional system for reading/writing bindings.  TParam now
facilitates an additional SetData method as detailed below:

procedure TParam.SetData(Memory: Pointer; ASize:Integer;
AFieldType:TFieldType; AParamType:TParamType)
begin
  FDataType:=AFieldType;
  FValue:=VPointer(Memory); << Access violation here...
  FSize:=ASize;
end;

The only problem I'm having is with the FValue:Variant.  How do I get
FValue to store the pointer without raising a read access violation?

Looking forward I think a TParamMemoryMode=(pmmCopy,pmmPointer) system
is in order here.  By default, the memorymode would be Copy and use
the existing infrastructure.   But if in Memory mode the system will
require pointers to values and their DataTypes and Size specified
during SetData.

I'm thinking I need to extend the TParam component to include a
FMemory:Pointer field as to keep all the old code intact.

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


Re: [fpc-pascal] DB unit and Parameter Binding with Variants

2009-08-04 Thread Andrew Brunner
Michael,

If I extend the Param system to depend on the memory being allocated
by the caller of the SetData and that the memory will be there for the
duration of the SQL operation then all we need to do is have a pointer
to the memory, the size of the memory, and the kind of memory.  With
these three things we can read/write as needed.  The present system is
using a Variant data and contains a copy of the initial data that was
passed during the SetData.

Eventyally, we could remove the variant and use the getmem method if
the TParm is in copy mode and the component would be entirely Variant
free.

>
> In my ideal world, the TParam would not need variants at all.
> The problem is that it must store all kinds of data. Implementing
> this would mean effectively re-implementing many FVariant mechanisms,
> such as conversions from one type to another.
>
> I'm not quite sure that I understand what you hope to gain with this
> new proposed field and parameter ?
>
> Michael.
>
> ___
> 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] Byte array manipulation

2009-08-16 Thread Andrew Brunner
Hi there,

I have a ByteArray unit that's pretty extensive.

function toString(Var Item:TByteArray):string
var
  iLen:Integer;
begin
  iLen:=System.Length(Item);
  SetLength(Result,iLen);
  if iLen>0 then
System.Move(Item[0],Result[1],iLen);
end;

On Sun, Aug 16, 2009 at 12:35 PM, Wimpie Nortje wrote:
> Hi all,
>
> I have a lot of byte arrays which contains mostly text but also #0. I am
> looking for functions to manipulate these arrays.
>
> The stuff in strutils are mainly what I need but they operate on strings
> which is not usable to me due to the #0. Are there any such functions in
> FPC?
>
> And while I am onto strings...does anyone know of a quick and easy way to
> convert strings to a byte array. Much like aPchar := PChar(aString)?
>
> Thanks
> Wimpie
> ___
> 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] FIONREAD FPC FpIOCtl for Cross platform Sockets

2009-10-07 Thread Andrew Brunner
Sockets programming often requires a poll for how much data is
available on a particular socket descriptor.

I'm porting an inhouse library for a sockets implementation and I
realize that while I have a FpIOCtl call in the baseUnix unit I have
no such animal in the Sockets implement which would be cross platform.
 Winsock does support this call and was wondering if someone wants to
just use the windows sockets implement in the Sockets unit instead of
using conditional definitions.

Windows Constants

  FD_READ = $01;
  FD_WRITE= $02;
  FD_OOB  = $04;
  FD_ACCEPT   = $08;
  FD_CONNECT  = $10;
  FD_CLOSE= $20;
  FD_QOS  = $40;
  FD_GROUP_QOS= $80;
  FD_MAX_EVENTS = 8;
  FD_ALL_EVENTS = $100; { AHS - trudno powiedzieæ, ile powinno byæ }

  IOCPARM_MASK = $7f;
  IOC_VOID = $2000;
  IOC_OUT  = $4000;
  IOC_IN   = $8000;
  IOC_INOUT= (IOC_IN or IOC_OUT);

 FIONREAD = IOC_OUT or { get # bytes to read }
   ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
   (Longint(Byte('f')) shl 8) or 127;
 FIONBIO  = IOC_IN or { set/clear non-blocking i/o }
   ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
   (Longint(Byte('f')) shl 8) or 126;
 FIOASYNC = IOC_IN or { set/clear async i/o }
   ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
   (Longint(Byte('f')) shl 8) or 125;

Winsock DLL calling for "ioctlsocket"

  TWSF_ioctlsocket   = function (s: TSocket; cmd: DWORD; var
arg: u_long): Integer; stdcall;

Anyone want to update the sockets unit to include a cross platform
ioctl function for sockets specifically?


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


Re: [fpc-pascal] How to free this memory and avoid memory leak

2009-10-08 Thread Andrew Brunner
>
>      Move(p, tocarray[0], SizeOf(tocarray));
> This causes an Access Violation at runtime.
>

This should not cause as RAV.  You must call
SetLength(toarray,SizeOfMemory) and also don't use SizeOf(tocarray)
use Length(tocarray)*SizeOf(What ever the element is))
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] QueueUserAPC Similar Cross platform Functionality

2009-10-08 Thread Andrew Brunner
Hi there,

I've got a unit I'm porting from Windows to Linux and I came across a
QueueUserAPC (Kernel32 Windows) I make to add a callback method that
gets executed by the thread I added this to.

function QueueUserAPC(Callback: Pointer; hThread: THandle;
dwData:DWORD): boolean; stdcall;

When the Thread gets around to it, it processes the callback function
I passed in during the queue call.

Judging by the performance of this method I would say that the Windows
Kernel maintains a queue of events to process for each thread.  And
this function allows me to attach a callback to that queue so I can
allocate memory within that stack rather than the stack of the calling
thread.  This feature is important as I want to keep memory allocation
to specific threads.

Does Threading under Linux have anything like this?  Have any of you
done anything like this under *nix?

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


[fpc-pascal] Re: QueueUserAPC Similar Cross platform Functionality

2009-10-09 Thread Andrew Brunner
After two days of research I've concluded that the best way to
implement this for cross platform support is to go with a FiFo queue
and have the individual threads transverse the list at a convenient
point during the Execute method.  It's gonna be CPU intensive compared
to a Windows Kernel call but hey... my options are limited.

If anyone has a better solution for Linux/Unix/Mac- I'm all ears.

Thanks.

On Thu, Oct 8, 2009 at 12:34 PM, Andrew Brunner
 wrote:

> Does Threading under Linux have anything like this?  Have any of you
> done anything like this under *nix?
>
> Thanks for any feedback.
>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] QueueUserAPC Similar Cross platform Functionality

2009-10-09 Thread Andrew Brunner
In theory that's what I'm planning to do to emulate the functionality.
 I'm going to create a queue using a FIFO technique and empty out the
queue executing the callbacks for each item in the queue - from a
manager thread.

Thanks for the advice.  -Andrew

On Fri, Oct 9, 2009 at 11:40 AM, David Emerson  wrote:
> Hi Andrew,
>
> I don't really understand your question as well as I'd like to (in
> particular, I don't understand the difference between a "callback" and
> any other sort of procedure; as well as other confusions) So this might
> be bunk advice, but here it is...
>
> Have you considered making your own thread function wrapper that could
> duplicate the functionality you need?
>
> type
>  thread_param_and_callback_func = record
>    thread_func : function (p : pointer) : ptrint;  // as required
>    thread_param : pointer;  // the parameter to the main thread func
>    callback_proc : procedure (...);
>    callback_param : ???;
>    end;
>  p_thread_param_and_callback_func = ^thread_param_and_callback_func;
>
> function thread_proc_wrapper (p : pointer) : ptrint;
> begin
>  with thread_param_and_callback_func (p^) do begin
>    thread_func (thread_param);
>    callback_proc (callback_param);
>    end;
> end;
>
> I've only made one multithreaded program at this point, but it was a
> huge success, and I used something similar to this-- a thread handling
> function that would repeatedly request tasks and execute them, until
> the tasks were all complete. (I added a repeat loop...)
>
> Hope this helps... (or inspires you to think of something that will
> work :)
>
> ~David.
>
>
> On Thu 8 Oct 2009, Andrew Brunner wrote:
>> Hi there,
>>
>> I've got a unit I'm porting from Windows to Linux and I came across a
>> QueueUserAPC (Kernel32 Windows) I make to add a callback method that
>> gets executed by the thread I added this to.
>>
>> function QueueUserAPC(Callback: Pointer; hThread: THandle;
>> dwData:DWORD): boolean; stdcall;
>>
>> When the Thread gets around to it, it processes the callback function
>> I passed in during the queue call.
>>
>> Judging by the performance of this method I would say that the Windows
>> Kernel maintains a queue of events to process for each thread.  And
>> this function allows me to attach a callback to that queue so I can
>> allocate memory within that stack rather than the stack of the calling
>> thread.  This feature is important as I want to keep memory allocation
>> to specific threads.
>>
>> Does Threading under Linux have anything like this?  Have any of you
>> done anything like this under *nix?
>>
>> Thanks for any feedback.
>> ___
>> fpc-pascal maillist  -  fpc-pas...@lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
>
> ___
> 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] Why use pointers to arrays?

2009-10-11 Thread Andrew Brunner
In general I use pointers to data structures and especially when they
are arrays.

Take the following

PIntArray: ^TIntArray;

TIntArray:Array of Integer;


1st benefit:

declaring methods associated with classes before TIntArray needs to be
defined or declared.
  eg. procedure DoSomething(Var Data:TIntArray); vs (DataP:PIntArray);

Non-obvious benefit to all FPC users

FPC forces the ^ operator while accessing structures as pointers.
Delphi didn't force it and I even suspect that memory leaks can result
in NOT using the ^ to denote the reference to the pointer rather than
the pointer itself.

Lastly, passing by reference rather than by value is much faster.
Since copies need not be made when entering a method when entered
using a Pointer declaration vs DoSomething(Data:TIntArray).  In the
latter a copy of the calling Data array would be made, slowing the
application and using more memory - and for recursive methods lead to
the Stack running out of memory.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Andrew Brunner
On Sun, Oct 11, 2009 at 5:25 PM, "Vinzent Höfler"
 wrote:
> Andrew Brunner :
>
>> 1st benefit:
>>
>> declaring methods associated with classes before TIntArray needs to be
>> defined or declared.
>>   eg. procedure DoSomething(Var Data:TIntArray); vs (DataP:PIntArray);
>
> Huh? Is there any difference other than the second one can take a NIL value?

Read up on forward declarations.  The technique of declaring a typed
pointer to any data structure in FPC and Delphi was that you can use
it in fields and methods of objects and data structures w/o having to
actually have it fleshed out until later in the interface envelope of
the unit.   I've found that using forward declarations is a saving
grace with complicated systems.

>> Lastly, passing by reference rather than by value is much faster.
>
> That's what "const" has been invented for: Letting the compiler decide the 
> most efficient way.

Oh I don't know about that one.  I'd like someone else to comment on
that.  Does using "const" prohibit copies of the memory.  I had memory
leaks with Delphi 5 or 6 doing this way back when and I attributed it
to trying to pass by reference using const... IMO it should do this
but may have had lead me to believe this is not the case...  But the
fact it that passing by reference is faster than passing by value...
That was my only point - which you made quite well.  As far as the
invention of const descriptor - I only use that for conventional
objects since dealing with pointers to data by const or by var is
trivial not organization or for maintanince or code review ;-)

> Not to mention, expressing your intent:
>
> You don't change it, say so: "const".
> You change it,       say so: "var".
> You initialize it,   say so: "out".
>
> If you just take the pointer no-one knows if the value is in/in out/or out. 
> That's clearly not a "benefit".
>
Ahhh... The beauty of Pascal over C++ ;-)  Buy you're getting way to
particular man...  You know I've never had a need for Out save for
once. LOL.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Why use pointers to arrays?

2009-10-12 Thread Andrew Brunner
On Mon, Oct 12, 2009 at 12:43 PM, Marc Weustink  wrote:
> Graeme Geldenhuys wrote:
>>
>> On 11/10/2009, Andrew Brunner  wrote:
>>>
>>>  FPC forces the ^ operator while accessing structures as pointers.
>>>  Delphi didn't force it and I even suspect that memory leaks can result
>>>  in NOT using the ^ to denote the reference to the pointer rather than
>>>  the pointer itself.
>>  pS[2] <<<<<<<<<<<<<<<

Any idea what the compiler option is under Lazarus (that's what I use
exclusively)?

I get a compiler error when I don't use the ^ operator.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
Hi there,

I just got a laptop that came with Windows Seven.  I have complete
automation scripts with my Ubuntu boxes but NONE of the commands to
"make" FPC translate for me.

I poured over wikis and blogs for info and even found the official
(link below).
http://wiki.lazarus.freepascal.org/Installing_Lazarus#FPC_Sources_for_Windows
 <<< Someone's TODO.

If anyone has a batch file with the propper commands send it here.. I
really want to start developing on this laptop.  Will go dual boot
shortly if I have to but I'd rather just have the ability to develop
on both platforms (using Lazarus/FPC).

Thanks to anyone who can /will help.  -Andy
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
Yes.  From any folder in command prompt I get fpc access.  I just
don't know the make commands and parameters.

-Andy

On Sat, Nov 7, 2009 at 7:31 AM, Vincent Snijders
 wrote:
> Andrew Brunner schreef:
>>
>> Hi there,
>>
>> I just got a laptop that came with Windows Seven.  I have complete
>> automation scripts with my Ubuntu boxes but NONE of the commands to
>> "make" FPC translate for me.
>>
>> I poured over wikis and blogs for info and even found the official
>> (link below).
>>
>> http://wiki.lazarus.freepascal.org/Installing_Lazarus#FPC_Sources_for_Windows
>>  <<< Someone's TODO.
>>
>> If anyone has a batch file with the propper commands send it here.. I
>> really want to start developing on this laptop.  Will go dual boot
>> shortly if I have to but I'd rather just have the ability to develop
>> on both platforms (using Lazarus/FPC).
>>
>
> Did you install fpc 2.2.4 and set the %PATH% to the directory that contains
> the fpc.exe executable?
>
> Vincent
> ___
> 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] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
Make Install PREFIX worked but it required Elevated User Status.  And
to do this under Seven you must right click the icon for command
prompt and select run as administrator.  Running command prompt as an
administrator will enable the installation properly from the command
prompt.  Otherwise the make install command fails.

Next I wannt to do the make source install.  I had a problem with the
source install.  The MyPrefix I used was c:\FPC. Where were the files
supposed to be copied?  I'm updating the Wiki site for Windows and I
just want to make sure my instructions are verified... And I didn't
get the source copied using make install sourceinstall PREFIX=MyPrefix

On Sat, Nov 7, 2009 at 7:54 AM, Vincent Snijders
 wrote:
> Andrew Brunner schreef:
>>
>> Yes.  From any folder in command prompt I get fpc access.  I just
>> don't know the make commands and parameters.
>
> Did you try the same as on linux (that is what the wiki suggested).
>
> Vincent
> ___
> 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] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
C:\Developer\FPC>make install sourceinstall PREFIX=C:\FPC

make -C win32 exampleinstall
make[4]: Entering directory `C:/Developer/FPC/rtl/win32'
make[4]: Nothing to be done for `exampleinstall'.
make[4]: Leaving directory `C:/Developer/FPC/rtl/win32'
make[3]: Leaving directory `C:/Developer/FPC/rtl'
make[2]: Leaving directory `C:/Developer/FPC'
make[1]: Leaving directory `C:/Developer/FPC'
make installother FPC=C:/Developer/FPC/compiler/ppc386.exe ZIPDESTDIR=C:/Develop
er/FPC FPCMAKE=C:/Developer/FPC/utils/fpcm/fpcmake.exe
make[1]: Entering directory `C:/Developer/FPC'
make packages_distinstall FPC=C:/Developer/FPC/compiler/ppc386.exe ZIPDESTDIR=C:
/Developer/FPC FPCMAKE=C:/Developer/FPC/utils/fpcm/fpcmake.exe
make[2]: Entering directory `C:/Developer/FPC'
make -C packages distinstall
make[3]: Entering directory `C:/Developer/FPC/packages'
make -C hash distinstall
make[4]: Entering directory `C:/Developer/FPC/packages/hash'
C:/Developer/FPC/utils/fpcm/fpcmake.exe -p -Ti386-win32 Makefile.fpc
Processing Makefile.fpc
 Writing Package.fpc
C:/FPC/bin/i386-Win32/ginstall.exe -m 755 -d C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/cp.exe -fp Package.fpc C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/ginstall.exe -m 755 -d C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/cp.exe -fp units/i386-win32/md5.ppu units/i386-win32/crc.p
pu units/i386-win32/ntlm.ppu units/i386-win32/uuid.ppu units/i386-win32/sha1.ppu
 C:\FPC/units/i386-win32/hash
C:/FPC/bin/i386-Win32/cp.exe -fp units/i386-win32/md5.o units/i386-win32/crc.o u
nits/i386-win32/ntlm.o units/i386-win32/uuid.o units/i386-win32/sha1.o C:\FPC/un
its/i386-win32/hash
make -C examples distclean
make[5]: Entering directory `C:/Developer/FPC/packages/hash/examples'
C:/FPC/bin/i386-Win32/rm.exe -f mdtest.exe crctest.exe sha1test.exe mdtest.o crc
test.o sha1test.o libpmdtest.a libpcrctest.a libpsha1test.a libimpmdtest.a libim
pcrctest.a libimpsha1test.a
C:/FPC/bin/i386-Win32/rm.exe -rf units
C:/FPC/bin/i386-Win32/rm.exe -f *.o *.ppu *.rst *.s *.a *.dll *.ppl
C:/FPC/bin/i386-Win32/rm.exe -rf *.sl
C:/FPC/bin/i386-Win32/rm.exe -f fpcmade.* Package.fpc ppas.bat script.res link.r
es
C:/FPC/bin/i386-Win32/rm.exe -f *_ppas.bat
make[5]: Leaving directory `C:/Developer/FPC/packages/hash/examples'
C:/FPC/bin/i386-Win32/ginstall.exe -m 755 -d C:\FPC/examples/hash
C:/FPC/bin/i386-Win32/cp.exe -Rfp examples/* C:\FPC/examples/hash
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/all-wcprops': Permi
ssion denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/entries': Permissio
n denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/crctest.p
as.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/Makefile.
fpc.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/Makefile.
svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/md5.ref.s
vn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/mdtest.pa
s.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/prop-base/sha1test.
pp.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/crctest.p
as.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/Makefile.
fpc.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/Makefile.
svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/md5.ref.s
vn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/mdtest.pa
s.svn-base': Permission denied
cp.exe: cannot remove old link to `C:/FPC/examples/hash/.svn/text-base/sha1test.
pp.svn-base': Permission denied
make[4]: *** [fpc_exampleinstall] Error 1
make[4]: Leaving directory `C:/Developer/FPC/packages/hash'
make[3]: *** [hash_distinstall] Error 2
make[3]: Leaving directory `C:/Developer/FPC/packages'
make[2]: *** [packages_distinstall] Error 2
make[2]: Leaving directory `C:/Developer/FPC'
make[1]: *** [installother] Error 2
make[1]: Leaving directory `C:/Developer/FPC'
make: *** [install] Error 2

Another problem I had from 2.2.4 is that the new binaries were mising
a few items like make and some others... So I had to merge missing
files to get 2.5.1 to work.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Windows Seven and SVN source install

2009-11-07 Thread Andrew Brunner
On Sat, Nov 7, 2009 at 12:21 PM, Jonas Maebe  wrote:
>
> You have to build/install an exported copy under Windows due to a bug in
> cp.exe there. First perform
>
> C:\Developer\FPC> svn export . c:\Developer\FPCExport
>
> Then build/install from c:\Developer\FPCExport

Well, if this is a bug I guess it would work itself out later.

> make is not an FPC utility, it is not built when building FPC. It's an
> external program that's used with FPC. That's why you have to copy those
> over if you want to start from scratch.

Ok, under linux make must be readily available w/o FPC.  Ummm.  This
really complicates things for ppl who don't know what they are doing
under Windows.  Linux is FAR EASIER to manage FPC/Lazarus via
SVN/trunk.

I suppose a command line utilty could be made to list PREFIX FPC
folder for missing files that are not present AFTER make install and
that would cover the merging automatcially.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] dynamic array contents and system.move

2010-04-24 Thread Andrew Brunner
David,

I don't see how you are not getting memory leaks by doing a move
before making sure that the destination buffer has the memory
allocated.  You see, in Delphi and FPC, move d/n actually move the
memory... It just copies it.

You were warned :-)

On Sat, Apr 24, 2010 at 3:01 PM, David Emerson  wrote:
> cobines wrote:
>> David Emerson wrote:
>> > move (src.f_data, self.f_data, length(self.f_data) * sizeof(byte));
>>
>> I think it should be:
>>
>> SetLength(self.f_data, length(src.f_data));
>> move (src.f_data[0], self.f_data[0], length(self.f_data) * sizeof(byte));
>
> Well, the setlength is not necessary, and very nearly prevented me from 
> noticing
> the real solution here, f_data[0] -- thanks very much, it is working now.
> (I have this feeling like I have asked this question before. d'oh.)
>
> ~David.
>
> ___
> 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: Re[2]: [fpc-pascal] dynamic array contents and system.move

2010-05-05 Thread Andrew Brunner
> Constants (values) or variable values (variables).

Let's not forget assignable constants that must be typed :-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-05 Thread Andrew Brunner
If Memory allocation is the point of discussion and you need to create
objects ...
You should nest the creations in order of usage.

In your declarations you needed bot Object1 and Object2 as TMyObject;

That said the proper usage would be:

obj1:=TMyObject.Create;
Try
  obj2:=TMyObject.Create;
  Try
Obj1.DoSomething1;
Obj2.DoSomething2;
   Finally
 FreeAndNil(Obj2);
   end;
 Finally
   FreeAndNil(Obj1);
end;

I would like to know what the purpose is for having an auxiliary
constructor if they both reference createObj.

Anything other than nested Exception Handling is very poor practice.

On Mon, Jul 5, 2010 at 1:48 PM, Marcos Douglas  wrote:
> We can to use methods of an object to create others objects, or this
> is a bad programming practice?
> eg:
> var
>  obj1, obj2: TmyObject;
> begin
>  obj1 := tobj1.create; //ok
>  obj2 := obj1.createObj; // is this recommended?
>  try
>  //...
>  finally
>    obj1.free;
>    obj2.free;
>  end;
> end;
>
> Why I ask this:
> If not exists the variable obj2 in call obj1.createObj will happen a
> memory leak, right? Because there is not variable to release.
>
>
> Marcos Douglas
> ___
> 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] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
>> obj1:=TMyObject.Create;
>> Try
>>  obj2:=TMyObject.Create;
>>  Try
>>    Obj1.DoSomething1;
>>    Obj2.DoSomething2;
>>   Finally
>>     FreeAndNil(Obj2);
>>   end;
>>  Finally
>>   FreeAndNil(Obj1);
>> end;
>
> Hum... I do not agree. Why not this? See..
>
> obj1:=TMyObject.Create;
> obj2:=TMyObject.Create;
> Try
>   Obj1.DoSomething1;
>   Obj2.DoSomething2;
> Finally
>  FreeAndNil(Obj1);
>  FreeAndNil(Obj2);
> end;
>

In your example, if obj2:=TMyObject.Create fails (which will happen if
resources are not available)... then the exception is raised and Obj1
never gets freed.  So in an example where this method is re-entrant,
you would see many instances of this occurring.

Nested exception handling is the only way to avoid memory from leaking.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
On Tue, Jul 6, 2010 at 10:31 AM, Marcos Douglas  wrote:
> Better:
>
> obj1 := nil;
> obj2 := nil;
> Try
>  obj1 := TMyObject.Create;
>  obj2 := TMyObject.Create;
>
>  obj1.DoSomething1;
>  obj2.DoSomething2;
> finally
>  obj1.Free;
>  obj2.Free;
> end;
>
> The objectcs are protected. But is boring... :)
> Everybody codify like that, afraid if resources are not available?
>

Nope. If Obj2 failed to create you will have a problem with Obj2.Free.
 If you used FreeAndNil(Obj1) and FreeAndNil(Obj2) that might work
around that one issue... But taking the real issue to the next
level... What if something in Obj1.free raised an exception... Then
you will not free Object2.  The "best" way is with nested exception
handling.  Sorry :-)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
On Tue, Jul 6, 2010 at 11:39 AM, Marco van de Voort  wrote:
> In our previous episode, Andrew Brunner said:
>> > obj1 := nil;
>> > obj2 := nil;
>> > Try
>> > ?obj1 := TMyObject.Create;
>> > ?obj2 := TMyObject.Create;
>> >
>> > ?obj1.DoSomething1;
>> > ?obj2.DoSomething2;
>> > finally
>> > ?obj1.Free;
>> > ?obj2.Free;
>> > end;
>> >
>> > The objectcs are protected. But is boring... :)
>> > Everybody codify like that, afraid if resources are not available?
>> >
>>
>> Nope. If Obj2 failed to create you will have a problem with Obj2.Free.
>
> Nope. That's why it is free and not destroy.

Double Nope.  You cannot access methods of a nil object.  Nil.Free
will in-it-and-of-it cause a read access violation.

>
>>  If you used FreeAndNil(Obj1) and FreeAndNil(Obj2) that might work
>> around that one issue..
>
> Doesn't matter either.
>
>> But taking the real issue to the next
>> level... What if something in Obj1.free raised an exception... Then
>> you will not free Object2.  The "best" way is with nested exception
>> handling.  Sorry :-)
>
> That's the problematic one I think.
> ___
> 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] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
> Wrong again Andrew. Calling .Free is safe (even if the instance
> variable is nil) because internally it checks if the instance exists
> before continuing with calling .Destroy on that instance.  Delphi 101.
>  ;-)

It most certainly is not "safe".  LOL.  Free calls destroy.. Destroy
may contain other frees and routines... You cannot guarantee that free
will even return.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
On Tue, Jul 6, 2010 at 4:41 PM, Graeme Geldenhuys
 wrote:
> On 6 July 2010 19:51, Marcos Douglas  wrote:
>>> That's the problematic one I think.
>>
>> Can an exception happen in Free method?!  :-O
>
> Yes! I often have to debug those in our complex business objects.
>

You got that right.  Which is my point exactly.  If free blows out w/o
a nested exception handle to catch it... The entire object goes into
limbo and will never be free and thus cause a memory leak.  Tell me
someone here realises this (other than me ;-) is the essential point
of this entire thread or I'm going to be very disappointed...
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
On Tue, Jul 6, 2010 at 5:04 PM, Graeme Geldenhuys
 wrote:

> I meant is as in it is safe to call MyObj.Free even if MyObj = nil. I
> answered based on the explicit question.
>
> But yes, in your example where MyObj was an instance, the code in the
> destructor could still trip you up if it caused an exception of some
> kind.
>
Whew,  Ok.  Years back Delphi (the experience I'm drawing on)
Object.Free could not be done.  Now that I know FPC does the check for
nil I probably won't be using FreeAndNil anymore.  But this raises a
large concern for me.  That is the EXTRA if statement being called for
every destruction of every object will lead to a decrease in high
scale operations where Classes were chosen instead of data structures.

I think that who ever decided to add that if statement did so at the
cost of performance for high-scale systems.  That if statement would
never be true if people coding knew what they were doing.  I would
certainly have a case for removing that if statement.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
On Tue, Jul 6, 2010 at 5:09 PM, Graeme Geldenhuys
 wrote:
> Even with a try..except, if you call MyObj.Free and it causes an
> exception, you are screwed either way and it will always cause a
> memory leak. Best is no notify the user some how, or crash out of the
> program, or fire the programmer for not writing enough unit tests. :)

No, if the nesting is done properly you could guarantee that Obj2.Free
would be called even if Obj1.Free failed with some exception.  And
further, nested exception handling offers safeguarding against such
memory leaks during destruction if done properly.  To me this is the
difference between good software and great software... How well it
handles exceptions.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-06 Thread Andrew Brunner
On Tue, Jul 6, 2010 at 8:14 PM, Marcos Douglas  wrote:
> On Tue, Jul 6, 2010 at 7:14 PM, Andrew Brunner
>  wrote:
>> On Tue, Jul 6, 2010 at 5:09 PM, Graeme Geldenhuys
>>  wrote:
>>> Even with a try..except, if you call MyObj.Free and it causes an
>>> exception, you are screwed either way and it will always cause a
>>> memory leak. Best is no notify the user some how, or crash out of the
>>> program, or fire the programmer for not writing enough unit tests. :)

The caveat is that exceptions in the Destroy does not necessarily mean
a memory leak.  The exception object will be taken care of.  So just
make sure the Destroy methods free what they are supposed to free.

>> No, if the nesting is done properly you could guarantee that Obj2.Free
>> would be called even if Obj1.Free failed with some exception.  And
>> further, nested exception handling offers safeguarding against such
>> memory leaks during destruction if done properly.  To me this is the
>> difference between good software and great software... How well it
>> handles exceptions.
>
> Okay, you're right. Nesting exception handling is the only way to
> avoid memory from leaking, in these cases.


> And now? Your program failed (e.g.) using Free method... you assured
> there is no memory leaking (using nesting exceptions), but this is a
> totally _unexpected_ exception!
> IMHO the program should be aborted, the user is notified, log this
> error... start again.

I must admit I am not a subscriber of any practice that allocates with
out strategizing where the memory will be reclaimed.  Everything I do
is accounted for.  So I just don't see any of these issues with
memory.  But because the power is in the developer... this issue is
paramount to developing stable code.

> If the program is a web app, you can't abort immediately (no?)... but
> you'll do it sometime  ;-)

Yes.  My experience is predominately based on a Social Computer Server
engine where it is just not advisable to leak memory.  I can move it,
allocate, deallocate but I just don't have any instances of where I
see memory leaking.  And if there are leaks rebooting the device or
server software is just not an option.

> I'm more concerned with programming errors that can not see
> immediately, such as forgetting to free some object. For me, an
> Exception is an exception! I did not expect and I need do something
> (if the program does not have its own treatment for what occurred).

>From the FPC development team prospective you would be correct.  From
other developers using FPC prospective - if they find themselves
having memory issues a Managed development platform with garbage
collection would be advisable.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-07 Thread Andrew Brunner
On Wed, Jul 7, 2010 at 2:09 AM, Graeme Geldenhuys
 wrote:
> Op 2010-07-07 03:32, Martin het geskryf:
>>
>> And in the 2nd case, mem leaks are no worry => the app is going to be
>> closed, mem will be freed by the OS.
>>[...snip...]
>>
>> The whole memory management could be corrupted. Trying to free
>> memory could just cause more and more exceptions.
>
>
> That is exactly what I was trying to explain to Andrew. If freeing an
> instance is what caused the exception, no amount of try..except or
> try..finally blocks will help you - you still can't free the instance, so
> better notify the user to try and save, then quit the app and start again.
>
Ok.  I think I understand the discrepancy in our reasoning.  The issue
is when exceptions are raised during Obj.Free.  I think it would help
if you would assume that all exceptions raised in Obj.Free were
handled - since my assertion is all developers using a non-managed
platform like FPC.  I'm saying that because if memory is allocated,
and deallocated you will not blow-out the memory manager in FPC.
Meaning, if you catch your exceptions FATAL errors will not even occur
and there will be NO NEED to worry about restarting an application.
Its a clean way of thinking.  I have no worries.  When I call Obj.Free
it can raise exceptions, and still recover to the calling methods -
whether we are talking about ObjX.free or ObjX.DoSomething.

My basic point is that just because an exception is raised does not
mean the method will blow-out.  It will be handled.  LOL... With
exception handling (often nested) where required.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-07 Thread Andrew Brunner
On Wed, Jul 7, 2010 at 8:05 AM, Martin  wrote:
>
> if " obj1.free; " crashes, then yes obj2 is not going to be released. But as
> explained in this and my last mail: It should not be attempted to be
> released.
>

Martin, I can't disagree more.  I find it completely ludicrous that if
obj1.free raises an exception you should just trow the baby out with
the bath water.  If Obj1.Free raised an exception because a disk drive
was unmounted... Inspect the log... Handle the exception... And fix
the problem.  Future instances will be handled and all is good.  It is
my belief that the notion of skipping exception handling and
restarting an application is very bad practice.

> if " obj1.free; " crashed, then the state of the app is unknown, anything
> that the app does from now on could cause more havoc. trying to free obj2
> could destroy value-able user-data that otherwhise may still have been saved
> to a file.

LOL.  If something inside Obj1.free HAD EXCEPTION handling you would
catch the error and understand what caused it.

procedure TObj1.Free;
begin
  Disk1.Unmount; <<< The disk object is missing now b/c a network failure;
  Inherited Destroy;
end;

procedure TObj1.Free;
begin
  Try
Disk1.Unmount;
  Except
On E:Exception do begin
   // Some case stuff here
end;
  end;
  Inherited Destroy;
end;

In my example... Your code would blow out an application.  With my
exception handling the app would continue on as normal with no
problems.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-07 Thread Andrew Brunner
On Wed, Jul 7, 2010 at 8:37 AM, Graeme Geldenhuys
 wrote:
>> procedure TObj1.Free;
>> begin
>>  Try
>>    Disk1.Unmount;
>>  Except
>>    On E:Exception do begin
>>       // Some case stuff here
>>    end;
>>  end;
>>  Inherited Destroy;
>> end;
>>
>
> With the exception of a possible memory leak in case Disk1.Unmount was
> supposed to free up some resources. And if your app is something that
> runs 24/7, that is a *huge* problem! Eventually you will run out of
> memory and the whole thing will come crumbling down (and maybe even
> cause more damage).
>

Grame, no more caveats.  If Unmount had memory that needed to be
released then the same methodology stands.  Disk1.Unmount was placed
there to prove a point.  That w/o handling Obj2.Free would never be
called in context (the outstanding proposed example).

As far as *HUGE* problem.  Having to restart my server would be huge..
Especially in high scale, high available production environments.
Having a handle in place that says CATCH STUFF HERE like Save to SQL
server (if your needing to write to disk).  The example I introduced
is a good one.  Ignoring the exception will indeed cause a fatal
error.  Handling the exception is the best practice here.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-07 Thread Andrew Brunner
On Wed, Jul 7, 2010 at 8:34 AM, Martin  wrote:
> Had you only read to the end of my mail. You are deliberately ignoring
> part of what I wrote and the blame me for the remainder being incomplete?
>
> I clearly stated that there are cases where "free" can raise a valid
> exception, and that the developper has to know this cases, and handle them
> (with nested try blocks).
>
> But I also wrote that (for me) the rule is that most "free" are not expected
> to do so (that may of course be totally different in your code).

Martin, I didn't get to the end of your email because I find that
first major part - part and parcel of why Delphi failed as a language.
 It became unviable because exception handling and blow-outs.  Which
in turn were caused by sloppy ideologies such as the standing notion
here... Which is to let the blow-out occur and move on.  Garbage
collection was the solution to this problem.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] methods of an object to create others objects

2010-07-07 Thread Andrew Brunner
> Well... I think CGI gateway is a good way. If the real app (FCGI) have
> troubles, I can change the URL that the CGI (gateway) uses to call the
> real app and to point to another app (in other server, e.g.). What do
> you think about it?

I think it would be worth discussing what can be done or at least
start thinking about getting the memory manager not to blow-out any
more.  I really don't want to re-start server software just because a
few apps (embedded in the service application) crash.

Has anyone with experience with developing the memory manager been
following?  What about a separate discussion on application
stabilization after an unhanded exception?  That would be a necessity
for at least my platform which is compiled with FPC - and certainly
FCLWeb generated back-end apps too.
___
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


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


[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
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


  1   2   >