Author: dcreager
Date: Wed Feb 29 01:33:03 2012
New Revision: 1294932
URL: http://svn.apache.org/viewvc?rev=1294932&view=rev
Log:
AVRO-1033. C: Fix x86 assembly implementation of reference count primitives.
There was a typo in the assembly implementation of our reference
counting primitives. (Vivek Nadkarni via dcreager)
Added:
avro/trunk/lang/c/tests/test_refcount.c
Modified:
avro/trunk/CHANGES.txt
avro/trunk/lang/c/src/avro/refcount.h
avro/trunk/lang/c/tests/CMakeLists.txt
Modified: avro/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1294932&r1=1294931&r2=1294932&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed Feb 29 01:33:03 2012
@@ -18,6 +18,9 @@ Avro 1.6.3 (unreleased)
AVRO-1031. C: Test cases made too many assumptions about memcmp
result. (dcreager)
+ AVRO-1033. C: Fixed x86 assembly implementation of atomic reference
+ counting primitives. (Vivek Nadkarni via dcreager)
+
Avro 1.6.2 (13 February 2012)
NEW FEATURES
Modified: avro/trunk/lang/c/src/avro/refcount.h
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/refcount.h?rev=1294932&r1=1294931&r2=1294932&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/refcount.h (original)
+++ avro/trunk/lang/c/src/avro/refcount.h Wed Feb 29 01:33:03 2012
@@ -139,8 +139,8 @@ avro_refcount_inc(volatile int *refcount
{
if (*refcount != (int) -1) {
__asm__ __volatile__ ("lock ; inc"REFCOUNT_SS" %0"
- :"=m" (refcount)
- :"m" (refcount));
+ :"=m" (*refcount)
+ :"m" (*refcount));
}
}
@@ -150,8 +150,8 @@ avro_refcount_dec(volatile int *refcount
if (*refcount != (int) -1) {
char result;
__asm__ __volatile__ ("lock ; dec"REFCOUNT_SS" %0; setz %1"
- :"=m" (refcount), "=q" (result)
- :"m" (refcount));
+ :"=m" (*refcount), "=q" (result)
+ :"m" (*refcount));
return result;
}
return 0;
Modified: avro/trunk/lang/c/tests/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/CMakeLists.txt?rev=1294932&r1=1294931&r2=1294932&view=diff
==============================================================================
--- avro/trunk/lang/c/tests/CMakeLists.txt (original)
+++ avro/trunk/lang/c/tests/CMakeLists.txt Wed Feb 29 01:33:03 2012
@@ -45,4 +45,5 @@ add_avro_test(test_avro_values)
add_avro_test(test_avro_968)
add_avro_test(test_avro_984)
add_avro_test(test_avro_data)
+add_avro_test(test_refcount)
add_avro_test(test_cpp test_cpp.cpp)
Added: avro/trunk/lang/c/tests/test_refcount.c
URL:
http://svn.apache.org/viewvc/avro/trunk/lang/c/tests/test_refcount.c?rev=1294932&view=auto
==============================================================================
--- avro/trunk/lang/c/tests/test_refcount.c (added)
+++ avro/trunk/lang/c/tests/test_refcount.c Wed Feb 29 01:33:03 2012
@@ -0,0 +1,46 @@
+#include <avro.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define SIMPLE_ARRAY \
+"{\"type\": \"array\", \"items\": \"long\"}"
+
+
+int main(void)
+{
+ avro_schema_t schema = NULL;
+ avro_schema_error_t error;
+ avro_value_iface_t *simple_array_class;
+ avro_value_t simple;
+
+ /* Initialize the schema structure from JSON */
+ if (avro_schema_from_json(SIMPLE_ARRAY, sizeof(SIMPLE_ARRAY),
+ &schema, &error)) {
+ fprintf(stdout, "Unable to parse schema\n");
+ exit(EXIT_FAILURE);
+ }
+
+ // Create avro class and value
+ simple_array_class = avro_generic_class_from_schema( schema );
+ if ( simple_array_class == NULL )
+ {
+ fprintf(stdout, "Unable to create simple array class\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if ( avro_generic_value_new( simple_array_class, &simple ) )
+ {
+ fprintf(stdout, "Error creating instance of record\n" );
+ exit(EXIT_FAILURE);
+ }
+
+ // Release the avro class and value
+ avro_value_decref( &simple );
+ avro_value_iface_decref( simple_array_class );
+ avro_schema_decref(schema);
+
+ return 0;
+
+}