mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
deps: update nghttp3 to 1.17.0
PR-URL: https://github.com/nodejs/node/pull/64182 Backport-PR-URL: https://github.com/nodejs/node/pull/64675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tim Perry <pimterry@gmail.com>
This commit is contained in:
1 parent
345d6ad4eb
commit
e3304cd31a
13 files changed
+4351
-4265
No files matched your search
@@ -2625,6 +2625,25 @@ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_writev_stream(nghttp3_conn *conn,
|
||||
NGHTTP3_EXTERN int nghttp3_conn_add_write_offset(nghttp3_conn *conn,
|
||||
int64_t stream_id, size_t n);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* `nghttp3_conn_is_stream_flushed` returns nonzero if all stream data
|
||||
* for a stream identified by |stream_id| so far have been accepted by
|
||||
* QUIC stack. This means that the cumulative number of bytes that
|
||||
* `nghttp3_conn_add_write_offset` notified covers all stream data
|
||||
* currently held. This does not mean more stream data cannot be
|
||||
* submitted to this stream via :type:`nghttp3_read_data_callback` and
|
||||
* all stream data have been acknowledged.
|
||||
*
|
||||
* If there is no stream identified by |stream_id|, this function
|
||||
* returns nonzero.
|
||||
*
|
||||
* .. version-added:: 1.17.0
|
||||
*/
|
||||
NGHTTP3_EXTERN int nghttp3_conn_is_stream_flushed(const nghttp3_conn *conn,
|
||||
int64_t stream_id);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
@@ -3418,6 +3437,75 @@ NGHTTP3_EXTERN const nghttp3_info *nghttp3_version(int least_version);
|
||||
*/
|
||||
NGHTTP3_EXTERN int nghttp3_err_is_fatal(int liberr);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* `nghttp3_get_uvarint` reads variable-length unsigned integer from
|
||||
* the buffer pointed by |p|, and stores it in the object pointed by
|
||||
* |dest| in host byte order. It returns |p| plus the number of bytes
|
||||
* read from |p|. This function assumes that |p| points to the buffer
|
||||
* that contains a valid variable-length unsigned integer. Use
|
||||
* `nghttp3_get_uvarintlen` to get the number of bytes to successfully
|
||||
* decode an integer.
|
||||
*
|
||||
* .. version-added:: 1.17.0
|
||||
*/
|
||||
NGHTTP3_EXTERN const uint8_t *nghttp3_get_uvarint(uint64_t *dest,
|
||||
const uint8_t *p);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* `nghttp3_get_uvarintlen` returns the required number of bytes to
|
||||
* read variable-length unsigned integer starting at |p|. |p| must
|
||||
* not be NULL. This function only reads the single byte from the
|
||||
* buffer pointed by |p|, and determines the number of bytes to read.
|
||||
*
|
||||
* .. version-added:: 1.17.0
|
||||
*/
|
||||
NGHTTP3_EXTERN size_t nghttp3_get_uvarintlen(const uint8_t *p);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* `nghttp3_get_varint` reads variable-length unsigned integer from
|
||||
* the buffer pointed by |p|, and stores it in the object pointed by
|
||||
* |dest| in host byte order. It returns |p| plus the number of bytes
|
||||
* read from |p|. This function assumes that |p| points to the buffer
|
||||
* that contains a valid variable-length unsigned integer. Use
|
||||
* `nghttp3_get_uvarintlen` to get the number of bytes to successfully
|
||||
* decode an integer.
|
||||
*
|
||||
* .. version-added:: 1.17.0
|
||||
*/
|
||||
NGHTTP3_EXTERN const uint8_t *nghttp3_get_varint(int64_t *dest,
|
||||
const uint8_t *p);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* `nghttp3_put_uvarint` writes |n| to the buffer pointed by |p| using
|
||||
* variable-length unsigned integer encoding. It returns the one
|
||||
* beyond of the last written position. This function assumes that
|
||||
* the buffer pointed by |p| has sufficient capacity to encode |n|.
|
||||
* To know the required capacity, use `nghttp3_put_uvarintlen`. |n|
|
||||
* must be less than or equal to (1 << 62) - 1.
|
||||
*
|
||||
* .. version-added:: 1.17.0
|
||||
*/
|
||||
NGHTTP3_EXTERN uint8_t *nghttp3_put_uvarint(uint8_t *p, uint64_t n);
|
||||
|
||||
/**
|
||||
* @function
|
||||
*
|
||||
* `nghttp3_put_uvarintlen` returns the required number of bytes to
|
||||
* encode |n| in variable-length unsigned integer encoding. |n| must
|
||||
* be less than or equal to (1 << 62) - 1.
|
||||
*
|
||||
* .. version-added:: 1.17.0
|
||||
*/
|
||||
NGHTTP3_EXTERN size_t nghttp3_put_uvarintlen(uint64_t n);
|
||||
|
||||
/*
|
||||
* Versioned function wrappers
|
||||
*/
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* Version number of the nghttp3 library release.
|
||||
*/
|
||||
#define NGHTTP3_VERSION "1.16.0"
|
||||
#define NGHTTP3_VERSION "1.17.0"
|
||||
|
||||
/**
|
||||
* @macro
|
||||
@@ -41,6 +41,6 @@
|
||||
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
|
||||
* becomes 0x010203.
|
||||
*/
|
||||
#define NGHTTP3_VERSION_NUM 0x011000
|
||||
#define NGHTTP3_VERSION_NUM 0x011100
|
||||
|
||||
#endif /* !defined(NGHTTP3_VERSION_H) */
|
||||
+22
@@ -2979,3 +2979,25 @@ int nghttp3_conn_is_drained2(const nghttp3_conn *conn) {
|
||||
nghttp3_stream_outq_write_done(conn->tx.ctrl) &&
|
||||
nghttp3_ringbuf_len(&conn->tx.ctrl->frq) == 0;
|
||||
}
|
||||
|
||||
int nghttp3_conn_is_stream_flushed(const nghttp3_conn *conn,
|
||||
int64_t stream_id) {
|
||||
nghttp3_stream *stream = nghttp3_conn_find_stream(conn, stream_id);
|
||||
const nghttp3_frame *fr;
|
||||
|
||||
if (!stream) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!nghttp3_stream_outq_write_done(stream)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (nghttp3_ringbuf_len(&stream->frq) == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
fr = nghttp3_ringbuf_get(&stream->frq, 0);
|
||||
|
||||
return fr->hd.type == NGHTTP3_FRAME_DATA;
|
||||
}
|
||||
+9
@@ -70,6 +70,15 @@ size_t nghttp3_get_uvarintlen(const uint8_t *p) {
|
||||
return (size_t)(1U << (*p >> 6));
|
||||
}
|
||||
|
||||
const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p) {
|
||||
uint64_t n;
|
||||
|
||||
p = nghttp3_get_uvarint(&n, p);
|
||||
*dest = (int64_t)n;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
uint8_t *nghttp3_put_uint64be(uint8_t *p, uint64_t n) {
|
||||
n = nghttp3_htonl64(n);
|
||||
return nghttp3_cpymem(p, (const uint8_t *)&n, sizeof(n));
|
||||
|
||||
-40
@@ -92,34 +92,6 @@
|
||||
# define ntohs(N) _byteswap_ushort(N)
|
||||
#endif /* defined(WIN32) */
|
||||
|
||||
/*
|
||||
* nghttp3_get_uvarint reads variable-length unsigned integer from
|
||||
* |p|, and stores it in the buffer pointed by |dest| in host byte
|
||||
* order. It returns |p| plus the number of bytes read from |p|.
|
||||
*/
|
||||
const uint8_t *nghttp3_get_uvarint(uint64_t *dest, const uint8_t *p);
|
||||
|
||||
/*
|
||||
* nghttp3_get_uvarintlen returns the required number of bytes to read
|
||||
* variable-length integer starting at |p|.
|
||||
*/
|
||||
size_t nghttp3_get_uvarintlen(const uint8_t *p);
|
||||
|
||||
/*
|
||||
* nghttp3_get_varint reads variable-length unsigned integer from |p|,
|
||||
* and stores it in the buffer pointed by |dest| in host byte order.
|
||||
* It returns |p| plus the number of bytes read from |p|.
|
||||
*/
|
||||
static inline const uint8_t *nghttp3_get_varint(int64_t *dest,
|
||||
const uint8_t *p) {
|
||||
uint64_t n;
|
||||
|
||||
p = nghttp3_get_uvarint(&n, p);
|
||||
*dest = (int64_t)n;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* nghttp3_put_uint64be writes |n| in host byte order in |p| in
|
||||
* network byte order. It returns the one beyond of the last written
|
||||
@@ -141,18 +113,6 @@ uint8_t *nghttp3_put_uint32be(uint8_t *p, uint32_t n);
|
||||
*/
|
||||
uint8_t *nghttp3_put_uint16be(uint8_t *p, uint16_t n);
|
||||
|
||||
/*
|
||||
* nghttp3_put_uvarint writes |n| in |p| using variable-length integer
|
||||
* encoding. It returns the one beyond of the last written position.
|
||||
*/
|
||||
uint8_t *nghttp3_put_uvarint(uint8_t *p, uint64_t n);
|
||||
|
||||
/*
|
||||
* nghttp3_put_uvarintlen returns the required number of bytes to
|
||||
* encode |n|.
|
||||
*/
|
||||
size_t nghttp3_put_uvarintlen(uint64_t n);
|
||||
|
||||
/*
|
||||
* nghttp3_ord_stream_id returns the ordinal number of |stream_id|.
|
||||
*/
|
||||
|
||||
+3
-6
@@ -36,12 +36,9 @@
|
||||
#include "nghttp3_macro.h"
|
||||
#include "nghttp3_conv.h"
|
||||
#include "nghttp3_unreachable.h"
|
||||
#include "nghttp3_str.h"
|
||||
#include "sfparse/sfparse.h"
|
||||
|
||||
static uint8_t downcase(uint8_t c) {
|
||||
return 'A' <= c && c <= 'Z' ? (uint8_t)(c - 'A' + 'a') : c;
|
||||
}
|
||||
|
||||
/*
|
||||
* memieq returns 1 if the data pointed by |a| of length |n| equals to
|
||||
* |b| of the same length in case-insensitive manner. The data
|
||||
@@ -52,7 +49,7 @@ static int memieq(const void *a, const void *b, size_t n) {
|
||||
const uint8_t *aa = a, *bb = b;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (aa[i] != downcase(bb[i])) {
|
||||
if (aa[i] != nghttp3_downcase_byte(bb[i])) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -704,7 +701,7 @@ int nghttp3_check_header_name(const uint8_t *name, size_t len) {
|
||||
--len;
|
||||
}
|
||||
for (last = name + len; name != last; ++name) {
|
||||
if (!VALID_HD_NAME_CHARS[*name]) {
|
||||
if (VALID_HD_NAME_CHARS[*name] != 1) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -80,7 +80,7 @@ uint8_t *nghttp3_qpack_huffman_encode(uint8_t *dest, const uint8_t *src,
|
||||
void nghttp3_qpack_huffman_decode_context_init(
|
||||
nghttp3_qpack_huffman_decode_context *ctx) {
|
||||
*ctx = (nghttp3_qpack_huffman_decode_context){
|
||||
.flags = NGHTTP3_QPACK_HUFFMAN_ACCEPTED,
|
||||
.flags = NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,12 +103,12 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_decode_context *ctx,
|
||||
for (; src != end;) {
|
||||
c = *src++;
|
||||
t = qpack_huffman_decode_table[t.fstate][c >> 4];
|
||||
if (t.flags & NGHTTP3_QPACK_HUFFMAN_SYM) {
|
||||
if (t.flags & NGHTTP3_QPACK_HUFFMAN_FLAG_SYM) {
|
||||
*p++ = t.sym;
|
||||
}
|
||||
|
||||
t = qpack_huffman_decode_table[t.fstate][c & 0xFU];
|
||||
if (t.flags & NGHTTP3_QPACK_HUFFMAN_SYM) {
|
||||
if (t.flags & NGHTTP3_QPACK_HUFFMAN_FLAG_SYM) {
|
||||
*p++ = t.sym;
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_decode_context *ctx,
|
||||
ctx->fstate = t.fstate;
|
||||
ctx->flags = t.flags;
|
||||
|
||||
if (fin && !(ctx->flags & NGHTTP3_QPACK_HUFFMAN_ACCEPTED)) {
|
||||
if (fin && !(ctx->flags & NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED)) {
|
||||
return NGHTTP3_ERR_QPACK_FATAL;
|
||||
}
|
||||
|
||||
|
||||
+12
-13
@@ -46,25 +46,24 @@ size_t nghttp3_qpack_huffman_encode_count(const uint8_t *src, size_t len);
|
||||
uint8_t *nghttp3_qpack_huffman_encode(uint8_t *dest, const uint8_t *src,
|
||||
size_t srclen);
|
||||
|
||||
typedef enum nghttp3_qpack_huffman_decode_flag {
|
||||
/* FSA accepts this state as the end of huffman encoding
|
||||
sequence. */
|
||||
NGHTTP3_QPACK_HUFFMAN_ACCEPTED = 1,
|
||||
/* This state emits symbol */
|
||||
NGHTTP3_QPACK_HUFFMAN_SYM = 1 << 1,
|
||||
} nghttp3_qpack_huffman_decode_flag;
|
||||
/* NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED indicates that FSA accepts this
|
||||
state as the end of huffman encoding sequence. */
|
||||
#define NGHTTP3_QPACK_HUFFMAN_FLAG_ACCEPTED 0x01U
|
||||
/* NGHTTP3_QPACK_HUFFMAN_FLAG_SYM indicates that this state emits
|
||||
symbol */
|
||||
#define NGHTTP3_QPACK_HUFFMAN_FLAG_SYM 0x02U
|
||||
|
||||
typedef struct nghttp3_qpack_huffman_decode_node {
|
||||
/* fstate is the current huffman decoding state, which is actually
|
||||
the node ID of internal huffman tree with
|
||||
nghttp3_qpack_huffman_decode_flag OR-ed. We have 257 leaf nodes,
|
||||
but they are identical to root node other than emitting a symbol,
|
||||
so we have 256 internal nodes [1..256], inclusive. The node ID
|
||||
256 is a special node and it is a terminal state that means
|
||||
decoding failed. */
|
||||
NGHTTP3_QPACK_HUFFMAN_FLAG_* flags OR-ed. We have 257 leaf
|
||||
nodes, but they are identical to root node other than emitting a
|
||||
symbol, so we have 256 internal nodes [1..256], inclusive. The
|
||||
node ID 256 is a special node and it is a terminal state that
|
||||
means decoding failed. */
|
||||
uint16_t fstate;
|
||||
uint8_t flags;
|
||||
/* symbol if NGHTTP3_QPACK_HUFFMAN_SYM flag set */
|
||||
/* symbol if NGHTTP3_QPACK_HUFFMAN_FLAG_SYM flag set */
|
||||
uint8_t sym;
|
||||
} nghttp3_qpack_huffman_decode_node;
|
||||
|
||||
|
||||
+4114
-4113
File diff suppressed because it is too large.
Load diff
+66
-66
@@ -35,76 +35,76 @@ uint8_t *nghttp3_cpymem(uint8_t *dest, const uint8_t *src, size_t n) {
|
||||
}
|
||||
|
||||
/* Generated by gendowncasetbl.py */
|
||||
static const uint8_t DOWNCASE_TBL[] = {
|
||||
0 /* NUL */, 1 /* SOH */, 2 /* STX */, 3 /* ETX */,
|
||||
4 /* EOT */, 5 /* ENQ */, 6 /* ACK */, 7 /* BEL */,
|
||||
8 /* BS */, 9 /* HT */, 10 /* LF */, 11 /* VT */,
|
||||
12 /* FF */, 13 /* CR */, 14 /* SO */, 15 /* SI */,
|
||||
16 /* DLE */, 17 /* DC1 */, 18 /* DC2 */, 19 /* DC3 */,
|
||||
20 /* DC4 */, 21 /* NAK */, 22 /* SYN */, 23 /* ETB */,
|
||||
24 /* CAN */, 25 /* EM */, 26 /* SUB */, 27 /* ESC */,
|
||||
28 /* FS */, 29 /* GS */, 30 /* RS */, 31 /* US */,
|
||||
32 /* SPC */, 33 /* ! */, 34 /* " */, 35 /* # */,
|
||||
36 /* $ */, 37 /* % */, 38 /* & */, 39 /* ' */,
|
||||
40 /* ( */, 41 /* ) */, 42 /* * */, 43 /* + */,
|
||||
44 /* , */, 45 /* - */, 46 /* . */, 47 /* / */,
|
||||
48 /* 0 */, 49 /* 1 */, 50 /* 2 */, 51 /* 3 */,
|
||||
52 /* 4 */, 53 /* 5 */, 54 /* 6 */, 55 /* 7 */,
|
||||
56 /* 8 */, 57 /* 9 */, 58 /* : */, 59 /* ; */,
|
||||
60 /* < */, 61 /* = */, 62 /* > */, 63 /* ? */,
|
||||
64 /* @ */, 97 /* A */, 98 /* B */, 99 /* C */,
|
||||
100 /* D */, 101 /* E */, 102 /* F */, 103 /* G */,
|
||||
104 /* H */, 105 /* I */, 106 /* J */, 107 /* K */,
|
||||
108 /* L */, 109 /* M */, 110 /* N */, 111 /* O */,
|
||||
112 /* P */, 113 /* Q */, 114 /* R */, 115 /* S */,
|
||||
116 /* T */, 117 /* U */, 118 /* V */, 119 /* W */,
|
||||
120 /* X */, 121 /* Y */, 122 /* Z */, 91 /* [ */,
|
||||
92 /* \ */, 93 /* ] */, 94 /* ^ */, 95 /* _ */,
|
||||
96 /* ` */, 97 /* a */, 98 /* b */, 99 /* c */,
|
||||
100 /* d */, 101 /* e */, 102 /* f */, 103 /* g */,
|
||||
104 /* h */, 105 /* i */, 106 /* j */, 107 /* k */,
|
||||
108 /* l */, 109 /* m */, 110 /* n */, 111 /* o */,
|
||||
112 /* p */, 113 /* q */, 114 /* r */, 115 /* s */,
|
||||
116 /* t */, 117 /* u */, 118 /* v */, 119 /* w */,
|
||||
120 /* x */, 121 /* y */, 122 /* z */, 123 /* { */,
|
||||
124 /* | */, 125 /* } */, 126 /* ~ */, 127 /* DEL */,
|
||||
128 /* 0x80 */, 129 /* 0x81 */, 130 /* 0x82 */, 131 /* 0x83 */,
|
||||
132 /* 0x84 */, 133 /* 0x85 */, 134 /* 0x86 */, 135 /* 0x87 */,
|
||||
136 /* 0x88 */, 137 /* 0x89 */, 138 /* 0x8A */, 139 /* 0x8B */,
|
||||
140 /* 0x8C */, 141 /* 0x8D */, 142 /* 0x8E */, 143 /* 0x8F */,
|
||||
144 /* 0x90 */, 145 /* 0x91 */, 146 /* 0x92 */, 147 /* 0x93 */,
|
||||
148 /* 0x94 */, 149 /* 0x95 */, 150 /* 0x96 */, 151 /* 0x97 */,
|
||||
152 /* 0x98 */, 153 /* 0x99 */, 154 /* 0x9A */, 155 /* 0x9B */,
|
||||
156 /* 0x9C */, 157 /* 0x9D */, 158 /* 0x9E */, 159 /* 0x9F */,
|
||||
160 /* 0xA0 */, 161 /* 0xA1 */, 162 /* 0xA2 */, 163 /* 0xA3 */,
|
||||
164 /* 0xA4 */, 165 /* 0xA5 */, 166 /* 0xA6 */, 167 /* 0xA7 */,
|
||||
168 /* 0xA8 */, 169 /* 0xA9 */, 170 /* 0xAA */, 171 /* 0xAB */,
|
||||
172 /* 0xAC */, 173 /* 0xAD */, 174 /* 0xAE */, 175 /* 0xAF */,
|
||||
176 /* 0xB0 */, 177 /* 0xB1 */, 178 /* 0xB2 */, 179 /* 0xB3 */,
|
||||
180 /* 0xB4 */, 181 /* 0xB5 */, 182 /* 0xB6 */, 183 /* 0xB7 */,
|
||||
184 /* 0xB8 */, 185 /* 0xB9 */, 186 /* 0xBA */, 187 /* 0xBB */,
|
||||
188 /* 0xBC */, 189 /* 0xBD */, 190 /* 0xBE */, 191 /* 0xBF */,
|
||||
192 /* 0xC0 */, 193 /* 0xC1 */, 194 /* 0xC2 */, 195 /* 0xC3 */,
|
||||
196 /* 0xC4 */, 197 /* 0xC5 */, 198 /* 0xC6 */, 199 /* 0xC7 */,
|
||||
200 /* 0xC8 */, 201 /* 0xC9 */, 202 /* 0xCA */, 203 /* 0xCB */,
|
||||
204 /* 0xCC */, 205 /* 0xCD */, 206 /* 0xCE */, 207 /* 0xCF */,
|
||||
208 /* 0xD0 */, 209 /* 0xD1 */, 210 /* 0xD2 */, 211 /* 0xD3 */,
|
||||
212 /* 0xD4 */, 213 /* 0xD5 */, 214 /* 0xD6 */, 215 /* 0xD7 */,
|
||||
216 /* 0xD8 */, 217 /* 0xD9 */, 218 /* 0xDA */, 219 /* 0xDB */,
|
||||
220 /* 0xDC */, 221 /* 0xDD */, 222 /* 0xDE */, 223 /* 0xDF */,
|
||||
224 /* 0xE0 */, 225 /* 0xE1 */, 226 /* 0xE2 */, 227 /* 0xE3 */,
|
||||
228 /* 0xE4 */, 229 /* 0xE5 */, 230 /* 0xE6 */, 231 /* 0xE7 */,
|
||||
232 /* 0xE8 */, 233 /* 0xE9 */, 234 /* 0xEA */, 235 /* 0xEB */,
|
||||
236 /* 0xEC */, 237 /* 0xED */, 238 /* 0xEE */, 239 /* 0xEF */,
|
||||
240 /* 0xF0 */, 241 /* 0xF1 */, 242 /* 0xF2 */, 243 /* 0xF3 */,
|
||||
244 /* 0xF4 */, 245 /* 0xF5 */, 246 /* 0xF6 */, 247 /* 0xF7 */,
|
||||
248 /* 0xF8 */, 249 /* 0xF9 */, 250 /* 0xFA */, 251 /* 0xFB */,
|
||||
252 /* 0xFC */, 253 /* 0xFD */, 254 /* 0xFE */, 255 /* 0xFF */,
|
||||
const uint8_t nghttp3_downcase_tbl[] = {
|
||||
0x00 /* NUL */, 0x01 /* SOH */, 0x02 /* STX */, 0x03 /* ETX */,
|
||||
0x04 /* EOT */, 0x05 /* ENQ */, 0x06 /* ACK */, 0x07 /* BEL */,
|
||||
0x08 /* BS */, 0x09 /* HT */, 0x0A /* LF */, 0x0B /* VT */,
|
||||
0x0C /* FF */, 0x0D /* CR */, 0x0E /* SO */, 0x0F /* SI */,
|
||||
0x10 /* DLE */, 0x11 /* DC1 */, 0x12 /* DC2 */, 0x13 /* DC3 */,
|
||||
0x14 /* DC4 */, 0x15 /* NAK */, 0x16 /* SYN */, 0x17 /* ETB */,
|
||||
0x18 /* CAN */, 0x19 /* EM */, 0x1A /* SUB */, 0x1B /* ESC */,
|
||||
0x1C /* FS */, 0x1D /* GS */, 0x1E /* RS */, 0x1F /* US */,
|
||||
0x20 /* SPC */, 0x21 /* ! */, 0x22 /* " */, 0x23 /* # */,
|
||||
0x24 /* $ */, 0x25 /* % */, 0x26 /* & */, 0x27 /* ' */,
|
||||
0x28 /* ( */, 0x29 /* ) */, 0x2A /* * */, 0x2B /* + */,
|
||||
0x2C /* , */, 0x2D /* - */, 0x2E /* . */, 0x2F /* / */,
|
||||
0x30 /* 0 */, 0x31 /* 1 */, 0x32 /* 2 */, 0x33 /* 3 */,
|
||||
0x34 /* 4 */, 0x35 /* 5 */, 0x36 /* 6 */, 0x37 /* 7 */,
|
||||
0x38 /* 8 */, 0x39 /* 9 */, 0x3A /* : */, 0x3B /* ; */,
|
||||
0x3C /* < */, 0x3D /* = */, 0x3E /* > */, 0x3F /* ? */,
|
||||
0x40 /* @ */, 0x61 /* A */, 0x62 /* B */, 0x63 /* C */,
|
||||
0x64 /* D */, 0x65 /* E */, 0x66 /* F */, 0x67 /* G */,
|
||||
0x68 /* H */, 0x69 /* I */, 0x6A /* J */, 0x6B /* K */,
|
||||
0x6C /* L */, 0x6D /* M */, 0x6E /* N */, 0x6F /* O */,
|
||||
0x70 /* P */, 0x71 /* Q */, 0x72 /* R */, 0x73 /* S */,
|
||||
0x74 /* T */, 0x75 /* U */, 0x76 /* V */, 0x77 /* W */,
|
||||
0x78 /* X */, 0x79 /* Y */, 0x7A /* Z */, 0x5B /* [ */,
|
||||
0x5C /* \ */, 0x5D /* ] */, 0x5E /* ^ */, 0x5F /* _ */,
|
||||
0x60 /* ` */, 0x61 /* a */, 0x62 /* b */, 0x63 /* c */,
|
||||
0x64 /* d */, 0x65 /* e */, 0x66 /* f */, 0x67 /* g */,
|
||||
0x68 /* h */, 0x69 /* i */, 0x6A /* j */, 0x6B /* k */,
|
||||
0x6C /* l */, 0x6D /* m */, 0x6E /* n */, 0x6F /* o */,
|
||||
0x70 /* p */, 0x71 /* q */, 0x72 /* r */, 0x73 /* s */,
|
||||
0x74 /* t */, 0x75 /* u */, 0x76 /* v */, 0x77 /* w */,
|
||||
0x78 /* x */, 0x79 /* y */, 0x7A /* z */, 0x7B /* { */,
|
||||
0x7C /* | */, 0x7D /* } */, 0x7E /* ~ */, 0x7F /* DEL */,
|
||||
0x80 /* 0x80 */, 0x81 /* 0x81 */, 0x82 /* 0x82 */, 0x83 /* 0x83 */,
|
||||
0x84 /* 0x84 */, 0x85 /* 0x85 */, 0x86 /* 0x86 */, 0x87 /* 0x87 */,
|
||||
0x88 /* 0x88 */, 0x89 /* 0x89 */, 0x8A /* 0x8A */, 0x8B /* 0x8B */,
|
||||
0x8C /* 0x8C */, 0x8D /* 0x8D */, 0x8E /* 0x8E */, 0x8F /* 0x8F */,
|
||||
0x90 /* 0x90 */, 0x91 /* 0x91 */, 0x92 /* 0x92 */, 0x93 /* 0x93 */,
|
||||
0x94 /* 0x94 */, 0x95 /* 0x95 */, 0x96 /* 0x96 */, 0x97 /* 0x97 */,
|
||||
0x98 /* 0x98 */, 0x99 /* 0x99 */, 0x9A /* 0x9A */, 0x9B /* 0x9B */,
|
||||
0x9C /* 0x9C */, 0x9D /* 0x9D */, 0x9E /* 0x9E */, 0x9F /* 0x9F */,
|
||||
0xA0 /* 0xA0 */, 0xA1 /* 0xA1 */, 0xA2 /* 0xA2 */, 0xA3 /* 0xA3 */,
|
||||
0xA4 /* 0xA4 */, 0xA5 /* 0xA5 */, 0xA6 /* 0xA6 */, 0xA7 /* 0xA7 */,
|
||||
0xA8 /* 0xA8 */, 0xA9 /* 0xA9 */, 0xAA /* 0xAA */, 0xAB /* 0xAB */,
|
||||
0xAC /* 0xAC */, 0xAD /* 0xAD */, 0xAE /* 0xAE */, 0xAF /* 0xAF */,
|
||||
0xB0 /* 0xB0 */, 0xB1 /* 0xB1 */, 0xB2 /* 0xB2 */, 0xB3 /* 0xB3 */,
|
||||
0xB4 /* 0xB4 */, 0xB5 /* 0xB5 */, 0xB6 /* 0xB6 */, 0xB7 /* 0xB7 */,
|
||||
0xB8 /* 0xB8 */, 0xB9 /* 0xB9 */, 0xBA /* 0xBA */, 0xBB /* 0xBB */,
|
||||
0xBC /* 0xBC */, 0xBD /* 0xBD */, 0xBE /* 0xBE */, 0xBF /* 0xBF */,
|
||||
0xC0 /* 0xC0 */, 0xC1 /* 0xC1 */, 0xC2 /* 0xC2 */, 0xC3 /* 0xC3 */,
|
||||
0xC4 /* 0xC4 */, 0xC5 /* 0xC5 */, 0xC6 /* 0xC6 */, 0xC7 /* 0xC7 */,
|
||||
0xC8 /* 0xC8 */, 0xC9 /* 0xC9 */, 0xCA /* 0xCA */, 0xCB /* 0xCB */,
|
||||
0xCC /* 0xCC */, 0xCD /* 0xCD */, 0xCE /* 0xCE */, 0xCF /* 0xCF */,
|
||||
0xD0 /* 0xD0 */, 0xD1 /* 0xD1 */, 0xD2 /* 0xD2 */, 0xD3 /* 0xD3 */,
|
||||
0xD4 /* 0xD4 */, 0xD5 /* 0xD5 */, 0xD6 /* 0xD6 */, 0xD7 /* 0xD7 */,
|
||||
0xD8 /* 0xD8 */, 0xD9 /* 0xD9 */, 0xDA /* 0xDA */, 0xDB /* 0xDB */,
|
||||
0xDC /* 0xDC */, 0xDD /* 0xDD */, 0xDE /* 0xDE */, 0xDF /* 0xDF */,
|
||||
0xE0 /* 0xE0 */, 0xE1 /* 0xE1 */, 0xE2 /* 0xE2 */, 0xE3 /* 0xE3 */,
|
||||
0xE4 /* 0xE4 */, 0xE5 /* 0xE5 */, 0xE6 /* 0xE6 */, 0xE7 /* 0xE7 */,
|
||||
0xE8 /* 0xE8 */, 0xE9 /* 0xE9 */, 0xEA /* 0xEA */, 0xEB /* 0xEB */,
|
||||
0xEC /* 0xEC */, 0xED /* 0xED */, 0xEE /* 0xEE */, 0xEF /* 0xEF */,
|
||||
0xF0 /* 0xF0 */, 0xF1 /* 0xF1 */, 0xF2 /* 0xF2 */, 0xF3 /* 0xF3 */,
|
||||
0xF4 /* 0xF4 */, 0xF5 /* 0xF5 */, 0xF6 /* 0xF6 */, 0xF7 /* 0xF7 */,
|
||||
0xF8 /* 0xF8 */, 0xF9 /* 0xF9 */, 0xFA /* 0xFA */, 0xFB /* 0xFB */,
|
||||
0xFC /* 0xFC */, 0xFD /* 0xFD */, 0xFE /* 0xFE */, 0xFF /* 0xFF */,
|
||||
};
|
||||
|
||||
void nghttp3_downcase(uint8_t *s, size_t len) {
|
||||
size_t i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
s[i] = DOWNCASE_TBL[s[i]];
|
||||
s[i] = nghttp3_downcase_byte(s[i]);
|
||||
}
|
||||
}
|
||||
+10
@@ -37,4 +37,14 @@ uint8_t *nghttp3_cpymem(uint8_t *dest, const uint8_t *src, size_t n);
|
||||
|
||||
void nghttp3_downcase(uint8_t *s, size_t len);
|
||||
|
||||
extern const uint8_t nghttp3_downcase_tbl[];
|
||||
|
||||
/*
|
||||
* nghttp3_downcase_byte returns the lower case version of |c| if 'A'
|
||||
* <= |c| && |c| <= 'Z'. Otherwise, it returns |c|.
|
||||
*/
|
||||
static inline uint8_t nghttp3_downcase_byte(uint8_t c) {
|
||||
return nghttp3_downcase_tbl[c];
|
||||
}
|
||||
|
||||
#endif /* !defined(NGHTTP3_STR_H) */
|
||||
+19
-19
@@ -34,18 +34,18 @@
|
||||
# include <immintrin.h>
|
||||
#endif /* __AVX2__ */
|
||||
|
||||
#define SFPARSE_STATE_DICT 0x08u
|
||||
#define SFPARSE_STATE_LIST 0x10u
|
||||
#define SFPARSE_STATE_ITEM 0x18u
|
||||
#define SFPARSE_STATE_DICT 0x08U
|
||||
#define SFPARSE_STATE_LIST 0x10U
|
||||
#define SFPARSE_STATE_ITEM 0x18U
|
||||
|
||||
#define SFPARSE_STATE_INNER_LIST 0x04u
|
||||
#define SFPARSE_STATE_INNER_LIST 0x04U
|
||||
|
||||
#define SFPARSE_STATE_BEFORE 0x00u
|
||||
#define SFPARSE_STATE_BEFORE_PARAMS 0x01u
|
||||
#define SFPARSE_STATE_PARAMS 0x02u
|
||||
#define SFPARSE_STATE_AFTER 0x03u
|
||||
#define SFPARSE_STATE_BEFORE 0x00U
|
||||
#define SFPARSE_STATE_BEFORE_PARAMS 0x01U
|
||||
#define SFPARSE_STATE_PARAMS 0x02U
|
||||
#define SFPARSE_STATE_AFTER 0x03U
|
||||
|
||||
#define SFPARSE_STATE_OP_MASK 0x03u
|
||||
#define SFPARSE_STATE_OP_MASK 0x03U
|
||||
|
||||
#define SFPARSE_SET_STATE_AFTER(NAME) \
|
||||
(SFPARSE_STATE_##NAME | SFPARSE_STATE_AFTER)
|
||||
@@ -69,7 +69,7 @@
|
||||
#define SFPARSE_STATE_ITEM_INNER_LIST_BEFORE \
|
||||
SFPARSE_SET_STATE_INNER_LIST_BEFORE(ITEM)
|
||||
|
||||
#define SFPARSE_STATE_INITIAL 0x00u
|
||||
#define SFPARSE_STATE_INITIAL 0x00U
|
||||
|
||||
#define LCALPHAS \
|
||||
['a'] = 1, ['b'] = 1, ['c'] = 1, ['d'] = 1, ['e'] = 1, ['f'] = 1, ['g'] = 1, \
|
||||
@@ -200,7 +200,7 @@ static int parser_key(sfparse_parser *sfp, sfparse_vec *dest) {
|
||||
|
||||
#ifdef __AVX2__
|
||||
if (sfp->end - sfp->pos >= 32) {
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1fu);
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1FU);
|
||||
|
||||
sfp->pos = find_char_key(sfp->pos, last);
|
||||
if (sfp->pos != last) {
|
||||
@@ -349,7 +349,7 @@ static const uint8_t *find_char_string(const uint8_t *first,
|
||||
const uint8_t *last) {
|
||||
const __m256i bs = _mm256_set1_epi8('\\');
|
||||
const __m256i dq = _mm256_set1_epi8('"');
|
||||
const __m256i del = _mm256_set1_epi8(0x7f);
|
||||
const __m256i del = _mm256_set1_epi8(0x7F);
|
||||
const __m256i sp = _mm256_set1_epi8(' ');
|
||||
__m256i s, x;
|
||||
uint32_t m;
|
||||
@@ -394,7 +394,7 @@ static int parser_string(sfparse_parser *sfp, sfparse_value *dest) {
|
||||
|
||||
#ifdef __AVX2__
|
||||
for (; sfp->end - sfp->pos >= 32; ++sfp->pos) {
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1fu);
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1FU);
|
||||
|
||||
sfp->pos = find_char_string(sfp->pos, last);
|
||||
if (sfp->pos == last) {
|
||||
@@ -541,7 +541,7 @@ static int parser_token(sfparse_parser *sfp, sfparse_value *dest) {
|
||||
|
||||
#ifdef __AVX2__
|
||||
if (sfp->end - sfp->pos >= 32) {
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1fu);
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1FU);
|
||||
|
||||
sfp->pos = find_char_token(sfp->pos, last);
|
||||
if (sfp->pos != last) {
|
||||
@@ -622,7 +622,7 @@ static int parser_byteseq(sfparse_parser *sfp, sfparse_value *dest) {
|
||||
|
||||
#ifdef __AVX2__
|
||||
if (sfp->end - sfp->pos >= 32) {
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1fu);
|
||||
last = sfp->pos + ((sfp->end - sfp->pos) & ~0x1FU);
|
||||
sfp->pos = find_char_byteseq(sfp->pos, last);
|
||||
}
|
||||
#endif /* __AVX2__ */
|
||||
@@ -1429,8 +1429,8 @@ void sfparse_base64decode(sfparse_vec *dest, const sfparse_vec *src) {
|
||||
}
|
||||
|
||||
*o++ = (uint8_t)(n >> 16);
|
||||
*o++ = (n >> 8) & 0xffu;
|
||||
*o++ = n & 0xffu;
|
||||
*o++ = (n >> 8) & 0xFFU;
|
||||
*o++ = n & 0xFFU;
|
||||
}
|
||||
|
||||
switch (left) {
|
||||
@@ -1467,8 +1467,8 @@ void sfparse_base64decode(sfparse_vec *dest, const sfparse_vec *src) {
|
||||
n = (uint32_t)(index_tbl[*p++] << 10);
|
||||
n += (uint32_t)(index_tbl[*p++] << 4);
|
||||
n += (uint32_t)(index_tbl[*p++] >> 2);
|
||||
*o++ = (n >> 8) & 0xffu;
|
||||
*o++ = n & 0xffu;
|
||||
*o++ = (n >> 8) & 0xFFU;
|
||||
*o++ = n & 0xFFU;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -130,7 +130,7 @@ typedef struct sfparse_vec {
|
||||
*
|
||||
* :macro:`SFPARSE_VALUE_FLAG_NONE` indicates no flag set.
|
||||
*/
|
||||
#define SFPARSE_VALUE_FLAG_NONE 0x0u
|
||||
#define SFPARSE_VALUE_FLAG_NONE 0x0U
|
||||
|
||||
/**
|
||||
* @macro
|
||||
@@ -138,7 +138,7 @@ typedef struct sfparse_vec {
|
||||
* :macro:`SFPARSE_VALUE_FLAG_ESCAPED_STRING` indicates that a string
|
||||
* contains escaped character(s).
|
||||
*/
|
||||
#define SFPARSE_VALUE_FLAG_ESCAPED_STRING 0x1u
|
||||
#define SFPARSE_VALUE_FLAG_ESCAPED_STRING 0x1U
|
||||
|
||||
/**
|
||||
* @struct
|
||||
|
||||
Reference in new issue
Block a user