Permalink
Browse files

R15 compatibility.

R15B introduced some incompatible changes in driver interface.
Some driver callbacks started using ErlDrvSizeT and ErlDrvSSizeT
typedef instead of int.
This patch changes callbacks to use the new typedefs and provides
compatibility fallbacks for older OTP versions.
  • Loading branch information...
1 parent 6987a0a commit f0f05ea3b091988f6937aa63eeb3d2cb5652fc5e @rraptorr rraptorr committed with badlop Dec 15, 2011
@@ -95,9 +95,9 @@ exmpp_compress_zlib_stop(ErlDrvData drv_data)
driver_free(edd);
}
-static int
+static ErlDrvSSizeT
exmpp_compress_zlib_control(ErlDrvData drv_data, unsigned int command,
- char *buf, int len, char **rbuf, int rlen)
+ char *buf, ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen)
{
struct exmpp_compress_zlib_data *edd;
int ret, index, type, type_size;
View
@@ -25,6 +25,16 @@
#include <erl_driver.h>
/*
+ * R15B changed several driver callbacks to use ErlDrvSizeT and
+ * ErlDrvSSizeT typedefs instead of int.
+ * This provides missing typedefs on older OTP versions.
+ */
+#if ERL_DRV_EXTENDED_MAJOR_VERSION < 2
+typedef int ErlDrvSizeT;
+typedef int ErlDrvSSizeT;
+#endif
+
+/*
* This macro is used to stringify the driver name in the driver's
* ErlDrvEntry. One use it like this:
* static ErlDrvEntry driver_entry = {
View
@@ -111,9 +111,9 @@ static int compose(int ch1, int ch2);
* Erlang port driver callbacks.
* ------------------------------------------------------------------- */
-static int
+static ErlDrvSSizeT
exmpp_stringprep_control(ErlDrvData drv_data, unsigned int command,
- char *buf, int len, char **rbuf, int rlen)
+ char *buf, ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen)
{
int i, j, pos;
unsigned char c;
@@ -162,9 +162,9 @@ exmpp_tls_openssl_stop(ErlDrvData drv_data)
driver_free(edd);
}
-static int
+static ErlDrvSSizeT
exmpp_tls_openssl_control(ErlDrvData drv_data, unsigned int command,
- char *buf, int len, char **rbuf, int rlen)
+ char *buf, ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen)
{
struct exmpp_tls_openssl_data *edd;
int ret, index, arity, type, type_size, flag;
View
@@ -138,9 +138,9 @@ exmpp_xml_stop(ErlDrvData drv_data)
driver_free(edd);
}
-static int
+static ErlDrvSSizeT
exmpp_xml_control(ErlDrvData drv_data, unsigned int command,
- char *buf, int len, char **rbuf, int rlen)
+ char *buf, ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen)
{
struct exmpp_xml_data *edd;
ei_x_buff *to_return;
@@ -116,9 +116,9 @@ exmpp_xml_stop(ErlDrvData drv_data)
driver_free(edd);
}
-static int
+static ErlDrvSSizeT
exmpp_xml_control(ErlDrvData drv_data, unsigned int command,
- char *buf, int len, char **rbuf, int rlen)
+ char *buf, ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen)
{
struct exmpp_xml_data *edd;
ei_x_buff *to_return;
@@ -144,9 +144,9 @@ exmpp_xml_stop(ErlDrvData drv_data)
driver_free(edd);
}
-static int
+static ErlDrvSSizeT
exmpp_xml_control(ErlDrvData drv_data, unsigned int command,
- char *buf, int len, char **rbuf, int rlen)
+ char *buf, ErlDrvSizeT len, char **rbuf, ErlDrvSizeT rlen)
{
struct exmpp_xml_data *edd;
ei_x_buff *to_return;

0 comments on commit f0f05ea

Please sign in to comment.