Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread Peter Vreman
   I found that the Do_Syscalls are written in assembly and have only
   limited number of parameters (up to 6). Is there a way to write it
   using array of TSysParam instead of having 7 different functions ?

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

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

I don't see any reason why it needs to be changed.
- It already works like var args in C from a program point of view.
- Syscalls have a known limited number of parameters.
- The way it now is programmed allows better code generation for the syscalls 
with
limited parameters.
- It is a syntax issue and there is a FAQ about syntax changes.

Peter


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


Re: [fpc-pascal] Compiler API specification

2008-02-15 Thread Skybuck Flying

How would you implement the specification ?

Would it be possible to simply embed the complete compiler into a DLL ?

Or would that make little sense ?

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


Re: [fpc-pascal] MySQL insert, load data

2008-02-15 Thread Wolfram Kläger
Ok. First one was simple. Keyword and opening bracket must be separated
by a blank, e.g.

'.. MYTABLE(..'  // wrong
'.. MYTABLE (..' // great

'..)values(..'   // wrong
'..) values (..' // great

All field contents have to be bracketed by double apostrophes, e.g.

q.sql.add('''Florian Klaempfl'',');

except it's an integer value, e.g.

q.sql.add('1,');

Date values seem to be put as formatted strings. Unfortunately, my MySQL
does not know Joost. His example, '1-jan-1975' works here as '1975.1.1'
only. Guess this is a config issue.

Now what about LOAD DATA?

I still have no idea where to look for it. I learned TSQLQuery is
descending Tbufdataset - TDBDataSet - TDataset - TComponent and
assume there is somewhere an option to load from a CSV text file or stream.

But how to push it forward to MySQL?
Wolfram


// Wolfram Kläger, 14.02.2008 22:49
 Along Joost's examples I managed to get connected, create a table, put a
 query, get the result, and insert a single row. But when I try to insert
 several rows at once, I get an EDatabaseError near to first char of
 second row.
 
 ...
 q.SQL.Clear;
 q.Add('insert into MYTABLE(c1, c2, ..) values ');
 q.Add('(r1v1, r1v2, ..),');
 q.Add('(r2v1, r2v1, ..),');
 ..
 q.Add(';');
 
 What am I missing or is multiple insert not supported?
 
 Alternatively, MySQL provides the LOAD DATA [LOCAL] INFILE statement. So
 far I was not able to find a special sqldb wrapper for it. Is it done
 via ExecuteDirect?


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


Re: [fpc-pascal] MySQL insert, load data

2008-02-15 Thread Leonardo M. Ram�
Try this:

q.SQL.Clear;
q.Add('LOAD DATA INFILE ''data.txt'' INTO TABLE database.my_table;');
q.Execute; // -- I don't remember the correct command right now

Leonardo


--- Wolfram Kläger [EMAIL PROTECTED] wrote:

 Ok. First one was simple. Keyword and opening bracket must be separated
 by a blank, e.g.
 
 '.. MYTABLE(..'  // wrong
 '.. MYTABLE (..' // great
 
 '..)values(..'   // wrong
 '..) values (..' // great
 
 All field contents have to be bracketed by double apostrophes, e.g.
 
 q.sql.add('''Florian Klaempfl'',');
 
 except it's an integer value, e.g.
 
 q.sql.add('1,');
 
 Date values seem to be put as formatted strings. Unfortunately, my MySQL
 does not know Joost. His example, '1-jan-1975' works here as '1975.1.1'
 only. Guess this is a config issue.
 
 Now what about LOAD DATA?
 
 I still have no idea where to look for it. I learned TSQLQuery is
 descending Tbufdataset - TDBDataSet - TDataset - TComponent and
 assume there is somewhere an option to load from a CSV text file or stream.
 
 But how to push it forward to MySQL?
 Wolfram
 
 
 // Wolfram Kläger, 14.02.2008 22:49
  Along Joost's examples I managed to get connected, create a table, put a
  query, get the result, and insert a single row. But when I try to insert
  several rows at once, I get an EDatabaseError near to first char of
  second row.
  
  ...
  q.SQL.Clear;
  q.Add('insert into MYTABLE(c1, c2, ..) values ');
  q.Add('(r1v1, r1v2, ..),');
  q.Add('(r2v1, r2v1, ..),');
  ..
  q.Add(';');
  
  What am I missing or is multiple insert not supported?
  
  Alternatively, MySQL provides the LOAD DATA [LOCAL] INFILE statement. So
  far I was not able to find a special sqldb wrapper for it. Is it done
  via ExecuteDirect?
 
 
 ___
 fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-pascal
 



  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

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


Re: [fpc-pascal] MySQL insert, load data

2008-02-15 Thread Michael Van Canneyt


On Fri, 15 Feb 2008,  wrote:

 Try this:
 
 q.SQL.Clear;
 q.Add('LOAD DATA INFILE ''data.txt'' INTO TABLE database.my_table;');
 q.Execute; // -- I don't remember the correct command right now
 

Normally it is: 

 Q.ExecSQL;

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


Re: [fpc-pascal] syscalls and fpc

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

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

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


Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread Vincent Snijders

Micha Nelissen schreef:

ik wrote:

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


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


Fortunately I studied mathematics, so I can count the mentioned 
registers: 7.


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


Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread Marco van de Voort
 Micha Nelissen schreef:
  ik wrote:
  Actually the assembler is not that hard to understand :)
  My point is, that I don't like the idea of 7 or 20 or 100 amount of
  parameters to give answer to every need. I think we should find a
  better way to implement it, like var args in C or open array in
  pascal...
  
  The linux kernel interface is always using registers, and since there
  are a limited amount of registers, there is a max. number of arguments.
  IIRC the maximum is 6, i386 limited: eax, ebx, ecx, edx, esi, edi, ebp.
 
 Fortunately I studied mathematics, so I can count the mentioned 
 registers: 7.

Then you should also see dangerous hidden assumptions:

Not all parameters occupy a single register. off_t for 64-bit fs calls e.g.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] syscalls and fpc

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

 The linux kernel interface is always using registers, and since there
 are a limited amount of registers, there is a max. number of arguments.
 IIRC the maximum is 6, i386 limited: eax, ebx, ecx, edx, esi, edi, ebp.
 
 Fortunately I studied mathematics, so I can count the mentioned
 registers: 7.

One stores the syscall number.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] syscalls and fpc

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

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

You are welcome to correct me if I wrong, but can't I use prameters as follows:

push param1
push param2
push param3

push paramX
call syscall

?

If so, then I don't think there is a specific need for using the eax,
ebx registers etc..
Please look at the C deceleration of the syscall:
int syscall(int number, ...);


It uses var_args, and therefor 6 registers are not enough imho...
because tomorrow some one can add new call with 10 params, and then
what ? I can't find any documentation that limit the amount of
parameters that can be given to the function (at least in Linux, maybe
POSIX/BSD/Solaris/Other have different rules)

  Micha


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


Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread ik
Another issue (I should report it as a bug imho) is that Do_Syscall is
not really usable if you require to use different parameters then
integer value, for example: PChar.

A call for example that use PChar as one of it's parameter is
inotify_add_watch .

I think that the entire design of the Do_SysCall is malformed in the
way it assumes the number of parameters and also the type of them, so
as I asked before, how I can either call the syscall command without
assembler, or how I can pass an array of const (prior to that I asked
regarding array of TSysParam) to assembly if three is no other way to
use syscall ?

Ido

On Feb 15, 2008 9:50 PM, ik [EMAIL PROTECTED] wrote:
 On Fri, Feb 15, 2008 at 8:36 PM, Micha Nelissen [EMAIL PROTECTED] wrote:
  ik wrote:
Actually the assembler is not that hard to understand :)
My point is, that I don't like the idea of 7 or 20 or 100 amount of
parameters to give answer to every need. I think we should find a
better way to implement it, like var args in C or open array in
pascal...
 
   The linux kernel interface is always using registers, and since there
   are a limited amount of registers, there is a max. number of arguments.
   IIRC the maximum is 6, i386 limited: eax, ebx, ecx, edx, esi, edi, ebp.

 You are welcome to correct me if I wrong, but can't I use prameters as 
 follows:

 push param1
 push param2
 push param3
 
 push paramX
 call syscall

 ?

 If so, then I don't think there is a specific need for using the eax,
 ebx registers etc..
 Please look at the C deceleration of the syscall:
 int syscall(int number, ...);


 It uses var_args, and therefor 6 registers are not enough imho...
 because tomorrow some one can add new call with 10 params, and then
 what ? I can't find any documentation that limit the amount of
 parameters that can be given to the function (at least in Linux, maybe
 POSIX/BSD/Solaris/Other have different rules)


   Micha


 Ido
 --
 http://ik.homelinux.org/




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


Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread Marco van de Voort
 Another issue (I should report it as a bug imho) is that Do_Syscall is
 not really usable if you require to use different parameters then
 integer value, for example: PChar.

 I think that the entire design of the Do_SysCall is malformed in the
 way it assumes the number of parameters and also the type of them, so
 as I asked before, how I can either call the syscall command without
 assembler, or how I can pass an array of const (prior to that I asked
 regarding array of TSysParam) to assembly if three is no other way to
 use syscall ?

So we can write you up as volunteer to write up prototypes (and worse
maintain them) for about 300 calls per OS per arch?

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


Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread Marco van de Voort
 On Feb 16, 2008 2:00 AM, Marco van de Voort [EMAIL PROTECTED] wrote:
   way it assumes the number of parameters and also the type of them, so
   as I asked before, how I can either call the syscall command without
   assembler, or how I can pass an array of const (prior to that I asked
   regarding array of TSysParam) to assembly if three is no other way to
   use syscall ?
 
  So we can write you up as volunteer to write up prototypes (and worse
  maintain them) for about 300 calls per OS per arch?
 
 So what you are saying is, that because there are many commands that
 can be used by syscall, you prefer to give support only to the ones
 that actually in use by most programs, rather then to write something
 more general that will support everything, and will do it right ?

There is no need to support all of them in the first place, and with formal
typing and support, also maintaining the structs come into play, making a
testsuite etc. Nothing that supports everything is easy, and nothing is ever
exactly right once reality comes crashing in, except the helicopter view
before actually getting your hands wet.
 
 Sorry but I still don't understand... The problem is the
 design/approach of the way syscall is implemented in FPC, while you
 are saying that because there are so many OS/commands that each use it
 differently, you just want to leave it as-is because it works for you

No, because it works period. 

 So according to what you say, I can either mark that there is no
 support for syscall in FPC (half work for most of the times is not
 enough, it's just wrong desgin), or I don't understand whats going on.

I still haven't the faintest clue what your problem actually is, aside from
style issues. Sure it is not the neatest solution, but neither are syscalls
in general. 

gcc solves it slightly better with heaps of macros and custom calling
conventions, a luxury that we don't have. And different per OS-arch
combination too. Moreover, there are multiple teams involved there (the
respective kernel teams, glibc, kernel), and we have to do it ourselves.

Moreover since more and more subsystems use functionality in libc that is
more than a mere wrapper (unicode is getting more popular, the
authentication and resolving systems get increasingly complicated due to
security), and duplicating that on bare bones syscalls is both an awful lot
of hard to get right work, and a security risk.

But if you want me to get you of the maintain calls list, and put you onto
the create custom calling conventions by having directives that can assign
each and other param to a precies reg list, by all means, say so. I'd be
happy to. I can write you up for the native unicode list and to fix netdb
too if you wish.

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


Re: [fpc-pascal] syscalls and fpc

2008-02-15 Thread ik
On Feb 16, 2008 2:00 AM, Marco van de Voort [EMAIL PROTECTED] wrote:
  Another issue (I should report it as a bug imho) is that Do_Syscall is
  not really usable if you require to use different parameters then
  integer value, for example: PChar.

  I think that the entire design of the Do_SysCall is malformed in the
  way it assumes the number of parameters and also the type of them, so
  as I asked before, how I can either call the syscall command without
  assembler, or how I can pass an array of const (prior to that I asked
  regarding array of TSysParam) to assembly if three is no other way to
  use syscall ?

 So we can write you up as volunteer to write up prototypes (and worse
 maintain them) for about 300 calls per OS per arch?

So what you are saying is, that because there are many commands that
can be used by syscall, you prefer to give support only to the ones
that actually in use by most programs, rather then to write something
more general that will support everything, and will do it right ?

Sorry but I still don't understand... The problem is the
design/approach of the way syscall is implemented in FPC, while you
are saying that because there are so many OS/commands that each use it
differently, you just want to leave it as-is because it works for you
...
So according to what you say, I can either mark that there is no
support for syscall in FPC (half work for most of the times is not
enough, it's just wrong desgin), or I don't understand whats going on.


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