367 Commits

Author SHA1 Message Date
Robert Edmonds
ab6de80ed1 ChangeLog: update 2014-03-27 18:56:50 -04:00
Robert Edmonds
c6f43d347f configure.ac: make pkg-config optional when building with --disable-protoc
if pkg-config is installed, the libprotobuf-c .pc file will be
installed; if pkg-config is not installed, the .pc file won't be
installed.

this behavior only applies when we're building with ./configure
--disable-protoc, since pkg-config is required in order to detect the
protobuf dependency.
2014-03-27 16:57:21 -04:00
Robert Edmonds
daad5868cf version the libprotobuf-c symbols on compatible linkers (Issue #116)
this is conditional on whether the linker supports version scripts, for
which we use the gl_LD_VERSION_SCRIPT macro from the gnulib project.

on platforms without version scripts, we fall back to libtool's
-export-symbols-regex.
2014-03-27 15:22:55 -04:00
Robert Edmonds
4da97eeaa3 protobuf-c/: update copyright notices 2014-03-26 15:51:47 -04:00
Robert Edmonds
0429d675c1 README.md: add note about semantic versioning 2014-03-26 15:31:03 -04:00
Robert Edmonds
6ea3b7c39f README.md: mention the <google/protobuf-c/protobuf-c.h> compat symlink 2014-03-26 14:15:45 -04:00
Robert Edmonds
8c8df07e39 LICENSE: update the copyright notice 2014-03-26 14:14:58 -04:00
Robert Edmonds
82635d618d .gitignore: anchor Makefile and Makefile.in at the top of the tree 2014-03-26 14:06:17 -04:00
Robert Edmonds
16e3465d21 configure.ac: check for a libprotoc header file
it's possible for the <google/protobuf/compiler/> header files to be
shipped in a separate package (e.g., debian's libprotoc-dev). check for
this at configure time rather than allowing the build process to fail.
2014-03-24 19:04:15 -04:00
Oleg Efimov
9c7f8ce798 t/: add test case for Issue #129 from Oleg Efimov 2014-03-24 18:07:04 -04:00
Robert Edmonds
d2658e25fe protoc-c: preserve case in C enum value names (Issue #129)
there is some confusion with regard to the use of lower case letters in
enum values. take the following message definition:

    message LowerCase {
      enum CaseEnum {
        UPPER = 1;
        lower = 2;
      }
      optional CaseEnum value = 1 [default = lower];
    }

this generates the following C enum:

    typedef enum _LowerCase__CaseEnum {
      LOWER_CASE__CASE_ENUM__UPPER = 1,
      LOWER_CASE__CASE_ENUM__lower = 2
        _PROTOBUF_C_FORCE_ENUM_TO_BE_INT_SIZE(LOWER_CASE__CASE_ENUM)
    } LowerCase__CaseEnum;

note that the case of the enum value 'lower' was preserved in the C
symbol name as 'LOWER_CASE__CASE_ENUM__lower', but that the _INIT macro
references the same enum value with the (non-existent) C symbol name
'LOWER_CASE__CASE_ENUM__LOWER':

    #define LOWER_CASE__INIT \
     { PROTOBUF_C_MESSAGE_INIT (&lower_case__descriptor) \
        , 0,LOWER_CASE__CASE_ENUM__LOWER }

additionally, the ProtobufCEnumValue array generated also refers to the
same enum value with the (non-existent) upper cased version:

    const ProtobufCEnumValue lower_case__case_enum__enum_values_by_number[2] =
    {
      { "UPPER", "LOWER_CASE__CASE_ENUM__UPPER", 1 },
      { "lower", "LOWER_CASE__CASE_ENUM__LOWER", 2 },
    };

we should preserve the existing behavior of copying the case from the
enum values in the message definition and fix up the places where the
(non-existent) upper case version is used, rather than changing the enum
definition itself to match the case used in the _INIT macro and
enum_values_by_number array, because it's possible that there might be
existing working code that uses enum values with lower case letters that
would be affected by such a change.

incidentally, google's C++ protobuf implementation preserves case in
enum values. protoc --cpp_out generates the following enum declaration
for the message descriptor above:

    enum LowerCase_CaseEnum {
      LowerCase_CaseEnum_UPPER = 1,
      LowerCase_CaseEnum_lower = 2
    };
2014-03-24 18:07:04 -04:00
Robert Edmonds
1f15ba9cdf protobuf-c: minor style fixes 2014-03-19 15:15:27 -04:00
Robert Edmonds
3429d8b197 protobuf-c: rename protobuf_c_message_init_generic() and update the TODO comment
this function is now static, so it shouldn't have the "protobuf_c_"
prefix in its name.
2014-03-19 15:14:52 -04:00
Tomasz Wasilczyk
4e3ace9757 Don't export private function as an external symbol 2014-03-14 23:59:18 +01:00
Tomasz Wasilczyk
05c7e4892c Don't use C++ style comments in C code 2014-03-14 23:56:21 +01:00
Tomasz Wasilczyk
1ab4acf919 Fix -Wcast-align warnings when compiled with clang 2014-03-14 22:21:07 +01:00
Robert Edmonds
2976be8666 configure.ac: tweak the ${has_doxygen} status display 2014-03-06 22:05:27 -05:00
Kevin Lyda
7881332164 Disable dot in Doxyfile. 2014-02-17 09:29:01 +00:00
Kevin Lyda
369f7e58a1 Default doxygen-doc to not enabled.
Also, don't default dot support to on and emit something to say if
the dogygen-doc target is enabled.
2014-02-17 09:24:51 +00:00
Kevin Lyda
b9f94db3cc Autoconf configuration for doxygen.
Still need to add the comments in the source code. Currently I've
seeded it with the libprotobuf-c files.  I've configured it
to make man pages and html pages.  Might not be ideal, but makes it easy
for me to check things (html is nicer, but man pages are handier for
remote servers).
2014-02-16 21:45:02 +00:00
Robert Edmonds
7ea757dd13 configure.ac: bump version to 1.0.0-pre 2014-02-10 10:57:27 -05:00
Kevin Lyda
f52f500995 Autoconf portability tweaks.
Use MKDIR_P and LN_S rather than their usual expansions.
2014-01-25 15:56:40 +00:00
Robert Edmonds
ed036b769f Revert "protobuf-c/libprotobuf-c.sym: new" (fixes #116)
This reverts commit aaa40c5881f12877cca63c06a798d8422f9470de.
2014-01-17 11:10:39 -05:00
Robert Edmonds
447964eee4 .travis.yml: add back "language: c"
of course, protobuf-c uses both C and C++.
2014-01-14 13:52:21 -05:00
Robert Edmonds
28e70e5e9a .travis.yml: remove "make clean" at end of build script 2014-01-14 13:51:30 -05:00
Robert Edmonds
dd0f0ea3ef Makefile.am: AM_TESTS_ENVIRONMENT -> LOG_COMPILER
It’s important to note that, differently from what we’ve seen for
    the serial test harness (see Parallel Test Harness), the
    AM_TESTS_ENVIRONMENT and TESTS_ENVIRONMENT variables cannot be use
    to define a custom test runner; the LOG_COMPILER and LOG_FLAGS (or
    their extension-specific counterparts) should be used instead:

    ## This is WRONG!
    AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib' $(PERL) -Mstrict -w

    ## Do this instead.
    AM_TESTS_ENVIRONMENT = PERL5LIB='$(srcdir)/lib'; export PERL5LIB;
    LOG_COMPILER = $(PERL)
    AM_LOG_FLAGS = -Mstrict -w

(http://www.gnu.org/software/automake/manual/html_node/Parallel-Test-Harness.html)
2014-01-14 13:46:19 -05:00
Robert Edmonds
bfd88382e6 .travis.yml: add VERBOSE=1 to make flags in order to log test failures
"As with the serial harness above, by default one status line is printed
per completed test, and a short summary after the suite has completed.
However, standard output and standard error of the test are redirected
to a per-test log file, so that parallel execution does not produce
intermingled output. The output from failed tests is collected in the
test-suite.log file. If the variable ‘VERBOSE’ is set, this file is
output after the summary."

(http://www.gnu.org/software/automake/manual/html_node/Parallel-Test-Harness.html)
2014-01-14 13:39:33 -05:00
Ilya Lipnitskiy
d74ef06435 .travis.yml: install valgrind on the CI VM 2014-01-14 00:20:05 -08:00
Ilya Lipnitskiy
baa3ab296d .travis.yml: add a travis build entry to run tests under valgrind
Makefile.am: add valgrind to the AM_TESTS_ENVIRONMENT
configure.ac: enable valgrind testing option for ./configure
m4/valgrind-tests.m4: enable tracing children for libtool wrapper
script compatibility, but ignore standard binaries in /usr or /bin
2014-01-14 00:20:05 -08:00
Ilya Lipnitskiy
2b371c154f m4/valgrind-tests.m4: add valgrind testing support to automake 2014-01-14 00:19:24 -08:00
Robert Edmonds
847091c86e ChangeLog: mention google compat symlink and protobuf-c-rpc splitout 2014-01-13 21:55:43 -05:00
Robert Edmonds
d10a022eb4 ChangeLog: configure --disable-protoc has been restored 2014-01-13 21:51:50 -05:00
Robert Edmonds
6f0237a6c6 ChangeLog: the entries about the rpc code have been moved to protobuf-c-rpc's ChangeLog 2014-01-13 21:51:14 -05:00
Robert Edmonds
caff46e1f6 make .alloc and .free methods of ProtobufCAllocator callable again
it turned out to be a bad idea to not export the default allocator's
methods via the ProtobufCAllocator's function pointers. there is at
least one user (protobuf-c-rpc) that makes allocations by directly
invoking those methods.
2014-01-13 21:47:28 -05:00
Robert Edmonds
aaa40c5881 protobuf-c/libprotobuf-c.sym: new
use a linker script rather than relying on libtool's
-export-symbols-regex. this lets us start versioning the library's
exported symbols.
2014-01-13 20:17:39 -05:00
Robert Edmonds
606c27b411 protobuf-c: update #include comments
in particular we no longer use abort().
2014-01-13 19:53:41 -05:00
Robert Edmonds
e8bf07dee0 protobuf-c: just use <stdint.h>
according to microsoft's platform evangelist, "we recommend that you
consider using a different compiler such as Intel or gcc" if you need a
conforming C compiler. since there's already a project that maintains
the stdint.h / inttypes.h headers for microsoft compilers
(https://code.google.com/p/msinttypes/) there's not much point in
maintaining this ourselves.
2014-01-13 19:53:41 -05:00
Robert Edmonds
677c3f0bdf remove protobuf-c-private.h
there's not much point to having the "private" definitions split out
into a separate header file. they're still in the namespace and there's
nothing that can be done to prevent "unauthorized" uses. just integrate
the definitions into the main header file but put them in the bottom and
note that they're "private".

this makes it very slightly easier to copy the protobuf-c support
library into another project wholesale, since one less file is required.
2014-01-13 19:53:41 -05:00
Robert Edmonds
85847c494e protobuf-c: remove PROTOBUF_C_PLEASE_INCLUDE_CTYPE, ProtobufC_CType
i'm not quite sure what this thing is used for or how useful it could
possibly be. it's not used anywhere in protobuf-c or protobuf-c-rpc, and
it wasn't in protobuf-c 0.14 or earlier. just delete it; if anything
actually needs this kind of logic, it's easy enough to replicate it.
2014-01-13 19:53:41 -05:00
Robert Edmonds
f6cee05cf0 protobuf-c: make it a bit harder to generate output to stdio
libraries should never generate output on their own to stdout/stderr.
remove the PRINT_UNPACK_ERRORS macro and rename UNPACK_ERROR to
PROTOBUF_C_UNPACK_ERROR.

the error strings are left in but compiled out by default. they could
theoretically be re-enabled for a debugging session by changing the
PROTOBUF_C_UNPACK_ERROR macro to something like:

	#define PROTOBUF_C_UNPACK_ERROR(...) do { fprintf(stderr, __VA_ARGS__); fputc('\n', stderr); } while (0)
2014-01-13 19:53:41 -05:00
Robert Edmonds
b1a2c06140 protobuf-c: add some whitespace to TRUE, FALSE defines 2014-01-13 19:53:41 -05:00
Robert Edmonds
5a026769e6 Makefile.am: set up a compatibility symlink for include paths that use <google/protobuf-c>
it might be premature to remove the <google/> prefix from the include
path. set up a compatibility symlink so that old code continues to
compile.
2014-01-13 19:53:41 -05:00
Robert Edmonds
a2fb294a22 build system: add back the --disable-protoc option to configure 2014-01-13 19:53:41 -05:00
Robert Edmonds
4c7904fc13 configure.ac: remove the AC_CHECK_HEADERS checks
some of these headers aren't used in the protobuf-c code base any more,
and in any case the results of these checks (the HAVE_*_H defines in
config.h) are not actually used anywhere and the absence of any of these
headers doesn't cause configure to fail, so just delete these useless
checks.
2014-01-13 19:53:41 -05:00
Robert Edmonds
09b801a968 protobuf-c: replace DO_ALLOC, FREE, system_alloc, system_free with inline memory allocation functions
this reworks memory allocation throughout the support library.

the old DO_ALLOC macro had several problems:

  1) only by reading the macro implementation is it possible to tell
  what actually occurs. consider:

        DO_ALLOC(x, ...);

  vs.:

        x = do_alloc(...);

  only in the latter is it clear that x is being assigned to.

  2) it looks like a typical macro/function call, except it alters the
  control flow, usually by return'ing or executing a goto in the
  enclosing function. this type of anti-pattern is explicitly called out
  in the linux kernel coding style.

  3) in one instance, setting the destination pointer to NULL is
  actually a *success* return. in parse_required_member(), when parsing
  a PROTOBUF_C_TYPE_BYTES wire field, it is possible that the field is
  present but of zero length, in which case memory shouldn't be
  allocated and nothing should actually be copied. this is not apparent
  from reading:

        DO_ALLOC(bd->data, allocator, len - pref_len, return 0);
        memcpy(bd->data, data + pref_len, len - pref_len);

  instead, make this behavior explicit:

        if (len - pref_len > 0) {
                bd->data = do_alloc(allocator, len - pref_len);
                if (bd->data == NULL)
                        return 0;
                memcpy(bd->data, data + pref_len, len - pref_len);
        }

  this is much more readable and makes it possible to write a
  replacement for DO_ALLOC which returns NULL on failures.

this changes the protobuf_c_default_allocator to contain only NULL
values; if a replacement function pointer is not present (non-NULL) in
this struct, the default malloc/free implementations are used. this
makes it impossible to call the default allocator functions directly and
represents an API/ABI break, which required a fix to the
PROTOBUF_C_BUFFER_SIMPLE_CLEAR macro.

despite turning one-line allocations in the simple case:

	DO_ALLOC(rv, allocator, desc->sizeof_message, return NULL);

into three-line statements like:

	rv = do_alloc(allocator, desc->sizeof_message);
	if (!rv)
		return (NULL);

this changeset actually *reduces* the total number of lines in the
support library.
2014-01-13 19:53:41 -05:00
Robert Edmonds
8216865a46 protobuf-c: remove alloc_failed_warning and protobuf_c_out_of_memory
in general, libraries shouldn't be responsible for terminating the
program if memory allocation fails. if we need to allocate memory and
can't, we should be returning a failure indicator, not providing a
strange interface to the user for receiving a callback in the event of
such an error.

also in general, libraries should never write to stdout or stderr.

this breaks the API/ABI and will require a note in the ChangeLog.
2014-01-13 15:35:44 -05:00
Robert Edmonds
8cd5f6764b protobuf-c: remove tmp_alloc and max_alloca fields of ProtobufCAllocator
i'm confused as to why these fields exist, since the typical
implementation of a "temporary alloc" would be something like alloca(),
and alloca() is usually just inlined code that adjusts the stack
pointer, which is not a function whose address could be taken.

this breaks the API/ABI and will require a note in the ChangeLog.

possibly we could revisit the idea of "temporary allocations" by using
C99 variable length arrays. this would have the advantage of being
standardized, unlike alloca().
2014-01-13 15:35:42 -05:00
Robert Edmonds
a533b594f7 spelling: "prefered" -> "preferred" 2014-01-13 14:57:54 -05:00
Robert Edmonds
871d678738 protobuf-c: remove UNALIGNED_ALLOC, DO_UNALIGNED_ALLOC macros 2014-01-13 14:19:28 -05:00
Robert Edmonds
b8c5e06de3 ChangeLog: coverity fixes 2014-01-11 15:52:16 -05:00