From: Tor Lillqvist Date: Sun, 26 Jun 2005 18:04:08 +0000 (+0000) Subject: libtool installs/uninstalls the import library, no need to do it X-Git-Tag: GLIB_2_7_1~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ef48ce636b948623ff2b3b83f4f0ca130ae6e7b0;p=platform%2Fupstream%2Fglib.git libtool installs/uninstalls the import library, no need to do it 2005-06-26 Tor Lillqvist * glib/Makefile.am: libtool installs/uninstalls the import library, no need to do it ourselves. Do still install/uninstall the .def file, though. * glib/gmappedfile.c: Add Win32 implementation. (g_mapped_file_free): Don't mention writable shared mappings in the doc comment. Free the GMappedFile struct. * tests/mapping-test.c (main): No kill() or SIGUSR1 on Win32, use a flag file instead to stop the child. Use g_usleep() instead of sleep(). --- diff --git a/ChangeLog b/ChangeLog index f445ec3..075d62e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-06-26 Tor Lillqvist + + * glib/Makefile.am: libtool installs/uninstalls the import + library, no need to do it ourselves. Do still install/uninstall + the .def file, though. + + * glib/gmappedfile.c: Add Win32 implementation. + (g_mapped_file_free): Don't mention writable shared mappings in + the doc comment. Free the GMappedFile struct. + + * tests/mapping-test.c (main): No kill() or SIGUSR1 on Win32, use + a flag file instead to stop the child. Use g_usleep() instead of + sleep(). + 2005-06-24 Matthias Clasen Add an mmap() wrapper called GMappedFile. (#148218, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f445ec3..075d62e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +2005-06-26 Tor Lillqvist + + * glib/Makefile.am: libtool installs/uninstalls the import + library, no need to do it ourselves. Do still install/uninstall + the .def file, though. + + * glib/gmappedfile.c: Add Win32 implementation. + (g_mapped_file_free): Don't mention writable shared mappings in + the doc comment. Free the GMappedFile struct. + + * tests/mapping-test.c (main): No kill() or SIGUSR1 on Win32, use + a flag file instead to stop the child. Use g_usleep() instead of + sleep(). + 2005-06-24 Matthias Clasen Add an mmap() wrapper called GMappedFile. (#148218, diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index f445ec3..075d62e 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,17 @@ +2005-06-26 Tor Lillqvist + + * glib/Makefile.am: libtool installs/uninstalls the import + library, no need to do it ourselves. Do still install/uninstall + the .def file, though. + + * glib/gmappedfile.c: Add Win32 implementation. + (g_mapped_file_free): Don't mention writable shared mappings in + the doc comment. Free the GMappedFile struct. + + * tests/mapping-test.c (main): No kill() or SIGUSR1 on Win32, use + a flag file instead to stop the child. Use g_usleep() instead of + sleep(). + 2005-06-24 Matthias Clasen Add an mmap() wrapper called GMappedFile. (#148218, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f445ec3..075d62e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +2005-06-26 Tor Lillqvist + + * glib/Makefile.am: libtool installs/uninstalls the import + library, no need to do it ourselves. Do still install/uninstall + the .def file, though. + + * glib/gmappedfile.c: Add Win32 implementation. + (g_mapped_file_free): Don't mention writable shared mappings in + the doc comment. Free the GMappedFile struct. + + * tests/mapping-test.c (main): No kill() or SIGUSR1 on Win32, use + a flag file instead to stop the child. Use g_usleep() instead of + sleep(). + 2005-06-24 Matthias Clasen Add an mmap() wrapper called GMappedFile. (#148218, diff --git a/glib/Makefile.am b/glib/Makefile.am index c7021d0..ad051b0 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -186,14 +186,14 @@ glibsubinclude_HEADERS = \ gwin32.h \ gprintf.h -install-data-local: install-ms-lib install-libtool-import-lib +install-data-local: install-ms-lib install-def-file @if test -f $(glibincludedir)/glist.h ; then \ echo "*** Old headers found in $(glibincludedir). You should remove the" ; \ echo "*** contents of this directory and type 'make install' again." ; \ false ; \ fi -uninstall-local: uninstall-ms-lib uninstall-libtool-import-lib +uninstall-local: uninstall-ms-lib uninstall-def-file if PLATFORM_WIN32 no_undefined = -no-undefined @@ -203,15 +203,14 @@ if OS_WIN32 # This requires a very new libtool export_symbols = -export-symbols glib.def -install-libtool-import-lib: - $(INSTALL) .libs/libglib-2.0.dll.a $(DESTDIR)$(libdir) +install-def-file: $(INSTALL) glib.def $(DESTDIR)$(libdir)/glib-2.0.def -uninstall-libtool-import-lib: - -rm $(DESTDIR)$(libdir)/libglib-2.0.dll.a $(DESTDIR)$(libdir)/glib-2.0.def +uninstall-def-file: + -rm $(DESTDIR)$(libdir)/glib-2.0.def else -install-libtool-import-lib: -uninstall-libtool-import-lib: +install-def-file: +uninstall-def-file: export_symbols = $(LIBTOOL_EXPORT_OPTIONS) endif diff --git a/glib/gmappedfile.c b/glib/gmappedfile.c index 33bbd1f..db1c5b7 100644 --- a/glib/gmappedfile.c +++ b/glib/gmappedfile.c @@ -32,6 +32,11 @@ #include #endif +#include "glibconfig.h" + +#ifdef G_OS_WIN32 +#include +#endif #include "gconvert.h" #include "gerror.h" @@ -46,6 +51,10 @@ #include "galias.h" +#ifndef _O_BINARY +#define _O_BINARY 0 +#endif + #ifndef MAP_FAILED #define MAP_FAILED ((void *) -1) #endif @@ -54,6 +63,9 @@ struct _GMappedFile { gsize length; gchar *contents; +#ifdef G_OS_WIN32 + HANDLE mapping; +#endif }; /** @@ -91,7 +103,7 @@ g_mapped_file_new (const gchar *filename, g_return_val_if_fail (filename != NULL, NULL); g_return_val_if_fail (!error || *error == NULL, NULL); - fd = g_open (filename, writable ? O_RDWR : O_RDONLY); + fd = g_open (filename, (writable ? O_RDWR : O_RDONLY) | _O_BINARY, 0); if (fd == -1) { int save_errno = errno; @@ -132,6 +144,27 @@ g_mapped_file_new (const gchar *filename, writable ? PROT_READ|PROT_WRITE : PROT_READ, MAP_PRIVATE, fd, 0); #endif +#ifdef G_OS_WIN32 + file->length = st.st_size; + file->mapping = CreateFileMapping ((HANDLE) _get_osfhandle (fd), NULL, + writable ? PAGE_WRITECOPY : PAGE_READONLY, + 0, 0, + NULL); + if (file->mapping != NULL) + { + file->contents = MapViewOfFile (file->mapping, + writable ? FILE_MAP_COPY : FILE_MAP_READ, + 0, 0, + 0); + if (file->contents == NULL) + { + file->contents = MAP_FAILED; + CloseHandle (file->mapping); + file->mapping = NULL; + } + } +#endif + if (file->contents == MAP_FAILED) { @@ -203,9 +236,6 @@ g_mapped_file_get_contents (GMappedFile *file) * * Unmaps the buffer of @file and frees it. * - * For writable, shared mappings, the contents - * will be written back to the file at this point. - * * Since: 2.8 */ void @@ -216,6 +246,12 @@ g_mapped_file_free (GMappedFile *file) #ifdef HAVE_MMAP munmap (file->contents, file->length); #endif +#ifdef G_OS_WIN32 + UnmapViewOfFile (file->contents); + CloseHandle (file->mapping); +#endif + + g_free (file); } diff --git a/tests/mapping-test.c b/tests/mapping-test.c index cfe0c3b..afc520d 100644 --- a/tests/mapping-test.c +++ b/tests/mapping-test.c @@ -24,22 +24,31 @@ #include #include "glib.h" +#include "gstdio.h" static gchar *dir, *filename, *displayname, *childname; static gboolean stop = FALSE; +#ifndef G_OS_WIN32 + static void handle_usr1 (int signum) { stop = TRUE; } +#endif + static gboolean check_stop (gpointer data) { GMainLoop *loop = data; +#ifdef G_OS_WIN32 + stop = g_file_test ("STOP", G_FILE_TEST_EXISTS); +#endif + if (stop) g_main_loop_quit (loop); @@ -93,7 +102,9 @@ child_main (int argc, char *argv[]) loop = g_main_loop_new (NULL, FALSE); +#ifndef G_OS_WIN32 signal (SIGUSR1, handle_usr1); +#endif g_idle_add (check_stop, loop); g_main_loop_run (loop); @@ -160,6 +171,11 @@ test_child_private (gchar *argv0) gchar *child_argv[3]; GPid child_pid; +#ifdef G_OS_WIN32 + g_remove ("STOP"); + g_assert (!g_file_test ("STOP", G_FILE_TEST_EXISTS)); +#endif + write_or_die (filename, "ABC", -1); map = map_or_die (filename, TRUE); @@ -175,7 +191,7 @@ test_child_private (gchar *argv0) } /* give the child some time to set up its mapping */ - sleep (2); + g_usleep (2000000); buffer = (gchar *)g_mapped_file_get_contents (map); buffer[0] = '1'; @@ -183,10 +199,14 @@ test_child_private (gchar *argv0) buffer[2] = '3'; g_mapped_file_free (map); +#ifndef G_OS_WIN32 kill (child_pid, SIGUSR1); +#else + g_file_set_contents ("STOP", "Hey there\n", -1, NULL); +#endif /* give the child some time to write the file */ - sleep (2); + g_usleep (2000000); if (!g_file_get_contents (childname, &buffer, &len, &error)) {