Skip to content

Commit

Permalink
R15 compatibility.
Browse files Browse the repository at this point in the history
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
rraptorr authored and badlop committed Dec 16, 2011
1 parent 6987a0a commit f0f05ea
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 12 deletions.
4 changes: 2 additions & 2 deletions c_src/exmpp_compress_zlib.c
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions c_src/exmpp_driver.h
Expand Up @@ -24,6 +24,16 @@
#include <ei.h>
#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:
Expand Down
4 changes: 2 additions & 2 deletions c_src/exmpp_stringprep.c
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions c_src/exmpp_tls_openssl.c
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions c_src/exmpp_xml_expat.c
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions c_src/exmpp_xml_expat_legacy.c
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions c_src/exmpp_xml_libxml2.c
Expand Up @@ -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;
Expand Down

0 comments on commit f0f05ea

Please sign in to comment.