Hey,
as the Windows Mobile platform is trying to be supported, a lot of #ifdef
might appear. So I began to move the win32 code from the efl to a single
lib (named 'evil'). The source code for that lib is attached, for those
who are interested. Currently, the main functions that are ported are dl*
functions, mmap and munmap, and fcntl.
There is also a patch for eet that is attached. It shows the modifications
in eet when 'evil' is used. It's not so evil, finally :)
Another thing I've discovered is how libtool manages the export of the
functions on Windows. Everything is done with EAPI with a small
modification. But, contrary to gcc on linux, which does not complain when
EAPI is used on declaration and definition of the functions, on Windows
there is an error. So I have to define to nothing EAPI on Windows. I added
that in eet_lib.c, eet_data.c and eet_image.c.
I can also add it in Eet_private.h, but I have to include Eet_private.h
after Eet.h.
Another solution would be to remove EAPI on definitions of the exported
functions (it's sufficient to have it on declarations). But raster prefers
to keep them as it shows which functions are really exported in the .c
files. I think that it can be replaced by organising the files like that:
static declarations and non exported functions
definitions of exported functions
definitions of non exported functions
definitions of static functions
and by adding good comments.
It's easy to manage EAPI with eet. I let you imagine with a beast like
evas (I have the diff somewhere. It's quite ugly)
comments, ideas are welcome.
Vincent
? eet_win32.diff
Index: configure.in
===================================================================
RCS file: /cvs/e/e17/libs/eet/configure.in,v
retrieving revision 1.84
diff -u -r1.84 configure.in
--- configure.in 26 Jan 2008 05:52:47 -0000 1.84
+++ configure.in 10 Feb 2008 23:20:37 -0000
@@ -30,22 +30,23 @@
AC_FUNC_ALLOCA
-AC_CHECK_HEADER(zlib.h,, AC_MSG_ERROR("Cannot find zlib.h. Make sure your
CFLAGS environment variable contains include lines for the location of this
file"))
-AC_CHECK_HEADER(jpeglib.h,, AC_MSG_ERROR("Cannot find jpeglib.h. Make sure
your CFLAGS environment variable contains include lines for the location of
this file"))
-
-AC_CHECK_HEADERS_ONCE(netinet/in.h sys/mman.h windows.h winsock2.h)
-
-winsock_libs=""
+win32_libs=""
create_shared_lib=""
case "$host_os" in
mingw|mingw32)
- winsock_libs="-lwsock32"
+ PKG_CHECK_MODULES([EVIL], evil)
+ AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed])
+ win32_libs="-lws2_32"
create_shared_lib="-no-undefined "
;;
esac
-
-AC_SUBST(winsock_libs)
+AC_SUBST(win32_libs)
AC_SUBST(create_shared_lib)
+
+AC_CHECK_HEADER(zlib.h,, AC_MSG_ERROR("Cannot find zlib.h. Make sure your
CFLAGS environment variable contains include lines for the location of this
file"))
+AC_CHECK_HEADER(jpeglib.h,, AC_MSG_ERROR("Cannot find jpeglib.h. Make sure
your CFLAGS environment variable contains include lines for the location of
this file"))
+
+AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADER(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure
your CFLAGS environment variable contains include lines for the location of
this file. MinGW users: see the INSTALL file]))
Index: src/lib/Eet.h
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/Eet.h,v
retrieving revision 1.44
diff -u -r1.44 Eet.h
--- src/lib/Eet.h 27 Jan 2008 13:08:30 -0000 1.44
+++ src/lib/Eet.h 10 Feb 2008 23:20:38 -0000
@@ -6,8 +6,8 @@
#ifdef EAPI
#undef EAPI
#endif
-#ifdef _MSC_VER
-# ifdef BUILDING_DLL
+#ifdef _WIN32
+# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
Index: src/lib/Eet_private.h
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/Eet_private.h,v
retrieving revision 1.18
diff -u -r1.18 Eet_private.h
--- src/lib/Eet_private.h 26 Jan 2008 05:50:09 -0000 1.18
+++ src/lib/Eet_private.h 10 Feb 2008 23:20:38 -0000
@@ -33,8 +33,9 @@
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
-#ifdef HAVE_WINSOCK2_H
-# include <winsock2.h>
+
+#ifdef HAVE_EVIL
+# include <Evil.h>
#endif
#include <zlib.h>
Index: src/lib/Makefile.am
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/Makefile.am,v
retrieving revision 1.17
diff -u -r1.17 Makefile.am
--- src/lib/Makefile.am 4 Nov 2007 09:10:50 -0000 1.17
+++ src/lib/Makefile.am 10 Feb 2008 23:20:38 -0000
@@ -6,7 +6,8 @@
-I$(top_srcdir)/src/lib \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \
--DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\"
+-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
[EMAIL PROTECTED]@
lib_LTLIBRARIES = libeet.la
include_HEADERS = Eet.h
@@ -18,6 +19,6 @@
eet_utils.c \
Eet_private.h
-libeet_la_LIBADD = -lz -ljpeg @fnmatch_libs@ @winsock_libs@ -lm
+libeet_la_LIBADD = @EVIL_LIBS@ -lz -ljpeg @fnmatch_libs@ @win32_libs@ -lm
libeet_la_DEPENDENCIES = $(top_builddir)/config.h
libeet_la_LDFLAGS = @create_shared_lib@ -version-info @version_info@
Index: src/lib/eet_data.c
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/eet_data.c,v
retrieving revision 1.62
diff -u -r1.62 eet_data.c
--- src/lib/eet_data.c 27 Jan 2008 13:17:22 -0000 1.62
+++ src/lib/eet_data.c 10 Feb 2008 23:20:38 -0000
@@ -3,6 +3,11 @@
#include "Eet_private.h"
#include "Eet.h"
+#ifdef _WIN32
+# undef EAPI
+# define EAPI
+#endif /* _WIN32 */
+
/*
* routines for doing data -> struct and struct -> data conversion
*
Index: src/lib/eet_image.c
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/eet_image.c,v
retrieving revision 1.14
diff -u -r1.14 eet_image.c
--- src/lib/eet_image.c 27 Jan 2008 13:17:22 -0000 1.14
+++ src/lib/eet_image.c 10 Feb 2008 23:20:39 -0000
@@ -1,6 +1,11 @@
#include "Eet_private.h"
#include "Eet.h"
+#ifdef _WIN32
+# undef EAPI
+# define EAPI
+#endif /* _WIN32 */
+
/*---*/
typedef struct _JPEG_error_mgr *emptr;
Index: src/lib/eet_lib.c
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/eet_lib.c,v
retrieving revision 1.88
diff -u -r1.88 eet_lib.c
--- src/lib/eet_lib.c 27 Jan 2008 13:17:22 -0000 1.88
+++ src/lib/eet_lib.c 10 Feb 2008 23:20:39 -0000
@@ -6,9 +6,12 @@
#include "Eet.h"
#include <sys/types.h>
-#ifdef HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-#endif
+#include <sys/mman.h>
+
+#ifdef _WIN32
+# undef EAPI
+# define EAPI
+#endif /* _WIN32 */
#ifdef HAVE_REALPATH
#undef HAVE_REALPATH
@@ -649,10 +652,6 @@
Eet_File *ef;
struct stat file_stat;
-#ifdef _WIN32
- HANDLE h;
-#endif
-
if (!file)
return NULL;
@@ -745,42 +744,13 @@
if (eet_test_close(!ef->fp, ef))
return NULL;
-#ifndef _WIN32
fcntl(fileno(ef->fp), F_SETFD, FD_CLOEXEC);
-#else
- /* FIXME: check if that code is needed / correct */
- h = (HANDLE) _get_osfhandle(fileno(ef->fp));
- if (h == INVALID_HANDLE_VALUE)
- return NULL;
- if (!SetHandleInformation(h, HANDLE_FLAG_INHERIT, 0))
- return NULL;
-#endif
/* if we opened for read or read-write */
if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))
{
-#ifdef _WIN32
- HANDLE fm;
-#endif
-
-
ef->data_size = file_stat.st_size;
-#ifndef _WIN32
ef->data = mmap(NULL, ef->data_size, PROT_READ,
MAP_SHARED, fileno(ef->fp), 0);
-#else
- fm = CreateFileMapping((HANDLE) _get_osfhandle (fileno(ef->fp)),
- NULL,
- PAGE_READONLY,
- 0,
- 0,
- NULL);
- ef->data = MapViewOfFile(fm,
- FILE_MAP_READ,
- 0,
- 0,
- ef->data_size);
- CloseHandle(fm);
-#endif
ef = eet_internal_read(ef);
if (!ef)
@@ -892,11 +862,7 @@
free(ef->header);
}
-#ifndef _WIN32
if (ef->data) munmap((void*)ef->data, ef->data_size);
-#else
- if (ef->data) UnmapViewOfFile (ef->data);
-#endif
if (ef->fp) fclose(ef->fp);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel