diff mbox

[FFmpeg-devel,2/2] fmin/fmax/fminf/fmaxf implementation for djgpp libc

Message ID e6415342764af9f8c6adf12e01e7055b2e674a37.1542026632.git.pross@xvid.org
State New
Headers show

Commit Message

Peter Ross Nov. 12, 2018, 12:51 p.m. UTC
---
 compat/djgpp/math.h | 22 ++++++++++++++++++++++
 configure           |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 compat/djgpp/math.h

Comments

Michael Niedermayer Nov. 13, 2018, 12:58 a.m. UTC | #1
On Mon, Nov 12, 2018 at 11:51:26PM +1100, Peter Ross wrote:
> ---
>  compat/djgpp/math.h | 22 ++++++++++++++++++++++
>  configure           |  1 +
>  2 files changed, 23 insertions(+)
>  create mode 100644 compat/djgpp/math.h
> 
> diff --git a/compat/djgpp/math.h b/compat/djgpp/math.h
> new file mode 100644
> index 0000000000..28fae5212e
> --- /dev/null
> +++ b/compat/djgpp/math.h
> @@ -0,0 +1,22 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#define fmin(x, y) ((x) > (y) ? (y) : ((x) == (x) ? (x) : (y)))
> +#define fmax(x, y) ((x) < (y) ? (y) : ((x) == (x) ? (x) : (y)))
> +#define fminf(x, y) fmin(x, y)
> +#define fmaxf(x, y) fmax(x, y)

these evaluate the arguments multiple times. This could be unexpected
also the way this tests for NaN is not guranteed to work i think


[...]
diff mbox

Patch

diff --git a/compat/djgpp/math.h b/compat/djgpp/math.h
new file mode 100644
index 0000000000..28fae5212e
--- /dev/null
+++ b/compat/djgpp/math.h
@@ -0,0 +1,22 @@ 
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define fmin(x, y) ((x) > (y) ? (y) : ((x) == (x) ? (x) : (y)))
+#define fmax(x, y) ((x) < (y) ? (y) : ((x) == (x) ? (x) : (y)))
+#define fminf(x, y) fmin(x, y)
+#define fmaxf(x, y) fmax(x, y)
diff --git a/configure b/configure
index 6db4333f25..97778df1ae 100755
--- a/configure
+++ b/configure
@@ -5462,6 +5462,7 @@  EOF
     elif test_${pfx}cpp_condition sys/version.h "defined __DJGPP__"; then
         eval ${pfx}libc_type=djgpp
         add_cppflags -U__STRICT_ANSI__
+        add_cflags "-include $source_path/compat/djgpp/math.h"
     fi
     test_${pfx}cc <<EOF
 #include <time.h>