Skip to content

Commit

Permalink
Merge branch 'main' into issue3576
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan-Jowett authored Jun 21, 2024
2 parents 670afae + 8440c60 commit 52b60a5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
<ClCompile>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WholeProgramOptimization Condition="'$(EnableAsan)' != 'true'">true</WholeProgramOptimization>
<!-- /Ob3 enable hinting to link time code generation that a function should be inlined -->
<AdditionalOptions>/Ob3 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalOptions Condition="'$(EnableASAN)' != 'true'">/spgo %(AdditionalOptions)</AdditionalOptions>
Expand Down
8 changes: 8 additions & 0 deletions libs/execution_context/ebpf_maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ extern "C"
* @param[in] flags Zero or more EBPF_MAP_FIND_ENTRY_FLAG_* flags.
* @return Pointer to the value if found or NULL.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_map_find_entry(
_Inout_ ebpf_map_t* map,
Expand All @@ -84,6 +85,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_NO_MEMORY Unable to allocate resources for this entry.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_map_update_entry(
_Inout_ ebpf_map_t* map,
Expand Down Expand Up @@ -122,6 +124,7 @@ extern "C"
* @retval EBPF_INVALID_ARGUMENT One or more parameters are
* invalid.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_map_delete_entry(_In_ ebpf_map_t* map, size_t key_size, _In_reads_(key_size) const uint8_t* key, int flags);

Expand Down Expand Up @@ -155,6 +158,7 @@ extern "C"
* @param[in] key_size Size of value to search for.
* @returns Program pointer, or NULL if none.
*/
EBPF_INLINE_HINT
_Ret_maybenull_ struct _ebpf_program*
ebpf_map_get_program_from_entry(_Inout_ ebpf_map_t* map, size_t key_size, _In_reads_(key_size) const uint8_t* key);

Expand Down Expand Up @@ -236,6 +240,7 @@ extern "C"
* @retval EBPF_SUCCESS Successfully wrote record into ring buffer.
* @retval EBPF_OUT_OF_SPACE Unable to output to ring buffer due to inadequate space.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_ring_buffer_map_output(_Inout_ ebpf_map_t* map, _In_reads_bytes_(length) uint8_t* data, size_t length);

Expand All @@ -251,6 +256,7 @@ extern "C"
* entry.
* @retval EBPF_OUT_OF_SPACE Map is full and BPF_EXIST was not supplied.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_map_push_entry(
_Inout_ ebpf_map_t* map, size_t value_size, _In_reads_(value_size) const uint8_t* value, int flags);
Expand All @@ -266,6 +272,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_OBJECT_NOT_FOUND The map is empty.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_map_pop_entry(_Inout_ ebpf_map_t* map, size_t value_size, _Out_writes_(value_size) uint8_t* value, int flags);

Expand All @@ -280,6 +287,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_OBJECT_NOT_FOUND The map is empty.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_map_peek_entry(_Inout_ ebpf_map_t* map, size_t value_size, _Out_writes_(value_size) uint8_t* value, int flags);

Expand Down
2 changes: 2 additions & 0 deletions libs/execution_context/ebpf_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ extern "C"
* @retval EBPF_SUCCESS The program was successfully invoked.
* @retval EBPF_EXTENSION_FAILED_TO_LOAD The program information provider is not available.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_program_invoke(
_In_ const ebpf_program_t* program,
Expand Down Expand Up @@ -281,6 +282,7 @@ extern "C"
* @retval EBPF_INVALID_ARGUMENT Internal error.
* @retval EBPF_NO_MORE_TAIL_CALLS Program has executed to many tail calls.
*/
EBPF_INLINE_HINT
_Must_inspect_result_ ebpf_result_t
ebpf_program_set_tail_call(_In_ const ebpf_program_t* next_program);

Expand Down
14 changes: 14 additions & 0 deletions libs/runtime/ebpf_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ extern "C"
{
#endif

/**
* @brief Hint to compiler that this function should be inlined during link time code generation.
*/
#if defined(NDEBUG)
#define EBPF_INLINE_HINT extern __forceinline
#else
#define EBPF_INLINE_HINT
#endif

#define EBPF_UTF8_STRING_FROM_CONST_STRING(x) \
{ \
((uint8_t*)(x)), sizeof((x)) - 1 \
Expand Down Expand Up @@ -242,6 +251,7 @@ extern "C"
* be preempted by other execution.
* @retval True if this execution can be preempted.
*/
EBPF_INLINE_HINT
bool
ebpf_is_preemptible();

Expand Down Expand Up @@ -608,6 +618,7 @@ extern "C"
* @param[in] include_suspended_time Include time the system spent in a suspended state.
* @return Time elapsed since boot in 100 nanosecond units.
*/
EBPF_INLINE_HINT
uint64_t
ebpf_query_time_since_boot(bool include_suspended_time);

Expand Down Expand Up @@ -653,6 +664,7 @@ extern "C"
*
* @returns Process ID.
*/
EBPF_INLINE_HINT
uint32_t
ebpf_platform_process_id();

Expand All @@ -661,6 +673,7 @@ extern "C"
*
* @returns Thread ID.
*/
EBPF_INLINE_HINT
uint32_t
ebpf_platform_thread_id();

Expand Down Expand Up @@ -799,6 +812,7 @@ extern "C"
*
* @return result of the operation.
*/
EBPF_INLINE_HINT
_IRQL_requires_max_(PASSIVE_LEVEL) _Must_inspect_result_ ebpf_result_t
ebpf_platform_get_authentication_id(_Out_ uint64_t* authentication_id);

Expand Down
1 change: 1 addition & 0 deletions libs/runtime/ebpf_random.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extern "C"
*
* @return A pseudorandom number.
*/
EBPF_INLINE_HINT
uint32_t
ebpf_random_uint32();

Expand Down

0 comments on commit 52b60a5

Please sign in to comment.