The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / freerdp / 0001-add-support-for-uclibc.patch
1 From 39ac68abaff0d7b59cbe80036aac37f41ad976ec Mon Sep 17 00:00:00 2001
2 From: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
3 Date: Wed, 24 Sep 2014 13:54:15 +0100
4 Subject: [PATCH] Add support for uClibc
5
6 The stable-1.1 branch of freerdp fails to build when using a uClibc
7 toolchain because it's using functions which are not implemented in
8 uClibc, like eventfd_read, eventfd_write and futimes. That is causing
9 build failures like these ones:
10
11 ../../libwinpr/synch/libwinpr-synch.so.0.1.0: undefined reference to
12 `eventfd_read'
13 ../../libwinpr/synch/libwinpr-synch.so.0.1.0: undefined reference to
14 `eventfd_write'
15
16 ../../common/libfreerdp-client.so.1.1.0: undefined reference to
17 `futimes'
18
19 This patch is based on this upstream patch:
20
21   https://github.com/FreeRDP/FreeRDP/commit/5f9c36da5d5cd3c5dce49f7b32fe011cb293f9ec/
22
23 To support newer versions of uClibc and uclibc-ng this patch also includes a
24 backported version of upstream commit 3b7d3190a16c (Fix build with newer
25 uclibc versions, 2015-04-28)
26
27 Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
28 [baruch: merge in upstream commit 3b7d3190a16c]
29 Signed-off-by: Baruch Siach <baruch@tkos.co.il>
30 ---
31  CMakeLists.txt                     |  3 +++
32  channels/drive/client/drive_file.c | 12 +++++++++---
33  config.h.in                        |  1 +
34  winpr/libwinpr/synch/event.c       | 14 ++++++++++++++
35  4 files changed, 27 insertions(+), 3 deletions(-)
36
37 diff --git a/CMakeLists.txt b/CMakeLists.txt
38 index 375e2d1b6845..5b7887601aa0 100755
39 --- a/CMakeLists.txt
40 +++ b/CMakeLists.txt
41 @@ -276,6 +276,9 @@ endif()
42  
43  if(UNIX OR CYGWIN)
44         check_include_files(sys/eventfd.h HAVE_EVENTFD_H)
45 +       if (HAVE_EVENTFD_H)
46 +               check_symbol_exists(eventfd_read sys/eventfd.h WITH_EVENTFD_READ_WRITE)
47 +       endif()
48         set(X11_FEATURE_TYPE "RECOMMENDED")
49  else()
50         set(X11_FEATURE_TYPE "DISABLED")
51 diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c
52 index 376b4fe74be7..b20f408aa356 100644
53 --- a/channels/drive/client/drive_file.c
54 +++ b/channels/drive/client/drive_file.c
55 @@ -480,7 +480,11 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
56         int status;
57         char* fullpath;
58         struct STAT st;
59 +#if defined(ANDROID)
60         struct timeval tv[2];
61 +#else
62 +       struct timespec tv[2];
63 +#endif
64         UINT64 LastWriteTime;
65         UINT32 FileAttributes;
66         UINT32 FileNameLength;
67 @@ -501,15 +505,17 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
68                                 return FALSE;
69  
70                         tv[0].tv_sec = st.st_atime;
71 -                       tv[0].tv_usec = 0;
72                         tv[1].tv_sec = (LastWriteTime > 0 ? FILE_TIME_RDP_TO_SYSTEM(LastWriteTime) : st.st_mtime);
73 -                       tv[1].tv_usec = 0;
74  #ifndef WIN32
75  /* TODO on win32 */                        
76  #ifdef ANDROID
77 +                       tv[0].tv_usec = 0;
78 +                       tv[1].tv_usec = 0;
79                         utimes(file->fullpath, tv);
80  #else
81 -                       futimes(file->fd, tv);
82 +                       tv[0].tv_nsec = 0;
83 +                       tv[1].tv_nsec = 0;
84 +                       futimens(file->fd, tv);
85  #endif
86  
87                         if (FileAttributes > 0)
88 diff --git a/config.h.in b/config.h.in
89 index 2b8ec09c2afb..55c595d0e162 100755
90 --- a/config.h.in
91 +++ b/config.h.in
92 @@ -33,6 +33,7 @@
93  #cmakedefine WITH_JPEG
94  #cmakedefine WITH_WIN8
95  #cmakedefine WITH_RDPSND_DSOUND
96 +#cmakedefine WITH_EVENTFD_READ_WRITE
97  
98  /* Plugins */
99  #cmakedefine STATIC_CHANNELS
100 diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c
101 index 173afafb7cc9..cb3f338178d9 100644
102 --- a/winpr/libwinpr/synch/event.c
103 +++ b/winpr/libwinpr/synch/event.c
104 @@ -115,6 +115,20 @@ HANDLE OpenEventA(DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
105         return NULL;
106  }
107  
108 +#ifdef HAVE_EVENTFD_H
109 +#if !defined(WITH_EVENTFD_READ_WRITE)
110 +static int eventfd_read(int fd, eventfd_t* value)
111 +{
112 +       return (read(fd, value, sizeof(*value)) == sizeof(*value)) ? 0 : -1;
113 +}
114 +
115 +static int eventfd_write(int fd, eventfd_t value)
116 +{
117 +       return (write(fd, &value, sizeof(value)) == sizeof(value)) ? 0 : -1;
118 +}
119 +#endif
120 +#endif
121 +
122  BOOL SetEvent(HANDLE hEvent)
123  {
124         ULONG Type;
125 -- 
126 1.7.1
127