evas - generic loaders - use eina properly so windows build works
authorVincent Torri <vincent.torri@gmail.com>
Fri, 2 Nov 2018 13:44:39 +0000 (13:44 +0000)
committerYeongjong Lee <yj34.lee@samsung.com>
Thu, 8 Nov 2018 06:40:48 +0000 (15:40 +0900)
src/Makefile_Evas.am
src/generic/evas/common/shmfile.c
src/generic/evas/common/timeout.c
src/generic/evas/gst/main.c
src/generic/evas/pdf/main.cpp

index 3d16c06..254b49c 100755 (executable)
@@ -2492,17 +2492,15 @@ generic/evas/common/timeout.c
 generic_evas_pdf_evas_image_loader_pdf_CFLAGS = \
 -I$(top_srcdir)/src/lib/efl \
 -I$(top_builddir)/src/lib/efl \
--I$(top_srcdir)/src/lib/eina \
--I$(top_builddir)/src/lib/eina \
 -I$(top_srcdir)/src/generic/evas/common \
-@POPPLER_CFLAGS@
+@POPPLER_CFLAGS@ \
+@EINA_CFLAGS@
 generic_evas_pdf_evas_image_loader_pdf_CXXFLAGS = \
 -I$(top_srcdir)/src/lib/efl \
 -I$(top_builddir)/src/lib/efl \
--I$(top_srcdir)/src/lib/eina \
--I$(top_builddir)/src/lib/eina \
 -I$(top_srcdir)/src/generic/evas/common \
-@POPPLER_CFLAGS@
+@POPPLER_CFLAGS@ \
+@EINA_CFLAGS@
 generic_evas_pdf_evas_image_loader_pdf_LDADD = @USE_EINA_LIBS@ @POPPLER_LIBS@ @SHM_LIBS@
 generic_evas_pdf_evas_image_loader_pdf_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
 
@@ -2544,9 +2542,8 @@ generic_evas_ps_evas_image_loader_ps_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
 generic_evas_ps_evas_image_loader_ps_CFLAGS = \
 -I$(top_srcdir)/src/lib/efl \
 -I$(top_builddir)/src/lib/efl \
--I$(top_srcdir)/src/lib/eina \
--I$(top_builddir)/src/lib/eina \
--I$(top_srcdir)/src/generic/evas/common
+-I$(top_srcdir)/src/generic/evas/common \
+@EINA_CFLAGS@
 
 endif
 
@@ -2563,10 +2560,9 @@ generic_evas_raw_evas_image_loader_raw_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
 generic_evas_raw_evas_image_loader_raw_CFLAGS = \
 -I$(top_srcdir)/src/lib/efl \
 -I$(top_builddir)/src/lib/efl \
--I$(top_srcdir)/src/lib/eina \
--I$(top_builddir)/src/lib/eina \
 -I$(top_srcdir)/src/generic/evas/common \
-@LIBRAW_CFLAGS@
+@LIBRAW_CFLAGS@ \
+@EINA_CFLAGS@
 
 EFL_INSTALL_EXEC_HOOK += \
 mkdir -p $(DESTDIR)$(libdir)/evas/utils; \
@@ -2603,10 +2599,9 @@ generic/evas/common/timeout.c
 generic_evas_svg_evas_image_loader_svg_CFLAGS = \
 -I$(top_srcdir)/src/lib/efl \
 -I$(top_builddir)/src/lib/efl \
--I$(top_srcdir)/src/lib/eina \
--I$(top_builddir)/src/lib/eina \
 -I$(top_srcdir)/src/generic/evas/common \
-@RSVG_CFLAGS@
+@RSVG_CFLAGS@ \
+@EINA_CFLAGS@
 generic_evas_svg_evas_image_loader_svg_LDADD = @USE_EINA_LIBS@ @RSVG_LIBS@ @SHM_LIBS@ -lm
 generic_evas_svg_evas_image_loader_svg_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
 
@@ -2631,9 +2626,8 @@ generic/evas/common/timeout.c
 generic_evas_xcf_evas_image_loader_xcf_CFLAGS = \
 @EVAS_CFLAGS@ \
 -I$(top_srcdir)/src/lib/efl \
--I$(top_srcdir)/src/lib/eina \
--I$(top_builddir)/src/lib/eina \
--I$(top_srcdir)/src/generic/evas/common
+-I$(top_srcdir)/src/generic/evas/common \
+@EINA_CFLAGS@
 generic_evas_xcf_evas_image_loader_xcf_LDADD = @USE_EINA_LIBS@ @SHM_LIBS@ -lm -lz
 generic_evas_xcf_evas_image_loader_xcf_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
 EFL_INSTALL_EXEC_HOOK += \
@@ -2711,10 +2705,9 @@ generic_evas_gst_evas_image_loader_gst_SOURCES = \
 generic_evas_gst_evas_image_loader_gst_CFLAGS = \
   -I$(top_srcdir)/src/lib/efl \
   -I$(top_builddir)/src/lib/efl \
-  -I$(top_srcdir)/src/lib/eina \
-  -I$(top_builddir)/src/lib/eina \
   -I$(top_srcdir)/src/generic/evas/common \
-  @EMOTION_MODULE_GSTREAMER_CFLAGS@
+  @EMOTION_MODULE_GSTREAMER_CFLAGS@ \
+  @EINA_CFLAGS@
 generic_evas_gst_evas_image_loader_gst_LDADD = \
   @USE_EINA_LIBS@ @SHM_LIBS@ -lm @EMOTION_MODULE_GSTREAMER_LIBS@
 generic_evas_gst_evas_image_loader_gst_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
@@ -2729,10 +2722,9 @@ generic_evas_gst_evas_image_loader_gst_SOURCES = \
 generic_evas_gst_evas_image_loader_gst_CFLAGS = \
   -I$(top_srcdir)/src/lib/efl \
   -I$(top_builddir)/src/lib/efl \
-  -I$(top_srcdir)/src/lib/eina \
-  -I$(top_builddir)/src/lib/eina \
   -I$(top_srcdir)/src/generic/evas/common \
-  @EMOTION_MODULE_GSTREAMER1_CFLAGS@
+  @EMOTION_MODULE_GSTREAMER1_CFLAGS@ \
+  @EINA_CFLAGS@
 generic_evas_gst_evas_image_loader_gst_LDADD = \
   @USE_EINA_LIBS@ @SHM_LIBS@ -lm @EMOTION_MODULE_GSTREAMER1_LIBS@
 generic_evas_gst_evas_image_loader_gst_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
index 9beb116..0f93613 100644 (file)
 # include <netinet/in.h>
 #endif
 #include <time.h>
-#include <sys/mman.h>
+#ifdef HAVE_SHM_OPEN
+# include <sys/mman.h>
+#endif
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <string.h>
 #include <zlib.h>
 
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
-   
+
+#ifdef _WIN32
+HANDLE shm_fd = NULL;
+#else
 int shm_fd = -1;
+#endif
 static int shm_size = 0;
 void *shm_addr = NULL;
 char *shmfile = NULL;
@@ -29,7 +39,31 @@ char *shmfile = NULL;
 void
 shm_alloc(unsigned long dsize)
 {
-#ifdef HAVE_SHM_OPEN
+#ifdef _WIN32
+   if (!shmfile) shmfile = malloc(1024);
+   if (!shmfile) goto failed;
+   shmfile[0] = 0;
+   srand(time(NULL));
+   do
+     {
+        snprintf(shmfile, 1024, "/evas-loader.%i.%i",
+                 (int)getpid(), (int)rand());
+        shm_fd = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
+                                   0, dsize, shmfile);
+     }
+   while ((shm_fd == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS));
+
+   shm_addr = MapViewOfFile(shm_fd, FILE_MAP_WRITE, 0, 0, dsize);
+   if (!shm_addr)
+     {
+        free(shmfile);
+        CloseHandle(shm_fd);
+        goto failed;
+     }
+   shm_size = dsize;
+   return;
+failed:
+#elif HAVE_SHM_OPEN
    if (!shmfile) shmfile = malloc(1024);
    if (!shmfile) goto failed;
    shmfile[0] = 0;
@@ -67,7 +101,18 @@ failed:
 void
 shm_free(void)
 {
-#ifdef HAVE_SHM_OPEN
+#ifdef _WIN32
+   if (shm_fd)
+     {
+        UnmapViewOfFile(shm_addr);
+        CloseHandle(shm_fd);
+        free(shmfile);
+        shm_addr = NULL;
+        shm_fd = NULL;
+        shmfile = NULL;
+        return;
+     }
+#elif HAVE_SHM_OPEN
    if (shm_fd >= 0)
      {
         munmap(shm_addr, shm_size);
@@ -81,7 +126,11 @@ shm_free(void)
 #endif
    free(shm_addr);
    shm_addr = NULL;
+#ifdef _WIN32
+   shm_fd = NULL;
+#else
    shm_fd = -1;
+#endif
 }
 
 #ifdef __cplusplus
index 7737bad..844884c 100644 (file)
@@ -6,7 +6,7 @@
 unsigned int
 _timeout(void *arg)
 {
-   int s (int)arg;
+   int s = (int)(uintptr_t)arg;
    Sleep(s * 1000);
    _Exit(-1);
    _endthreadex(0);
@@ -17,7 +17,7 @@ void
 timeout_init(int seconds)
 {
    unsigned int id;
-   _beginthreadex( NULL, 0, _timeout, (void *)seconds, 0, &id);
+   _beginthreadex( NULL, 0, _timeout, (void *)(uintptr_t)seconds, 0, &id);
 }
 #else
 # include <unistd.h>
index 9156227..e4f9f00 100644 (file)
@@ -2,7 +2,9 @@
 # include <config.h>
 #endif
 
-#include <sys/mman.h>
+#ifdef HAVE_SHM_OPEN
+# include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <unistd.h>
 
index 65a4008..d8532fe 100644 (file)
@@ -2,7 +2,9 @@
 # include <config.h>
 #endif
 
-#include <sys/mman.h>
+#ifdef HAVE_SHM_OPEN
+# include <sys/mman.h>
+#endif
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -315,8 +317,11 @@ main(int argc, char **argv)
 
    if (!head_only)
      {
-        if (shm_fd >= 0) printf("shmfile %s\n", shmfile);
+#ifdef HAVE_SHM_OPEN
+        if (shm_fd >= 0)
+          printf("shmfile %s\n", shmfile);
         else
+#endif
           {
              // could also to "tmpfile %s\n" like shmfile but just
              // a mmaped tmp file on the system