QP/C  6.5.1
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_(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 
signed int int_fast8_t
fast at-least 8-bit signed int
Definition: stdint.h:35
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: stdint.h:29
QSPriv QS_priv_
Definition: qs.c:53
QSCtr used
number of bytes currently in the ring buffer
Definition: qs.h:1101
unsigned long long uint64_t
exact-width 64-bit unsigned int
Definition: stdint.h:32
Internal (package scope) QS/C interface.
uint8_t * buf
pointer to the start of the ring buffer
Definition: qs.h:1097
uint_fast16_t QSCtr
QS ring buffer counter and offset type.
Definition: qs.h:1076
uint8_t chksum
the checksum of the current record
Definition: qs.h:1103
QSCtr head
offset to where next byte will be inserted
Definition: qs.h:1099
#define QS_INSERT_ESC_BYTE(b_)
Internal QS macro to insert an escaped byte into the QS buffer.
Definition: qs_pkg.h:53
QSCtr end
offset of the end of the ring buffer
Definition: qs.h:1098