port driver naming

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

port driver naming

Serge Aleynikov-3
When writing a port driver the "driver_name" field in the ErlDrvEntry structure is defined to match the name of the driver file.

Is it possible to name the driver file differently from what's specified in the ErlDrvEntry?

I have two architectures x86 and x64, and would like to distribute a prebuilt library with my application in the 32 and 64 bit flavors, and have the application choose the proper driver filename depending on the target architecture of the host machine.  For this reason I am wondering if it's possible to name a driver file as "myapp-x86" or "myapp-x64" with a driver name field containing "myapp".  Is that doable?

Regards,

Serge

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: port driver naming

Max Lapshin-2
It would be a great idea!

Have one deb package for all architectures at once.

On Wed, Jun 26, 2019 at 12:17 AM Serge Aleynikov <[hidden email]> wrote:
When writing a port driver the "driver_name" field in the ErlDrvEntry structure is defined to match the name of the driver file.

Is it possible to name the driver file differently from what's specified in the ErlDrvEntry?

I have two architectures x86 and x64, and would like to distribute a prebuilt library with my application in the 32 and 64 bit flavors, and have the application choose the proper driver filename depending on the target architecture of the host machine.  For this reason I am wondering if it's possible to name a driver file as "myapp-x86" or "myapp-x64" with a driver name field containing "myapp".  Is that doable?

Regards,

Serge
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: port driver naming

Michael Truog
In reply to this post by Serge Aleynikov-3
On 6/25/19 2:17 PM, Serge Aleynikov wrote:
When writing a port driver the "driver_name" field in the ErlDrvEntry structure is defined to match the name of the driver file.

Is it possible to name the driver file differently from what's specified in the ErlDrvEntry?

I have two architectures x86 and x64, and would like to distribute a prebuilt library with my application in the 32 and 64 bit flavors, and have the application choose the proper driver filename depending on the target architecture of the host machine.  For this reason I am wondering if it's possible to name a driver file as "myapp-x86" or "myapp-x64" with a driver name field containing "myapp".  Is that doable?

Regards,

Serge
Hi Serge,

With the current Erlang/OTP source code, you can get this to work by having driver_name be different for each file by using the preprocessor to create the unique filename.  You would effectively be using the string "myapp-" #arch, though it would require a few macros to expand properly (in the C/C++).

Best Regards,
Michael

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: port driver naming

Serge Aleynikov-3
Yes, I've worked around the issue with the compile-time defines that are different for the 32 and 64 bit architectures.  However, it's not entirely clear why there's a requirement for the driver name to match the file name.  It seems that it would be more flexible to allow them to be different.

On Tue, Jun 25, 2019 at 9:30 PM Michael Truog <[hidden email]> wrote:
On 6/25/19 2:17 PM, Serge Aleynikov wrote:
When writing a port driver the "driver_name" field in the ErlDrvEntry structure is defined to match the name of the driver file.

Is it possible to name the driver file differently from what's specified in the ErlDrvEntry?

I have two architectures x86 and x64, and would like to distribute a prebuilt library with my application in the 32 and 64 bit flavors, and have the application choose the proper driver filename depending on the target architecture of the host machine.  For this reason I am wondering if it's possible to name a driver file as "myapp-x86" or "myapp-x64" with a driver name field containing "myapp".  Is that doable?

Regards,

Serge
Hi Serge,

With the current Erlang/OTP source code, you can get this to work by having driver_name be different for each file by using the preprocessor to create the unique filename.  You would effectively be using the string "myapp-" #arch, though it would require a few macros to expand properly (in the C/C++).

Best Regards,
Michael

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: port driver naming

Michael Truog
On 6/25/19 9:06 PM, Serge Aleynikov wrote:
Yes, I've worked around the issue with the compile-time defines that are different for the 32 and 64 bit architectures.  However, it's not entirely clear why there's a requirement for the driver name to match the file name.  It seems that it would be more flexible to allow them to be different.
My impression is that it is beneficial to have the extra validation that the build artifact matches the appropriate content.  That could be more important when you have more variations that provide the same source code in different dynamic library files (even for the same architecture, multiple files).  However, the same constraint doesn't exist for NIFs and due to that inconsistency it may be hard to justify.

Best Regards,
Michael

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions