mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-01 00:42:16 +01:00 
			
		
		
		
	libtool installs/uninstalls the import library, no need to do it
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().
This commit is contained in:
		
				
					committed by
					
						 Tor Lillqvist
						Tor Lillqvist
					
				
			
			
				
	
			
			
			
						parent
						
							d8926119d1
						
					
				
				
					commit
					ef48ce636b
				
			
							
								
								
									
										14
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								ChangeLog
									
									
									
									
									
								
							| @@ -1,3 +1,17 @@ | ||||
| 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, | ||||
|   | ||||
| @@ -1,3 +1,17 @@ | ||||
| 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, | ||||
|   | ||||
| @@ -1,3 +1,17 @@ | ||||
| 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, | ||||
|   | ||||
| @@ -1,3 +1,17 @@ | ||||
| 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, | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -32,6 +32,11 @@ | ||||
| #include <sys/mman.h> | ||||
| #endif | ||||
|  | ||||
| #include "glibconfig.h" | ||||
|  | ||||
| #ifdef G_OS_WIN32 | ||||
| #include <windows.h> | ||||
| #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); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -24,22 +24,31 @@ | ||||
| #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); | ||||
|  | ||||
| @@ -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)) | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user