Re: [fpc-pascal] Missing messages

2016-10-30 Thread David W Noon
On Sun, 30 Oct 2016 18:11:55 +, Graeme Geldenhuys
(mailingli...@geldenhuys.co.uk) wrote about "Re: [fpc-pascal] Missing
messages" (in <5183ee9b-c6e2-d77f-e5e4-f0b8b12e4...@geldenhuys.co.uk>):

[snip]
> First Lazarus, now FPC. Can we not switch fpc-pascal to a NNTP newsgroup

+1
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

 




signature.asc
Description: OpenPGP digital signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Bitcounting

2016-03-06 Thread David W Noon
On Sat, 5 Mar 2016 19:03:24 +0100, Bart (bartjun...@gmail.com) wrote
about "[fpc-pascal] Bitcounting" (in
<camye31xhge_egouaqk7hegk7by0steko5en11dkg3dmjyxd...@mail.gmail.com>):

> Does FreePascal have a routine for counting bits?
[snip]
> Surely this can be done better?

If you don't mind a bit of C, attached is what I use. It is blazingly
fast compared to examining each bit.

It uses ASCIIZ strings, but can easily be converted to Pascal and
AnsiStrings (or whatever). However, I'll leave that to you.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
#ifndef BIT_COUNT_H_INCLUDED
#define BIT_COUNT_H_INCLUDED

/* Functions to count how many 1-bits or 0-bits are in a buffer area.
 *
 * Copyright (C) 2015, David W. Noon.  All rights reserved.
 * This code is released under the Berkeley License.
 *
 */

#ifdef __cplusplus
#include 
#include  /* Requires C++11 or later. */
#else
#include 
#include  /* Requires C99 or later. */
#endif

/* Function to count the number of 1 bits in a buffer. */
static uint32_t count_ones(const void * buffer, size_t bytes_count)
{
	static const uint8_t ONES[256] = {
			0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
			1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
			1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
			2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
			1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
			2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
			2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
			3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
			1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
			2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
			2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
			3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
			2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
			3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
			3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
			4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 };
	uint32_t result = 0U;
#ifdef __cplusplus
	const uint8_t * byte_ptr = reinterpret_cast(buffer);
#else
	const uint8_t * byte_ptr = (const uint8_t *) buffer;
#endif

	for (size_t ctr = bytes_count; ctr > 0; --ctr)
	{
		result += ONES[*byte_ptr];
		++byte_ptr;
	}

	return result;
}

/* Function to count the number of 0 bits in a buffer. */
static uint32_t count_zeroes(const void * buffer, size_t bytes_count)
{
	static const uint8_t ZEROES[256] = {
			8, 7, 7, 6, 7, 6, 6, 5, 7, 6, 6, 5, 6, 5, 5, 4,
			7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
			7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
			6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
			7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
			6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
			6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
			5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
			7, 6, 6, 5, 6, 5, 5, 4, 6, 5, 5, 4, 5, 4, 4, 3,
			6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
			6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
			5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
			6, 5, 5, 4, 5, 4, 4, 3, 5, 4, 4, 3, 4, 3, 3, 2,
			5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
			5, 4, 4, 3, 4, 3, 3, 2, 4, 3, 3, 2, 3, 2, 2, 1,
			4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0 };
	uint32_t result = 0U;
#ifdef __cplusplus
	const uint8_t * byte_ptr = reinterpret_cast(buffer);
#else
	const uint8_t * byte_ptr = (const uint8_t *) buffer;
#endif

	for (size_t ctr = bytes_count; ctr > 0; --ctr)
	{
		result += ZEROES[*byte_ptr];
		++byte_ptr;
	}

	return result;
}
#endif /* BIT_COUNT_H_INCLUDED */
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] is scrypt available?

2015-10-27 Thread David W Noon
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Mon, 26 Oct 2015 22:02:23 -0400, Wkitty42 (wkitt...@windstream.net)
wrote about "Re: [fpc-pascal] is scrypt available?" (in
<562edb2f.4080...@windstream.net>):

> On 10/26/2015 06:28 PM, David W Noon wrote:
[snip]
>> I use PostgreSQL, which offers MD5 hashing of passwords as a
>> built-in, without me adding any of my own (or anybody else's)
>> code to perform hashing.
> 
> sadly MD5 have been being cracked in little time for over a
> decade... that's why we're looking at other means...

Well, we can start here:

<https://en.wikipedia.org/wiki/Secure_Hash_Algorithm>

I also own a couple of books by Bruce Schneier, the doyen of cryptography.

More recently, there is RFC 6234. This was published in 2011 and its
hashes are considered secure at the moment.

<https://tools.ietf.org/html/rfc6234>

> bcrypt came up first in the searched and then scrypt was pointed
> out along with bcrypt's failings... the question now is being
> able/willing to use someone else's code or to reinvent the wheel...
> if it were me, i'd use the other code if its license fits the app
> in question...

I could code up almost any of these algorithms you want. I have
reference implementations under Linux to test the validity of my code.
I would make any such code available under the Berkeley License (or
GPL v3). Indeed, I would make the source code available to all FPC
users if there is interest in hashing here.
- -- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iEYEARECAAYFAlYvuqwACgkQogYgcI4W/5QTEACeIgNf72/m5i1d4XY4RkMbN0UR
QocAnRBkqsYbQR7e7LGDOFK/ZVkG6/G7
=qaUT
-END PGP SIGNATURE-
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] is scrypt available?

2015-10-26 Thread David W Noon
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Mon, 26 Oct 2015 16:54:16 -0400, Wkitty42 (wkitt...@windstream.net)
wrote about "Re: [fpc-pascal] is scrypt available?" (in
<562e92f8.1010...@windstream.net>):

[snip]
> no, i haven't heard of dcrypt... i'm specifically after scrypt for 
> securing passwords in a database...

So what you are really after is a hash, rather than streaming or block
cryptography.

I use PostgreSQL, which offers MD5 hashing of passwords as a built-in,
without me adding any of my own (or anybody else's) code to perform
hashing.

HTH
- -- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iEYEARECAAYFAlYuqQIACgkQogYgcI4W/5RChQCeJxDxcBuycuHZRJKywuQdhwDo
8DYAoIXF4Q0kgOpMZNdHtNIcH8RFfO/n
=tvjb
-END PGP SIGNATURE-
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] quality of FPC random

2015-08-20 Thread David W Noon
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Thu, 20 Aug 2015 22:50:05 +0200, Klaus Hartnegg (hartn...@gmx.de)
wrote about Re: [fpc-pascal] quality of FPC random (in
55d63d7d.6040...@gmx.de):

 Am 14.08.2015 um 15:38 schrieb Xiangrong Fang:
 I need to generate random numbers to be used as IV of block
 ciphers.  My question is: is FPC built-in PRNG good enough as
 comparing to /dev/urandom?
 
 NO!!! For crypto always use /dev/urandom
 
 On the other hand, /dev/urandom in my impression is fairly slow,
 how is the speed of Random() comparing to that?
 
 Speed is irrelevant, because you do not need many truely random
 numbers for crypto. For crypto always use /dev/urandom

man 4 random

The /dev/urandom device can resort to a PRNG and can, therefore, be
attacked when used for crypto.  Consequently, /dev/urandom is *not*
universally suitable for cryptographic purposes.

In contrast, /dev/random is based on the system entropy pool.  Its
numbers are genuinely random.  The downside is that if the entropy
pool runs low on bytes, read requests will block until the pool is
refilled.

On this machine, I have a hardware random number generator on the bus
control chipset and a daemon process that uses the hardware to top up
the entropy pool when it gets low.  I highly recommend such a set-up.
 Failing that, you can use the HAVEGE daemon (Google is your friend)
to top up the entropy pool from other sources, if you don't have a
hardware RNG.
- -- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iEYEARECAAYFAlXWWF4ACgkQogYgcI4W/5RqJQCgsVvdf3ihJrvqs4UQdICQTB7T
epkAoMXQR+Kjai///7EibePEoT6RUoq/
=IGX0
-END PGP SIGNATURE-
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using Cairo lib on Linux without X

2015-04-07 Thread David W Noon
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Tue, 7 Apr 2015 22:13:51 +0300, Juha Manninen
(juha.mannine...@gmail.com) wrote about [fpc-pascal] Using Cairo lib
on Linux without X (in
CAPN1EhAK6YF2+AJ1To4qD064cr5+UXq14MFeUncwCM_2K=x...@mail.gmail.com):

[snip]
 Cairo is advertized to support multiple output devices, including
 X Window, image buffers, PostScript, PDF, and SVG file output. I
 understand it means that X Window is required only for the X Window
 backend. PDF or SVG backends should not require X Window.

If you build the library from source, you can select various output
streams during the configure script.  We Gentoo users have that choice
since we build almost everything from source with configuration flags
to drive the configure script.

 However on my Linux Mint 17 libcairo has a dependency for
 libX11.so.6.

That's because the Mint people have configured it for X11.
- -- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iEYEARECAAYFAlUkMe8ACgkQogYgcI4W/5QOtgCgplRdO5D1YXUHCiIIUKtOGdyB
CG0AoLV/tfRJKIGZMwsgHDRnAe0aRHB4
=LJZz
-END PGP SIGNATURE-
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Size of a partition

2014-12-19 Thread David W Noon
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Sat, 20 Dec 2014 00:00:35 +0100, Rainer Stratmann
(rainerstratm...@t-online.de) wrote about Re: [fpc-pascal] Size of a
partition (in 20141220.35347.rainerstratm...@t-online.de):

 Hi Dave!
 
 that's exactly what I was searching for. Thanks a lot.

You're welcome.

 One question is left:
 
 Where can I read the blocksize. Normally it is 512 bytes. But there
 are (newer) devices where there is a different blocksize. Also a CD
 has a different blocksize as far I know.

There are 2 functions in the unit to do that:
get_physical_sector_size() and get_logical_sector_size().

If the disk's sector size is 512 bytes they will give the same answer.
 Likewise, for a CD or DVD they will give the same answer of 2048 bytes.

If a disk has a physical sector size of 4096 bytes, it is up to the
SATA/SAS driver to publish a logical sector size of either 4096 or
512.  I think this configuration is determined when you partition the
drive, where using GPT sets it to 4096 and using DOS-style partition
reverts it to 512 bytes, but this is just my guess -- I don't have a
large disk on which to test.
- -- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iEYEARECAAYFAlSUscQACgkQogYgcI4W/5To2wCfeUNNrWY1Gl7KK/HRvLdzUfWs
aZ8An2jp7kBJcJkGkdSmLP/C4DxZ35SU
=zCW3
-END PGP SIGNATURE-
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Range checking in a for loop

2010-10-25 Thread David W Noon
On Mon, 25 Oct 2010 01:06:16 -0700 (PDT), leledumbo wrote about
[fpc-pascal] Range checking in a for loop:

[snip]
program test;

var
  a: array [1..3] of Integer;
  i: Integer;
begin
  for i := 1 to 4 do
a[i] := i;
end.

The compiler will accept this code happily, despite the fact that
there's an out of bounds array index when i = 4.

There is no reason in the for-loop construct that i cannot have the
value 4; it is only a problem when i is used as a subscript on the
array a.

Try declaring
   i : 1..3;
instead, as that range matches the array's bounds.  You should then get
a range check at compile time.  It is also the idiomatic Pascal way of
doing this.
-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread David W Noon
On Mon, 18 Oct 2010 15:42:31 +0200, Florian Klaempfl wrote about Re:
[fpc-pascal] Can variables be declared within a block?:

[snip]
 It's just a matter of readability, e.g. having a variable declared in
 two blocks with the same name can cause you a lot of headache:
 
 procedure p;
 
 begin
   ...
   begin
 var i : integer;
 ...
 ...
 ...
 i:=12341234;
 ...
 ...
 ...
 ...
   end;
   ...
   ...
   ...
   begin
 var i : integer;
 ...
 writeln(i); --- this i is not the same as above so i does not
 contain 12341234 but it contains probably some garbage.
   end;

This was not usually a problem in ALGOL 60/68, PL/I or C/C++ -- these
languages have supported short scopes for up to 50 years -- as the
programmer was required to be aware of the different scopes of the
like-named variables.

I still use short scoped variables today, usually in C or C++.  I have
never had any such problems, even going back almost 40 years when I
programmed in ALGOL 60.  All block structured languages require the
programmer to understand the scope of all variables.

Indeed, short scopes can often circumvent name collisions, e.g.

 long some_func(unsigned long arg_1)
 {
long i;  /* procedure/function scoped */
unsigned max_iters;
. . .
/* calculate i, max_iters and any others */
. . .
for (unsigned i = 0; i  max_iters; ++i) /* short scope i */
{
   /* i here is distinct from the one at function scope. */
   . . .
}
. . .
return i; /* back to procedure scoped i. */
 }

Whether it is wise to use such lax naming of variables is open to
debate, but at least C and C++ allow the above.

That said, short scoping was never a part of original Pascal.  I think
Jensen  Wirth omitted it because it made the compiler simpler.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Can variables be declared within a block?

2010-10-18 Thread David W Noon
On Mon, 18 Oct 2010 19:46:04 -0200, Andreas Berger wrote about Re:
[fpc-pascal] Can variables be declared within a block?:

 
  for (int i = 0;...)
  Can't see anything wrong. I use declaration of variables inside
  blocks quite often in Java and C++ but have never missed it in
  pascal. Please enlighten me. What is so bad about creating
  temporary variables inside blocks instead of the beginning of a
  function in a language that supports it?
 
  R.
 But it should make you wonder why this is no longer allowed in the 
 latest C++ standards.

What do you mean?

The current C++ standard (ISO 1998+TR1) permits short scope
declarations.  Indeed, C++ permits declarations to appear anywhere, not
just after a { to open a function or compound statement.  It has done
since the A.R.M. days, and in some implementations before that.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Detecting what is the linux distro

2010-10-12 Thread David W Noon
On Tue, 12 Oct 2010 09:54:35 +0200, ik wrote about Re: [fpc-pascal]
Detecting what is the linux distro:

 On Tue, Oct 12, 2010 at 09:30, Henry Vermaak
 henry.verm...@gmail.comwrote:
[snip]
  Just curious, why would you like to detect this?
 
 
 You want to know how to install files for daemons, append information
 in other existed packages etc... But instead of creating 1000%
 packages types for each distro, you can for example know  that Gentoo
 and ArchLinux uses /etc/rc.d/ for init deamons.
 You know that Debian, CentOS, RedHat and few others uses /etc/init.d/
 etc...

Both of those directories are used by virtually all UNIX
implementations. /etc/init.d/ contains the init scripts for system
daemons, whereas /etc/rc.d/ contains the configuration files that are
interpolated into the init scripts to establish environment variables
for the daemons.  These directories do not have an either/or
relationship.

This is a consequence of using an init process based on the System V
model.

Why don't you just use a package manager, such as apt/dpkg, Portage,
RPM, etc., instead?  Most distros can handle more than one of these.
For example, I run Gentoo, and it will handle .deb and .rpm packages,
as well as its native Portage ebuilds.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Detecting what is the linux distro

2010-10-12 Thread David W Noon
On Tue, 12 Oct 2010 16:29:42 +0200, Sven Barth wrote about Re:
[fpc-pascal] Detecting what is the linux distro:

 Am 12.10.2010 14:01, schrieb David W Noon:
[snip]
  This is a consequence of using an init process based on the System V
  model.
 
 ArchLinux does not use a System V init system, but a simpler BSD one. 
 And thus it does not use /etc/init.d, but only /etc/rc.d.

So does the BSD init use run levels?  One of the major distinctions
between /etc/init.d/ and /etc/rc.d is that the latter is segregated by
run levels, so that each daemon can have a different environment for
different run levels.  All of the actual init scripts in my /etc/rc.d/
ultimately resolve to symlinks into /etc/init.d/, which is typical for
any System V style system.

Indeed, this makes installing a script directly into /etc/rc.d/ a
strict no-no under Gentoo, as all insertions into a run level have to
be performed by the sysadmin by hand; other Linuxes are more
permissive, though.  Consequently, I would never want any program to
install anything into that directory, except by the rc-update program
run by hand.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Optimized matrix multiplication functions for pascal?

2010-10-09 Thread David W Noon
On Sat, 9 Oct 2010 07:59:26 +0200, Bo Berglund wrote about [fpc-pascal]
Optimized matrix multiplication functions for pascal?:

[snip]
 Where can I find such functions?

They are available in a library named LAPACK.  You can find downloads
by doing a Google search on this name.  It is coded in FORTRAN though.

 I am not a matematician myself so I don't know what these 
 functions really do...

They are easy to code, as they are simple linear algebra.  A good
textbook on linear algebra would be a great help to you.

However, LAPACK gets mighty complicated when it gets into other areas
of numerical linear algebra.  If your FORTRAN code uses more
complicated routines, you might find it convenient simply to call the
LAPACK FORTRAN code directly.  Maintaining a Pascal version of LAPACK
would be a non-trivial -- even arduous -- task, but you could check the
FPC Wiki to see if somebody might already have done that for you.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Help translating C++ to Object Pascal

2010-09-14 Thread David W Noon
On Tue, 14 Sep 2010 11:50:31 +0200, Graeme Geldenhuys wrote about
[fpc-pascal] Help translating C++ to Object Pascal:

 In a C++ method as shown below, does the '... return True;'
 immediately exit the HandleClientMessage method, or will it still
 continue processing the remainder of the method (just exiting the
 current code block)?

It will return directly to the calling routine.  The following
statement:

   return OXCompositeFrame::HandleClientMessage(event);

will be ignored.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] ReadLine history works in windows/cmd.exe but not in bash/linux

2010-09-01 Thread David W Noon
On Wed, 1 Sep 2010 19:30:07 +0200, Dusan Halicky wrote about
[fpc-pascal] ReadLine history works in windows/cmd.exe but not in
bash/linux:

 I compiled it in windows (FPC 2.4.0), run it in cmd.exe and I was
 surprised that history of commands is working out of the box (by
 pressing arrow UP).

That is standard behaviour for most modern shells.

 Can you help me to make readln history working on linux too?

The readln() function has nothing to do with libreadline.

The problem you are seeing is due to the shell you are using and the
key binding options you have assigned or defaulted to in the shell
and/or the terminal emulator. It has nothing to do with FPC.

Try:

man 1 bash

and see how you can set the options you need.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


signature.asc
Description: PGP signature
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] ReadLine history works in windows/cmd.exe but not in bash/linux

2010-09-01 Thread David W Noon
On Wed, 1 Sep 2010 21:17:04 +0200, Dusan Halicky wrote about Re:
[fpc-pascal] ReadLine history works in windows/cmd.exe but not in
bash/linux:

  If you run the program twice, you'll see that you can scroll back
  even to what you typed in the first run of the program; This is
  clear proof that it is not the program itself which does that.
 
 Ok. This somehow convinced me. Can I achieve the same thing in bash?

Not bash itself, but you can call readline() explicitly and achieve the
desired effect.

Remember that the program and the shell are largely independent under
all UNIX systems, including Linux.  So, if you want the scrollback
capabilities you need to use the appropriate API.
-- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.n...@ntlworld.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Which -Op??? parameter is appropriate

2010-02-26 Thread David W Noon
On Fri, 26 Feb 2010 11:16:53 +0200, Graeme Geldenhuys wrote about Re:
[fpc-pascal] Which -Op??? parameter is appropriate:

 Graeme Geldenhuys wrote:
  
  Is -OpPENTIUMM better or worse than -OpPENTIUM4?  Is any of them
  appropriate for a Core2Quad CPU?
 
 OK, I think I answered my own question when I tried it on my projects.
 
 
 -OpATHLON64 seems to be the option for my CPU type. 'fpc -i' gives
 you the available options. Lazarus IDE seems to use a hard-coded set
 of values, not actually what the current fpc compiler supports.

I always put my hardware-specific options in /etc/fpc.cfg, so that all
users [of the compiler] on my systems get the right options for local
usage of the compiled applications.  Hopefully, Lazarus does not
override them with any hard-coded values.

If I were shipping compiled binaries, I would take a more lowest
common denominator approach, specifying an 80386 or some such.
However, I don't have that problem.
-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] some new features to delphi prisem

2010-02-21 Thread David W Noon
On Sun, 21 Feb 2010 20:37:12 +0100, JoshyFun wrote about Re[2]:
[fpc-pascal] some new features to delphi prisem:

 Sunday, February 21, 2010, 7:29:54 PM, you wrote:
 
 MK This is a matter of taste, I can imagine uses when at least
 MK functional if would make code *more* readable. Noone forces
 MK programmers to convert all their case/if to functional versions
 MK if they look unreadable. The functional variants are supposed to
 MK be used in particular situations, when they make sense.
 
 For me the bigger problem is that both statements change its behavior
 in function of its context.
 
 if a=b then 1 else 2;

That is an attempt at a statement, but what is being offered in Prism
is an enhanced *expression* syntax.

 this is a pascal error, but
 
 z := if a=b then 1 else 2;

This is actually valid ALGOL 60 and/or ALGOL 68.  Conditional
expressions were available in both languages.  I think Niklaus Wirth
continued with this in ALGOL W, but dropped it from Pascal.

Note that the ALGOLs required the else clause, as does C today (see
below).

 Is it correct ? From my point of view is much more reasonable to use
 something like:
 
 z := iff(a=b,1,2);

This is over-punctuated Visual BASIC.  Yuck.

 But to me it looks awful and a bit of c-ism and really horrible code
 could be written:
 
 z: Boolean;
 begin
 z := iff(a=b,iif(b=2,a=b,ba),not(a=b));

Mega-yuck!!

I can only infer that you don't write C.  The C equivalent is:

   z = a == b ? 1 : 2;

It's terse, but one gets used to it.
-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] programmatically creating desktop icons under Linux

2010-02-07 Thread David W Noon
On Sun, 7 Feb 2010 23:43:52 +0200, Graeme Geldenhuys wrote about Re:
[fpc-pascal] programmatically creating desktop icons under Linux:

 On 7 February 2010 23:42, Graeme Geldenhuys graemeg.li...@gmail.com
 wrote:
 
  Creating symbolic links (ls -s src target) should suffice.
 
 Typo, it should read:  ln -s src target

Actually, there is a symlink() API that can be called without creating a
separate address space for an external command.
-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Early BSD's Pascal system

2009-10-06 Thread David W Noon
On Tue, 6 Oct 2009 23:44:28 +0800, 章宏九 wrote about [fpc-pascal]
Early BSD's Pascal system:

 I notice that in early 1977, BSD contains a Pascal interpreter (or
 maybe compiler, I am not sure). How was it later? Is there any remain
 archives?

I suspect it is the UCSD (University of California at San Diego) Pascal
compiler. It compiled source to p-code and its run-time interpreted the
p-code tokens (a la Java, today).

Google is your friend.
-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Checking Linux process existence (child or not) without OS command ?

2009-09-21 Thread David W Noon
On Mon, 21 Sep 2009 14:58:20 +0200 (CEST), T. Guilleminot wrote about
[fpc-pascal] Checking Linux process existence (child or not) without OS
command ?:

 Does anyone know a simple way to check if a Linux process exists/runs
 (child or not) *without* running an OS command via TProcess (or
 other)?

One word: procfs

I don't know how you plan to identify the process: by program name,
process id., parent process id., or running as a specific userid.

Whatever you choose, you scan /proc and its subdirectories to see
everything else that is running in userspace under Linux. All the
entries can be treated as text files of directories.
-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


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

2009-09-19 Thread David W Noon
On Sat, 19 Sep 2009 10:25:20 +0200, Micha Nelissen wrote about Re:
[fpc-pascal] Re: getting started with threads:

 Graeme Geldenhuys wrote:
  So far I have single interface for create/destroy/lock/unlock of
  semaphores for Windows, Linux, *BSD. The latter two is actually for
  all
 
 A semaphore is not locked and unlocked, it is posted and waited
 for.

An event semaphore (or condition in POSIX-speak) is waited for and
posted.

A simple mutex semaphore is locked and unlocked -- or, more
idiomatically, acquired and released.

A read/write mutex semaphore (or rwlock in POSIX-speak) is acquired
for sharing or acquired for exclusion and released.

A Dijkstra semaphore is upped or downed. This is the original usage
of the term semaphore in computing. It is largely useless in
comparison to the other types of semaphore.
-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] The names of the various FPC documentation

2009-09-07 Thread David W Noon
On Mon, 7 Sep 2009 12:12:42 +0200 (CEST), Michael Van Canneyt wrote
about Re: [fpc-pascal] The names of the various FPC documentation:

 On Mon, 7 Sep 2009, Graeme Geldenhuys wrote:
 
  Such an old file-system limitation does not apply in newer OS
  versions anymore. I must say, old habits die hard! :) I often find
  myself naming eBooks, TV series or music with underscores instead
  of spaces. But lately I started using actual spaces in such file
  names as well. It simply makes them look prettier in my file
  manager tool.
 
 I almost exclusively use the command-line, and a lot of shell
 scripts, and in that case quotes and spaces are a pain.

Indeed, quotes () and apostrophes (') are a particular pain, as most
shells use them as meta-characters for wrapping arguments to programs.
They need to be escaped or wrapped, so that the shell ignores them and
passes them through to the underlying application program -- in this
case a PDF reader.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TFileStream.SetSize sometimes fails

2009-08-14 Thread David W Noon
On Fri, 14 Aug 2009 09:19:40 +0200 (CEST), Michael Van Canneyt wrote
about Re: [fpc-pascal] TFileStream.SetSize sometimes fails:

 On Thu, 13 Aug 2009, Mattias Gaertner wrote:
[snip]
  This will loose the access rights and type of the file.
 
 Why does that matter ? I don't think the IDE needs to preserve these.

Any program that updates a file and in so doing alters the
security mask or deletes any ACL's or extended attributes of that file
is intrinsically broken.

If I have a source file to which I have assigned an ACL permitting
another specific user to access the file, that ACL *must* stay in
place. Likewise, if I have set a security mask to keep other users in
my group out of a file, i.e. 0600, that security mask must be
preserved.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-20 Thread David W Noon
On Sat, 2009-06-20 at 18:31 +0200, Jürgen Hestermann wrote:

   Richard Ward schrieb:
  In my opinion also, the 
  semantics should be changed to reflect the actual nature of the 
  construct and behavior.   
 
 Agree.

I think Richard Ward actually meant the syntax, not the semantics.

The semantics of static duration are fixed and need to be so. The
current syntax of the inconstant constant is nonsensical, really. It
smacks of an almighty kludge.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Writeable typed constants - what's the point?

2009-06-19 Thread David W Noon
On Fri, 2009-06-19 at 18:35 +0200, Jürgen Hestermann wrote:

  The var version, acts as if your first statement in the procedure was 
  a:= 1;. It initializes the variable each time you enter the function. 
  If you enter the function recursively, then each level, has it's own a, 
  not touching the value of the callers a
 
 I also used Borlands const-hack a lot. But now I changed my behaviour 
 and use VAR declarations directly before the function declaration (one 
 level higher, outside the function context). That serves the same purpose.

The writeable const hack is slightly different in that the scope of the
inconstant constant is local to the function, whereas moving it to a var
at global scope makes it visible to all functions within the unit.

This issue has been a criticism of the Pascal language dating back to
the days of Jensen and Wirth. In ALGOL 60, variables with static
duration were declared as own, which made no sense in English terms;
worse still, ALGOL 60 had no initializers at all, so these variables
could not be initialized at program load time. In contrast, PL/I used
the attribute STATIC, which described the semantics concisely, and
permitted an INIT() option to set an initial value. [In those days, both
FORTRAN and COBOL used static duration with no option available to alter
it. Yuck!]

I think it is more expressive to make the semantics clear by declaring
an inconstant constant as a variable -- because that's what it is --
with a duration modifier to show that it has static duration. I suppose
that for symmetry there should be an antonym, automatic, which is
accepted by the compiler but produces the current, default semantics.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A complex trouble(at least for me)

2009-05-08 Thread David W Noon
On Fri, 2009-05-08 at 09:41 -0300, Arí Ricardo Ody wrote:

 It's out matter but, I'm working with legacy 
 modernization. The company I work deals with 
 legacy modernization. Mainly in mainframes

So, are you trying to convert COBOL code to some more modern language?

If not, I still don't understand what you are trying to do.

Moreover, very few modern languages implement COBOL semantics,
especially as regards decimal arithmetic. You will likely need to
generate assembler code for your target platform, and that is even more
of a legacy approach to software than coding in COBOL. [Note: double
precision floating point does *not* implement decimal semantics, in
spite of it seeming an easy substitute.] The modern language that is
most likely to provide you with decimal capability is Java; it also runs
even slower than COBOL.

Assuming you are trying to automate conversion of COBOL source to some
newer language, then you will largely need to write a parser for the
COBOL grammar. This is far from trivial. You will then need to write an
emitter for your chosen modern language, so that you rebuild the COBOL
semantics as exactly as possible.

From your original message, you seem to be still working on the parser.
I would suggest you use a more compiler theoretical approach than just
generating a string list. If you encode the parsed COBOL source into
some internal meta-language, this will make your emitter much easier to
write. Better yet, if your encoding includes some semantic analysis of
the COBOL source, you can optimize the generated code so that it both
runs better and is easier maintained in your modern language.

Just my 2¢ worth.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] A complex trouble(at least for me)

2009-05-07 Thread David W Noon
On Thu, 2009-05-07 at 18:12 -0300, Arí Ricardo Ody wrote:

 Suppose the following structure:
 
 01 a-1.
03 b-1 pic xxx.
03 b-2 pic 999.
03 b-3.
   05 c-1 pic aaa.
   05 c-2.
  07 d-1 pic zzz.
  07 d-2 pic xxx.
   05 c-3 pic 99.
03 b-4 pic zzz.
03 b-5.
   05 e-1 pic zzz.
 
 All line not containing the word pic I would call a group item and the
 other lines will be elementary items.

This is loosely COBOL source code.
 
 I would like to wrote a routine(or program) that save each group item
 and the elementary items contained in a StringList. Admit that the
 pattern of the structure is random. The example above is only an
 example.
 
 In this example:
 StringList1 will contain 'a-1' '03 b-1 pic xxx.' '03 b-2 pic 999.' '03
 b-4 pic zzz.'
 StringList2 will contain 'b-3' '05 c-1 pic aaa.' '05 c-3 pic 99.'
 StringList3 will contain 'c-2' '07 d-1 pic zzz.' '07 d-2 pic xxx.'
 StringList4 will contain 'b-5' '05 e-1 pic zzz.'

Do you want to put the COBOL source into a TStringList?
 
Are you trying to write a COBOL compiler?

If not, what are you trying to do?

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Syntax problem with first unit

2009-04-05 Thread David W Noon
On Sun, 2009-04-05 at 10:03 -0400, Francisco Reyes wrote:

 Mehmet Erol Sanliturk writes:
 
  Unit and function names DebugPrint are the same .
  Pascal is case insensitive . Making their cases different does NOT
  make them different .
  
  Please make them different and retry .
 
 Thanks. That worked.
 
 It may help newcomers like myself if this was mentioned on the ref document. 
 Just double checked and it does not mention this.
 
 Likely an error that people will only commit once, but still would be nice 
 to have int he ref doc.

But the Pascal language has *always* been case insensitive. [As are
FORTRAN, PL/I, ALGOL 60/68, COBOL and a host of others.]

I wrote my first Pascal programs on punched cards around 1975, hosted on
a Control Data Corp. Cyber 72 mainframe. The key-punch machines we used
to punch the cards did not support lower case letters, so we could not
readily prepare case sensitive input. This is why almost all the older
generation of programming languages are case insensitive.

Once we started using timesharing on the mainframe, we were
automatically accustomed to lower case letters being treated the same as
capital letters, as even the system commands were punched in capital
letters on cards, but typed as lower case from a terminal.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Find out local IP adress

2009-03-22 Thread David W Noon
On Sun, 2009-03-22 at 20:36 +0100, Rainer Stratmann wrote:

 Am Sonntag, 22. März 2009 20:24 schrieb Jonas Maebe:
  On 22 Mar 2009, at 20:21, Rainer Stratmann wrote:
   May be there exists another way to find out the local IP adress.
 
  The local ip address does not exist. A system can have multiple
  network cards, there can be vpn tunnels, NAT gateways to other
  networks and virtual machines, ... Which of these local addresses are
  you interested in?
 
 The IP adress of the network card(s).

Since the machine can have several NICs, you first need to decide which
one. If your machine has only one, then this is easy.

There is an ioctl for querying the IP address of a given Ethernet
interface, for which you need to open a socket. It is SIOCGIFADDR. See:
man 2 ioctl_list

If you want some C++ code to perform this, I can send you some via
private email. It's up to you to translate it to Pascal.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Can I incorporate PDF files?

2009-02-20 Thread David W Noon
On Fri, 2009-02-20 at 15:49 -0200, John Coppens wrote:

 On Fri, 20 Feb 2009 12:35:07 -0500
 John Youngquist jo...@iaw.com wrote:
 
  I would like to add a help facility that would search a topic in a
  PDF format manual and display the appropriate page. It there
  Module to read and search PDF file available.
 
 An easy solution in Linux would be to call xpdf from the program. You can
 specify the PDF on the line, and either a page number to jump to, or a
 named destination (if they were defined inside the pdf).

What causes you to believe everyone has XPDF installed?

A more widely used option would be Ghostview, but even that cannot be
guaranteed.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Simple question about {$R +}

2009-01-31 Thread David W Noon
Hi all,

When I use a dynamic array and SetLength(), does the {$R +} option check
subscript ranges on that array?

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] CPU affinity of TThread descendants

2009-01-24 Thread David W Noon
On Tue, 2009-01-20 at 21:20 +, David W Noon wrote:

[snip]
 I have noticed one thing that might shed a little light on the topic:
 whenever I use a pipe for the output and I allow the pipe to stall with
 a full buffer, after execution is resumed the program sometimes restarts
 on the other CPU, but again all threads run on the same CPU.

I have finally tracked down what is going on here, and the above was a
significant hint.

In years past, the SMP Linux kernel would dispatch threads to CPUs using
a more-or-less round-robin basis: whenever a thread was preempted or
yielded its timeslice, the kernel would try to use the next available
CPU to dispatch the next true-ready thread. This had the nice effect of
spreading the thermal stress across all CPUs fairly evenly. However, if
the next true-ready thread happened to be in the same process as the
preempted/yielding thread, the caches, TLBs, etc., would have to be
flushed from the current CPU and then reloaded on the next CPU.

With current (2.6) kernels, this approach has changed. The current CPU
is reused, so that when the next true-ready thread happens to be in the
same process, the caches, TLBs, etc., are already valid.

Now, the thread routines in my test program all pivot on the one mutex
semaphore and do very little work before blocking again, so only one of
them can execute at any point in time. This has the effect of reducing
the execution model to that of a uniprocessor system. I added some bogus
CPU-intensive workload that ran outside of the mutex, so that this could
be executed by more than one thread concurrently. The upshot was that I
could get both CPUs at 100% busy.

This also led me to the discovery of a similar concept tp CPU affinity,
called thread scope. There are 2 APIs, called pthread_attr_setscope()
and pthread_attr_getscope(), the first of which allows a thread to be
created with a scope of PTHREAD_SCOPE_PROCESS or PTHREAD_SCOPE_SYSTEM.
The behaviour I was seeing was akin to PTHREAD_SCOPE_PROCESS, which ties
all threads of that scope within a process to dispatch on the same CPU.
However, Linux does not implement this thread scope; it only implements
PTHREAD_SCOPE_SYSTEM, which allows a thread to be dispatched on any CPU
to which it has an affinity.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] CPU affinity of TThread descendants

2009-01-20 Thread David W Noon
On Tue, 2009-01-20 at 11:34 +0100, Vinzent Höfler wrote:

  Original-Nachricht 
  Datum: Tue, 20 Jan 2009 09:07:54 +0100 (CET)
  Von: Michael Van Canneyt mich...@freepascal.org
[snip] 
  No CPU affinity is imposed as far as I know; 
  Under Linux, this is not possible, at least I've never heard of such a
  call.
 
 sched_set_affinity()
 sched_get_affinity()

Correct spelling:

sched_setaffinity()
sched_getaffinity()

 (Now you've heard. ;)

There are also pthread_setaffinity_np() and pthread_getaffinity_np(),
where the _np suffix is a mnemonic for non-portable.

 The default for the CPU masks should be all 1s though, so the scheduler
  should distribute the threads evenly to all available CPUs. But... AFAIR
  the affinity mask is inherited by child processes, so maybe the main
  thread already has some affinity mask set (well, I don't see no reason
  why it should, but you never know).
 
 So for the original poster I'd suggest inserting a sched_get_affinity()
  call and check the resulting bit mask. If that's not all 1s, one should
  investigate the reason... if it is, then maybe the scheduler detects too
  many dependencies between the threads, so it doesn't distribute the
  thread on both CPUs, or maybe there's one totally different reason for
  the behaviour...

I have checked the CPU masks for all threads and the first byte is
always 0x03, which indicates that both CPUs can be considered for
dispatching the thread.

I have noticed one thing that might shed a little light on the topic:
whenever I use a pipe for the output and I allow the pipe to stall with
a full buffer, after execution is resumed the program sometimes restarts
on the other CPU, but again all threads run on the same CPU. This would
indicate to me that the child threads are tightly associated with the
parent thread, as far as CPU selection goes.

I will reimplement my code in C++ using wxWidgets and its wxThread
class, and see what behaviour that produces.

I might also reimplement the code in C, using the pthread_??? family of
API calls in their raw state. This could be a bit ugly, as the code is
decidedly object oriented.

As it appears that this issue is at a lower level than the TThread
class, we might need to examine the BeginThread() function of the RTL.
However, it could be attributable to the threading library I use with
Linux (NPTL, in my case).

I shall report back with whatever I find.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] CPU affinity of TThread descendants

2009-01-19 Thread David W Noon
Hi,

I am running FPC 2.3.1 under Linux 2.6.26 on a twin CPU AMD Athlon MP
system.

Whenever I instantiate multiple descendants of the TThread class, they
all seem to run on the same CPU, which is the same CPU as the parent
thread is running on. With 21 threads in the program, the system monitor
shows one CPU at 100% busy and the other CPU idle.

Does this class, by default, impose CPU affinity, in the manner of the
Windows NT/2K/XP CreateThread() API? If so, how can I disable this?
[I.e., I want all my threads to be runnable by any CPU inside the box.]

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Unit/library for writing data structures to files

2008-08-10 Thread David W Noon
On Sun, 2008-08-10 at 16:51 -0400, Francisco Reyes wrote:

 Michael Van Canneyt writes:
 
  You can also try the Classes unit if you use object oriented programming.
  Each component can write itself to stream.
 
 Played a little bit with the Classes unit.
 Don't really see any benefit over justin writing records directly.
 Am I missing something?
 
 Also when reading back, on both cases(class or directly using records) it 
 seems I need to use fixed length records. At least based on the examples I 
 have seen so far. Is there a way to save variable length records and then 
 read them back?

Normally you write the length as a prefix before the record, typically
as some kind of integer type (e.g. LongWord or TsSize). When you read
the record later you read the length prefix first, then read the number
of bytes that the prefix specified. As a rough and ready example:

in_file := FpOpen('input_data.dat', O_RdOnly);
.
{ Other stuff goes here. }
.
bytes_read := FpRead(in_file, record_len, sizeof(record_len));

bytes_read := FpRead(in_file, buf_area, record_len);


Incidentally, from your first message in this thread, you said you were
writing an OLAP application. You might care to look at PostgreSQL as a
database manager. It does rather nice OLAP functionality, straight out
of the box -- and it's free.

Regards,
Dave [RLU#314465]
==
[EMAIL PROTECTED] (David W Noon)
==


signature.asc
Description: This is a digitally signed message part
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] HTML browser for help under Lazarus

2008-07-17 Thread David W Noon
Whenever I try to browse the help under Lazarus, the browser used is
always Konqueror, even when I am using GNOME or Xfce as my desktop. How
can I configure Lazarus to use the desktop's default browser or
explicitly to use Evolution?

Regards

Dave [RLU#314465]
==
[EMAIL PROTECTED] (David W Noon)
==

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