| 1 | #ifndef AWS_COMMON_PRIVATE_BYTE_BUF_H |
| 2 | #define AWS_COMMON_PRIVATE_BYTE_BUF_H |
| 3 | /* |
| 4 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"). |
| 7 | * You may not use this file except in compliance with the License. |
| 8 | * A copy of the License is located at |
| 9 | * |
| 10 | * http://aws.amazon.com/apache2.0 |
| 11 | * |
| 12 | * or in the "license" file accompanying this file. This file is distributed |
| 13 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 14 | * express or implied. See the License for the specific language governing |
| 15 | * permissions and limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <aws/common/byte_buf.h> |
| 19 | |
| 20 | /** |
| 21 | * If index >= bound, bound > (SIZE_MAX / 2), or index > (SIZE_MAX / 2), returns |
| 22 | * 0. Otherwise, returns UINTPTR_MAX. This function is designed to return the correct |
| 23 | * value even under CPU speculation conditions, and is intended to be used for |
| 24 | * SPECTRE mitigation purposes. |
| 25 | */ |
| 26 | AWS_COMMON_API size_t aws_nospec_mask(size_t index, size_t bound); |
| 27 | |
| 28 | #endif /* AWS_COMMON_PRIVATE_BYTE_BUF_H */ |
| 29 | |