+2005-06-26 Tor Lillqvist <tml@novell.com>
+
+ * 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 <mclasen@redhat.com>
Add an mmap() wrapper called GMappedFile. (#148218,
+2005-06-26 Tor Lillqvist <tml@novell.com>
+
+ * 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 <mclasen@redhat.com>
Add an mmap() wrapper called GMappedFile. (#148218,
+2005-06-26 Tor Lillqvist <tml@novell.com>
+
+ * 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 <mclasen@redhat.com>
Add an mmap() wrapper called GMappedFile. (#148218,
+2005-06-26 Tor Lillqvist <tml@novell.com>
+
+ * 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 <mclasen@redhat.com>
Add an mmap() wrapper called GMappedFile. (#148218,
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
# 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
#include <sys/mman.h>
#endif
+#include "glibconfig.h"
+
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
#include "gconvert.h"
#include "gerror.h"
#include "galias.h"
+#ifndef _O_BINARY
+#define _O_BINARY 0
+#endif
+
#ifndef MAP_FAILED
#define MAP_FAILED ((void *) -1)
#endif
{
gsize length;
gchar *contents;
+#ifdef G_OS_WIN32
+ HANDLE mapping;
+#endif
};
/**
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;
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)
{
*
* 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
#ifdef HAVE_MMAP
munmap (file->contents, file->length);
#endif
+#ifdef G_OS_WIN32
+ UnmapViewOfFile (file->contents);
+ CloseHandle (file->mapping);
+#endif
+
+ g_free (file);
}
#include <signal.h>
#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);
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);
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);
}
/* 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';
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))
{