You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by dc...@apache.org on 2012/04/28 21:40:55 UTC
svn commit: r1331812 [1/5] - in /avro/trunk: ./ lang/c/ lang/c/examples/
lang/c/jansson/src/ lang/c/src/ lang/c/src/avro/ lang/c/tests/
Author: dcreager
Date: Sat Apr 28 19:40:52 2012
New Revision: 1331812
URL: http://svn.apache.org/viewvc?rev=1331812&view=rev
Log:
AVRO-551. C: Compiles on Win32 via VC++ 2008.
Patch submitted by Vivek Nadkarni. Includes a README file describing the
changes that were necessary, and what we'll need to do to maintain compatibility
on Windows moving forward.
Added:
avro/trunk/lang/c/README.maintaining_win32.txt
avro/trunk/lang/c/src/avro/msinttypes.h
avro/trunk/lang/c/src/avro/msstdint.h
avro/trunk/lang/c/src/avro/platform.h
avro/trunk/lang/c/tests/msdirent.h
Modified:
avro/trunk/CHANGES.txt
avro/trunk/LICENSE.txt
avro/trunk/lang/c/CMakeLists.txt
avro/trunk/lang/c/examples/CMakeLists.txt
avro/trunk/lang/c/examples/quickstop.c
avro/trunk/lang/c/jansson/src/dump.c
avro/trunk/lang/c/jansson/src/hashtable.c
avro/trunk/lang/c/jansson/src/hashtable.h
avro/trunk/lang/c/jansson/src/jansson_private.h
avro/trunk/lang/c/jansson/src/load.c
avro/trunk/lang/c/jansson/src/memory.c
avro/trunk/lang/c/jansson/src/strbuffer.c
avro/trunk/lang/c/jansson/src/strbuffer.h
avro/trunk/lang/c/jansson/src/utf.h
avro/trunk/lang/c/jansson/src/value.c
avro/trunk/lang/c/src/CMakeLists.txt
avro/trunk/lang/c/src/allocation.c
avro/trunk/lang/c/src/array.c
avro/trunk/lang/c/src/avro.h
avro/trunk/lang/c/src/avro/allocation.h
avro/trunk/lang/c/src/avro/consumer.h
avro/trunk/lang/c/src/avro/data.h
avro/trunk/lang/c/src/avro/errors.h
avro/trunk/lang/c/src/avro/generic.h
avro/trunk/lang/c/src/avro/io.h
avro/trunk/lang/c/src/avro/legacy.h
avro/trunk/lang/c/src/avro/refcount.h
avro/trunk/lang/c/src/avro/schema.h
avro/trunk/lang/c/src/avro/value.h
avro/trunk/lang/c/src/avro_private.h
avro/trunk/lang/c/src/avropipe.c
avro/trunk/lang/c/src/codec.h
avro/trunk/lang/c/src/consume-binary.c
avro/trunk/lang/c/src/datafile.c
avro/trunk/lang/c/src/datum.c
avro/trunk/lang/c/src/datum.h
avro/trunk/lang/c/src/datum_equal.c
avro/trunk/lang/c/src/datum_size.c
avro/trunk/lang/c/src/datum_validate.c
avro/trunk/lang/c/src/datum_value.c
avro/trunk/lang/c/src/dump.c
avro/trunk/lang/c/src/dump.h
avro/trunk/lang/c/src/encoding.h
avro/trunk/lang/c/src/encoding_binary.c
avro/trunk/lang/c/src/generic.c
avro/trunk/lang/c/src/io.c
avro/trunk/lang/c/src/map.c
avro/trunk/lang/c/src/memoize.c
avro/trunk/lang/c/src/resolved-reader.c
avro/trunk/lang/c/src/resolved-writer.c
avro/trunk/lang/c/src/resolver.c
avro/trunk/lang/c/src/schema.c
avro/trunk/lang/c/src/schema.h
avro/trunk/lang/c/src/st.c
avro/trunk/lang/c/src/st.h
avro/trunk/lang/c/src/string.c
avro/trunk/lang/c/src/value-hash.c
avro/trunk/lang/c/src/value-json.c
avro/trunk/lang/c/src/value-read.c
avro/trunk/lang/c/src/value-sizeof.c
avro/trunk/lang/c/src/value-write.c
avro/trunk/lang/c/src/wrapped-buffer.c
avro/trunk/lang/c/tests/CMakeLists.txt
avro/trunk/lang/c/tests/generate_interop_data.c
avro/trunk/lang/c/tests/test_avro_1034.c
avro/trunk/lang/c/tests/test_avro_984.c
avro/trunk/lang/c/tests/test_avro_data.c
avro/trunk/lang/c/tests/test_avro_schema.c
avro/trunk/lang/c/tests/test_avro_values.c
avro/trunk/lang/c/tests/test_data_structures.c
avro/trunk/lang/c/tests/test_interop_data.c
avro/trunk/lang/c/tests/test_refcount.c
Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Sat Apr 28 19:40:52 2012
@@ -22,6 +22,9 @@ Avro 1.7.0 (unreleased)
AVRO-1068. Avro Java does not build on recent Eclipse versions with m2eclipse (thiru)
+ AVRO-551. C: Now compiles on Win32, using Visual Studio C++ 2008.
+ (Vivek Nadkarni via dcreager)
+
BUG FIXES
AVRO-1045. Java: Fix a bug in GenericData#deepCopy() of ByteBuffer values.
Modified: avro/trunk/LICENSE.txt
URL: http://svn.apache.org/viewvc/avro/trunk/LICENSE.txt?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/LICENSE.txt (original)
+++ avro/trunk/LICENSE.txt Sat Apr 28 19:40:52 2012
@@ -247,3 +247,62 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE A
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+----------------------------------------------------------------------
+License for msinttypes used in the C implementation:
+Source from:
+http://code.google.com/p/msinttypes/downloads/detail?name=msinttypes-r26.zip
+
+Copyright (c) 2006-2008 Alexander Chemeris
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The name of the author may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+----------------------------------------------------------------------
+License for Dirent API for Microsoft Visual Studio used in the C implementation:
+Source from:
+http://www.softagalleria.net/download/dirent/dirent-1.11.zip
+
+Copyright (C) 2006 Toni Ronkko
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+``Software''), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+----------------------------------------------------------------------
Modified: avro/trunk/lang/c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/CMakeLists.txt?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/CMakeLists.txt (original)
+++ avro/trunk/lang/c/CMakeLists.txt Sat Apr 28 19:40:52 2012
@@ -27,47 +27,56 @@ cmake_policy(SET CMP0003 NEW)
#-----------------------------------------------------------------------
# Retrieve the current version number
-execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/version.sh project
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- RESULT_VARIABLE AVRO_VERSION_RESULT
- OUTPUT_VARIABLE AVRO_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(AVRO_VERSION_RESULT)
- message(FATAL_ERROR "Cannot determine Avro version number")
-endif(AVRO_VERSION_RESULT)
-
-execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/version.sh libtool
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- RESULT_VARIABLE LIBAVRO_VERSION_RESULT
- OUTPUT_VARIABLE LIBAVRO_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(LIBAVRO_VERSION_RESULT)
- message(FATAL_ERROR "Cannot determine libavro version number")
-endif(LIBAVRO_VERSION_RESULT)
+if (UNIX)
+ execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/version.sh project
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE AVRO_VERSION_RESULT
+ OUTPUT_VARIABLE AVRO_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(AVRO_VERSION_RESULT)
+ message(FATAL_ERROR "Cannot determine Avro version number")
+ endif(AVRO_VERSION_RESULT)
+
+ execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/version.sh libtool
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE LIBAVRO_VERSION_RESULT
+ OUTPUT_VARIABLE LIBAVRO_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(LIBAVRO_VERSION_RESULT)
+ message(FATAL_ERROR "Cannot determine libavro version number")
+ endif(LIBAVRO_VERSION_RESULT)
+else(UNIX)
+ # Hard code for win32 -- need to figure out how to port version.sh for
+ # Windows.
+ set(LIBAVRO_VERSION "22:0:0")
+endif(UNIX)
+
#-----------------------------------------------------------------------
# Extract major.minor.patch from version number
-string(REGEX REPLACE "([0-9]+)\\..*"
- "\\1"
- AVRO_MAJOR_VERSION
- ${AVRO_VERSION}
-)
-string(REGEX REPLACE ".*\\.([0-9]+)\\..*"
- "\\1"
- AVRO_MINOR_VERSION
- ${AVRO_VERSION}
-)
-string(REGEX REPLACE ".*\\..*\\.([0-9]+).*"
- "\\1"
- AVRO_PATCH_VERSION
- ${AVRO_VERSION}
-)
-string(REGEX REPLACE ".*\\..*\\.[0-9]+(.*)"
- "\\1"
- AVRO_VERSION_EXTENSION
- ${AVRO_VERSION}
-)
+if (UNIX)
+ string(REGEX REPLACE "([0-9]+)\\..*"
+ "\\1"
+ AVRO_MAJOR_VERSION
+ ${AVRO_VERSION}
+ )
+ string(REGEX REPLACE ".*\\.([0-9]+)\\..*"
+ "\\1"
+ AVRO_MINOR_VERSION
+ ${AVRO_VERSION}
+ )
+ string(REGEX REPLACE ".*\\..*\\.([0-9]+).*"
+ "\\1"
+ AVRO_PATCH_VERSION
+ ${AVRO_VERSION}
+ )
+ string(REGEX REPLACE ".*\\..*\\.[0-9]+(.*)"
+ "\\1"
+ AVRO_VERSION_EXTENSION
+ ${AVRO_VERSION}
+ )
+endif(UNIX)
#-----------------------------------------------------------------------
# Source package support
@@ -89,6 +98,17 @@ if(CMAKE_COMPILER_IS_GNUCC)
add_definitions(-W -Wall)
endif(CMAKE_COMPILER_IS_GNUCC)
+if (WIN32)
+ # Compile win32 in C++ to allow declarations after statements
+ add_definitions(/TP)
+endif(WIN32)
+
+# Uncomment to allow missing fields in the resolved-writer
+# add_definitions(-DAVRO_ALLOW_MISSING_FIELDS_IN_RESOLVED_WRITER)
+
+# Uncomment to allow non-atomic increment/decrement of reference count
+# add_definitions(-DAVRO_ALLOW_NON_ATOMIC_REFCOUNT)
+
include_directories(${AvroC_SOURCE_DIR}/src)
include_directories(${AvroC_SOURCE_DIR}/jansson/src)
Added: avro/trunk/lang/c/README.maintaining_win32.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/README.maintaining_win32.txt?rev=1331812&view=auto
==============================================================================
--- avro/trunk/lang/c/README.maintaining_win32.txt (added)
+++ avro/trunk/lang/c/README.maintaining_win32.txt Sat Apr 28 19:40:52 2012
@@ -0,0 +1,154 @@
+Win32 C++ builds of Avro-C
+*****************************
+
+April 2, 2012
+
+These instructions describe some of the changes required to allow
+Avro-C to compile under the Microsoft Visual C++ 2008 compiler, as
+well as some limitations of the Windows build.
+
+Status of the Windows Build:
+****************************
+
+The Windows build of Avro-C compiles under Microsoft Visual C++
+2008. You can use C-Make to create the solution file (AvroC.sln) for
+the build. The solution file contains projects for the build as well
+as projects for the tests. All the tests are run and pass when the
+project RUN_TESTS is built from within MS Visual C++ 2008.
+
+Limitations of Windows Build:
+******************************
+
+1. The Windows build of Avro-C is compiled using Microsoft's C++
+ compiler and not Microsoft's C compiler. This is done using the /TP
+ flag in the MSVC++ compiler. This flag is automatically set using
+ CMakeLists.txt
+
+ The reason to compile Win32 under C++ instead of C is that there
+ are lots of places where variables are declared after statements,
+ the Microsoft C compiler does not support declarations after
+ statements. It is possible, that if all the declarations after
+ statements were removed, that Avro-C would compile under
+ Microsoft's C compiler also. I have not tried this.
+
+2. The shared library, i.e. DLL, for avro has not been built. There
+ are instructions on how to build DLLs using CMake at
+ http://www.cmake.org/Wiki/BuildingWinDLL
+
+3. Currently avropipe.c and avromod.c do not compile under Windows. In
+ order for them to compile we would have to either port getopt() to
+ Windows, or remove their dependency on getopt().
+
+4. Windows cannot run version.sh to generate the version
+ number. Currently, LIBAVRO_VERSION is hard coded to "22:0:0" for
+ the Windows build, in the top level CMakeLists.txt.
+
+5. Found two bugs related to improper return values under error
+ conditions in Avro. These bugs were marked with #warnings in the
+ code.
+
+
+Instructions for Maintenance
+*****************************
+
+1. Instructions to check name mangling in Visual C++:
+
+ In a DOS prompt go to "C:\Program Files(x86)\Microsoft Visual Studio 9.0\VC\"
+ Run the program vcvarsall.bat . This will set up environment variables.
+
+ Now go to the avro_c\build_win32\src\Debug\ directory.
+ Run the command
+
+ dumpbin /ALL avro.lib > tmp.txt
+
+ View tmp.txt in your favorite editor. This will allow you to see
+ which names are mangled and which names are not mangled.
+
+ Every header file should start with
+
+ #ifndef HEADER_FILE_NAME_H
+ #define HEADER_FILE_NAME_H
+ #ifdef __cplusplus
+ extern "C" {
+ #define CLOSE_EXTERN }
+ #else
+ #define CLOSE_EXTERN
+ #endif
+
+ and end with
+
+ CLOSE_EXTERN
+ #endif /* HEADER_FILE_NAME_H */
+
+ This will ensure that all exported (public) functions are mangled
+ using C name mangling instead of C++ name mangling.
+
+2. All file I/O operations should have "b" for binary in the fopen
+ statements. Otherwise Windows will replace LF with CRLF in binary
+ data.
+
+3. Windows does not allow writing to a file with exclusive access
+ using the mode "wbx". Use the non-exclusive mode "wb" instead.
+
+4. If the hashtable from st.c is used, the functions in the struct
+ st_hash_type should be cast to HASH_FUNCTION_CAST.
+
+5. Do not use "%zu" to print size_t. Use '"%" PRIsz' without the
+ single quotes, instead.
+
+6. MS Visual C++ 2008 does not properly expand variadic preprocessor
+ macros by default. It is possible to "trick" MSVC++ to properly
+ expand variadic preprocessor macros by using an extra (dummy)
+ preprocessor macro, whose only purpose is to properly expand its
+ input. This method is described here:
+
+ http://stackoverflow.com/questions/2575864/the-problem-about-different-treatment-to-va-args-when-using-vs-2008-and-gcc
+ See the solution described by monkeyman.
+
+ This method is used in the macro expand_args(...) in test_avro_values.c.
+
+7. Web site describing how to debug macro expansion in Visual C++:
+ http://fneep.fiffa.net/?p=66
+
+8. Sometimes it is necessary to declare a struct at the top of a file
+ and define it at the bottom of a file. An example is
+ AVRO_DATUM_VALUE_CLASS in src/datum_value.c. A C++ compiler will
+ complain that the struct is defined twice. To avoid this, declare
+ the struct with the modifier "extern" at the top of the file, and
+ then define it at the bottom of the file. Note that it cannot be
+ defined as "static" because Win32 does not like an extern struct
+ mapping to a static struct.
+
+9. Use __FUNCTION__ instead of __func__ for generating the function
+ name.
+
+10. All variables need to be explicitly cast when calling functions
+ with differing function signatures
+
+11. All pointers need to be explicitly cast when assigning to other
+ pointers of a different type.
+
+12. Do not perform pointer arithmetic on void * pointers. Cast the
+ pointers to char * before performing pointer arithmetic.
+
+13. The executable names of any examples and tests need to be set
+ explicitly to include the "Debug/" directory in the path, and the
+ ".exe" ending. See the CMakeLists.txt in the examples and the
+ tests directory to see how this is done.
+
+14. Do not include the headers inttypes.h or unistd.h or
+ stdint.h. Instead include avro/platform.h in your C files.
+
+15. Do not include dirent.h in your tests. When _WIN32 is defined
+ include msdirent.h. See example in test_avro_schema.c.
+
+16. If _WIN32 is defined, define snprintf() to_snprintf(), which MS
+ Visual C++ recognizes. See jansson_private.h for an example.
+
+17. MSVC++ does not recognize strtoll(). Define it to _strtoi64()
+ instead. See jansson/src/load.c for an example.
+
+18. Old-style C function declarations are not allowed in C++. See the
+ changes in st.c and st.h -- which were converted to new-style
+ function declarations.
+
Modified: avro/trunk/lang/c/examples/CMakeLists.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/examples/CMakeLists.txt?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/examples/CMakeLists.txt (original)
+++ avro/trunk/lang/c/examples/CMakeLists.txt Sat Apr 28 19:40:52 2012
@@ -20,6 +20,13 @@
add_executable(quickstop quickstop.c)
target_link_libraries(quickstop avro-static)
+if (WIN32)
+ set(exec_name ${CMAKE_CURRENT_BINARY_DIR}/Debug/quickstop.exe)
+else (WIN32)
+ set(exec_name ${CMAKE_CURRENT_BINARY_DIR}/quickstop)
+endif (WIN32)
+
add_test(quickstop
${CMAKE_COMMAND} -E chdir ${AvroC_SOURCE_DIR}/examples
- ${CMAKE_CURRENT_BINARY_DIR}/quickstop)
+ ${exec_name}
+)
Modified: avro/trunk/lang/c/examples/quickstop.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/examples/quickstop.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/examples/quickstop.c (original)
+++ avro/trunk/lang/c/examples/quickstop.c Sat Apr 28 19:40:52 2012
@@ -16,10 +16,8 @@
*/
#include <avro.h>
-#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#ifdef DEFLATE_CODEC
#define QUICKSTOP_CODEC "deflate"
@@ -144,7 +142,7 @@ int main(void)
init_schema();
/* Delete the database if it exists */
- unlink(dbname);
+ remove(dbname);
/* Create a new database */
rval = avro_file_writer_create_with_codec
(dbname, person_schema, &db, QUICKSTOP_CODEC, 0);
Modified: avro/trunk/lang/c/jansson/src/dump.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/dump.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/dump.c (original)
+++ avro/trunk/lang/c/jansson/src/dump.c Sat Apr 28 19:40:52 2012
@@ -122,7 +122,7 @@ static int dump_string(const char *str,
/* codepoint is in BMP */
if(codepoint < 0x10000)
{
- sprintf(seq, "\\u%04x", codepoint);
+ sprintf(seq, "\\u%04x", (int) codepoint);
length = 6;
}
@@ -135,7 +135,7 @@ static int dump_string(const char *str,
first = 0xD800 | ((codepoint & 0xffc00) >> 10);
last = 0xDC00 | (codepoint & 0x003ff);
- sprintf(seq, "\\u%04x\\u%04x", first, last);
+ sprintf(seq, "\\u%04x\\u%04x", (int) first, (int) last);
length = 12;
}
@@ -313,7 +313,7 @@ static int do_dump(const json_t *json, s
int (*cmp_func)(const void *, const void *);
size = json_object_size(json);
- keys = jsonp_malloc(size * sizeof(object_key_t *));
+ keys = (const object_key_t **) jsonp_malloc(size * sizeof(object_key_t *));
if(!keys)
goto object_error;
Modified: avro/trunk/lang/c/jansson/src/hashtable.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/hashtable.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/hashtable.c (original)
+++ avro/trunk/lang/c/jansson/src/hashtable.c Sat Apr 28 19:40:52 2012
@@ -160,7 +160,7 @@ static int hashtable_do_rehash(hashtable
hashtable->num_buckets++;
new_size = num_buckets(hashtable);
- hashtable->buckets = jsonp_malloc(new_size * sizeof(bucket_t));
+ hashtable->buckets = (struct hashtable_bucket *) jsonp_malloc(new_size * sizeof(bucket_t));
if(!hashtable->buckets)
return -1;
@@ -187,7 +187,7 @@ static int hashtable_do_rehash(hashtable
hashtable_t *hashtable_create(key_hash_fn hash_key, key_cmp_fn cmp_keys,
free_fn free_key, free_fn free_value)
{
- hashtable_t *hashtable = jsonp_malloc(sizeof(hashtable_t));
+ hashtable_t *hashtable = (hashtable_t *) jsonp_malloc(sizeof(hashtable_t));
if(!hashtable)
return NULL;
@@ -214,7 +214,7 @@ int hashtable_init(hashtable_t *hashtabl
hashtable->size = 0;
hashtable->num_buckets = 0; /* index to primes[] */
- hashtable->buckets = jsonp_malloc(num_buckets(hashtable) * sizeof(bucket_t));
+ hashtable->buckets = (struct hashtable_bucket *) jsonp_malloc(num_buckets(hashtable) * sizeof(bucket_t));
if(!hashtable->buckets)
return -1;
@@ -266,7 +266,7 @@ int hashtable_set(hashtable_t *hashtable
}
else
{
- pair = jsonp_malloc(sizeof(pair_t));
+ pair = (pair_t *) jsonp_malloc(sizeof(pair_t));
if(!pair)
return -1;
Modified: avro/trunk/lang/c/jansson/src/hashtable.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/hashtable.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/hashtable.h (original)
+++ avro/trunk/lang/c/jansson/src/hashtable.h Sat Apr 28 19:40:52 2012
@@ -7,6 +7,12 @@
#ifndef HASHTABLE_H
#define HASHTABLE_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
typedef size_t (*key_hash_fn)(const void *key);
typedef int (*key_cmp_fn)(const void *key1, const void *key2);
@@ -204,4 +210,5 @@ void *hashtable_iter_value(void *iter);
*/
void hashtable_iter_set(hashtable_t *hashtable, void *iter, void *value);
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/jansson/src/jansson_private.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/jansson_private.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/jansson_private.h (original)
+++ avro/trunk/lang/c/jansson/src/jansson_private.h Sat Apr 28 19:40:52 2012
@@ -7,11 +7,21 @@
#ifndef JANSSON_PRIVATE_H
#define JANSSON_PRIVATE_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
#include <stddef.h>
#include "jansson.h"
#include "hashtable.h"
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
+
#define container_of(ptr_, type_, member_) \
((type_ *)((char *)ptr_ - offsetof(type_, member_)))
@@ -88,4 +98,5 @@ void* jsonp_malloc(size_t size);
void jsonp_free(void *ptr);
char *jsonp_strdup(const char *str);
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/jansson/src/load.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/load.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/load.c (original)
+++ avro/trunk/lang/c/jansson/src/load.c Sat Apr 28 19:40:52 2012
@@ -343,7 +343,7 @@ static void lex_scan_string(lex_t *lex,
- two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair
are converted to 4 bytes
*/
- lex->value.string = jsonp_malloc(lex->saved_text.length + 1);
+ lex->value.string = (char *) jsonp_malloc(lex->saved_text.length + 1);
if(!lex->value.string) {
/* this is not very nice, since TOKEN_INVALID is returned */
goto out;
@@ -437,7 +437,11 @@ out:
}
#if JSON_INTEGER_IS_LONG_LONG
+#ifdef _WIN32
+#define json_strtoint _strtoi64
+#else
#define json_strtoint strtoll
+#endif
#else
#define json_strtoint strtol
#endif
@@ -888,7 +892,7 @@ typedef struct
static int buffer_get(void *data)
{
char c;
- buffer_data_t *stream = data;
+ buffer_data_t *stream = (buffer_data_t *) data;
if(stream->pos >= stream->len)
return EOF;
Modified: avro/trunk/lang/c/jansson/src/memory.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/memory.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/memory.c (original)
+++ avro/trunk/lang/c/jansson/src/memory.c Sat Apr 28 19:40:52 2012
@@ -36,7 +36,7 @@ char *jsonp_strdup(const char *str)
{
char *new_str;
- new_str = jsonp_malloc(strlen(str) + 1);
+ new_str = (char *) jsonp_malloc(strlen(str) + 1);
if(!new_str)
return NULL;
Modified: avro/trunk/lang/c/jansson/src/strbuffer.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/strbuffer.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/strbuffer.c (original)
+++ avro/trunk/lang/c/jansson/src/strbuffer.c Sat Apr 28 19:40:52 2012
@@ -19,7 +19,7 @@ int strbuffer_init(strbuffer_t *strbuff)
strbuff->size = STRBUFFER_MIN_SIZE;
strbuff->length = 0;
- strbuff->value = jsonp_malloc(strbuff->size);
+ strbuff->value = (char *) jsonp_malloc(strbuff->size);
if(!strbuff->value)
return -1;
@@ -74,7 +74,7 @@ int strbuffer_append_bytes(strbuffer_t *
new_size = max(strbuff->size * STRBUFFER_FACTOR,
strbuff->length + size + 1);
- new_value = jsonp_malloc(new_size);
+ new_value = (char *) jsonp_malloc(new_size);
if(!new_value)
return -1;
Modified: avro/trunk/lang/c/jansson/src/strbuffer.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/strbuffer.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/strbuffer.h (original)
+++ avro/trunk/lang/c/jansson/src/strbuffer.h Sat Apr 28 19:40:52 2012
@@ -7,6 +7,12 @@
#ifndef STRBUFFER_H
#define STRBUFFER_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
typedef struct {
char *value;
@@ -28,4 +34,5 @@ int strbuffer_append_bytes(strbuffer_t *
char strbuffer_pop(strbuffer_t *strbuff);
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/jansson/src/utf.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/utf.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/utf.h (original)
+++ avro/trunk/lang/c/jansson/src/utf.h Sat Apr 28 19:40:52 2012
@@ -7,6 +7,12 @@
#ifndef UTF_H
#define UTF_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -28,7 +34,7 @@ typedef int int32_t;
#endif /* HAVE_CONFIG_H */
-int utf8_encode(int codepoint, char *buffer, int *size);
+int utf8_encode(int32_t codepoint, char *buffer, int *size);
int utf8_check_first(char byte);
int utf8_check_full(const char *buffer, int size, int32_t *codepoint);
@@ -36,4 +42,5 @@ const char *utf8_iterate(const char *buf
int utf8_check_string(const char *string, int length);
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/jansson/src/value.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/jansson/src/value.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/jansson/src/value.c (original)
+++ avro/trunk/lang/c/jansson/src/value.c Sat Apr 28 19:40:52 2012
@@ -72,7 +72,7 @@ static void value_decref(void *value)
json_t *json_object(void)
{
- json_object_t *object = jsonp_malloc(sizeof(json_object_t));
+ json_object_t *object = (json_object_t *) jsonp_malloc(sizeof(json_object_t));
if(!object)
return NULL;
json_init(&object->json, JSON_OBJECT);
@@ -116,7 +116,7 @@ json_t *json_object_get(const json_t *js
return NULL;
object = json_to_object(json);
- return hashtable_get(&object->hashtable, string_to_key(key));
+ return (json_t *) hashtable_get(&object->hashtable, string_to_key(key));
}
int json_object_set_new_nocheck(json_t *json, const char *key, json_t *value)
@@ -137,7 +137,7 @@ int json_object_set_new_nocheck(json_t *
/* offsetof(...) returns the size of object_key_t without the
last, flexible member. This way, the correct amount is
allocated. */
- k = jsonp_malloc(offsetof(object_key_t, key) + strlen(key) + 1);
+ k = (object_key_t *) jsonp_malloc(offsetof(object_key_t, key) + strlen(key) + 1);
if(!k)
{
json_decref(value);
@@ -253,7 +253,7 @@ const object_key_t *jsonp_object_iter_fu
if(!iter)
return NULL;
- return hashtable_iter_key(iter);
+ return (const object_key_t *) hashtable_iter_key(iter);
}
const char *json_object_iter_key(void *iter)
@@ -366,7 +366,7 @@ static json_t *json_object_deep_copy(jso
json_t *json_array(void)
{
- json_array_t *array = jsonp_malloc(sizeof(json_array_t));
+ json_array_t *array = (json_array_t *) jsonp_malloc(sizeof(json_array_t));
if(!array)
return NULL;
json_init(&array->json, JSON_ARRAY);
@@ -374,7 +374,7 @@ json_t *json_array(void)
array->entries = 0;
array->size = 8;
- array->table = jsonp_malloc(array->size * sizeof(json_t *));
+ array->table = (json_t **) jsonp_malloc(array->size * sizeof(json_t *));
if(!array->table) {
jsonp_free(array);
return NULL;
@@ -469,7 +469,7 @@ static json_t **json_array_grow(json_arr
old_table = array->table;
new_size = max(array->size + amount, array->size * 2);
- new_table = jsonp_malloc(new_size * sizeof(json_t *));
+ new_table = (json_t **) jsonp_malloc(new_size * sizeof(json_t *));
if(!new_table)
return NULL;
@@ -668,7 +668,7 @@ json_t *json_string_nocheck(const char *
if(!value)
return NULL;
- string = jsonp_malloc(sizeof(json_string_t));
+ string = (json_string_t *) jsonp_malloc(sizeof(json_string_t));
if(!string)
return NULL;
json_init(&string->json, JSON_STRING);
@@ -743,7 +743,7 @@ static json_t *json_string_copy(json_t *
json_t *json_integer(json_int_t value)
{
- json_integer_t *integer = jsonp_malloc(sizeof(json_integer_t));
+ json_integer_t *integer = (json_integer_t *) jsonp_malloc(sizeof(json_integer_t));
if(!integer)
return NULL;
json_init(&integer->json, JSON_INTEGER);
@@ -790,7 +790,7 @@ static json_t *json_integer_copy(json_t
json_t *json_real(double value)
{
- json_real_t *real = jsonp_malloc(sizeof(json_real_t));
+ json_real_t *real = (json_real_t *) jsonp_malloc(sizeof(json_real_t));
if(!real)
return NULL;
json_init(&real->json, JSON_REAL);
@@ -838,7 +838,7 @@ static json_t *json_real_copy(json_t *re
double json_number_value(const json_t *json)
{
if(json_is_integer(json))
- return json_integer_value(json);
+ return (double) json_integer_value(json);
else if(json_is_real(json))
return json_real_value(json);
else
Modified: avro/trunk/lang/c/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/CMakeLists.txt?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/CMakeLists.txt (original)
+++ avro/trunk/lang/c/src/CMakeLists.txt Sat Apr 28 19:40:52 2012
@@ -104,11 +104,15 @@ string(REPLACE ":" "." LIBAVRO_DOT_VERSI
add_library(avro-static STATIC ${AVRO_SRC} ${JANSSON_SRC})
target_link_libraries(avro-static ${CODEC_LIBRARIES})
set_target_properties(avro-static PROPERTIES OUTPUT_NAME avro)
+
+if (NOT WIN32)
+# TODO: Create Windows DLLs. See http://www.cmake.org/Wiki/BuildingWinDLL
add_library(avro-shared SHARED ${AVRO_SRC} ${JANSSON_SRC})
target_link_libraries(avro-shared ${CODEC_LIBRARIES})
set_target_properties(avro-shared PROPERTIES
OUTPUT_NAME avro
SOVERSION ${LIBAVRO_DOT_VERSION})
+endif(NOT WIN32)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/avro.h
@@ -117,11 +121,20 @@ install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/avro
DESTINATION include
FILES_MATCHING PATTERN "*.h")
+
+if (WIN32)
+install(TARGETS avro-static
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ )
+else(WIN32)
install(TARGETS avro-static avro-shared
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
-)
+ )
+endif(WIN32)
# Install pkg-config file
@@ -135,6 +148,8 @@ add_executable(avrocat avrocat.c)
target_link_libraries(avrocat avro-static)
install(TARGETS avrocat RUNTIME DESTINATION bin)
+if (NOT WIN32)
+#TODO: Port getopt() to Windows to compile avropipe.c and avromod.c
add_executable(avropipe avropipe.c)
target_link_libraries(avropipe avro-static)
install(TARGETS avropipe RUNTIME DESTINATION bin)
@@ -142,3 +157,4 @@ install(TARGETS avropipe RUNTIME DESTINA
add_executable(avromod avromod.c)
target_link_libraries(avromod avro-static)
install(TARGETS avromod RUNTIME DESTINATION bin)
+endif(NOT WIN32)
Modified: avro/trunk/lang/c/src/allocation.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/allocation.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/allocation.c (original)
+++ avro/trunk/lang/c/src/allocation.c Sat Apr 28 19:40:52 2012
@@ -21,6 +21,7 @@
#include "avro_private.h"
#include "avro/allocation.h"
#include "avro/data.h"
+#include "avro/legacy.h"
static void *
avro_default_allocator(void *ud, void *ptr, size_t osize, size_t nsize)
@@ -70,20 +71,20 @@ char *avro_strdup(const char *str)
return NULL;
}
- size_t *size = buf;
+ size_t *size = (size_t *) buf;
char *new_str = (char *) (size + 1);
*size = buf_size;
memcpy(new_str, str, str_size);
- //fprintf(stderr, "--- new %zu %p %s\n", *size, new_str, new_str);
+ //fprintf(stderr, "--- new %" PRIsz " %p %s\n", *size, new_str, new_str);
return new_str;
}
void avro_str_free(char *str)
{
size_t *size = ((size_t *) str) - 1;
- //fprintf(stderr, "--- free %zu %p %s\n", *size, str, str);
+ //fprintf(stderr, "--- free %" PRIsz " %p %s\n", *size, str, str);
avro_free(size, *size);
}
Modified: avro/trunk/lang/c/src/array.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/array.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/array.c (original)
+++ avro/trunk/lang/c/src/array.c Sat Apr 28 19:40:52 2012
@@ -76,7 +76,7 @@ avro_raw_array_ensure_size(avro_raw_arra
array->data = avro_realloc(array->data, array->allocated_size, new_size);
if (array->data == NULL) {
- avro_set_error("Cannot allocate space in array for %zu elements",
+ avro_set_error("Cannot allocate space in array for %" PRIsz " elements",
desired_count);
return ENOMEM;
}
@@ -96,7 +96,7 @@ avro_raw_array_ensure_size0(avro_raw_arr
if (array->allocated_size > old_allocated_size) {
size_t extra_space = array->allocated_size - old_allocated_size;
void *buf = array->data;
- memset(buf + old_allocated_size, 0, extra_space);
+ memset((char *)buf + old_allocated_size, 0, extra_space);
}
return 0;
@@ -114,5 +114,5 @@ void *avro_raw_array_append(avro_raw_arr
size_t offset = array->element_size * array->element_count;
array->element_count++;
- return array->data + offset;
+ return (char *)array->data + offset;
}
Modified: avro/trunk/lang/c/src/avro.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro.h (original)
+++ avro/trunk/lang/c/src/avro.h Sat Apr 28 19:40:52 2012
@@ -31,6 +31,7 @@ extern "C" {
#include <avro/generic.h>
#include <avro/io.h>
#include <avro/legacy.h>
+#include <avro/platform.h>
#include <avro/resolver.h>
#include <avro/schema.h>
#include <avro/value.h>
Modified: avro/trunk/lang/c/src/avro/allocation.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/allocation.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/allocation.h (original)
+++ avro/trunk/lang/c/src/avro/allocation.h Sat Apr 28 19:40:52 2012
@@ -17,6 +17,13 @@
#ifndef AVRO_ALLOCATION_H
#define AVRO_ALLOCATION_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
+
#include <stdlib.h>
/*
@@ -76,4 +83,5 @@ void *avro_calloc(size_t count, size_t s
char *avro_strdup(const char *str);
void avro_str_free(char *str);
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/src/avro/consumer.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/consumer.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/consumer.h (original)
+++ avro/trunk/lang/c/src/avro/consumer.h Sat Apr 28 19:40:52 2012
@@ -24,7 +24,7 @@ extern "C" {
#define CLOSE_EXTERN
#endif
-#include <stdint.h>
+#include <avro/platform.h>
#include <stdlib.h>
#include <avro/io.h>
Modified: avro/trunk/lang/c/src/avro/data.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/data.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/data.h (original)
+++ avro/trunk/lang/c/src/avro/data.h Sat Apr 28 19:40:52 2012
@@ -100,7 +100,7 @@ avro_raw_array_ensure_size0(avro_raw_arr
*/
#define avro_raw_array_get_raw(array, index) \
- ((array)->data + (array)->element_size * index)
+ ((char *) (array)->data + (array)->element_size * index)
/**
* Returns the given element of an avro_raw_array_t, using element_type
@@ -425,6 +425,14 @@ void avro_raw_string_set(avro_raw_string
void avro_raw_string_append(avro_raw_string_t *str, const char *src);
/**
+ * Appends the given C string to an avro_raw_string_t, using the
+ * provided length instead of calling strlen(src).
+ */
+
+void avro_raw_string_append_length(avro_raw_string_t *str,
+ const void *src,
+ size_t length);
+/**
* Gives control of a buffer to an avro_raw_string_t.
*/
Modified: avro/trunk/lang/c/src/avro/errors.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/errors.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/errors.h (original)
+++ avro/trunk/lang/c/src/avro/errors.h Sat Apr 28 19:40:52 2012
@@ -17,6 +17,12 @@
#ifndef AVRO_ERRORS_H
#define AVRO_ERRORS_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
/*
* Returns a textual description of the last error condition returned by
@@ -31,4 +37,5 @@ avro_set_error(const char *fmt, ...);
void
avro_prefix_error(const char *fmt, ...);
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/src/avro/generic.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/generic.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/generic.h (original)
+++ avro/trunk/lang/c/src/avro/generic.h Sat Apr 28 19:40:52 2012
@@ -24,7 +24,7 @@ extern "C" {
#define CLOSE_EXTERN
#endif
-#include <stdint.h>
+#include <avro/platform.h>
#include <stdlib.h>
#include <avro/schema.h>
Modified: avro/trunk/lang/c/src/avro/io.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/io.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/io.h (original)
+++ avro/trunk/lang/c/src/avro/io.h Sat Apr 28 19:40:52 2012
@@ -24,7 +24,7 @@ extern "C" {
#define CLOSE_EXTERN
#endif
-#include <stdint.h>
+#include <avro/platform.h>
#include <stdio.h>
#include <avro/basics.h>
Modified: avro/trunk/lang/c/src/avro/legacy.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/legacy.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/legacy.h (original)
+++ avro/trunk/lang/c/src/avro/legacy.h Sat Apr 28 19:40:52 2012
@@ -24,7 +24,7 @@ extern "C" {
#define CLOSE_EXTERN
#endif
-#include <stdint.h>
+#include <avro/platform.h>
#include <stdio.h>
#include <avro/basics.h>
Added: avro/trunk/lang/c/src/avro/msinttypes.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/msinttypes.h?rev=1331812&view=auto
==============================================================================
--- avro/trunk/lang/c/src/avro/msinttypes.h (added)
+++ avro/trunk/lang/c/src/avro/msinttypes.h Sat Apr 28 19:40:52 2012
@@ -0,0 +1,315 @@
+// ISO C9x compliant inttypes.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_INTTYPES_H_ // [
+#define _MSC_INTTYPES_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+//////////////////////////////////////
+// Start AVRO specific modifications
+//////////////////////////////////////
+#include "msstdint.h"
+
+// Modification for AVRO of inttypes.h
+#define __STDC_FORMAT_MACROS (1)
+
+//////////////////////////////////////
+// End AVRO specific modifications
+//////////////////////////////////////
+
+// 7.8 Format conversion of integer types
+
+typedef struct {
+ intmax_t quot;
+ intmax_t rem;
+} imaxdiv_t;
+
+// 7.8.1 Macros for format specifiers
+
+#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
+
+// The fprintf macros for signed integers are:
+#define PRId8 "d"
+#define PRIi8 "i"
+#define PRIdLEAST8 "d"
+#define PRIiLEAST8 "i"
+#define PRIdFAST8 "d"
+#define PRIiFAST8 "i"
+
+#define PRId16 "hd"
+#define PRIi16 "hi"
+#define PRIdLEAST16 "hd"
+#define PRIiLEAST16 "hi"
+#define PRIdFAST16 "hd"
+#define PRIiFAST16 "hi"
+
+#define PRId32 "I32d"
+#define PRIi32 "I32i"
+#define PRIdLEAST32 "I32d"
+#define PRIiLEAST32 "I32i"
+#define PRIdFAST32 "I32d"
+#define PRIiFAST32 "I32i"
+
+#define PRId64 "I64d"
+#define PRIi64 "I64i"
+#define PRIdLEAST64 "I64d"
+#define PRIiLEAST64 "I64i"
+#define PRIdFAST64 "I64d"
+#define PRIiFAST64 "I64i"
+
+#define PRIdMAX "I64d"
+#define PRIiMAX "I64i"
+
+#define PRIdPTR "Id"
+#define PRIiPTR "Ii"
+
+// The fprintf macros for unsigned integers are:
+#define PRIo8 "o"
+#define PRIu8 "u"
+#define PRIx8 "x"
+#define PRIX8 "X"
+#define PRIoLEAST8 "o"
+#define PRIuLEAST8 "u"
+#define PRIxLEAST8 "x"
+#define PRIXLEAST8 "X"
+#define PRIoFAST8 "o"
+#define PRIuFAST8 "u"
+#define PRIxFAST8 "x"
+#define PRIXFAST8 "X"
+
+#define PRIo16 "ho"
+#define PRIu16 "hu"
+#define PRIx16 "hx"
+#define PRIX16 "hX"
+#define PRIoLEAST16 "ho"
+#define PRIuLEAST16 "hu"
+#define PRIxLEAST16 "hx"
+#define PRIXLEAST16 "hX"
+#define PRIoFAST16 "ho"
+#define PRIuFAST16 "hu"
+#define PRIxFAST16 "hx"
+#define PRIXFAST16 "hX"
+
+#define PRIo32 "I32o"
+#define PRIu32 "I32u"
+#define PRIx32 "I32x"
+#define PRIX32 "I32X"
+#define PRIoLEAST32 "I32o"
+#define PRIuLEAST32 "I32u"
+#define PRIxLEAST32 "I32x"
+#define PRIXLEAST32 "I32X"
+#define PRIoFAST32 "I32o"
+#define PRIuFAST32 "I32u"
+#define PRIxFAST32 "I32x"
+#define PRIXFAST32 "I32X"
+
+#define PRIo64 "I64o"
+#define PRIu64 "I64u"
+#define PRIx64 "I64x"
+#define PRIX64 "I64X"
+#define PRIoLEAST64 "I64o"
+#define PRIuLEAST64 "I64u"
+#define PRIxLEAST64 "I64x"
+#define PRIXLEAST64 "I64X"
+#define PRIoFAST64 "I64o"
+#define PRIuFAST64 "I64u"
+#define PRIxFAST64 "I64x"
+#define PRIXFAST64 "I64X"
+
+#define PRIoMAX "I64o"
+#define PRIuMAX "I64u"
+#define PRIxMAX "I64x"
+#define PRIXMAX "I64X"
+
+#define PRIoPTR "Io"
+#define PRIuPTR "Iu"
+#define PRIxPTR "Ix"
+#define PRIXPTR "IX"
+
+// The fscanf macros for signed integers are:
+#define SCNd8 "d"
+#define SCNi8 "i"
+#define SCNdLEAST8 "d"
+#define SCNiLEAST8 "i"
+#define SCNdFAST8 "d"
+#define SCNiFAST8 "i"
+
+#define SCNd16 "hd"
+#define SCNi16 "hi"
+#define SCNdLEAST16 "hd"
+#define SCNiLEAST16 "hi"
+#define SCNdFAST16 "hd"
+#define SCNiFAST16 "hi"
+
+#define SCNd32 "ld"
+#define SCNi32 "li"
+#define SCNdLEAST32 "ld"
+#define SCNiLEAST32 "li"
+#define SCNdFAST32 "ld"
+#define SCNiFAST32 "li"
+
+#define SCNd64 "I64d"
+#define SCNi64 "I64i"
+#define SCNdLEAST64 "I64d"
+#define SCNiLEAST64 "I64i"
+#define SCNdFAST64 "I64d"
+#define SCNiFAST64 "I64i"
+
+#define SCNdMAX "I64d"
+#define SCNiMAX "I64i"
+
+#ifdef _WIN64 // [
+# define SCNdPTR "I64d"
+# define SCNiPTR "I64i"
+#else // _WIN64 ][
+# define SCNdPTR "ld"
+# define SCNiPTR "li"
+#endif // _WIN64 ]
+
+// The fscanf macros for unsigned integers are:
+#define SCNo8 "o"
+#define SCNu8 "u"
+#define SCNx8 "x"
+#define SCNX8 "X"
+#define SCNoLEAST8 "o"
+#define SCNuLEAST8 "u"
+#define SCNxLEAST8 "x"
+#define SCNXLEAST8 "X"
+#define SCNoFAST8 "o"
+#define SCNuFAST8 "u"
+#define SCNxFAST8 "x"
+#define SCNXFAST8 "X"
+
+#define SCNo16 "ho"
+#define SCNu16 "hu"
+#define SCNx16 "hx"
+#define SCNX16 "hX"
+#define SCNoLEAST16 "ho"
+#define SCNuLEAST16 "hu"
+#define SCNxLEAST16 "hx"
+#define SCNXLEAST16 "hX"
+#define SCNoFAST16 "ho"
+#define SCNuFAST16 "hu"
+#define SCNxFAST16 "hx"
+#define SCNXFAST16 "hX"
+
+#define SCNo32 "lo"
+#define SCNu32 "lu"
+#define SCNx32 "lx"
+#define SCNX32 "lX"
+#define SCNoLEAST32 "lo"
+#define SCNuLEAST32 "lu"
+#define SCNxLEAST32 "lx"
+#define SCNXLEAST32 "lX"
+#define SCNoFAST32 "lo"
+#define SCNuFAST32 "lu"
+#define SCNxFAST32 "lx"
+#define SCNXFAST32 "lX"
+
+#define SCNo64 "I64o"
+#define SCNu64 "I64u"
+#define SCNx64 "I64x"
+#define SCNX64 "I64X"
+#define SCNoLEAST64 "I64o"
+#define SCNuLEAST64 "I64u"
+#define SCNxLEAST64 "I64x"
+#define SCNXLEAST64 "I64X"
+#define SCNoFAST64 "I64o"
+#define SCNuFAST64 "I64u"
+#define SCNxFAST64 "I64x"
+#define SCNXFAST64 "I64X"
+
+#define SCNoMAX "I64o"
+#define SCNuMAX "I64u"
+#define SCNxMAX "I64x"
+#define SCNXMAX "I64X"
+
+#ifdef _WIN64 // [
+# define SCNoPTR "I64o"
+# define SCNuPTR "I64u"
+# define SCNxPTR "I64x"
+# define SCNXPTR "I64X"
+#else // _WIN64 ][
+# define SCNoPTR "lo"
+# define SCNuPTR "lu"
+# define SCNxPTR "lx"
+# define SCNXPTR "lX"
+#endif // _WIN64 ]
+
+#endif // __STDC_FORMAT_MACROS ]
+
+// 7.8.2 Functions for greatest-width integer types
+
+// 7.8.2.1 The imaxabs function
+#define imaxabs _abs64
+
+// 7.8.2.2 The imaxdiv function
+
+// This is modified version of div() function from Microsoft's div.c found
+// in %MSVC.NET%\crt\src\div.c
+#ifdef STATIC_IMAXDIV // [
+static
+#else // STATIC_IMAXDIV ][
+_inline
+#endif // STATIC_IMAXDIV ]
+imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
+{
+ imaxdiv_t result;
+
+ result.quot = numer / denom;
+ result.rem = numer % denom;
+
+ if (numer < 0 && result.rem > 0) {
+ // did division wrong; must fix up
+ ++result.quot;
+ result.rem -= denom;
+ }
+
+ return result;
+}
+
+// 7.8.2.3 The strtoimax and strtoumax functions
+#define strtoimax _strtoi64
+#define strtoumax _strtoui64
+
+// 7.8.2.4 The wcstoimax and wcstoumax functions
+#define wcstoimax _wcstoi64
+#define wcstoumax _wcstoui64
+
+
+#endif // _MSC_INTTYPES_H_ ]
Added: avro/trunk/lang/c/src/avro/msstdint.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/msstdint.h?rev=1331812&view=auto
==============================================================================
--- avro/trunk/lang/c/src/avro/msstdint.h (added)
+++ avro/trunk/lang/c/src/avro/msstdint.h Sat Apr 28 19:40:52 2012
@@ -0,0 +1,247 @@
+// ISO C9x compliant stdint.h for Microsoft Visual Studio
+// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
+//
+// Copyright (c) 2006-2008 Alexander Chemeris
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// 3. The name of the author may be used to endorse or promote products
+// derived from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _MSC_VER // [
+#error "Use this header only with Microsoft Visual C++ compilers!"
+#endif // _MSC_VER ]
+
+#ifndef _MSC_STDINT_H_ // [
+#define _MSC_STDINT_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif
+
+#include <limits.h>
+
+// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
+// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
+// or compiler give many errors like this:
+// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
+#ifdef __cplusplus
+extern "C" {
+#endif
+# include <wchar.h>
+#ifdef __cplusplus
+}
+#endif
+
+// Define _W64 macros to mark types changing their size, like intptr_t.
+#ifndef _W64
+# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
+# define _W64 __w64
+# else
+# define _W64
+# endif
+#endif
+
+
+// 7.18.1 Integer types
+
+// 7.18.1.1 Exact-width integer types
+
+// Visual Studio 6 and Embedded Visual C++ 4 doesn't
+// realize that, e.g. char has the same size as __int8
+// so we give up on __intX for them.
+#if (_MSC_VER < 1300)
+ typedef signed char int8_t;
+ typedef signed short int16_t;
+ typedef signed int int32_t;
+ typedef unsigned char uint8_t;
+ typedef unsigned short uint16_t;
+ typedef unsigned int uint32_t;
+#else
+ typedef signed __int8 int8_t;
+ typedef signed __int16 int16_t;
+ typedef signed __int32 int32_t;
+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+#endif
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+
+// 7.18.1.2 Minimum-width integer types
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+// 7.18.1.3 Fastest minimum-width integer types
+typedef int8_t int_fast8_t;
+typedef int16_t int_fast16_t;
+typedef int32_t int_fast32_t;
+typedef int64_t int_fast64_t;
+typedef uint8_t uint_fast8_t;
+typedef uint16_t uint_fast16_t;
+typedef uint32_t uint_fast32_t;
+typedef uint64_t uint_fast64_t;
+
+// 7.18.1.4 Integer types capable of holding object pointers
+#ifdef _WIN64 // [
+ typedef signed __int64 intptr_t;
+ typedef unsigned __int64 uintptr_t;
+#else // _WIN64 ][
+ typedef _W64 signed int intptr_t;
+ typedef _W64 unsigned int uintptr_t;
+#endif // _WIN64 ]
+
+// 7.18.1.5 Greatest-width integer types
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+
+
+// 7.18.2 Limits of specified-width integer types
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
+
+// 7.18.2.1 Limits of exact-width integer types
+#define INT8_MIN ((int8_t)_I8_MIN)
+#define INT8_MAX _I8_MAX
+#define INT16_MIN ((int16_t)_I16_MIN)
+#define INT16_MAX _I16_MAX
+#define INT32_MIN ((int32_t)_I32_MIN)
+#define INT32_MAX _I32_MAX
+#define INT64_MIN ((int64_t)_I64_MIN)
+#define INT64_MAX _I64_MAX
+#define UINT8_MAX _UI8_MAX
+#define UINT16_MAX _UI16_MAX
+#define UINT32_MAX _UI32_MAX
+#define UINT64_MAX _UI64_MAX
+
+// 7.18.2.2 Limits of minimum-width integer types
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MIN INT64_MIN
+#define INT_LEAST64_MAX INT64_MAX
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+// 7.18.2.3 Limits of fastest minimum-width integer types
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST16_MIN INT16_MIN
+#define INT_FAST16_MAX INT16_MAX
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST32_MAX INT32_MAX
+#define INT_FAST64_MIN INT64_MIN
+#define INT_FAST64_MAX INT64_MAX
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST16_MAX UINT16_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+// 7.18.2.4 Limits of integer types capable of holding object pointers
+#ifdef _WIN64 // [
+# define INTPTR_MIN INT64_MIN
+# define INTPTR_MAX INT64_MAX
+# define UINTPTR_MAX UINT64_MAX
+#else // _WIN64 ][
+# define INTPTR_MIN INT32_MIN
+# define INTPTR_MAX INT32_MAX
+# define UINTPTR_MAX UINT32_MAX
+#endif // _WIN64 ]
+
+// 7.18.2.5 Limits of greatest-width integer types
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+// 7.18.3 Limits of other integer types
+
+#ifdef _WIN64 // [
+# define PTRDIFF_MIN _I64_MIN
+# define PTRDIFF_MAX _I64_MAX
+#else // _WIN64 ][
+# define PTRDIFF_MIN _I32_MIN
+# define PTRDIFF_MAX _I32_MAX
+#endif // _WIN64 ]
+
+#define SIG_ATOMIC_MIN INT_MIN
+#define SIG_ATOMIC_MAX INT_MAX
+
+#ifndef SIZE_MAX // [
+# ifdef _WIN64 // [
+# define SIZE_MAX _UI64_MAX
+# else // _WIN64 ][
+# define SIZE_MAX _UI32_MAX
+# endif // _WIN64 ]
+#endif // SIZE_MAX ]
+
+// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
+#ifndef WCHAR_MIN // [
+# define WCHAR_MIN 0
+#endif // WCHAR_MIN ]
+#ifndef WCHAR_MAX // [
+# define WCHAR_MAX _UI16_MAX
+#endif // WCHAR_MAX ]
+
+#define WINT_MIN 0
+#define WINT_MAX _UI16_MAX
+
+#endif // __STDC_LIMIT_MACROS ]
+
+
+// 7.18.4 Limits of other integer types
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
+
+// 7.18.4.1 Macros for minimum-width integer constants
+
+#define INT8_C(val) val##i8
+#define INT16_C(val) val##i16
+#define INT32_C(val) val##i32
+#define INT64_C(val) val##i64
+
+#define UINT8_C(val) val##ui8
+#define UINT16_C(val) val##ui16
+#define UINT32_C(val) val##ui32
+#define UINT64_C(val) val##ui64
+
+// 7.18.4.2 Macros for greatest-width integer constants
+#define INTMAX_C INT64_C
+#define UINTMAX_C UINT64_C
+
+#endif // __STDC_CONSTANT_MACROS ]
+
+
+#endif // _MSC_STDINT_H_ ]
Added: avro/trunk/lang/c/src/avro/platform.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/platform.h?rev=1331812&view=auto
==============================================================================
--- avro/trunk/lang/c/src/avro/platform.h (added)
+++ avro/trunk/lang/c/src/avro/platform.h Sat Apr 28 19:40:52 2012
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+#ifndef AVRO_PLATFORM_H
+#define AVRO_PLATFORM_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
+
+/* Use this header file to include platform specific definitions */
+
+#ifdef _WIN32
+ #include <avro/msinttypes.h>
+#else
+ #include <inttypes.h>
+#endif
+
+// Defines for printing size_t.
+#if defined(_WIN64)
+ #define PRIsz PRIu64
+#elif defined(_WIN32)
+ #define PRIsz PRIu32
+#else // GCC
+ #define PRIsz "zu"
+#endif
+
+CLOSE_EXTERN
+#endif
Modified: avro/trunk/lang/c/src/avro/refcount.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/refcount.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/refcount.h (original)
+++ avro/trunk/lang/c/src/avro/refcount.h Sat Apr 28 19:40:52 2012
@@ -17,6 +17,12 @@
#ifndef AVRO_REFCOUNT_H
#define AVRO_REFCOUNT_H
+
+#if defined(_WIN32) && defined(__cplusplus)
+/* Include the C++ file <intrin.h> outside the scope of extern "C" */
+#include <intrin.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
#define CLOSE_EXTERN }
@@ -49,10 +55,38 @@ avro_refcount_dec(volatile int *refcount
/*-----------------------------------------------------------------------
+ * Non-Atomic Reference Count
+ */
+#if defined(AVRO_NON_ATOMIC_REFCOUNT)
+static inline void
+avro_refcount_set(volatile int *refcount, int value)
+{
+ *refcount = value;
+}
+
+static inline void
+avro_refcount_inc(volatile int *refcount)
+{
+ if (*refcount != (int) -1) {
+ *refcount += 1;
+ }
+}
+
+static inline int
+avro_refcount_dec(volatile int *refcount)
+{
+ if (*refcount != (int) -1) {
+ *refcount -= 1;
+ return (*refcount == 0);
+ }
+ return 0;
+}
+
+/*-----------------------------------------------------------------------
* Mac OS X
*/
-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
+#elif __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
#include <libkern/OSAtomic.h>
@@ -119,7 +153,7 @@ avro_refcount_dec(volatile int *refcount
/* determine the size of int */
#include <limits.h>
-#include <stdint.h>
+#include <avro/platform.h>
#if INT_MAX == INT32_MAX
#define REFCOUNT_SS "l"
#elif INT_MAX == INT64_MAX
@@ -228,11 +262,14 @@ avro_refcount_dec(volatile int *refcount
/*-----------------------------------------------------------------------
* Windows intrinsics
*/
+#elif defined(_WIN32)
-#elif defined(__WIN32__)
-
+#ifdef __cplusplus
+// Note: <intrin.h> included outside the extern "C" wrappers above
+#else
#include <windows.h>
#include <intrin.h>
+#endif // __cplusplus
static inline void
avro_refcount_set(volatile int *refcount, int value)
@@ -244,7 +281,7 @@ static inline void
avro_refcount_inc(volatile int *refcount)
{
if (*refcount != (int) -1) {
- _InterlockedIncrement(refcount);
+ _InterlockedIncrement((volatile long *) refcount);
}
}
@@ -252,16 +289,14 @@ static inline int
avro_refcount_dec(volatile int *refcount)
{
if (*refcount != (int) -1) {
- return (_InterlockedDecrement(refcount) == 0);
+ return (_InterlockedDecrement((volatile long *) refcount) == 0);
}
return 0;
}
-
/*-----------------------------------------------------------------------
* Fallback
*/
-
#else
#error "No atomic implementation!"
#endif
Modified: avro/trunk/lang/c/src/avro/schema.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/schema.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/schema.h (original)
+++ avro/trunk/lang/c/src/avro/schema.h Sat Apr 28 19:40:52 2012
@@ -24,7 +24,7 @@ extern "C" {
#define CLOSE_EXTERN
#endif
-#include <stdint.h>
+#include <avro/platform.h>
#include <stdlib.h>
#include <avro/basics.h>
Modified: avro/trunk/lang/c/src/avro/value.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro/value.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro/value.h (original)
+++ avro/trunk/lang/c/src/avro/value.h Sat Apr 28 19:40:52 2012
@@ -25,7 +25,7 @@ extern "C" {
#endif
#include <errno.h>
-#include <stdint.h>
+#include <avro/platform.h>
#include <stdlib.h>
#include <avro/data.h>
Modified: avro/trunk/lang/c/src/avro_private.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avro_private.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avro_private.h (original)
+++ avro/trunk/lang/c/src/avro_private.h Sat Apr 28 19:40:52 2012
@@ -16,16 +16,48 @@
*/
#ifndef AVRO_PRIVATE_H
#define AVRO_PRIVATE_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
#include <errno.h>
#include "avro/errors.h"
+#include "avro/platform.h"
#ifdef HAVE_CONFIG_H
/* This is only true for now in the autotools build */
#include "config.h"
#endif
+#ifdef _WIN32
+#define snprintf _snprintf
+#endif
+
+/* Note that AVRO_PLATFORM_IS_BIG_ENDIAN is *always* defined. It is
+ * either TRUE (1) or FALSE (0).
+ */
+#ifdef _WIN32
+ #define AVRO_PLATFORM_IS_BIG_ENDIAN (0)
+#else // UNIX
+ #include <sys/param.h>
+ #if BYTE_ORDER == BIG_ENDIAN
+ #define AVRO_PLATFORM_IS_BIG_ENDIAN (1)
+ #else
+ #define AVRO_PLATFORM_IS_BIG_ENDIAN (0)
+ #endif
+#endif
+
+/* Add definition of EILSEQ if it is not defined in errno.h. */
+#include <errno.h>
+#ifndef EILSEQ
+#define EILSEQ 138
+#endif
+
+
#define check(rval, call) { rval = call; if(rval) return rval; }
#define check_set(rval, call, ...) \
@@ -50,7 +82,7 @@
{ \
if (!(test)) { \
avro_set_error("Invalid " name " in %s", \
- __func__); \
+ __FUNCTION__); \
return result; \
} \
}
@@ -60,4 +92,5 @@
#define container_of(ptr_, type_, member_) \
((type_ *)((char *)ptr_ - (size_t)&((type_ *)0)->member_))
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/src/avropipe.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/avropipe.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/avropipe.c (original)
+++ avro/trunk/lang/c/src/avropipe.c Sat Apr 28 19:40:52 2012
@@ -18,8 +18,8 @@
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
-#include <inttypes.h>
-#include <stdint.h>
+#include <avro/platform.h>
+#include <avro/platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -43,7 +43,7 @@ static void
create_array_prefix(avro_raw_string_t *dest, const char *prefix, size_t index)
{
static char buf[100];
- snprintf(buf, sizeof(buf), "%zu", index);
+ snprintf(buf, sizeof(buf), "%" PRIsz, index);
avro_raw_string_set(dest, prefix);
avro_raw_string_append(dest, separator);
avro_raw_string_append(dest, buf);
@@ -120,7 +120,7 @@ process_array(const char *prefix, avro_v
avro_value_get_by_index(value, i, &element_value, NULL);
create_array_prefix(&element_prefix, prefix, i);
- process_value(avro_raw_string_get(&element_prefix), &element_value);
+ process_value((const char *) avro_raw_string_get(&element_prefix), &element_value);
}
avro_raw_string_done(&element_prefix);
@@ -157,7 +157,7 @@ process_map(const char *prefix, avro_val
avro_value_get_by_index(value, i, &element_value, &key);
create_object_prefix(&element_prefix, prefix, key);
- process_value(avro_raw_string_get(&element_prefix), &element_value);
+ process_value((const char *) avro_raw_string_get(&element_prefix), &element_value);
}
avro_raw_string_done(&element_prefix);
@@ -180,7 +180,7 @@ process_record(const char *prefix, avro_
avro_value_get_by_index(value, i, &field_value, &field_name);
create_object_prefix(&field_prefix, prefix, field_name);
- process_value(avro_raw_string_get(&field_prefix), &field_value);
+ process_value((const char *) avro_raw_string_get(&field_prefix), &field_value);
}
avro_raw_string_done(&field_prefix);
@@ -210,7 +210,7 @@ process_union(const char *prefix, avro_v
create_object_prefix(&branch_prefix, prefix, branch_name);
printf("%s\t{}\n", prefix);
- process_value(avro_raw_string_get(&branch_prefix), &branch_value);
+ process_value((const char *) avro_raw_string_get(&branch_prefix), &branch_value);
avro_raw_string_done(&branch_prefix);
}
@@ -234,7 +234,7 @@ process_value(const char *prefix, avro_v
size_t size;
avro_value_get_bytes(value, &buf, &size);
printf("%s\t", prefix);
- print_bytes_value(buf, size);
+ print_bytes_value((const char *) buf, size);
printf("\n");
return;
}
@@ -306,7 +306,7 @@ process_value(const char *prefix, avro_v
size_t size;
avro_value_get_fixed(value, &buf, &size);
printf("%s\t", prefix);
- print_bytes_value(buf, size);
+ print_bytes_value((const char *) buf, size);
printf("\n");
return;
}
@@ -365,7 +365,7 @@ process_file(const char *filename)
for (; avro_file_reader_read_value(reader, &value) == 0; record_number++) {
create_array_prefix(&prefix, "", record_number);
- process_value(avro_raw_string_get(&prefix), &value);
+ process_value((const char *) avro_raw_string_get(&prefix), &value);
avro_value_reset(&value);
}
@@ -377,7 +377,6 @@ process_file(const char *filename)
/*-- MAIN PROGRAM --*/
-
static struct option longopts[] = {
{ "separator", required_argument, NULL, 's' },
{ NULL, 0, NULL, 0 }
@@ -396,7 +395,7 @@ int main(int argc, char **argv)
char *data_filename;
int ch;
- while ((ch = getopt_long(argc, argv, "s:", longopts, NULL)) != -1) {
+ while ((ch = getopt_long(argc, argv, "s:", longopts, NULL) ) != -1) {
switch (ch) {
case 's':
separator = optarg;
Modified: avro/trunk/lang/c/src/codec.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/codec.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/codec.h (original)
+++ avro/trunk/lang/c/src/codec.h Sat Apr 28 19:40:52 2012
@@ -17,6 +17,14 @@
#ifndef AVRO_CODEC_H
#define AVRO_CODEC_H
+#ifdef __cplusplus
+extern "C" {
+#define CLOSE_EXTERN }
+#else
+#define CLOSE_EXTERN
+#endif
+
+#include <avro/platform.h>
enum avro_codec_type_t {
AVRO_CODEC_NULL,
@@ -40,4 +48,5 @@ int avro_codec_reset(avro_codec_t c);
int avro_codec_encode(avro_codec_t c, void * data, int64_t len);
int avro_codec_decode(avro_codec_t c, void * data, int64_t len);
+CLOSE_EXTERN
#endif
Modified: avro/trunk/lang/c/src/consume-binary.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/consume-binary.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/consume-binary.c (original)
+++ avro/trunk/lang/c/src/consume-binary.c Sat Apr 28 19:40:52 2012
@@ -279,7 +279,7 @@ avro_consume_binary(avro_reader_t reader
int64_t size =
avro_schema_to_fixed(consumer->schema)->size;
- bytes = avro_malloc(size);
+ bytes = (char *) avro_malloc(size);
if (!bytes) {
avro_prefix_error("Cannot allocate new fixed value");
return ENOMEM;
Modified: avro/trunk/lang/c/src/datafile.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datafile.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datafile.c (original)
+++ avro/trunk/lang/c/src/datafile.c Sat Apr 28 19:40:52 2012
@@ -55,7 +55,9 @@ struct avro_file_writer_t_ {
#define DEFAULT_BLOCK_SIZE 16 * 1024
-/* TODO: should we just read /dev/random? */
+/* Note: We should not just read /dev/random here, because it may not
+ * exist on all platforms e.g. Win32.
+ */
static void generate_sync(avro_file_writer_t w)
{
unsigned int i;
@@ -120,18 +122,29 @@ file_writer_init_fp(const char *path, co
return 0;
}
+/* Exclusive file writing is supported by GCC using the mode
+ * "wx". Win32 does not support exclusive file writing, so for win32
+ * fall back to the non-exclusive file writing.
+ */
+#ifdef _WIN32
+ #define EXCLUSIVE_WRITE_MODE "wb"
+#else
+ #define EXCLUSIVE_WRITE_MODE "wbx"
+#endif
+
static int
file_writer_create(const char *path, avro_schema_t schema, avro_file_writer_t w, size_t block_size)
{
int rval;
+
w->block_count = 0;
- rval = file_writer_init_fp(path, "wx", w);
+ rval = file_writer_init_fp(path, EXCLUSIVE_WRITE_MODE, w);
if (rval) {
- check(rval, file_writer_init_fp(path, "w", w));
+ check(rval, file_writer_init_fp(path, "wb", w));
}
w->datum_buffer_size = block_size;
- w->datum_buffer = avro_malloc(w->datum_buffer_size);
+ w->datum_buffer = (char *) avro_malloc(w->datum_buffer_size);
if(!w->datum_buffer) {
avro_set_error("Could not allocate datum buffer\n");
@@ -174,12 +187,12 @@ int avro_file_writer_create_with_codec(c
block_size = DEFAULT_BLOCK_SIZE;
}
- w = avro_new(struct avro_file_writer_t_);
+ w = (avro_file_writer_t) avro_new(struct avro_file_writer_t_);
if (!w) {
avro_set_error("Cannot allocate new file writer");
return ENOMEM;
}
- w->codec = avro_new(struct avro_codec_t_);
+ w->codec = (avro_codec_t) avro_new(struct avro_codec_t_);
if (!w->codec) {
avro_set_error("Cannot allocate new codec");
return ENOMEM;
@@ -255,7 +268,7 @@ static int file_read_header(avro_reader_
avro_value_get_bytes(&codec_val, &buf, &size);
memset(codec_name, 0, sizeof(codec_name));
- strncpy(codec_name, buf, size < 10 ? size : 10);
+ strncpy(codec_name, (const char *) buf, size < 10 ? size : 10);
if (avro_codec(codec, codec_name) != 0) {
avro_set_error("File header contains an unknown codec");
@@ -272,7 +285,7 @@ static int file_read_header(avro_reader_
}
avro_value_get_bytes(&schema_bytes, &p, &len);
- rval = avro_schema_from_json_length(p, len, writers_schema);
+ rval = avro_schema_from_json_length((const char *) p, len, writers_schema);
if (rval) {
avro_prefix_error("Cannot parse file header: ");
avro_value_decref(&meta);
@@ -290,7 +303,7 @@ static int file_writer_open(const char *
FILE *fp;
avro_reader_t reader;
- fp = fopen(path, "r");
+ fp = fopen(path, "rb");
if (!fp) {
avro_set_error("Error opening file: %s",
strerror(errno));
@@ -307,7 +320,7 @@ static int file_writer_open(const char *
sizeof(w->sync));
avro_reader_free(reader);
/* Position to end of file and get ready to write */
- rval = file_writer_init_fp(path, "a", w);
+ rval = file_writer_init_fp(path, "ab", w);
if (rval) {
avro_freet(struct avro_file_writer_t_, w);
}
@@ -321,7 +334,7 @@ int avro_file_writer_open(const char *pa
check_param(EINVAL, path, "path");
check_param(EINVAL, writer, "writer");
- w = avro_new(struct avro_file_writer_t_);
+ w = (avro_file_writer_t) avro_new(struct avro_file_writer_t_);
if (!w) {
avro_set_error("Cannot create new file writer for %s", path);
return ENOMEM;
@@ -347,10 +360,10 @@ static int file_read_block_count(avro_fi
"Cannot read file block size: ");
if (r->current_blockdata && len > r->current_blocklen) {
- r->current_blockdata = avro_realloc(r->current_blockdata, r->current_blocklen, len);
+ r->current_blockdata = (char *) avro_realloc(r->current_blockdata, r->current_blocklen, len);
r->current_blocklen = len;
} else if (!r->current_blockdata) {
- r->current_blockdata = avro_malloc(len);
+ r->current_blockdata = (char *) avro_malloc(len);
r->current_blocklen = len;
}
@@ -359,7 +372,7 @@ static int file_read_block_count(avro_fi
avro_codec_decode(r->codec, r->current_blockdata, len);
- avro_reader_memory_set_source(r->block_reader, r->codec->block_data, r->codec->used_size);
+ avro_reader_memory_set_source(r->block_reader, (const char *) r->codec->block_data, r->codec->used_size);
r->blocks_read = 0;
return 0;
@@ -369,7 +382,7 @@ int avro_file_reader_fp(FILE *fp, const
avro_file_reader_t * reader)
{
int rval;
- avro_file_reader_t r = avro_new(struct avro_file_reader_t_);
+ avro_file_reader_t r = (avro_file_reader_t) avro_new(struct avro_file_reader_t_);
if (!r) {
if (should_close) {
fclose(fp);
@@ -394,7 +407,7 @@ int avro_file_reader_fp(FILE *fp, const
return ENOMEM;
}
- r->codec = avro_new(struct avro_codec_t_);
+ r->codec = (avro_codec_t) avro_new(struct avro_codec_t_);
if (!r->codec) {
avro_set_error("Could not allocate codec for file %s", path);
avro_freet(struct avro_file_reader_t_, r);
@@ -427,7 +440,7 @@ int avro_file_reader(const char *path, a
{
FILE *fp;
- fp = fopen(path, "r");
+ fp = fopen(path, "rb");
if (!fp) {
return errno;
}
Modified: avro/trunk/lang/c/src/datum.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.c (original)
+++ avro/trunk/lang/c/src/datum.c Sat Apr 28 19:40:52 2012
@@ -43,14 +43,14 @@ avro_str_free_wrapper(void *ptr, size_t
{
// don't need sz, since the size is stored in the string buffer
AVRO_UNUSED(sz);
- avro_str_free(ptr);
+ avro_str_free((char *)ptr);
}
static avro_datum_t avro_string_private(char *str, int64_t size,
avro_free_func_t string_free)
{
struct avro_string_datum_t *datum =
- avro_new(struct avro_string_datum_t);
+ (struct avro_string_datum_t *) avro_new(struct avro_string_datum_t);
if (!datum) {
avro_set_error("Cannot create new string datum");
return NULL;
@@ -135,7 +135,7 @@ static avro_datum_t avro_bytes_private(c
avro_free_func_t bytes_free)
{
struct avro_bytes_datum_t *datum;
- datum = avro_new(struct avro_bytes_datum_t);
+ datum = (struct avro_bytes_datum_t *) avro_new(struct avro_bytes_datum_t);
if (!datum) {
avro_set_error("Cannot create new bytes datum");
return NULL;
@@ -150,7 +150,7 @@ static avro_datum_t avro_bytes_private(c
avro_datum_t avro_bytes(const char *bytes, int64_t size)
{
- char *bytes_copy = avro_malloc(size);
+ char *bytes_copy = (char *) avro_malloc(size);
if (!bytes_copy) {
avro_set_error("Cannot copy bytes content");
return NULL;
@@ -191,7 +191,7 @@ static int avro_bytes_set_private(avro_d
int avro_bytes_set(avro_datum_t datum, const char *bytes, const int64_t size)
{
int rval;
- char *bytes_copy = avro_malloc(size);
+ char *bytes_copy = (char *) avro_malloc(size);
if (!bytes_copy) {
avro_set_error("Cannot copy bytes content");
return ENOMEM;
@@ -225,7 +225,7 @@ int avro_bytes_get(avro_datum_t datum, c
avro_datum_t avro_int32(int32_t i)
{
struct avro_int32_datum_t *datum =
- avro_new(struct avro_int32_datum_t);
+ (struct avro_int32_datum_t *) avro_new(struct avro_int32_datum_t);
if (!datum) {
avro_set_error("Cannot create new int datum");
return NULL;
@@ -258,7 +258,7 @@ int avro_int32_set(avro_datum_t datum, c
avro_datum_t avro_int64(int64_t l)
{
struct avro_int64_datum_t *datum =
- avro_new(struct avro_int64_datum_t);
+ (struct avro_int64_datum_t *) avro_new(struct avro_int64_datum_t);
if (!datum) {
avro_set_error("Cannot create new long datum");
return NULL;
@@ -291,7 +291,7 @@ int avro_int64_set(avro_datum_t datum, c
avro_datum_t avro_float(float f)
{
struct avro_float_datum_t *datum =
- avro_new(struct avro_float_datum_t);
+ (struct avro_float_datum_t *) avro_new(struct avro_float_datum_t);
if (!datum) {
avro_set_error("Cannot create new float datum");
return NULL;
@@ -324,7 +324,7 @@ int avro_float_get(avro_datum_t datum, f
avro_datum_t avro_double(double d)
{
struct avro_double_datum_t *datum =
- avro_new(struct avro_double_datum_t);
+ (struct avro_double_datum_t *) avro_new(struct avro_double_datum_t);
if (!datum) {
avro_set_error("Cannot create new double atom");
return NULL;
@@ -357,7 +357,7 @@ int avro_double_get(avro_datum_t datum,
avro_datum_t avro_boolean(int8_t i)
{
struct avro_boolean_datum_t *datum =
- avro_new(struct avro_boolean_datum_t);
+ (struct avro_boolean_datum_t *) avro_new(struct avro_boolean_datum_t);
if (!datum) {
avro_set_error("Cannot create new boolean datum");
return NULL;
@@ -402,7 +402,7 @@ avro_datum_t avro_union(avro_schema_t sc
check_param(NULL, is_avro_schema(schema), "schema");
struct avro_union_datum_t *datum =
- avro_new(struct avro_union_datum_t);
+ (struct avro_union_datum_t *) avro_new(struct avro_union_datum_t);
if (!datum) {
avro_set_error("Cannot create new union datum");
return NULL;
@@ -472,7 +472,7 @@ avro_datum_t avro_record(avro_schema_t s
check_param(NULL, is_avro_schema(schema), "schema");
struct avro_record_datum_t *datum =
- avro_new(struct avro_record_datum_t);
+ (struct avro_record_datum_t *) avro_new(struct avro_record_datum_t);
if (!datum) {
avro_set_error("Cannot create new record datum");
return NULL;
@@ -554,7 +554,7 @@ avro_datum_t avro_enum(avro_schema_t sch
check_param(NULL, is_avro_schema(schema), "schema");
struct avro_enum_datum_t *datum =
- avro_new(struct avro_enum_datum_t);
+ (struct avro_enum_datum_t *) avro_new(struct avro_enum_datum_t);
if (!datum) {
avro_set_error("Cannot create new enum datum");
return NULL;
@@ -616,7 +616,7 @@ static avro_datum_t avro_fixed_private(a
}
struct avro_fixed_datum_t *datum =
- avro_new(struct avro_fixed_datum_t);
+ (struct avro_fixed_datum_t *) avro_new(struct avro_fixed_datum_t);
if (!datum) {
avro_set_error("Cannot create new fixed datum");
return NULL;
@@ -633,7 +633,7 @@ static avro_datum_t avro_fixed_private(a
avro_datum_t avro_fixed(avro_schema_t schema,
const char *bytes, const int64_t size)
{
- char *bytes_copy = avro_malloc(size);
+ char *bytes_copy = (char *) avro_malloc(size);
if (!bytes_copy) {
avro_set_error("Cannot copy fixed content");
return NULL;
@@ -676,7 +676,7 @@ static int avro_fixed_set_private(avro_d
int avro_fixed_set(avro_datum_t datum, const char *bytes, const int64_t size)
{
int rval;
- char *bytes_copy = avro_malloc(size);
+ char *bytes_copy = (char *) avro_malloc(size);
if (!bytes_copy) {
avro_set_error("Cannot copy fixed content");
return ENOMEM;
@@ -736,7 +736,7 @@ avro_datum_t avro_map(avro_schema_t sche
check_param(NULL, is_avro_schema(schema), "schema");
struct avro_map_datum_t *datum =
- avro_new(struct avro_map_datum_t);
+ (struct avro_map_datum_t *) avro_new(struct avro_map_datum_t);
if (!datum) {
avro_set_error("Cannot create new map datum");
return NULL;
@@ -876,7 +876,7 @@ avro_datum_t avro_array(avro_schema_t sc
check_param(NULL, is_avro_schema(schema), "schema");
struct avro_array_datum_t *datum =
- avro_new(struct avro_array_datum_t);
+ (struct avro_array_datum_t *) avro_new(struct avro_array_datum_t);
if (!datum) {
avro_set_error("Cannot create new array datum");
return NULL;
@@ -1087,7 +1087,7 @@ static void avro_datum_free(avro_datum_t
record = avro_datum_to_record(datum);
avro_schema_decref(record->schema);
st_foreach(record->fields_byname,
- char_datum_free_foreach, 0);
+ HASH_FUNCTION_CAST char_datum_free_foreach, 0);
st_free_table(record->field_order);
st_free_table(record->fields_byname);
avro_freet(struct avro_record_datum_t, record);
@@ -1115,7 +1115,7 @@ static void avro_datum_free(avro_datum_t
struct avro_map_datum_t *map;
map = avro_datum_to_map(datum);
avro_schema_decref(map->schema);
- st_foreach(map->map, char_datum_free_foreach,
+ st_foreach(map->map, HASH_FUNCTION_CAST char_datum_free_foreach,
0);
st_free_table(map->map);
st_free_table(map->indices_by_key);
@@ -1127,7 +1127,7 @@ static void avro_datum_free(avro_datum_t
struct avro_array_datum_t *array;
array = avro_datum_to_array(datum);
avro_schema_decref(array->schema);
- st_foreach(array->els, array_free_foreach, 0);
+ st_foreach(array->els, HASH_FUNCTION_CAST array_free_foreach, 0);
st_free_table(array->els);
avro_freet(struct avro_array_datum_t, array);
}
@@ -1153,7 +1153,7 @@ datum_reset_foreach(int i, avro_datum_t
{
AVRO_UNUSED(i);
int rval;
- int *result = arg;
+ int *result = (int *) arg;
rval = avro_datum_reset(datum);
if (rval == 0) {
@@ -1175,7 +1175,7 @@ avro_datum_reset(avro_datum_t datum)
{
struct avro_array_datum_t *array;
array = avro_datum_to_array(datum);
- st_foreach(array->els, array_free_foreach, 0);
+ st_foreach(array->els, HASH_FUNCTION_CAST array_free_foreach, 0);
st_free_table(array->els);
rval = avro_init_array(array);
@@ -1190,7 +1190,7 @@ avro_datum_reset(avro_datum_t datum)
{
struct avro_map_datum_t *map;
map = avro_datum_to_map(datum);
- st_foreach(map->map, char_datum_free_foreach, 0);
+ st_foreach(map->map, HASH_FUNCTION_CAST char_datum_free_foreach, 0);
st_free_table(map->map);
st_free_table(map->indices_by_key);
st_free_table(map->keys_by_index);
@@ -1209,7 +1209,7 @@ avro_datum_reset(avro_datum_t datum)
record = avro_datum_to_record(datum);
rval = 0;
st_foreach(record->fields_byname,
- datum_reset_foreach, (st_data_t) &rval);
+ HASH_FUNCTION_CAST datum_reset_foreach, (st_data_t) &rval);
return rval;
}
Modified: avro/trunk/lang/c/src/datum.h
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.h?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.h (original)
+++ avro/trunk/lang/c/src/datum.h Sat Apr 28 19:40:52 2012
@@ -17,7 +17,7 @@
#ifndef AVRO_DATUM_H
#define AVRO_DATUM_H
-#include <stdint.h>
+#include <avro/platform.h>
#include "avro/basics.h"
#include "avro/data.h"
#include "avro/legacy.h"
Modified: avro/trunk/lang/c/src/datum_equal.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_equal.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_equal.c (original)
+++ avro/trunk/lang/c/src/datum_equal.c Sat Apr 28 19:40:52 2012
@@ -78,7 +78,7 @@ static int map_equal(struct avro_map_dat
if (a->map->num_entries != b->map->num_entries) {
return 0;
}
- st_foreach(a->map, st_equal_foreach, (st_data_t) & args);
+ st_foreach(a->map, HASH_FUNCTION_CAST st_equal_foreach, (st_data_t) & args);
return args.rval;
}
@@ -93,7 +93,7 @@ static int record_equal(struct avro_reco
if (a->fields_byname->num_entries != b->fields_byname->num_entries) {
return 0;
}
- st_foreach(a->fields_byname, st_equal_foreach, (st_data_t) & args);
+ st_foreach(a->fields_byname, HASH_FUNCTION_CAST st_equal_foreach, (st_data_t) & args);
return args.rval;
}
Modified: avro/trunk/lang/c/src/datum_size.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_size.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_size.c (original)
+++ avro/trunk/lang/c/src/datum_size.c Sat Apr 28 19:40:52 2012
@@ -126,7 +126,7 @@ size_map(avro_writer_t writer, const avr
if (datum->map->num_entries) {
size_accum(rval, size,
enc->size_long(writer, datum->map->num_entries));
- st_foreach(datum->map, size_map_foreach, (st_data_t) & args);
+ st_foreach(datum->map, HASH_FUNCTION_CAST size_map_foreach, (st_data_t) & args);
size += args.size;
}
if (!args.rval) {
Modified: avro/trunk/lang/c/src/datum_validate.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum_validate.c?rev=1331812&r1=1331811&r2=1331812&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum_validate.c (original)
+++ avro/trunk/lang/c/src/datum_validate.c Sat Apr 28 19:40:52 2012
@@ -123,7 +123,7 @@ avro_schema_datum_validate(avro_schema_t
{ avro_schema_to_map(expected_schema)->values, 1
};
st_foreach(avro_datum_to_map(datum)->map,
- schema_map_validate_foreach,
+ HASH_FUNCTION_CAST schema_map_validate_foreach,
(st_data_t) & vst);
return vst.rval;
}