• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* This file is generated by venus-protocol.  See vn_protocol_driver.h. */
2 
3 /*
4  * Copyright 2020 Google LLC
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef VN_PROTOCOL_DRIVER_CS_H
9 #define VN_PROTOCOL_DRIVER_CS_H
10 
11 #include <assert.h>
12 
13 /*
14  * These types/functions are expected
15  *
16  *   struct vn_cs_encoder
17  *   vn_cs_encoder_get_len
18  *   vn_cs_encoder_reserve
19  *   vn_cs_encoder_write
20  *
21  *   struct vn_cs_decoder
22  *   vn_cs_decoder_set_fatal
23  *   vn_cs_decoder_read
24  *   vn_cs_decoder_peek
25  *
26  *   vn_cs_handle_load_id
27  *   vn_cs_handle_store_id
28  */
29 #include "vn_cs.h"
30 
31 static inline void
vn_encode(struct vn_cs_encoder * enc,size_t size,const void * data,size_t data_size)32 vn_encode(struct vn_cs_encoder *enc, size_t size, const void *data, size_t data_size)
33 {
34    assert(size % 4 == 0);
35    /* TODO check if the generated code is optimal */
36    vn_cs_encoder_write(enc, size, data, data_size);
37 }
38 
39 static inline void
vn_decode(struct vn_cs_decoder * dec,size_t size,void * data,size_t data_size)40 vn_decode(struct vn_cs_decoder *dec, size_t size, void *data, size_t data_size)
41 {
42    assert(size % 4 == 0);
43    vn_cs_decoder_read(dec, size, data, data_size);
44 }
45 
46 #endif /* VN_PROTOCOL_DRIVER_CS_H */
47