T
tad.bochan
Hi Florian,
Thanks very much for your tip. It does intrigue me how you came to know
about
this one (ruby/DL).
Unfortunately, I haven't been able to verify that it works yet because of
an apparent
bug in ruby when I try the syscall to mmap. I running 1.8.0 on HPUX, and I
can't
upgrade to a later version just yet. (don't have an ansi C compiler!)
""""
#Foo=Struct.new("Foo",:astrg)
SYS_mmap = 71
PROT_NONE = 0
PROT_USER = 0
PROT_READ = 1
PROT_WRITE = 2
MAP_SHARED = 1
addr,len,prot,flags,ofs=0,80,PROT_READ, MAP_SHARED,0
filedes=open("shmfile","r+")
mmfptr=syscall(SYS_mmap, addr, len, prot, flags, filedes.fileno, ofs)
Gives ...........................
ruby 1.8.0 (2003-08-04) [hppa2.0w-hpux11.11]
Abort(coredump)""""
But a rather odd problem occurs when I run the above with the 'require'
line uncommented,
#Foo=Struct.new("Foo",:astrg)
SYS_mmap = 71
PROT_NONE = 0
PROT_USER = 0
PROT_READ = 1
PROT_WRITE = 2
MAP_SHARED = 1
addr,len,prot,flags,ofs=0,80,PROT_READ, MAP_SHARED,0
filedes=open("shmfile","r+")
mmfptr=syscall(SYS_mmap, addr, len, prot, flags, filedes.fileno, ofs)
Gives ...........................
from pntrs.rb:11
Internet
(e-mail address removed) - 26/08/2004 21:05
Veuillez répondre à (e-mail address removed)
Pour : ruby-talk
cc :
Objet : Re: Dereferencing pointers returned by syscall
Have a look at Ruby/DL which is part of Standard Ruby. With
DL::Importable you can create a struct like this:
Foo = struct [
"long foo",
"int bar",
...
]
And later you can do Foo.new(DL:trData.new(ptr)).
Regards,
Florian Gross
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.
Thanks very much for your tip. It does intrigue me how you came to know
about
this one (ruby/DL).
Unfortunately, I haven't been able to verify that it works yet because of
an apparent
bug in ruby when I try the syscall to mmap. I running 1.8.0 on HPUX, and I
can't
upgrade to a later version just yet. (don't have an ansi C compiler!)
""""
#require "dl"cat pntrs.rb
#Foo=Struct.new("Foo",:astrg)
SYS_mmap = 71
PROT_NONE = 0
PROT_USER = 0
PROT_READ = 1
PROT_WRITE = 2
MAP_SHARED = 1
addr,len,prot,flags,ofs=0,80,PROT_READ, MAP_SHARED,0
filedes=open("shmfile","r+")
mmfptr=syscall(SYS_mmap, addr, len, prot, flags, filedes.fileno, ofs)
Gives ...........................
pntrs.rb:11: [BUG] rb_sys_fail() - errno == 0ruby pntrs.rb
ruby 1.8.0 (2003-08-04) [hppa2.0w-hpux11.11]
Abort(coredump)""""
But a rather odd problem occurs when I run the above with the 'require'
line uncommented,
require "dl"cat pntrs.rb
#Foo=Struct.new("Foo",:astrg)
SYS_mmap = 71
PROT_NONE = 0
PROT_USER = 0
PROT_READ = 1
PROT_WRITE = 2
MAP_SHARED = 1
addr,len,prot,flags,ofs=0,80,PROT_READ, MAP_SHARED,0
filedes=open("shmfile","r+")
mmfptr=syscall(SYS_mmap, addr, len, prot, flags, filedes.fileno, ofs)
Gives ...........................
pntrs.rb:11:in `syscall': No such file or directory (Errno::ENOENT)ruby pntrs.rb
from pntrs.rb:11
Internet
(e-mail address removed) - 26/08/2004 21:05
Veuillez répondre à (e-mail address removed)
Pour : ruby-talk
cc :
Objet : Re: Dereferencing pointers returned by syscall
Hi,
Moin!
I'm using 'syscall' in ruby to access the 'mmap' function in Unix (HPUX),
to try to read/write a memory-mapped file.
The 'mmap' function returns a pointer to the mapped file.
I can't figure out how I am supposed to be able to use
this pointer to access the data from ruby.
Have a look at Ruby/DL which is part of Standard Ruby. With
DL::Importable you can create a struct like this:
Foo = struct [
"long foo",
"int bar",
...
]
And later you can do Foo.new(DL:trData.new(ptr)).
Regards,
Florian Gross
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.