Skip to content

Commit

Permalink
Merge from vendor branch FIX_VENDOR:
Browse files Browse the repository at this point in the history
Import devel/protobuf-c, a C implementation of google protocol
buffers.

This is a new dependency of an upcoming update of audio/umurmur.

Tested by Jonathon Sisson, who also takes maintainership
OK ajacoutot@
  • Loading branch information
David Coppa committed Jul 8, 2011
2 parents c1f5763 + 3903ebb commit 65daa43
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 0 deletions.
35 changes: 35 additions & 0 deletions devel/protobuf-c/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# $OpenBSD: Makefile,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $

COMMENT = c protocol buffers

DISTNAME = protobuf-c-0.15

SHARED_LIBS = protobuf-c 0.0 # 0.0

CATEGORIES = devel

HOMEPAGE = http://protobuf-c.googlecode.com/

MASTER_SITES = ${HOMEPAGE}/files/

MAINTAINER = Jonathon Sisson <[email protected]>

# New BSD
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM =Yes
PERMIT_DISTFILES_FTP = Yes

WANTLIB = c m protobuf protoc pthread stdc++ z

LIB_DEPENDS = devel/protobuf

USE_LIBTOOL = Yes
CONFIGURE_STYLE = gnu

CONFIGURE_ENV = CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib"

SEPARATE_BUILD = concurrent

.include <bsd.port.mk>
5 changes: 5 additions & 0 deletions devel/protobuf-c/distinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MD5 (protobuf-c-0.15.tar.gz) = c/8MjfUNLu51JprY+MB9yA==
RMD160 (protobuf-c-0.15.tar.gz) = UDGbuisXOq+5bdH+cFUNN45p+HE=
SHA1 (protobuf-c-0.15.tar.gz) = T72T9JLFIVRxPeGVHAohM93UOrs=
SHA256 (protobuf-c-0.15.tar.gz) = j8tTjhOlQxxGFo/I8uatJXTi25toTAxysGbiTwEKADY=
SIZE (protobuf-c-0.15.tar.gz) = 500911
43 changes: 43 additions & 0 deletions devel/protobuf-c/patches/patch-configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
$OpenBSD: patch-configure,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $

Fix libpthread linkage
Fix endianess test

--- configure.orig Thu Mar 10 20:12:02 2011
+++ configure Thu Jul 7 14:53:37 2011
@@ -16686,7 +16686,7 @@ fi


pbc_savelibs="$LIBS"
- LIBS="$LIBS -lprotoc -lprotobuf -lpthread"
+ LIBS="$LIBS -lprotoc -lprotobuf -pthread"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -17004,7 +17004,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$

# ------------------ try <mach/endian.h> ------------------

-for ac_header in mach/endian.h
+for ac_header in sys/endian.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -17158,13 +17158,14 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <mach/endian.h>
+#include <sys/types.h>
+#include <sys/endian.h>
int
main ()
{

- switch (1) { case __LITTLE_ENDIAN: break;
- case __BYTE_ORDER: break; }
+ switch (1) { case LITTLE_ENDIAN: break;
+ case BYTE_ORDER: break; }
;
return 0;
}
15 changes: 15 additions & 0 deletions devel/protobuf-c/patches/patch-src_Makefile_in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$OpenBSD: patch-src_Makefile_in,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $

Fix libpthread linkage

--- src/Makefile.in.orig Thu Jul 7 15:11:45 2011
+++ src/Makefile.in Thu Jul 7 15:11:55 2011
@@ -262,7 +262,7 @@ top_srcdir = @top_srcdir@
@BUILD_PROTOC_C_TRUE@google/protobuf/compiler/c/c_bytes_field.cc

@BUILD_PROTOC_C_TRUE@protoc_c_LDADD = \
-@BUILD_PROTOC_C_TRUE@-lprotoc -lprotobuf -lpthread
+@BUILD_PROTOC_C_TRUE@-lprotoc -lprotobuf -pthread

lib_LTLIBRARIES = libprotobuf-c.la
protobufcincludedir = $(includedir)/google/protobuf-c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$OpenBSD: patch-src_google_protobuf-c_protobuf-c-data-buffer_c,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $

malloc.h is obsolete

--- src/google/protobuf-c/protobuf-c-data-buffer.c.orig Thu Jul 7 17:13:21 2011
+++ src/google/protobuf-c/protobuf-c-data-buffer.c Thu Jul 7 17:13:35 2011
@@ -33,11 +33,6 @@
#endif
#include <string.h>
#include <errno.h>
-#if HAVE_ALLOCA_H
-# include <alloca.h>
-#elif HAVE_MALLOC_H
-# include <malloc.h>
-#endif
#include <stdlib.h>
#include "protobuf-c-data-buffer.h"

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
$OpenBSD: patch-src_google_protobuf-c_protobuf-c-dispatch_c,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $

malloc.h is obsolete

clear_changes isn't necessary because n_changes is cleared in
dispatch_dispatch (upstream svn revision r286)

--- src/google/protobuf-c/protobuf-c-dispatch.c.orig Thu Mar 10 20:02:48 2011
+++ src/google/protobuf-c/protobuf-c-dispatch.c Thu Jul 7 12:50:09 2011
@@ -10,11 +10,7 @@
#include "protobuf-c-config.h"
#endif
#include <assert.h>
-#if HAVE_ALLOCA_H
-# include <alloca.h>
-#elif HAVE_MALLOC_H
-# include <malloc.h>
-#endif
+#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <string.h>
@@ -98,6 +94,7 @@ struct _RealDispatch
FDMapNode *fd_map_tree; /* map indexed by fd */
#endif

+ protobuf_c_boolean is_dispatching;

ProtobufCDispatchTimer *timer_tree;
ProtobufCAllocator *allocator;
@@ -193,8 +190,10 @@ ProtobufCDispatch *protobuf_c_dispatch_new (ProtobufCA
rv->allocator = allocator;
rv->timer_tree = NULL;
rv->first_idle = rv->last_idle = NULL;
+ rv->base.has_idle = 0;
rv->recycled_idles = NULL;
rv->recycled_timeouts = NULL;
+ rv->is_dispatching = 0;

/* need to handle SIGPIPE more gracefully than default */
signal (SIGPIPE, SIG_IGN);
@@ -531,6 +530,12 @@ protobuf_c_dispatch_dispatch (ProtobufCDispatch *dispa
unsigned i;
FDMap *fd_map = d->fd_map;
struct timeval tv;
+
+ /* Re-entrancy guard. If this is triggerred, then
+ you are calling protobuf_c_dispatch_dispatch (or _run)
+ from a callback function. That's not allowed. */
+ d->is_dispatching = 1;
+
fd_max = 0;
for (i = 0; i < n_notifies; i++)
if (fd_max < (unsigned) notifies[i].fd)
@@ -604,6 +609,9 @@ protobuf_c_dispatch_dispatch (ProtobufCDispatch *dispa
}
if (d->timer_tree == NULL)
d->base.has_timeout = 0;
+
+ /* Finish reentrance guard. */
+ d->is_dispatching = 0;
}

void
@@ -717,7 +725,6 @@ protobuf_c_dispatch_run (ProtobufCDispatch *dispatch)
if (events[n_events].events != 0)
n_events++;
}
- protobuf_c_dispatch_clear_changes (dispatch);
protobuf_c_dispatch_dispatch (dispatch, n_events, events);
if (to_free)
FREE (to_free);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$OpenBSD: patch-src_google_protobuf-c_protobuf-c-rpc_c,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $

Remove incorrect assertion (upstream svn revision r281)

--- src/google/protobuf-c/protobuf-c-rpc.c.orig Thu Jul 7 12:24:56 2011
+++ src/google/protobuf-c/protobuf-c-rpc.c Thu Jul 7 12:25:24 2011
@@ -476,7 +476,6 @@ enqueue_request (ProtobufC_RPC_Client *client,
protobuf_c_assert (method_index < desc->n_methods);

/* Allocate request_id */
- protobuf_c_assert (client->state == PROTOBUF_C_CLIENT_STATE_CONNECTED);
if (client->info.connected.first_free_request_id == 0)
grow_closure_array (client);
request_id = client->info.connected.first_free_request_id;
58 changes: 58 additions & 0 deletions devel/protobuf-c/patches/patch-src_google_protobuf-c_protobuf-c_c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
$OpenBSD: patch-src_google_protobuf-c_protobuf-c_c,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $

malloc.h is obsolete

Be more permissive in accepting packed data for non-packed repeated
members (upstream svn revision r285)

--- src/google/protobuf-c/protobuf-c.c.orig Thu Mar 10 20:02:48 2011
+++ src/google/protobuf-c/protobuf-c.c Thu Jul 7 17:14:06 2011
@@ -38,11 +38,6 @@
#include <stdio.h> /* for occasional printf()s */
#include <stdlib.h> /* for abort(), malloc() etc */
#include <string.h> /* for strlen(), memcpy(), memmove() */
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#elif HAVE_MALLOC_H
-#include <malloc.h>
-#endif

#ifndef PRINT_UNPACK_ERRORS
#define PRINT_UNPACK_ERRORS 1
@@ -1983,6 +1978,14 @@ no_unpacking_needed:
}

static protobuf_c_boolean
+is_packable_type (ProtobufCType type)
+{
+ return type != PROTOBUF_C_TYPE_STRING
+ && type != PROTOBUF_C_TYPE_BYTES
+ && type != PROTOBUF_C_TYPE_MESSAGE;
+}
+
+static protobuf_c_boolean
parse_member (ScannedMember *scanned_member,
ProtobufCMessage *message,
ProtobufCAllocator *allocator)
@@ -2007,8 +2010,8 @@ parse_member (ScannedMember *scanned_member,
case PROTOBUF_C_LABEL_OPTIONAL:
return parse_optional_member (scanned_member, member, message, allocator);
case PROTOBUF_C_LABEL_REPEATED:
- if (field->packed
- && scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
+ if (scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
+ && (field->packed || is_packable_type (field->type)))
return parse_packed_repeated_member (scanned_member, member, message);
else
return parse_repeated_member (scanned_member, member, message, allocator);
@@ -2261,8 +2264,8 @@ protobuf_c_message_unpack (const ProtobufCMess
if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED)
{
size_t *n = STRUCT_MEMBER_PTR (size_t, rv, field->quantifier_offset);
- if (field->packed
- && wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
+ if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
+ && (field->packed || is_packable_type (field->type)))
{
size_t count;
if (!count_packed_elements (field->type,
9 changes: 9 additions & 0 deletions devel/protobuf-c/pkg/DESCR
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Protocol buffers are a flexible, efficient, automated mechanism for
serializing structured data - think XML, but smaller, faster, and
simpler. You define how you want your data to be structured once, then
you can use special generated source code to easily write and read your
structured data to and from a variety of data streams and using a
variety of languages. You can even update your data structure without
breaking deployed programs that are compiled against the "old" format.

This is the C implementation of protocol buffers.
2 changes: 2 additions & 0 deletions devel/protobuf-c/pkg/PFRAG.shared
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@comment $OpenBSD: PFRAG.shared,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $
@lib lib/libprotobuf-c.so.${LIBprotobuf-c_VERSION}
13 changes: 13 additions & 0 deletions devel/protobuf-c/pkg/PLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $
%%SHARED%%
@bin bin/protoc-c
include/google/
include/google/protobuf-c/
include/google/protobuf-c/protobuf-c-dispatch.h
include/google/protobuf-c/protobuf-c-private.h
include/google/protobuf-c/protobuf-c-rpc.h
include/google/protobuf-c/protobuf-c.h
lib/libprotobuf-c.a
lib/libprotobuf-c.la
lib/pkgconfig/
lib/pkgconfig/libprotobuf-c.pc

0 comments on commit 65daa43

Please sign in to comment.