Re: [fpc-pascal] spin_lock
[ Charset ISO-8859-15 unsupported, converting... ] > Am Dienstag, 30. Mai 2006 01:05 schrieb Alain Michaud: > > Hi, > > > > would someone know how to execute: spin_lock spin_lock_init and > > spin_unlock > > > > I just want to disable the interrupts for 200 miliseconds maximum! > > This is not too long and hopefuly, my system will not crash... > > Well, 200 ms is about ages for the CPU/Kernel .. > > > Does someone has any experience with this kind of situation. > > This is not that easy: Is it only for UP or maybe also for SMP machines? > Basically, for x86 the "cli" and "sti" asm instructions do disable/ > enable interrupts, but read about it before you try. > Currently, I do such stuff only inside a driver (Linux kernel: > spin_lock, or win98 vxd: cli/sti) and don't know about any user space > function for this. FreeBSD has (in pthread.h): int pthread_spin_init(pthread_spinlock_t *, int); int pthread_spin_destroy(pthread_spinlock_t *); int pthread_spin_lock(pthread_spinlock_t *); int pthread_spin_trylock(pthread_spinlock_t *); int pthread_spin_unlock(pthread_spinlock_t *); ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] real to integer
Tony Pelton schreef: On 5/29/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: Use a IDE with code tools that support find declaration. that is a terrible answer. this isn't the "IDE" list, it is the Free Pascal "compiler" list. Indeed. But sometimes the compiler doesn't give enough information and other tools do. Another view: An IDE is to help people write code, a compiler is to compile it and not to guess what it should have been, if some error occurs. i would have beat my head against a wall for days on a problem like that. Using the wrong tool for the wrong job, I would say. A compiler is to compiler, an IDE to write code. i would suggest that this is an opportunity to think about error reporting in the compiler. i would suggest, as a compiler enhancement, maybe ... a) the compiler could report ambigous symbols as a warning AFAIK in this case there were no ambiguous symbols. Only a procedure hidden by an other. Some languages don't have disambiguation rules (C# for example) for units/namespaces and always require you to add the unitname (e.g. SysUtils.DeleteFile). I don't like that solution. b) the error could report fully qualifed symbols on errors Yes, more verbose error messages are always nice (until they get too verbose). i don't know how simple that is for the compiler, but it is simple to understand for the programmer. Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] spin_lock
Am Dienstag, 30. Mai 2006 01:05 schrieb Alain Michaud: > Hi, > > would someone know how to execute: spin_lock spin_lock_init and > spin_unlock > > I just want to disable the interrupts for 200 miliseconds maximum! > This is not too long and hopefuly, my system will not crash... Well, 200 ms is about ages for the CPU/Kernel .. > Does someone has any experience with this kind of situation. This is not that easy: Is it only for UP or maybe also for SMP machines? Basically, for x86 the "cli" and "sti" asm instructions do disable/ enable interrupts, but read about it before you try. Currently, I do such stuff only inside a driver (Linux kernel: spin_lock, or win98 vxd: cli/sti) and don't know about any user space function for this. You might want to give some more details about your "situation". arch? os? and why would you do this? There might be a better solution.. than locking the hole system for 1/5 second .. Burkhard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] real to integer
On 5/29/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: Use a IDE with code tools that support find declaration. that is a terrible answer. this isn't the "IDE" list, it is the Free Pascal "compiler" list. i would have beat my head against a wall for days on a problem like that. i would suggest that this is an opportunity to think about error reporting in the compiler. i would suggest, as a compiler enhancement, maybe ... a) the compiler could report ambigous symbols as a warning b) the error could report fully qualifed symbols on errors i don't know how simple that is for the compiler, but it is simple to understand for the programmer. Vincent. Tony -- X-SA user ? 0.5.1 is out ! XData 0.1 for X-SA is out ! http://x-plane.dsrts.com http://games.groups.yahoo.com/group/x-plane-foo/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] spin_lock
Hi, would someone know how to execute: spin_lock spin_lock_init and spin_unlock I just want to disable the interrupts for 200 miliseconds maximum! This is not too long and hopefuly, my system will not crash... Does someone has any experience with this kind of situation. Sincerely Alain Michaud ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] porting fpIoctl() to windows
Am Montag, den 29.05.2006, 23:30 +0200 schrieb Burkhard Carstens: > Am Montag, 29. Mai 2006 22:47 schrieb Marc Santhoff: > > Hi, > > > > on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. > > In my porting efforts to win32 I have found the more generic > > FileOpen, but no equivalent of fpIoctl or it's underlying unix system > > call ioctl(). > > > > An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not > > really sure if this is what I need. At least there is ntohing about > > this funtion in the RTL sources of fps 2.0.2. > > DeviceIOControl is the one I use in Delphi to talk to my vxd driver .. > it is linked to kernel32.dll. Should be pretty much what you want. Okay, I'll give it a try. I oly wanted to make sure there is no meore general (in sense of platform independant) way to do it and my docs are not to old. > > How can I port this calls? > > check, how other winapi calls are implemented .. > I am not that far yet. Did it in Delphi, but now trying to do it on > linux .. This is where I'm coming from (FreeBSD should be as much Posix as Linux, I think). Somewhere deep down in the darkness of NT and OS/2 there must be artefacts of Unix in Windows 2k and XP. ;) Regards, Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] porting fpIoctl() to windows
On 5/29/06, Alain Michaud <[EMAIL PROTECTED]> wrote: I wanted to write a unit that would simulate this file (ioctl.h), but, this header file contains mainly macros. I do not think that it is possible to write some Pascal code that would in fact be a macro! If someone knows if it possible to write macros in Pascal please tell me. You can´t. Transform macros into functions. Some macros can also be substituted directly into the code. -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] porting fpIoctl() to windows
Alain Michaud wrote: > In the mean time, I calculate the function number "by hand", knowing the > device number, function number, IO_RW, etc... Or if I use a precedure do > do this, then this will slow the program down. AFAIK, these numbers are mostly constants, so you need to do this work only once. Micha ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] porting fpIoctl() to windows
Am Montag, 29. Mai 2006 22:47 schrieb Marc Santhoff: > Hi, > > on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. > In my porting efforts to win32 I have found the more generic > FileOpen, but no equivalent of fpIoctl or it's underlying unix system > call ioctl(). > > An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not > really sure if this is what I need. At least there is ntohing about > this funtion in the RTL sources of fps 2.0.2. DeviceIOControl is the one I use in Delphi to talk to my vxd driver .. it is linked to kernel32.dll. Should be pretty much what you want. > How can I port this calls? check, how other winapi calls are implemented .. I am not that far yet. Did it in Delphi, but now trying to do it on linux .. Burkhard ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] porting fpIoctl() to windows
On 29 May 2006, at 23:09, Alain Michaud wrote: In the mean time, I calculate the function number "by hand", knowing the device number, function number, IO_RW, etc... Or if I use a precedure do do this, then this will slow the program down. It should be no problem to use (inline or not)functions. The cost of a system call dwarfs the time that may be needed to shift and "or" a few numbers together (even if you add in the cost of a regular call). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] porting fpIoctl() to windows
Hi, I use FpIOctl from "BaseUnix" . My platform is Linux. I do FpOpen then FpIOCTL. It works! However: The kernel 2.6 has a new naming convention for the function number. See the file: asm/ioctl.h This file contains many constants and the final call number is assembled from the direction type, device number, function number, etc... I wanted to write a unit that would simulate this file (ioctl.h), but, this header file contains mainly macros. I do not think that it is possible to write some Pascal code that would in fact be a macro! If someone knows if it possible to write macros in Pascal please tell me. In the mean time, I calculate the function number "by hand", knowing the device number, function number, IO_RW, etc... Or if I use a precedure do do this, then this will slow the program down. For the Windows platform, I can not help you sorry. Thank you Alain Michaud On Mon, 2006-05-29 at 22:47 +0200, Marc Santhoff wrote: > Hi, > > on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In > my porting efforts to win32 I have found the more generic FileOpen, but > no equivalent of fpIoctl or it's underlying unix system call ioctl(). > > An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not really > sure if this is what I need. At least there is ntohing about this > funtion in the RTL sources of fps 2.0.2. > > How can I port this calls? > > TIA, > 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
[fpc-pascal] porting fpIoctl() to windows
Hi, on FreeBSD I use fpOpen, fpIoctl, etc. to drive some generic device. In my porting efforts to win32 I have found the more generic FileOpen, but no equivalent of fpIoctl or it's underlying unix system call ioctl(). An old win32.hlp told me Windows has "DeviceIoCtl()", but I'm not really sure if this is what I need. At least there is ntohing about this funtion in the RTL sources of fps 2.0.2. How can I port this calls? TIA, Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re[2]: [fpc-pascal] real to integer
> > While compiler gives a hint about "true" declaration, it does not point to > > the problematic unit. > Use a IDE with code tools that support find declaration. > In your case Lazarus would for example have jumped to an include file that > that > contains the wrong declaration. Search include directive once or twice would > have > brought you to the main unit file. > Vincent. Probably you are right. I'll wait for Lazarus 1.0 though (I tried two previous releases and still fear it). ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] real to integer
Пётр Косаревский schreef: The problem is that Apple's universal interfaces also include a "round" function, which returns a real instead of an integral type. How can one find such a thing himself without trial&error? Some time ago I had a similar problem with "bool DeleteFile(PChar)" function in Windows API and sysutils function "DeleteFile(string):boolean". "Good" program: uses windows,sysutils; const B:shortstring='1.txt'; begin DeleteFile(B); end. "Bad" program: // Error: PChar expected uses sysutils,windows; const B:shortstring='1.txt'; begin DeleteFile(B); end. While compiler gives a hint about "true" declaration, it does not point to the problematic unit. Use a IDE with code tools that support find declaration. In your case Lazarus would for example have jumped to an include file that that contains the wrong declaration. Search include directive once or twice would have brought you to the main unit file. Vincent. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re[2]: [fpc-pascal] real to integer
> The problem is that Apple's universal interfaces also include a > "round" function, which returns a real instead of an integral type. How can one find such a thing himself without trial&error? Some time ago I had a similar problem with "bool DeleteFile(PChar)" function in Windows API and sysutils function "DeleteFile(string):boolean". "Good" program: uses windows,sysutils; const B:shortstring='1.txt'; begin DeleteFile(B); end. "Bad" program: // Error: PChar expected uses sysutils,windows; const B:shortstring='1.txt'; begin DeleteFile(B); end. While compiler gives a hint about "true" declaration, it does not point to the problematic unit. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] real to integer
On 29 mei 2006, at 14:46, Thomas Miller wrote: I am frustrated by a very simple problem. I am trying to convert real to integer, using free pascal for mac. I am an old Think Pascal user who just recently found free pascal and, while thrilled to have a pascal compiler for mac OSX, I am still a bit lost. In Think Pascal, I would have just used "round", but this doesn't seem to work. x : integer; y : real; x := round(y); gives me an error saying "got "Double" expected "SmallInt"". This occurs no matter how I define x: integer, smallint, etc. In fact, if I set x to real, then the program compiles and works, simply converting decimal values to 0 but not deleting them. I suspect I am making some simple error. Any advice? The problem is that Apple's universal interfaces also include a "round" function, which returns a real instead of an integral type. There are two solutions: a) use "system.round(y)" so the compiler uses the round function from the system unit instead of from your carbon unit b) switch to a new version of the Universal Interfaces translations (where that "round" function has been renamed "roundd"), available from http://www.elis.ugent.be/~jmaebe/nobackup/fpc/ FPCPInterfaces060428.zip Note that in case b), instead of the Carbon unit, you have to use the "fpcmacosall" unit instead. It also fixes several bugs in the UI translations, so it's a good idea to upgrade them in either case. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] real to integer
Thomas Miller schreef: I am frustrated by a very simple problem. I am trying to convert real to integer, using free pascal for mac. I am an old Think Pascal user who just recently found free pascal and, while thrilled to have a pascal compiler for mac OSX, I am still a bit lost. In Think Pascal, I would have just used "round", but this doesn't seem to work. x : integer; y : real; x := round(y); gives me an error saying "got "Double" expected "SmallInt"". This occurs no matter how I define x: integer, smallint, etc. In fact, if I set x to real, then the program compiles and works, simply converting decimal values to 0 but not deleting them. I suspect I am making some simple error. Any advice? I don't know what is going wrong. I just created a sample app below on windows and that compiles without errors. Maybe you can try that. program Project1; {$mode objfpc}{$H+} uses Classes, SysUtils { add your units here }; var x : integer; y : real; begin y := pi; x := round(y); end. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] fpc for ARM on FreeBSD
Hi, since I know fpc has a code generator for ARM CPUs and is running on FreeBSD I'd like to know: What would be needed to make the compiled programm run on FreeBSD for ARM? If there is some real porting work to do (as an opposite of "re-configuration"), how much time may that take? The FreeBSD port is beginning to get usable and I'm thinking about using an ARM board as basis for embedded devices. (see: http://www.freebsd.org/platforms/arm.html) TIA, Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] real to integer
I am frustrated by a very simple problem. I am trying to convert real to integer, using free pascal for mac. I am an old Think Pascal user who just recently found free pascal and, while thrilled to have a pascal compiler for mac OSX, I am still a bit lost. In Think Pascal, I would have just used "round", but this doesn't seem to work. x : integer; y : real; x := round(y); gives me an error saying "got "Double" expected "SmallInt"". This occurs no matter how I define x: integer, smallint, etc. In fact, if I set x to real, then the program compiles and works, simply converting decimal values to 0 but not deleting them. I suspect I am making some simple error. Any advice? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal