driver_output_term() and unsigned long (32 bit) values
Shawn Pearce
spearce@REDACTED
Fri Jul 26 17:18:46 CEST 2002
Per Bergqvist <per@REDACTED> scrawled:
> > For what it's worth, it doesn't appear possible to have the driver
> > create a reference and send that back to Erlang, either.
> >
> IMHO, I think it is a bad idea to allow a driver to create a reference
> since references should be unique and it will be hard to guarantee
> uniqueness if there are several allocators ...
Why not a function:
ErlDrvTerm driver_mkref()
which will always use the internal reference allocator? Or is it
not possible to use the existing allocator underlying erlang:mkref/0
while a driver is executing?
It would be very convient for drivers to be able to use references,
esp. as the references could be stored in a small hash table linking
to driver specific objects, for example a widget in a GUI library.
Of course, driver authors could still try to send illegal reference
values by attempting to create their own references without the
driver_mkref() function. But today driver authors could also try to
make an ErlDrvBinary on their own without driver_alloc_binary(), and
the results would be just as bad.
I had really considered making a bunch of ErlDrvBinary objects in a
mmap region at one point, until I noticed in the Erts source that the
ErlDrvBinary is not the entire binary structure - there is data stored
before it by the emulator. I would have had pretty ugly results had
I tried to use my own binary.
Therefore I'm arguing that its acceptable if there are ugly results
because a driver author used a value for a reference which did not
come from driver_mkref().
--
Shawn.
Why do I like Perl? Because ``in accordance with Unix tradition Perl
gives you enough rope to hang yourself with.''
Why do I dislike Java? Because ``the class ROPE that should contain the
method HANG to do the hanging doesn't exist because there is too much
'security' built into the base language.''
More information about the erlang-questions
mailing list