RetroArch
float_minmax.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2018 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (float_minmax.h).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #ifndef __LIBRETRO_SDK_MATH_FLOAT_MINMAX_H__
23 #define __LIBRETRO_SDK_MATH_FLOAT_MINMAX_H__
24 
25 #include <stdint.h>
26 #include <math.h>
27 
28 #include <retro_inline.h>
29 #include <retro_miscellaneous.h>
30 #include <retro_environment.h>
31 
32 #ifdef __SSE2__
33 #include <emmintrin.h>
34 #include <mmintrin.h>
35 #endif
36 
37 static INLINE float float_min(float a, float b)
38 {
39 #ifdef __SSE2__
40  _mm_store_ss( &a, _mm_min_ss(_mm_set_ss(a),_mm_set_ss(b)) );
41  return a;
42 #elif !defined(DJGPP) && (defined(__STDC_C99__) || defined(__STDC_C11__))
43  return fminf(a, b);
44 #else
45  return MIN(a, b);
46 #endif
47 }
48 
49 static INLINE float float_max(float a, float b)
50 {
51 #ifdef __SSE2__
52  _mm_store_ss( &a, _mm_max_ss(_mm_set_ss(a),_mm_set_ss(b)) );
53  return a;
54 #elif !defined(DJGPP) && (defined(__STDC_C99__) || defined(__STDC_C11__))
55  return fmaxf(a, b);
56 #else
57  return MAX(a, b);
58 #endif
59 }
60 
61 
62 #endif
#define INLINE
Definition: retro_inline.h:35
static INLINE float float_min(float a, float b)
Definition: float_minmax.h:37
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
#define fmaxf(a, b)
Definition: math.h:29
#define MIN(x, y)
Definition: macros.h:65
static INLINE float float_max(float a, float b)
Definition: float_minmax.h:49
#define fminf(a, b)
Definition: math.h:30
#define MAX(x, y)
Definition: macros.h:69
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6844