1e23c0d0b6cd54aeaa069eb03b3f0e504f5d59d2
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / freerdp / 0003-dont-use-unavailable-c99-math.patch
1 From c0d27019745184052bd428ba74a50de96053cea1 Mon Sep 17 00:00:00 2001
2 From: Baruch Siach <baruch@tkos.co.il>
3 Date: Sun, 3 May 2015 20:46:22 +0300
4 Subject: [PATCH] Don't use unavailable C99 long double math functions
5
6 uClibc variants do not provide the C99 long double math functions like ceill,
7 powl, etc.. For future compatibility use check_symbol_exists() to check
8 whether these functions are available, and keep the result in
9 HAVE_MATH_C99_LONG_DOUBLE. Use that instead of the fragile Cygwin version
10 check in triodef.h.
11
12 Fixes build failures under uClibc(-ng) like:
13
14 ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `powl'
15 ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `fmodl'
16 ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `ceill'
17 ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `log10l'
18 ../../libwinpr/utils/libwinpr-utils.so.0.1.0: undefined reference to `floorl'
19 collect2: error: ld returned 1 exit status
20
21 Backported from upstream commit
22 https://github.com/FreeRDP/FreeRDP/commit/414663cc363108cb71a290de1c86a1b04384fb39
23
24 Signed-off-by: Baruch Siach <baruch@tkos.co.il>
25 ---
26  CMakeLists.txt                      |  3 +++
27  config.h.in                         |  1 +
28  winpr/libwinpr/utils/trio/triodef.h | 25 ++++++-------------------
29  3 files changed, 10 insertions(+), 19 deletions(-)
30
31 diff --git a/CMakeLists.txt b/CMakeLists.txt
32 index 5b7887601aa0..177e44cfff10 100755
33 --- a/CMakeLists.txt
34 +++ b/CMakeLists.txt
35 @@ -279,6 +279,9 @@ if(UNIX OR CYGWIN)
36         if (HAVE_EVENTFD_H)
37                 check_symbol_exists(eventfd_read sys/eventfd.h WITH_EVENTFD_READ_WRITE)
38         endif()
39 +       list(APPEND CMAKE_REQUIRED_LIBRARIES m)
40 +       check_symbol_exists(ceill math.h HAVE_MATH_C99_LONG_DOUBLE)
41 +       list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES m)
42         set(X11_FEATURE_TYPE "RECOMMENDED")
43  else()
44         set(X11_FEATURE_TYPE "DISABLED")
45 diff --git a/config.h.in b/config.h.in
46 index 55c595d0e162..983310d5b9e6 100755
47 --- a/config.h.in
48 +++ b/config.h.in
49 @@ -34,6 +34,7 @@
50  #cmakedefine WITH_WIN8
51  #cmakedefine WITH_RDPSND_DSOUND
52  #cmakedefine WITH_EVENTFD_READ_WRITE
53 +#cmakedefine HAVE_MATH_C99_LONG_DOUBLE
54  
55  /* Plugins */
56  #cmakedefine STATIC_CHANNELS
57 diff --git a/winpr/libwinpr/utils/trio/triodef.h b/winpr/libwinpr/utils/trio/triodef.h
58 index 11c14b9c42c7..2a0479526f33 100644
59 --- a/winpr/libwinpr/utils/trio/triodef.h
60 +++ b/winpr/libwinpr/utils/trio/triodef.h
61 @@ -313,25 +313,12 @@ typedef void * trio_pointer_t;
62  # define TRIO_COMPILER_SUPPORTS_LL
63  #endif
64  
65 -#if defined(__CYGWIN__)
66 -/*
67 - * Cygwin defines the macros for hosted C99, but does not support certain
68 - * long double math functions.
69 - */
70 -# include <cygwin/version.h>
71 -# define TRIO_CYGWIN_VERSION_API CYGWIN_VERSION_API_MAJOR * 1000 + \
72 -   CYGWIN_VERSION_API_MINOR
73 -/*
74 - * Please change the version number below when the Cygwin API supports
75 - * long double math functions (powl, fmodl, etc.)
76 - */
77 -# if TRIO_CYGWIN_VERSION_API < 99999999
78 -#  define TRIO_NO_FLOORL 1
79 -#  define TRIO_NO_CEILL 1
80 -#  define TRIO_NO_POWL 1
81 -#  define TRIO_NO_FMODL 1
82 -#  define TRIO_NO_LOG10L 1
83 -# endif
84 +#if !defined(HAVE_MATH_C99_LONG_DOUBLE)
85 +# define TRIO_NO_FLOORL 1
86 +# define TRIO_NO_CEILL 1
87 +# define TRIO_NO_POWL 1
88 +# define TRIO_NO_FMODL 1
89 +# define TRIO_NO_LOG10L 1
90  #endif
91  
92  #endif /* TRIO_TRIODEF_H */
93 -- 
94 2.1.4
95