evas - generic loaders - use eina properly so windows build works

This commit is contained in:
Vincent Torri 2018-11-02 13:44:39 +00:00 committed by Carsten Haitzler (Rasterman)
parent 1c9c8beb40
commit 01c756a851
5 changed files with 81 additions and 33 deletions

View File

@ -2362,17 +2362,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@
@ -2414,9 +2412,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
@ -2433,10 +2430,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; \
@ -2473,10 +2469,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@
@ -2501,9 +2496,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 += \
@ -2581,10 +2575,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@
@ -2599,10 +2592,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@

View File

@ -11,17 +11,27 @@
# 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

View 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>

View 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>

View 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