Skip to content

Commit 3f2b7f8

Browse files
committed
Prepare 0.4.0 release
1 parent ccde962 commit 3f2b7f8

File tree

13 files changed

+596
-75
lines changed

13 files changed

+596
-75
lines changed

CHANGELOG

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
protobluff-0.x.x
1+
protobluff-0.4.0 (2015-12-16)
22

3-
In progress.
3+
This release adds full support for packed fields (in lite and full runtime).
4+
Furthermore, some functions have been deprecated to prepare for the 1.0.0
5+
release, in particular raw pointer access, because unaligned access of floats
6+
and doubles may cause undefined behavior on some architectures, and the
7+
position of the cursor, as due to the possible erasure of fields during a
8+
cursor's lifetime, the position may not be accurately determined.
9+
10+
Again, this release is mostly compatible with prior versions, but a few
11+
breaking changes to the ABI could not be omitted. See the MIGRATION file for
12+
further assistance. However, approaching the 1.0.0 release, the ABI can be
13+
considered stable very soon. The libtool version has been updated to 3.0.0.
414

515
Runtime:
616

717
* Deprecated raw pointer access (will be removed in 1.0.0)
18+
* Deprecated pb_cursor_pos() (will be removed in 1.0.0)
819
* Fixed invalid reads reported when compiling with -fsanitize
920
* Fixed incorrectly reported position in pb_cursor_seek()
21+
* Fixed cursor state when erasing the last field in a message
22+
* Fixed alignment issues and checks after erasing parts
1023
* Added support for packed fields
1124
* Added missing error string for PB_ERROR_EOM (could have caused segfault)
1225
* Added tests for packed fields

MIGRATION

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
0.3.x => 0.4.0
2+
3+
Encoder
4+
5+
In order to handle packed fields, the encoder does now take a fourth
6+
argument, namely the amount of values to be encoded. This is a prerequisite
7+
for the support of packed fields. Now, multiple values can be encoded all
8+
at once, regardless of whether a field is packed or not. This also applies
9+
for messages, which have already been implemented as nested encoders.
10+
11+
This makes it necessary to regenerate the bindings and change all accessors
12+
that write values to repeated fields.
13+
14+
< 0.4.0:
15+
16+
pb_encoder_t person = person_encoder_create(...);
17+
person_encode_phone(&person, &phonenumbers[0]);
18+
person_encode_phone(&person, &phonenumbers[1]);
19+
20+
= 0.4.0:
21+
22+
pb_encoder_t person = person_encoder_create(...);
23+
person_encode_phone(&person, &phonenumbers, 2);
24+
125
0.2.x => 0.3.0
226

327
Binaries

README.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ journal. If no alterations that change the size of the underlying journal are
2525
expected, the journal can be used in *zero-copy mode*, omitting all dynamic
2626
allocations.
2727

28-
Updates on fixed-sized wire types on little-endian machines can be carried out
29-
in-place using raw-pointers to the underlying data. These include the native
30-
Protocol Buffers types `fixed(32|64)`, `sfixed(32|64)`, `float` and `double`
31-
(see the [Protocol Buffers Encoding Guide][] for more information). Strings may
32-
also be accessed through raw-pointers, however writing a string of different
33-
length may result in garbled data, and is thus not recommended.
34-
3528
## Installation
3629

3730
### Building from source
@@ -197,21 +190,19 @@ PKG_CHECK_MODULES([protobluff], [protobluff])
197190
7. Imports
198191
8. Packages
199192
9. Extensions and nested extensions
200-
10. Deprecation warnings
193+
10. Deprecations for messages, fields, enums and enum values
194+
11. Packed fields
201195

202196
### Not yet supported
203197

204-
1. Packed fields
205-
2. Oneofs
198+
1. Oneofs
199+
2. proto3 support
206200
3. Services (using gRPC and/or ZMQ)
207201
4. Groups (unsure)
208-
5. General proto3 support (unsure)
209202

210-
### Roadmap
211-
212-
1. Oneofs
213-
2. Packed fields
214-
3. Services
203+
These features will be implemented in the order presented. protobluff is
204+
basically compatible with proto3, as proto2 is binary compatible, but some
205+
special types like maps and the Any type need to be implemented.
215206

216207
## License
217208

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
AC_PREREQ(2.69)
2626

27-
AC_INIT([protobluff], [0.3.0], [[email protected]])
27+
AC_INIT([protobluff], [0.4.0], [[email protected]])
2828
AM_INIT_AUTOMAKE([subdir-objects foreign])
2929

3030
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@@ -48,7 +48,7 @@ AC_CONFIG_MACRO_DIR([m4])
4848

4949
# Library versioning as <current:revision:age> - also remember to synchronize
5050
# this value with the version info in the core/common.h header file.
51-
AC_SUBST([VERSION_INFO], [2:0:0])
51+
AC_SUBST([VERSION_INFO], [3:0:0])
5252

5353
# Checks for programs
5454
AC_PROG_AWK

include/protobluff/core/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* Current ABI version as a single integer to test binary compatibility in
3434
* the generated header files: current * 10^6 + revision * 10^3 + age
3535
*/
36-
#define PB_VERSION (2 * 1000000) + (0 * 1000) + 0
36+
#define PB_VERSION (3 * 1000000) + (0 * 1000) + 0
3737

3838
/*
3939
* Agnostic C-linkage classifier for extern functions when compiling from C++

include/protobluff/message/cursor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pb_cursor_descriptor(const pb_cursor_t *cursor) {
142142
* \param[in] cursor Cursor
143143
* \return Current position
144144
*/
145+
PB_DEPRECATED
145146
PB_INLINE size_t
146147
pb_cursor_pos(const pb_cursor_t *cursor) {
147148
assert(cursor);

src/message/cursor.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,18 @@ next(pb_cursor_t *cursor) {
164164
}
165165

166166
/* Cleanup and return */
167-
pb_buffer_destroy(&buffer);
168167
pb_stream_destroy(&stream);
168+
pb_buffer_destroy(&buffer);
169169
return !packed->end;
170170
}
171171

172-
/* Cleanup and invalidate cursor */
173-
pb_buffer_destroy(&buffer);
174-
pb_stream_destroy(&stream);
175-
if (!cursor->error)
172+
/* Invalidate cursor if at end */
173+
if (!(pb_stream_left(&stream) && cursor->error))
176174
cursor->error = PB_ERROR_EOM;
175+
176+
/* Cleanup and return */
177+
pb_stream_destroy(&stream);
178+
pb_buffer_destroy(&buffer);
177179
return 0;
178180
}
179181

@@ -289,7 +291,7 @@ pb_cursor_next(pb_cursor_t *cursor) {
289291
assert(cursor);
290292
int result = 0;
291293
if (pb_cursor_valid(cursor)) {
292-
cursor->error = pb_cursor_align(cursor);
294+
pb_cursor_align(cursor);
293295
do {
294296
result = cursor->current.packed.end
295297
? next_packed(cursor)
@@ -531,9 +533,8 @@ pb_cursor_align(pb_cursor_t *cursor) {
531533
assert(pb_cursor_valid(cursor));
532534
pb_error_t error = PB_ERROR_NONE;
533535

534-
/* Check, if current part is already aligned */
535-
const pb_part_t *part = pb_message_part(&(cursor->message));
536-
if (unlikely_(!pb_part_aligned(part))) {
536+
/* Check, if cursor is already aligned */
537+
if (unlikely_(!pb_cursor_aligned(cursor))) {
537538
pb_version_t version = pb_cursor_version(cursor);
538539

539540
/* Align current packed context offset, if given */

src/message/cursor.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pb_cursor_create_internal(
4141
pb_message_t *message, /* Message */
4242
pb_tag_t tag); /* Tag */
4343

44-
PB_WARN_UNUSED_RESULT
4544
extern pb_error_t
4645
pb_cursor_align(
4746
pb_cursor_t *cursor); /* Cursor */
@@ -129,6 +128,18 @@ pb_cursor_version(const pb_cursor_t *cursor) {
129128
return pb_message_version(&(cursor->message));
130129
}
131130

131+
/*!
132+
* Test whether a cursor is properly aligned.
133+
*
134+
* \param[in] cursor Cursor
135+
* \return Test result
136+
*/
137+
PB_INLINE int
138+
pb_cursor_aligned(const pb_cursor_t *cursor) {
139+
assert(cursor);
140+
return pb_message_aligned(&(cursor->message));
141+
}
142+
132143
/*!
133144
* Retrieve the offsets at the current position of a cursor.
134145
*

src/message/field.h

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,33 @@ pb_field_version(const pb_field_t *field) {
9999
return pb_part_version(&(field->part));
100100
}
101101

102+
/*!
103+
* Test whether a field is properly aligned.
104+
*
105+
* \param[in] field Field
106+
* \return Test result
107+
*/
108+
PB_INLINE int
109+
pb_field_aligned(const pb_field_t *field) {
110+
assert(field);
111+
return pb_part_aligned(&(field->part));
112+
}
113+
114+
/*!
115+
* Ensure that a field is properly aligned.
116+
*
117+
* \param[in,out] field Field
118+
* \return Error code
119+
*/
120+
PB_WARN_UNUSED_RESULT
121+
PB_INLINE pb_error_t
122+
pb_field_align(pb_field_t *field) {
123+
assert(field);
124+
return !pb_part_aligned(&(field->part))
125+
? pb_part_align(&(field->part))
126+
: PB_ERROR_NONE;
127+
}
128+
102129
/*!
103130
* Retrieve the start offset of a field within its underlying journal.
104131
*
@@ -147,21 +174,6 @@ pb_field_empty(const pb_field_t *field) {
147174
return pb_part_empty(&(field->part));
148175
}
149176

150-
/*!
151-
* Ensure that a field is properly aligned.
152-
*
153-
* \param[in,out] field Field
154-
* \return Error code
155-
*/
156-
PB_WARN_UNUSED_RESULT
157-
PB_INLINE pb_error_t
158-
pb_field_align(pb_field_t *field) {
159-
assert(field);
160-
return !pb_part_aligned(&(field->part))
161-
? pb_part_align(&(field->part))
162-
: PB_ERROR_NONE;
163-
}
164-
165177
/* ------------------------------------------------------------------------- */
166178

167179
/*!

src/message/journal.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ pb_journal_align(
371371
if (entry->origin >= offset->start) {
372372
offset->end += entry->delta;
373373

374+
/* Current part is a packed field: invalidate */
375+
if (offset->diff.origin && !offset->diff.tag &&
376+
offset->start == offset->end)
377+
invalid = 1;
378+
374379
/* Current part was cleared: clear */
375380
} else if ((offset->start + offset->diff.origin) -
376381
(offset->end + entry->delta) == 0) {

0 commit comments

Comments
 (0)