1 /* { dg-do compile } */
3 typedef unsigned _GCC_ATTR_ALIGN_u32t;
4 typedef _GCC_ATTR_ALIGN_u32t _Uint32t __attribute__ ((__aligned__ (4)));
5 typedef unsigned int _GCC_ATTR_ALIGN_u8t __attribute__ ((__mode__ (__QI__)));
6 typedef _GCC_ATTR_ALIGN_u8t _Uint8t __attribute__ ((__aligned__ (1)));
7 typedef unsigned _Sizet;
9 typedef _Uint8t uint8_t;
10 typedef _Uint32t uint32_t;
13 PROTOBUF_C_LABEL_REQUIRED, PROTOBUF_C_LABEL_OPTIONAL,
14 PROTOBUF_C_LABEL_REPEATED
19 PROTOBUF_C_TYPE_INT32, PROTOBUF_C_TYPE_SINT32, PROTOBUF_C_TYPE_SFIXED32,
20 PROTOBUF_C_TYPE_INT64, PROTOBUF_C_TYPE_SINT64, PROTOBUF_C_TYPE_SFIXED64,
21 PROTOBUF_C_TYPE_UINT32, PROTOBUF_C_TYPE_FIXED32, PROTOBUF_C_TYPE_UINT64,
22 PROTOBUF_C_TYPE_FIXED64, PROTOBUF_C_TYPE_FLOAT, PROTOBUF_C_TYPE_DOUBLE,
23 PROTOBUF_C_TYPE_BOOL, PROTOBUF_C_TYPE_ENUM, PROTOBUF_C_TYPE_STRING,
24 PROTOBUF_C_TYPE_BYTES, PROTOBUF_C_TYPE_MESSAGE,
27 typedef struct _ProtobufCBinaryData ProtobufCBinaryData;
28 struct _ProtobufCBinaryData
32 typedef struct _ProtobufCMessageDescriptor ProtobufCMessageDescriptor;
33 typedef struct _ProtobufCFieldDescriptor ProtobufCFieldDescriptor;
34 typedef struct _ProtobufCMessage ProtobufCMessage;
35 struct _ProtobufCFieldDescriptor
42 struct _ProtobufCMessageDescriptor
45 const ProtobufCFieldDescriptor *fields;
47 struct _ProtobufCMessage
49 const ProtobufCMessageDescriptor *descriptor;
53 PROTOBUF_C_WIRE_TYPE_VARINT, PROTOBUF_C_WIRE_TYPE_64BIT,
54 PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED, PROTOBUF_C_WIRE_TYPE_START_GROUP,
55 PROTOBUF_C_WIRE_TYPE_END_GROUP, PROTOBUF_C_WIRE_TYPE_32BIT
59 uint32_pack (uint32_t value, uint8_t * out)
73 binary_data_pack (const ProtobufCBinaryData * bd, uint8_t * out)
76 size_t rv = uint32_pack (len, out);
81 required_field_pack (const ProtobufCFieldDescriptor * field,
82 const void *member, uint8_t * out)
84 size_t rv = tag_pack (field->id, out);
87 case PROTOBUF_C_TYPE_BYTES:
89 const ProtobufCBinaryData *bd =
90 ((const ProtobufCBinaryData *) member);
91 out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
92 return rv + binary_data_pack (bd, out + rv);
94 case PROTOBUF_C_TYPE_MESSAGE:
96 out[0] |= PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED;
98 prefixed_message_pack (*(ProtobufCMessage * const *) member,
105 protobuf_c_message_pack (const ProtobufCMessage * message, uint8_t * out)
109 for (i = 0; i < message->descriptor->n_fields; i++)
111 const ProtobufCFieldDescriptor *field = message->descriptor->fields + i;
112 const void *member = ((const char *) message) + field->offset;
113 if (field->label == PROTOBUF_C_LABEL_REQUIRED)
114 rv += required_field_pack (field, member, out + rv);