esdl (1.2-2) driver.patch

Summary

 c_src/esdl_driver.c |   42 +++++++++++++++++++++++++++++-------------
 1 file changed, 29 insertions(+), 13 deletions(-)

    
download this patch

Patch contents

Patch fixes esdl_driver loading into Erlang R15B.

--- esdl-1.2.orig/c_src/esdl_driver.c
+++ esdl-1.2/c_src/esdl_driver.c
@@ -32,15 +32,20 @@
 
 #include "esdl.h"
 
+#if ERL_DRV_EXTENDED_MAJOR_VERSION < 2
+typedef int ErlDrvSizeT;
+typedef int ErlDrvSSizeT;
+#endif
+
 #define TEMP_BINARY_SIZE 512
 
 static ErlDrvData sdl_driver_start(ErlDrvPort port, char *buff);
 static void sdl_driver_stop(ErlDrvData handle);
 static void sdl_driver_finish(void);
-static int sdl_driver_control(ErlDrvData handle, unsigned int command, 
-			      char* buf, int count, char** res, int res_size);
-static int sdl_driver_debug_control(ErlDrvData handle, unsigned int command, 
-				    char* buf, int count, char** res, int res_size);
+static ErlDrvSSizeT sdl_driver_control(ErlDrvData handle, unsigned int command, 
+			      char* buf, ErlDrvSizeT count, char** res, ErlDrvSizeT res_size);
+static ErlDrvSSizeT sdl_driver_debug_control(ErlDrvData handle, unsigned int command, 
+				    char* buf, ErlDrvSizeT count, char** res, ErlDrvSizeT res_size);
 
 static void standard_outputv(ErlDrvData drv_data, ErlIOVec *ev);
 
@@ -62,6 +67,17 @@
     sdl_driver_control,    /* F_PTR control, port_control callback */
     NULL,                  /* F_PTR timeout, reserved */
     standard_outputv,	   /* F_PTR outputv, reserved */
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    ERL_DRV_EXTENDED_MARKER,
+    ERL_DRV_EXTENDED_MAJOR_VERSION,
+    ERL_DRV_EXTENDED_MINOR_VERSION,
+    0,
+    NULL,
+    NULL,
+    NULL
 };
 
 DRIVER_INIT(sdl_driver)
@@ -176,9 +192,9 @@
 {
 }
 
-static int
+static ErlDrvSSizeT
 sdl_driver_control(ErlDrvData handle, unsigned op,
-		   char* buf, int count, char** res, int res_size)
+		   char* buf, ErlDrvSizeT count, char** res, ErlDrvSizeT res_size)
 {
   sdl_data* sd = (sdl_data *) handle;
   sdl_fun func;
@@ -190,7 +206,7 @@
   if(op < OPENGL_START) {
      // fprintf(stderr, "Command:%d:%s: ", op, sd->str_tab[op]);fflush(stderr);
      func = sd->fun_tab[op];
-     func(sd, count, buf);
+     func(sd, (int)count, buf);
   } else {
       // fprintf(stderr, "Command:%d:gl_??\r\n", op); fflush(stderr);
      gl_dispatch(sd, op, count, buf);
@@ -198,12 +214,12 @@
   }
   // fprintf(stderr, "%s:%d: Eed %d\r\n", __FILE__,__LINE__,op); fflush(stderr);
   (*res) = sd->buff;
-  return sd->len;
+  return (ErlDrvSSizeT)(sd->len);
 }
 
-static int
+static ErlDrvSSizeT
 sdl_driver_debug_control(ErlDrvData handle, unsigned op,
-			 char* buf, int count, char** res, int res_size)
+			 char* buf, ErlDrvSizeT count, char** res, ErlDrvSizeT res_size)
 {
   sdl_data* sd = (sdl_data *) handle;
   sdl_fun func;
@@ -215,15 +231,15 @@
   if(op < OPENGL_START) {
      fprintf(stderr, "Command:%d:%s: ", op, sd->str_tab[op]);fflush(stderr);
      func = sd->fun_tab[op];
-     func(sd, count, buf);
+     func(sd, (int)count, buf);
      if ((len = sd->len) >= 0) {
 	fprintf(stderr, "ok %d %p\r\n", len, sd->buff);fflush(stderr);
 	(*res) = sd->buff;
-	return len;
+	return (ErlDrvSSizeT)len;
      } else {
 	fprintf(stderr, "error\r\n");fflush(stderr);
 	*res = 0;
-	return -1;
+	return (ErlDrvSSizeT)(-1);
      }     
   } else {
       fprintf(stderr, "Command:%d ", op);fflush(stderr);