THRIFT-302. ruby: Native extension fails to build
authorBryan Duxbury <bryanduxbury@apache.org>
Tue, 3 Feb 2009 18:16:54 +0000 (18:16 +0000)
committerBryan Duxbury <bryanduxbury@apache.org>
Tue, 3 Feb 2009 18:16:54 +0000 (18:16 +0000)
A piece of code needed for compilation on Linux was missing; this patch replaces it. Also, there were some compiler warnings and declarations that were missing that are now fixed.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@740366 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/ext/binary_protocol_accelerated.c
lib/rb/ext/binary_protocol_accelerated.h
lib/rb/ext/constants.h
lib/rb/ext/memory_buffer.c
lib/rb/ext/memory_buffer.h
lib/rb/ext/protocol.c
lib/rb/ext/protocol.h
lib/rb/ext/struct.c
lib/rb/ext/struct.h
lib/rb/ext/thrift_native.c

index 27567fc..8a6757f 100644 (file)
@@ -1,5 +1,6 @@
 #include <ruby.h>
 #include <stdbool.h>
+#include <stdint.h>
 #include <constants.h>
 #include <struct.h>
 
@@ -434,4 +435,4 @@ void Init_binary_protocol_accelerated() {
   
   VALUE method_table_object = Data_Wrap_Struct(rb_cObject, 0, free, npmt);
   rb_const_set(bpa_class, rb_intern("@native_method_table"), method_table_object);
-}
\ No newline at end of file
+}
index 4d3517b..6175ff4 100644 (file)
@@ -1,2 +1 @@
-
-void Init_binary_protocol_accelerated();
\ No newline at end of file
+void Init_binary_protocol_accelerated();
index f66a3ac..e540234 100644 (file)
@@ -72,4 +72,4 @@ extern VALUE rb_cSet;
 extern VALUE thrift_module;
 extern VALUE thrift_types_module;
 extern VALUE class_thrift_protocol;
-extern VALUE protocol_exception_class;
\ No newline at end of file
+extern VALUE protocol_exception_class;
index a607ae2..00545cc 100644 (file)
@@ -49,4 +49,4 @@ void Init_memory_buffer() {
   slice_method_id = rb_intern("slice");
   
   GARBAGE_BUFFER_SIZE = FIX2INT(rb_const_get(thrift_memory_buffer_class, rb_intern("GARBAGE_BUFFER_SIZE")));
-}
\ No newline at end of file
+}
index ccc2aed..9e01d13 100644 (file)
@@ -1,2 +1 @@
-
-void Init_memory_buffer();
\ No newline at end of file
+void Init_memory_buffer();
index b548f97..207e78d 100644 (file)
@@ -163,4 +163,4 @@ void Init_protocol() {
   // 
   // VALUE method_table_object = Data_Wrap_Struct(rb_cObject, 0, free, npmt);
   // rb_const_set(c_protocol, rb_intern("@native_method_table"), method_table_object);
-}
\ No newline at end of file
+}
index 534c859..b5e066f 100644 (file)
@@ -1,2 +1 @@
-
-void Init_protocol();
\ No newline at end of file
+void Init_protocol();
index 0e7aa1a..b882344 100644 (file)
@@ -1,7 +1,28 @@
-
 #include <struct.h>
 #include <constants.h>
 
+#ifndef HAVE_STRLCPY
+
+static
+size_t
+strlcpy (char *dst, const char *src, size_t dst_sz)
+{
+    size_t n;
+
+    for (n = 0; n < dst_sz; n++) {
+      if ((*dst++ = *src++) == '\0')
+        break;
+    }
+
+    if (n < dst_sz)
+      return n;
+    if (n > 0)
+      *(dst - 1) = '\0';
+    return n + strlen (src);
+}
+
+#endif
+
 static native_proto_method_table *mt;
 
 #define IS_CONTAINER(ttype) ((ttype) == TTYPE_MAP || (ttype) == TTYPE_LIST || (ttype) == TTYPE_SET)
index bf2350d..870d24e 100644 (file)
@@ -45,4 +45,4 @@ typedef struct native_proto_method_table {
   
 } native_proto_method_table;
 
-void Init_struct();
\ No newline at end of file
+void Init_struct();
index 60d0fc0..89d32c5 100644 (file)
@@ -166,4 +166,4 @@ void Init_thrift_native() {
   Init_struct();
   Init_binary_protocol_accelerated();
   Init_memory_buffer();
-}
\ No newline at end of file
+}