Skip to content

Commit 5bee478

Browse files
robot-pigletmaVovk
authored andcommitted
Update contrib/restricted/aws/aws-c-common to 0.12.5
commit_hash:a5eea4b5dc9467a6e6ced7629b2f7f220e46408a
1 parent 7b27fb1 commit 5bee478

30 files changed

+692
-119
lines changed

contrib/restricted/aws/aws-c-common/.yandex_meta/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def post_install(self):
5959

6060
posix_srcs = []
6161
for src in sorted(m.SRCS):
62-
if "/posix/" in src:
62+
if ("/posix/" in src) or ("/linux" in src):
6363
m.SRCS.remove(src)
6464
posix_srcs.append(src)
6565

contrib/restricted/aws/aws-c-common/.yandex_meta/devtools.copyrights.report

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ BELONGS ya.make
154154
source/json.c [2:2]
155155
source/lifo_cache.c [2:2]
156156
source/linked_hash_table.c [2:2]
157+
source/linux/file_direct_io.c [2:2]
157158
source/linux/system_info.c [2:2]
158159
source/log_channel.c [2:2]
159160
source/log_formatter.c [2:2]

contrib/restricted/aws/aws-c-common/.yandex_meta/devtools.licenses.report

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ BELONGS ya.make
394394
source/json.c [3:3]
395395
source/lifo_cache.c [3:3]
396396
source/linked_hash_table.c [3:3]
397+
source/linux/file_direct_io.c [3:3]
397398
source/linux/system_info.c [3:3]
398399
source/log_channel.c [3:3]
399400
source/log_formatter.c [3:3]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
pkgs: attrs: with pkgs; with attrs; rec {
2-
version = "0.12.4";
2+
version = "0.12.5";
33

44
src = fetchFromGitHub {
55
owner = "awslabs";
66
repo = "aws-c-common";
77
rev = "v${version}";
8-
hash = "sha256-hKCIPZlLPyH7D3Derk2onyqTzWGUtCx+f2+EKtAKlwA=";
8+
hash = "sha256-NrKeDEI6TOFogqKQzRS25il9fU8XJ+swFLhqMVkDk2o=";
99
};
1010
}

contrib/restricted/aws/aws-c-common/THIRD-PARTY-LICENSES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434

3535
------
3636

37-
** cJSON; version 1.7.18 -- https://github.com/DaveGamble/cJSON
37+
** cJSON; version 1.7.19 -- https://github.com/DaveGamble/cJSON
3838
Copyright (c) 2009-2017 Dave Gamble and cJSON contributors
3939

4040
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -57,7 +57,7 @@ THE SOFTWARE.
5757

5858
------
5959

60-
** libcbor; version 0.12.0 -- https://github.com/PJK/libcbor
60+
** libcbor; version 0.13.0 -- https://github.com/PJK/libcbor
6161
Copyright (c) 2014-2017 Pavel Kalvoda
6262

6363
MIT License

contrib/restricted/aws/aws-c-common/include/aws/common/allocator.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,19 @@ size_t aws_small_block_allocator_page_size(struct aws_allocator *sba_allocator);
228228
AWS_COMMON_API
229229
size_t aws_small_block_allocator_page_size_available(struct aws_allocator *sba_allocator);
230230

231+
/*
232+
* Create an aligned allocator with an explicit alignment. Always align the allocated buffer with the passed-in
233+
* alignment value.
234+
*/
235+
AWS_COMMON_API
236+
struct aws_allocator *aws_explicit_aligned_allocator_new(size_t alignment);
237+
238+
/*
239+
* Destroys a customized aligned allocator instance and frees its memory.
240+
*/
241+
AWS_COMMON_API
242+
void aws_explicit_aligned_allocator_destroy(struct aws_allocator *aligned_alloc);
243+
231244
AWS_EXTERN_C_END
232245
AWS_POP_SANE_WARNING_LEVEL
233246

contrib/restricted/aws/aws-c-common/include/aws/common/file.h

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,66 @@ int aws_fseek(FILE *file, int64_t offset, int whence);
207207
AWS_COMMON_API
208208
int aws_file_get_length(FILE *file, int64_t *length);
209209

210-
AWS_EXTERN_C_END
211-
AWS_POP_SANE_WARNING_LEVEL
210+
/*
211+
* Read from the file using the file path with DIRECT I/O, starting at offset to fill the output_buf or to the
212+
* max_read_length.
213+
* Using direct IO to bypass the OS cache. Helpful when the disk I/O outperform the kernel cache.
214+
* If O_DIRECT is not supported, returns AWS_ERROR_UNSUPPORTED_OPERATION.
215+
* Notes:
216+
* - ONLY supports linux for now and raise AWS_ERROR_UNSUPPORTED_OPERATION on all other platforms (eg: FreeBSD).
217+
* - check the NOTES for O_DIRECT in https://man7.org/linux/man-pages/man2/openat.2.html
218+
* - The offset, length and output_buf->buffer all need to be aligned with the page size. Otherwise,
219+
* AWS_ERROR_INVALID_ARGUMENT will be raised.
220+
*
221+
* @param file_path The file path to read from.
222+
* @param offset The offset in the file to start reading from.
223+
* @param max_read_length The maximum number of bytes to read.
224+
* @param output_buf The buffer read to.
225+
* @param out_actual_read The actual number of bytes read.
226+
*
227+
* Returns AWS_OP_SUCCESS, or AWS_OP_ERR (after an error has been raised).
228+
*/
229+
AWS_COMMON_API
230+
int aws_file_path_read_from_offset_direct_io(
231+
const struct aws_string *file_path,
232+
uint64_t offset,
233+
size_t max_read_length,
234+
struct aws_byte_buf *output_buf,
235+
size_t *out_actual_read);
236+
237+
/*
238+
* Read from the file using the file path, starting at offset to fill the output_buf or to the
239+
* max_read_length.
240+
*
241+
* @param file_path The file path to read from.
242+
* @param offset The offset in the file to start reading from.
243+
* @param max_read_length The maximum number of bytes to read.
244+
* @param output_buf The buffer read to.
245+
* @param out_actual_read The actual number of bytes read.
246+
*
247+
* Returns AWS_OP_SUCCESS, or AWS_OP_ERR (after an error has been raised).
248+
*/
249+
AWS_COMMON_API
250+
int aws_file_path_read_from_offset(
251+
const struct aws_string *file_path,
252+
uint64_t offset,
253+
size_t max_read_length,
254+
struct aws_byte_buf *output_buf,
255+
size_t *out_actual_read);
256+
257+
/*
258+
* The function serve the same purpose as `aws_file_path_read_from_offset_direct_io`.
259+
* Please use `aws_file_path_read_from_offset_direct_io` directly.
260+
*/
261+
AWS_COMMON_API
262+
int aws_file_path_read_from_offset_direct_io_with_chunk_size(
263+
const struct aws_string *file_path,
264+
uint64_t offset,
265+
size_t max_read_length,
266+
size_t max_chunk_size,
267+
struct aws_byte_buf *output_buf,
268+
size_t *out_actual_read);
269+
270+
AWS_EXTERN_C_END AWS_POP_SANE_WARNING_LEVEL
212271

213272
#endif /* AWS_COMMON_FILE_H */

contrib/restricted/aws/aws-c-common/include/aws/common/system_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ enum aws_platform_os aws_get_platform_build_os(void);
7878
AWS_COMMON_API
7979
size_t aws_system_info_processor_count(void);
8080

81+
/* Returns the system page size in bytes. */
82+
AWS_COMMON_API
83+
size_t aws_system_info_page_size(void);
84+
8185
/**
8286
* Returns the logical processor groupings on the system (such as multiple numa nodes).
8387
*/

contrib/restricted/aws/aws-c-common/source/allocator.c

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,28 @@ bool aws_allocator_is_valid(const struct aws_allocator *alloc) {
3535
}
3636

3737
static void *s_aligned_malloc(struct aws_allocator *allocator, size_t size) {
38-
(void)allocator;
39-
/* larger allocations should be aligned so that AVX and friends can avoid
40-
* the extra preamble during unaligned versions of memcpy/memset on big buffers
41-
* This will also accelerate hardware CRC and SHA on ARM chips
42-
*
43-
* 64 byte alignment for > page allocations on 64 bit systems
44-
* 32 byte alignment for > page allocations on 32 bit systems
45-
* 16 byte alignment for <= page allocations on 64 bit systems
46-
* 8 byte alignment for <= page allocations on 32 bit systems
47-
*
48-
* We use PAGE_SIZE as the boundary because we are not aware of any allocations of
49-
* this size or greater that are not data buffers
50-
*/
51-
const size_t alignment = sizeof(void *) * (size > (size_t)PAGE_SIZE ? 8 : 2);
38+
size_t alignment = 0;
39+
if (allocator->impl != NULL) {
40+
alignment = (size_t)allocator->impl;
41+
} else {
42+
/**
43+
* For implicit alignment.
44+
* larger allocations should be aligned so that AVX and friends can avoid
45+
* the extra preamble during unaligned versions of memcpy/memset on big buffers
46+
* This will also accelerate hardware CRC and SHA on ARM chips
47+
*
48+
* 64 byte alignment for > page allocations on 64 bit systems
49+
* 32 byte alignment for > page allocations on 32 bit systems
50+
* 16 byte alignment for <= page allocations on 64 bit systems
51+
* 8 byte alignment for <= page allocations on 32 bit systems
52+
*
53+
* We use PAGE_SIZE as the boundary because we are not aware of any allocations of
54+
* this size or greater that are not data buffers.
55+
*
56+
* Unless there is a customized alignment size.
57+
*/
58+
alignment = sizeof(void *) * (size > (size_t)PAGE_SIZE ? 8 : 2);
59+
}
5260
#if !defined(_WIN32)
5361
void *result = NULL;
5462
int err = posix_memalign(&result, alignment, size);
@@ -146,26 +154,48 @@ static void *s_non_aligned_calloc(struct aws_allocator *allocator, size_t num, s
146154
return mem;
147155
}
148156

149-
static struct aws_allocator default_allocator = {
157+
static struct aws_allocator s_default_allocator = {
150158
.mem_acquire = s_non_aligned_malloc,
151159
.mem_release = s_non_aligned_free,
152160
.mem_realloc = s_non_aligned_realloc,
153161
.mem_calloc = s_non_aligned_calloc,
154162
};
155163

156164
struct aws_allocator *aws_default_allocator(void) {
157-
return &default_allocator;
165+
return &s_default_allocator;
158166
}
159167

160-
static struct aws_allocator aligned_allocator = {
168+
static struct aws_allocator s_implicit_aligned_allocator = {
161169
.mem_acquire = s_aligned_malloc,
162170
.mem_release = s_aligned_free,
163171
.mem_realloc = s_aligned_realloc,
164172
.mem_calloc = s_aligned_calloc,
165173
};
166174

167175
struct aws_allocator *aws_aligned_allocator(void) {
168-
return &aligned_allocator;
176+
return &s_implicit_aligned_allocator;
177+
}
178+
179+
struct aws_allocator *aws_explicit_aligned_allocator_new(size_t customized_alignment) {
180+
if (customized_alignment == 0 || (customized_alignment & (customized_alignment - 1)) != 0 ||
181+
customized_alignment % sizeof(void *) != 0) {
182+
/**
183+
* the alignment must be a power of two and a multiple of sizeof(void *) and non-zero.
184+
*/
185+
aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
186+
return NULL;
187+
}
188+
struct aws_allocator *aligned_alloc = aws_mem_calloc(aws_default_allocator(), 1, sizeof(struct aws_allocator));
189+
*aligned_alloc = s_implicit_aligned_allocator;
190+
aligned_alloc->impl = (void *)customized_alignment;
191+
return aligned_alloc;
192+
}
193+
194+
void aws_explicit_aligned_allocator_destroy(struct aws_allocator *aligned_alloc) {
195+
if (!aligned_alloc) {
196+
return;
197+
}
198+
aws_mem_release(aws_default_allocator(), aligned_alloc);
169199
}
170200

171201
void *aws_mem_acquire(struct aws_allocator *allocator, size_t size) {

0 commit comments

Comments
 (0)