QP/C  6.7.0
qs_64bit.c
Go to the documentation of this file.
1 
40 #define QP_IMPL /* this is QP implementation */
41 #include "qs_port.h" /* QS port */
42 
43 #if (QS_OBJ_PTR_SIZE == 8) || (QS_FUN_PTR_SIZE == 8)
44 
45 #include "qs_pkg.h"
46 
47 /****************************************************************************/
51 void QS_u64_raw_(uint64_t d) {
52  uint8_t chksum = QS_priv_.chksum;
53  uint8_t *buf = QS_priv_.buf;
54  QSCtr head = QS_priv_.head;
55  QSCtr end = QS_priv_.end;
56  int_fast8_t i;
57 
58  QS_priv_.used += (QSCtr)8; /* 8 bytes are about to be added */
59  for (i = (int_fast8_t)8; i != (int_fast8_t)0; --i) {
60  uint8_t b = (uint8_t)d;
62  d >>= 8;
63  }
64 
65  QS_priv_.head = head; /* save the head */
66  QS_priv_.chksum = chksum; /* save the checksum */
67 }
68 
69 /****************************************************************************/
73 void QS_u64(uint8_t format, uint64_t d) {
74  uint8_t chksum = QS_priv_.chksum;
75  uint8_t *buf = QS_priv_.buf;
76  QSCtr head = QS_priv_.head;
77  QSCtr end = QS_priv_.end;
78  int_fast8_t i;
79 
80  QS_priv_.used += (QSCtr)9; /* 9 bytes are about to be added */
81  QS_INSERT_ESC_BYTE_(format) /* insert the format byte */
82 
83  /* output 8 bytes of data... */
84  for (i = (int_fast8_t)8; i != (int_fast8_t)0; --i) {
85  format = (uint8_t)d;
86  QS_INSERT_ESC_BYTE_(format)
87  d >>= 8;
88  }
89 
90  QS_priv_.head = head; /* save the head */
91  QS_priv_.chksum = chksum; /* save the checksum */
92 }
93 
94 #endif /* (QS_OBJ_PTR_SIZE == 8) || (QS_FUN_PTR_SIZE == 8) */
95 
uint8_t
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: stdint.h:30
int_fast8_t
signed int int_fast8_t
fast at-least 8-bit signed int
Definition: stdint.h:36
QS_INSERT_ESC_BYTE_
#define QS_INSERT_ESC_BYTE_(b_)
Internal QS macro to insert an escaped byte into the QS buffer.
Definition: qs_pkg.h:58
QSCtr
uint_fast16_t QSCtr
QS ring buffer counter and offset type.
Definition: qs.h:1113
uint64_t
unsigned long long uint64_t
exact-width 64-bit unsigned int
Definition: stdint.h:33
QSPrivAttr::chksum
uint8_t chksum
the checksum of the current record
Definition: qs.h:1140
qs_pkg.h
Internal (package scope) QS/C interface.
QSPrivAttr::used
QSCtr used
number of bytes currently in the ring buffer
Definition: qs.h:1138
QSPrivAttr::buf
uint8_t * buf
pointer to the start of the ring buffer
Definition: qs.h:1134
QSPrivAttr::head
QSCtr head
offset to where next byte will be inserted
Definition: qs.h:1136
QS_priv_
QSPrivAttr QS_priv_
Definition: qs.c:49
QSPrivAttr::end
QSCtr end
offset of the end of the ring buffer
Definition: qs.h:1135