Skip to content

Commit

Permalink
Use SSE4.1 ceilf when available and add badges to readme (#288)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anilm3 authored Apr 30, 2024
1 parent 28e9752 commit 48c6909
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Fuzz

on:
# schedule:
# - cron: 30 0 * * *
pull_request:
branches:
- "**"
push:
branches: [ master ]
tags:
- "*"
schedule:
- cron: 30 0 * * *
workflow_dispatch:
inputs:
duration:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[![Build](https://github.com/DataDog/libddwaf/actions/workflows/build.yml/badge.svg)](https://github.com/DataDog/libddwaf/actions/workflows/build.yml)
[![Test](https://github.com/DataDog/libddwaf/actions/workflows/test.yml/badge.svg)](https://github.com/DataDog/libddwaf/actions/workflows/test.yml)
[![fuzz](https://github.com/DataDog/libddwaf/actions/workflows/fuzz.yml/badge.svg)](https://github.com/DataDog/libddwaf/actions/workflows/fuzz.yml)
[![Coverage status](https://codecov.io/github/DataDog/libddwaf/coverage.svg?branch=master)](https://codecov.io/github/DataDog/libddwaf?branch=master)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)

# Datadog's WAF & RASP Engine

Expand Down
21 changes: 21 additions & 0 deletions src/glibc-compat/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ static float ceilf_local(float x)
return x;
}
#else
#if defined(__x86_64__)
static float ceilf_local_sse41(float x)
{
float result;
__asm__(
"roundss $0x0A, %[x], %[result]"
: [result] "=x" (result)
: [x] "x" (x)
);
return result;
}
#endif
/* fp_force_eval ensures that the input value is computed when that's
otherwise unused. To prevent the constant folding of the input
expression, an additional fp_barrier may be needed or a compilation
Expand Down Expand Up @@ -79,7 +91,16 @@ float ceilf(float x)
if (unlikely(ceilf_global_ == NULL)) {
void *ceilf_sym = dlsym(RTLD_DEFAULT, "ceilf");
if (ceilf_sym == NULL || ceilf_sym == &ceilf) {
#if defined(__x86_64__)
__builtin_cpu_init();
if (__builtin_cpu_supports("sse4.1")) {
ceilf_global_ = &ceilf_local_sse41;
} else {
ceilf_global_ = &ceilf_local;
}
# else
ceilf_global_ = &ceilf_local;
#endif
} else {
ceilf_global_ = (ceilf_t)ceilf_sym;
}
Expand Down

0 comments on commit 48c6909

Please sign in to comment.