You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ma...@apache.org on 2010/03/15 23:38:00 UTC

svn commit: r923482 - in /hadoop/avro/trunk: CHANGES.txt lang/c/configure.in lang/c/src/avro.h lang/c/src/datafile.c lang/c/src/io.c lang/c/src/schema.c lang/c/tests/CMakeLists.txt lang/c/tests/Makefile.am lang/c/tests/test_cpp.cpp lang/c/version.sh

Author: massie
Date: Mon Mar 15 22:38:00 2010
New Revision: 923482

URL: http://svn.apache.org/viewvc?rev=923482&view=rev
Log:
AVRO-418. avro.h generates errors when included in C++ code. Contributed by Bruce Mitchener.

Added:
    hadoop/avro/trunk/lang/c/tests/test_cpp.cpp
Modified:
    hadoop/avro/trunk/CHANGES.txt
    hadoop/avro/trunk/lang/c/configure.in
    hadoop/avro/trunk/lang/c/src/avro.h
    hadoop/avro/trunk/lang/c/src/datafile.c
    hadoop/avro/trunk/lang/c/src/io.c
    hadoop/avro/trunk/lang/c/src/schema.c
    hadoop/avro/trunk/lang/c/tests/CMakeLists.txt
    hadoop/avro/trunk/lang/c/tests/Makefile.am
    hadoop/avro/trunk/lang/c/version.sh

Modified: hadoop/avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/CHANGES.txt?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/CHANGES.txt (original)
+++ hadoop/avro/trunk/CHANGES.txt Mon Mar 15 22:38:00 2010
@@ -45,6 +45,9 @@ Avro 1.3.1 (16 March 2010)
 
     AVRO-449. CMake-based build system for Avro/C (Bruce Mitchener via massie)
 
+    AVRO-418. avro.h generates errors when included in C++ code 
+    (Bruce Mitchener via massie)
+
   BUG FIXES
 
     AVRO-424. Fix the specification of the deflate codec.

Modified: hadoop/avro/trunk/lang/c/configure.in
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/configure.in?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/configure.in (original)
+++ hadoop/avro/trunk/lang/c/configure.in Mon Mar 15 22:38:00 2010
@@ -15,6 +15,7 @@ AC_DEFINE_UNQUOTED(LIBAVRO_VERSION, $LIB
 
 # Checks for programs.
 AC_PROG_CC
+AC_PROG_CXX
 AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
 

Modified: hadoop/avro/trunk/lang/c/src/avro.h
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/avro.h?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/avro.h (original)
+++ hadoop/avro/trunk/lang/c/src/avro.h Mon Mar 15 22:38:00 2010
@@ -90,8 +90,8 @@ struct avro_obj_t {
 #define is_avro_complex_type(obj) (!(is_avro_primitive(obj))
 #define is_avro_link(obj)     (obj && avro_typeof(obj) == AVRO_LINK)
 
-typedef struct avro_reader_t *avro_reader_t;
-typedef struct avro_writer_t *avro_writer_t;
+typedef struct avro_reader_t_ *avro_reader_t;
+typedef struct avro_writer_t_ *avro_writer_t;
 
 /*
  * schema 
@@ -128,7 +128,7 @@ int avro_schema_union_append(const avro_
 
 avro_schema_t avro_schema_link(avro_schema_t schema);
 
-typedef struct avro_schema_error_t *avro_schema_error_t;
+typedef struct avro_schema_error_t_ *avro_schema_error_t;
 int avro_schema_from_json(const char *jsontext,
 			  const int32_t len,
 			  avro_schema_t * schema, avro_schema_error_t * error);
@@ -261,8 +261,8 @@ int64_t avro_size_data(avro_writer_t wri
 		       avro_schema_t writer_schema, avro_datum_t datum);
 
 /* File object container */
-typedef struct avro_file_reader_t *avro_file_reader_t;
-typedef struct avro_file_writer_t *avro_file_writer_t;
+typedef struct avro_file_reader_t_ *avro_file_reader_t;
+typedef struct avro_file_writer_t_ *avro_file_writer_t;
 
 int avro_file_writer_create(const char *path, avro_schema_t schema,
 			    avro_file_writer_t * writer);

Modified: hadoop/avro/trunk/lang/c/src/datafile.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/datafile.c?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/datafile.c (original)
+++ hadoop/avro/trunk/lang/c/src/datafile.c Mon Mar 15 22:38:00 2010
@@ -24,7 +24,7 @@
 #include <time.h>
 #include <string.h>
 
-struct avro_file_reader_t {
+struct avro_file_reader_t_ {
 	avro_schema_t writers_schema;
 	avro_reader_t reader;
 	char sync[16];
@@ -33,7 +33,7 @@ struct avro_file_reader_t {
 	int64_t current_blocklen;
 };
 
-struct avro_file_writer_t {
+struct avro_file_writer_t_ {
 	avro_schema_t writers_schema;
 	avro_writer_t writer;
 	char sync[16];
@@ -43,7 +43,7 @@ struct avro_file_writer_t {
 };
 
 /* TODO: should we just read /dev/random? */
-static void generate_sync(struct avro_file_writer_t *w)
+static void generate_sync(avro_file_writer_t w)
 {
 	unsigned int i;
 	srand(time(NULL));
@@ -52,12 +52,12 @@ static void generate_sync(struct avro_fi
 	}
 }
 
-static int write_sync(struct avro_file_writer_t *w)
+static int write_sync(avro_file_writer_t w)
 {
 	return avro_write(w->writer, w->sync, sizeof(w->sync));
 }
 
-static int write_header(struct avro_file_writer_t *w)
+static int write_header(avro_file_writer_t w)
 {
 	int rval;
 	uint8_t version = 1;
@@ -92,8 +92,7 @@ static int write_header(struct avro_file
 }
 
 static int
-file_writer_init_fp(const char *path, const char *mode,
-		    struct avro_file_writer_t *w)
+file_writer_init_fp(const char *path, const char *mode, avro_file_writer_t w)
 {
 	FILE *fp = fopen(path, mode);
 	if (!fp) {
@@ -107,8 +106,7 @@ file_writer_init_fp(const char *path, co
 }
 
 static int
-file_writer_create(const char *path, avro_schema_t schema,
-		   struct avro_file_writer_t *w)
+file_writer_create(const char *path, avro_schema_t schema, avro_file_writer_t w)
 {
 	int rval = file_writer_init_fp(path, "wx", w);
 	if (rval) {
@@ -130,12 +128,12 @@ int
 avro_file_writer_create(const char *path, avro_schema_t schema,
 			avro_file_writer_t * writer)
 {
-	struct avro_file_writer_t *w;
+	avro_file_writer_t w;
 	int rval;
 	if (!path || !is_avro_schema(schema) || !writer) {
 		return EINVAL;
 	}
-	w = malloc(sizeof(struct avro_file_writer_t));
+	w = malloc(sizeof(struct avro_file_writer_t_));
 	if (!w) {
 		return ENOMEM;
 	}
@@ -181,7 +179,7 @@ static int file_read_header(avro_reader_
 	return avro_read(reader, sync, synclen);
 }
 
-static int file_writer_open(const char *path, struct avro_file_writer_t *w)
+static int file_writer_open(const char *path, avro_file_writer_t w)
 {
 	int rval;
 	FILE *fp;
@@ -209,12 +207,12 @@ static int file_writer_open(const char *
 
 int avro_file_writer_open(const char *path, avro_file_writer_t * writer)
 {
-	struct avro_file_writer_t *w;
+	avro_file_writer_t w;
 	int rval;
 	if (!path || !writer) {
 		return EINVAL;
 	}
-	w = malloc(sizeof(struct avro_file_writer_t));
+	w = malloc(sizeof(struct avro_file_writer_t_));
 	if (!w) {
 		return ENOMEM;
 	}
@@ -242,8 +240,7 @@ int avro_file_reader(const char *path, a
 {
 	int rval;
 	FILE *fp;
-	struct avro_file_reader_t *r =
-	    malloc(sizeof(struct avro_file_reader_t));
+	avro_file_reader_t r = malloc(sizeof(struct avro_file_reader_t_));
 	if (!r) {
 		return ENOMEM;
 	}

Modified: hadoop/avro/trunk/lang/c/src/io.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/io.c?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/io.c (original)
+++ hadoop/avro/trunk/lang/c/src/io.c Mon Mar 15 22:38:00 2010
@@ -28,38 +28,38 @@ enum avro_io_type_t {
 };
 typedef enum avro_io_type_t avro_io_type_t;
 
-struct avro_reader_t {
+struct avro_reader_t_ {
 	avro_io_type_t type;
 	unsigned long refcount;
 };
 
-struct avro_writer_t {
+struct avro_writer_t_ {
 	avro_io_type_t type;
 	unsigned long refcount;
 };
 
-struct avro_file_reader_t {
-	struct avro_reader_t reader;
+struct _avro_reader_file_t {
+	struct avro_reader_t_ reader;
 	FILE *fp;
 	char *cur;
 	char *end;
 	char buffer[4096];
 };
 
-struct avro_file_writer_t {
-	struct avro_writer_t writer;
+struct _avro_writer_file_t {
+	struct avro_writer_t_ writer;
 	FILE *fp;
 };
 
-struct avro_memory_reader_t {
-	struct avro_reader_t reader;
+struct _avro_reader_memory_t {
+	struct avro_reader_t_ reader;
 	const char *buf;
 	int64_t len;
 	int64_t read;
 };
 
-struct avro_memory_writer_t {
-	struct avro_writer_t writer;
+struct _avro_writer_memory_t {
+	struct avro_writer_t_ writer;
 	const char *buf;
 	int64_t len;
 	int64_t written;
@@ -69,10 +69,10 @@ struct avro_memory_writer_t {
 #define is_memory_io(obj)        (obj && avro_io_typeof(obj) == AVRO_MEMORY_IO)
 #define is_file_io(obj)          (obj && avro_io_typeof(obj) == AVRO_FILE_IO)
 
-#define avro_reader_to_memory(reader_)  container_of(reader_, struct avro_memory_reader_t, reader)
-#define avro_reader_to_file(reader_)    container_of(reader_, struct avro_file_reader_t, reader)
-#define avro_writer_to_memory(writer_)  container_of(writer_, struct avro_memory_writer_t, writer)
-#define avro_writer_to_file(writer_)    container_of(writer_, struct avro_file_writer_t, writer)
+#define avro_reader_to_memory(reader_)  container_of(reader_, struct _avro_reader_memory_t, reader)
+#define avro_reader_to_file(reader_)    container_of(reader_, struct _avro_reader_file_t, reader)
+#define avro_writer_to_memory(writer_)  container_of(writer_, struct _avro_writer_memory_t, writer)
+#define avro_writer_to_file(writer_)    container_of(writer_, struct _avro_writer_file_t, writer)
 
 static void reader_init(avro_reader_t reader, avro_io_type_t type)
 {
@@ -88,12 +88,12 @@ static void writer_init(avro_writer_t wr
 
 avro_reader_t avro_reader_file(FILE * fp)
 {
-	struct avro_file_reader_t *file_reader =
-	    malloc(sizeof(struct avro_file_reader_t));
+	struct _avro_reader_file_t *file_reader =
+	    malloc(sizeof(struct _avro_reader_file_t));
 	if (!file_reader) {
 		return NULL;
 	}
-	memset(file_reader, 0, sizeof(struct avro_file_reader_t));
+	memset(file_reader, 0, sizeof(struct _avro_reader_file_t));
 	file_reader->fp = fp;
 	reader_init(&file_reader->reader, AVRO_FILE_IO);
 	return &file_reader->reader;
@@ -101,8 +101,8 @@ avro_reader_t avro_reader_file(FILE * fp
 
 avro_writer_t avro_writer_file(FILE * fp)
 {
-	struct avro_file_writer_t *file_writer =
-	    malloc(sizeof(struct avro_file_writer_t));
+	struct _avro_writer_file_t *file_writer =
+	    malloc(sizeof(struct _avro_writer_file_t));
 	if (!file_writer) {
 		return NULL;
 	}
@@ -113,8 +113,8 @@ avro_writer_t avro_writer_file(FILE * fp
 
 avro_reader_t avro_reader_memory(const char *buf, int64_t len)
 {
-	struct avro_memory_reader_t *mem_reader =
-	    malloc(sizeof(struct avro_memory_reader_t));
+	struct _avro_reader_memory_t *mem_reader =
+	    malloc(sizeof(struct _avro_reader_memory_t));
 	if (!mem_reader) {
 		return NULL;
 	}
@@ -127,8 +127,8 @@ avro_reader_t avro_reader_memory(const c
 
 avro_writer_t avro_writer_memory(const char *buf, int64_t len)
 {
-	struct avro_memory_writer_t *mem_writer =
-	    malloc(sizeof(struct avro_memory_writer_t));
+	struct _avro_writer_memory_t *mem_writer =
+	    malloc(sizeof(struct _avro_writer_memory_t));
 	if (!mem_writer) {
 		return NULL;
 	}
@@ -140,7 +140,7 @@ avro_writer_t avro_writer_memory(const c
 }
 
 static int
-avro_read_memory(struct avro_memory_reader_t *reader, void *buf, int64_t len)
+avro_read_memory(struct _avro_reader_memory_t *reader, void *buf, int64_t len)
 {
 	if (len > 0) {
 		if ((reader->len - reader->read) < len) {
@@ -156,7 +156,7 @@ avro_read_memory(struct avro_memory_read
 #define buffer_reset(reader) {reader->cur = reader->end = reader->buffer;}
 
 static int
-avro_read_file(struct avro_file_reader_t *reader, void *buf, int64_t len)
+avro_read_file(struct _avro_reader_file_t *reader, void *buf, int64_t len)
 {
 	int64_t needed = len;
 	void *p = buf;
@@ -220,7 +220,7 @@ int avro_read(avro_reader_t reader, void
 	return EINVAL;
 }
 
-static int avro_skip_memory(struct avro_memory_reader_t *reader, int64_t len)
+static int avro_skip_memory(struct _avro_reader_memory_t *reader, int64_t len)
 {
 	if (len > 0) {
 		if ((reader->len - reader->read) < len) {
@@ -231,7 +231,7 @@ static int avro_skip_memory(struct avro_
 	return 0;
 }
 
-static int avro_skip_file(struct avro_file_reader_t *reader, int64_t len)
+static int avro_skip_file(struct _avro_reader_file_t *reader, int64_t len)
 {
 	int rval;
 	int64_t needed = len;
@@ -266,7 +266,7 @@ int avro_skip(avro_reader_t reader, int6
 }
 
 static int
-avro_write_memory(struct avro_memory_writer_t *writer, void *buf, int64_t len)
+avro_write_memory(struct _avro_writer_memory_t *writer, void *buf, int64_t len)
 {
 	if (len) {
 		if ((writer->len - writer->written) < len) {
@@ -279,7 +279,7 @@ avro_write_memory(struct avro_memory_wri
 }
 
 static int
-avro_write_file(struct avro_file_writer_t *writer, void *buf, int64_t len)
+avro_write_file(struct _avro_writer_file_t *writer, void *buf, int64_t len)
 {
 	int rval;
 	if (len > 0) {

Modified: hadoop/avro/trunk/lang/c/src/schema.c
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/src/schema.c?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/src/schema.c (original)
+++ hadoop/avro/trunk/lang/c/src/schema.c Mon Mar 15 22:38:00 2010
@@ -27,7 +27,7 @@
 
 #define DEFAULT_TABLE_SIZE 32
 
-struct avro_schema_error_t {
+struct avro_schema_error_t_ {
 	st_table *named_schemas;
 	json_error_t json_error;
 };
@@ -840,7 +840,7 @@ avro_schema_from_json(const char *jsonte
 {
 	json_t *root;
 	int rval = 0;
-	struct avro_schema_error_t *error;
+	avro_schema_error_t error;
 
 	AVRO_UNUSED(len);
 
@@ -848,7 +848,7 @@ avro_schema_from_json(const char *jsonte
 		return EINVAL;
 	}
 
-	error = malloc(sizeof(struct avro_schema_error_t));
+	error = malloc(sizeof(struct avro_schema_error_t_));
 	if (!error) {
 		return ENOMEM;
 	}

Modified: hadoop/avro/trunk/lang/c/tests/CMakeLists.txt
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/CMakeLists.txt?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/CMakeLists.txt (original)
+++ hadoop/avro/trunk/lang/c/tests/CMakeLists.txt Mon Mar 15 22:38:00 2010
@@ -30,3 +30,6 @@ add_executable(test_avro_data test_avro_
 target_link_libraries(test_avro_data avro-static)
 add_test(test_avro_data ${CMAKE_COMMAND} -E chdir ${AvroC_SOURCE_DIR}/tests ${CMAKE_CURRENT_BINARY_DIR}/test_avro_data)
 
+add_executable(test_cpp test_cpp.cpp)
+target_link_libraries(test_cpp avro-static)
+add_test(test_cpp ${CMAKE_COMMAND} -E chdir ${AvroC_SOURCE_DIR}/tests ${CMAKE_CURRENT_BINARY_DIR}/test_cpp)

Modified: hadoop/avro/trunk/lang/c/tests/Makefile.am
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/Makefile.am?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/Makefile.am (original)
+++ hadoop/avro/trunk/lang/c/tests/Makefile.am Mon Mar 15 22:38:00 2010
@@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS=-I m4
 
 EXTRA_DIST=schema_tests test_valgrind
 
-check_PROGRAMS=test_avro_schema test_avro_data
+check_PROGRAMS=test_avro_schema test_avro_data test_cpp
 
 noinst_PROGRAMS=generate_interop_data test_interop_data
 
@@ -17,6 +17,9 @@ test_avro_schema_LDADD=$(test_LDADD)
 test_avro_data_SOURCES=test_avro_data.c
 test_avro_data_LDADD=$(test_LDADD)
 
+test_cpp_SOURCES=test_cpp.cpp
+test_cpp_LDADD=$(test_LDADD)
+
 generate_interop_data_SOURCES=generate_interop_data.c
 generate_interop_data_LDADD=$(test_LDADD)
 

Added: hadoop/avro/trunk/lang/c/tests/test_cpp.cpp
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/tests/test_cpp.cpp?rev=923482&view=auto
==============================================================================
--- hadoop/avro/trunk/lang/c/tests/test_cpp.cpp (added)
+++ hadoop/avro/trunk/lang/c/tests/test_cpp.cpp Mon Mar 15 22:38:00 2010
@@ -0,0 +1,7 @@
+#include "avro.h"
+
+int main(int argc, char **argv)
+{
+	return 0;
+}
+

Modified: hadoop/avro/trunk/lang/c/version.sh
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/c/version.sh?rev=923482&r1=923481&r2=923482&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/c/version.sh (original)
+++ hadoop/avro/trunk/lang/c/version.sh Mon Mar 15 22:38:00 2010
@@ -18,9 +18,9 @@
 #         libavro_binary_age = 0
 #         libavro_interface_age = 0
 #
-libavro_micro_version=19
-libavro_interface_age=0
-libavro_binary_age=1
+libavro_micro_version=20
+libavro_interface_age=1
+libavro_binary_age=2
 
 # IGNORE EVERYTHING ELSE FROM HERE DOWN.........
 if test $# != 1; then