[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r113816: Fix build with zlib on MS-Windows.
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] trunk r113816: Fix build with zlib on MS-Windows. |
Date: |
Mon, 12 Aug 2013 13:15:37 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 113816
revision-id: address@hidden
parent: address@hidden
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Mon 2013-08-12 16:15:01 +0300
message:
Fix build with zlib on MS-Windows.
configure.ac (LIBZ): Comment on w32 peculiarities regarding LIBZ.
src/decompress.c [WINDOWSNT]: Include windows.h and w32.h.
(DEF_ZLIB_FN, LOAD_ZLIB_FN) [WINDOWSNT]: New macros. Use them to
define static variables that are pointers to zlib functions to be
dynamically loaded.
(init_zlib_functions) [WINDOWSNT]: New function.
(fn_inflateInit2_, fn_inflate, fn_inflateEnd, fn_inflateInit2):
New macros.
(Fdecompress_gzipped_region, unwind_decompress): Use the fn_*
macros instead of invoking the zlib functions directly.
(syms_of_decompress): DEFSYM Qzlib_dll. Staticpro
Szlib_available_p.
lisp/term/w32-win.el (dynamic-library-alist): Add DLLs for zlib.
modified:
ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1538
configure.ac
configure.in-20091113204419-o5vbwnq5f7feedwu-783
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/term/w32-win.el w32win.el-20091113204419-o5vbwnq5f7feedwu-943
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/decompress.c decompress.c-20130811194033-wfhl0tqmmc36jfmu-1
=== modified file 'ChangeLog'
--- a/ChangeLog 2013-08-12 00:52:17 +0000
+++ b/ChangeLog 2013-08-12 13:15:01 +0000
@@ -1,3 +1,7 @@
+2013-08-12 Eli Zaretskii <address@hidden>
+
+ * configure.ac (LIBZ): Comment on w32 peculiarities regarding LIBZ.
+
2013-08-12 Paul Eggert <address@hidden>
Merge from gnulib, incorporating:
=== modified file 'configure.ac'
--- a/configure.ac 2013-08-12 00:04:15 +0000
+++ b/configure.ac 2013-08-12 13:15:01 +0000
@@ -2948,6 +2948,9 @@
if test "${with_zlib}" != "no"; then
if test "${HAVE_PNG}" = "yes"; then
### PNG depends on zlib, so if we have PNG, we have zlib.
+ ### Note: w32 does not link against libpng, but instead loads it
+ ### dynamically, but it also does the same with zlib. So it is OK
+ ### not to have -lz in LIBZ on w32.
HAVE_ZLIB=yes
else
### No PNG, so check zlib ourselves.
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-08-12 00:09:11 +0000
+++ b/lisp/ChangeLog 2013-08-12 13:15:01 +0000
@@ -1,3 +1,7 @@
+2013-08-12 Eli Zaretskii <address@hidden>
+
+ * term/w32-win.el (dynamic-library-alist): Add DLLs for zlib.
+
2013-08-12 Glenn Morris <address@hidden>
* format.el (format-annotate-function):
=== modified file 'lisp/term/w32-win.el'
--- a/lisp/term/w32-win.el 2013-04-16 02:41:37 +0000
+++ b/lisp/term/w32-win.el 2013-08-12 13:15:01 +0000
@@ -229,7 +229,8 @@
'(glib "libglib-2.0-0.dll")
'(gobject "libgobject-2.0-0.dll")
'(gnutls "libgnutls-28.dll" "libgnutls-26.dll")
- '(libxml2 "libxml2-2.dll" "libxml2.dll")))
+ '(libxml2 "libxml2-2.dll" "libxml2.dll")
+ '(zlib "zlib1.dll" "libz-1.dll")))
;;; multi-tty support
(defvar w32-initialized nil
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2013-08-12 09:34:00 +0000
+++ b/src/ChangeLog 2013-08-12 13:15:01 +0000
@@ -1,3 +1,17 @@
+2013-08-12 Eli Zaretskii <address@hidden>
+
+ * decompress.c [WINDOWSNT]: Include windows.h and w32.h.
+ (DEF_ZLIB_FN, LOAD_ZLIB_FN) [WINDOWSNT]: New macros. Use them to
+ define static variables that are pointers to zlib functions to be
+ dynamically loaded.
+ (init_zlib_functions) [WINDOWSNT]: New function.
+ (fn_inflateInit2_, fn_inflate, fn_inflateEnd, fn_inflateInit2):
+ New macros.
+ (Fdecompress_gzipped_region, unwind_decompress): Use the fn_*
+ macros instead of invoking the zlib functions directly.
+ (syms_of_decompress): DEFSYM Qzlib_dll. Staticpro
+ Szlib_available_p.
+
2013-08-12 Dmitry Antipov <address@hidden>
Avoid looping over all frame windows to freeze and unfreeze.
=== modified file 'src/decompress.c'
--- a/src/decompress.c 2013-08-11 23:09:26 +0000
+++ b/src/decompress.c 2013-08-12 13:15:01 +0000
@@ -26,6 +26,58 @@
#include "character.h"
#include "buffer.h"
+static Lisp_Object Qzlib_dll;
+
+#ifdef WINDOWSNT
+#include <windows.h>
+#include "w32.h"
+
+/* Macro for defining functions that will be loaded from the zlib DLL. */
+#define DEF_ZLIB_FN(rettype,func,args) static rettype (FAR CDECL
*fn_##func)args
+
+/* Macro for loading zlib functions from the library. */
+#define LOAD_ZLIB_FN(lib,func) { \
+ fn_##func = (void *) GetProcAddress (lib, #func); \
+ if (!fn_##func) return 0; \
+ }
+
+DEF_ZLIB_FN (int, inflateInit2_,
+ (z_streamp strm, int windowBits, const char *version, int
stream_size));
+
+DEF_ZLIB_FN (int, inflate,
+ (z_streamp strm, int flush));
+
+DEF_ZLIB_FN (int, inflateEnd,
+ (z_streamp strm));
+
+static bool
+init_zlib_functions (void)
+{
+ HMODULE library = w32_delayed_load (Qzlib_dll);
+
+ if (!library)
+ {
+ message1 ("zlib library not found");
+ return 0;
+ }
+
+ LOAD_ZLIB_FN (library, inflateInit2_);
+ LOAD_ZLIB_FN (library, inflate);
+ LOAD_ZLIB_FN (library, inflateEnd);
+ return 1;
+}
+
+#else /* !WINDOWSNT */
+
+#define fn_inflateInit2_ inflateInit2_
+#define fn_inflate inflate
+#define fn_inflateEnd inflateEnd
+
+#endif /* WINDOWSNT */
+
+#define fn_inflateInit2(strm, windowBits) \
+ fn_inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
+
struct decompress_unwind_data
{
@@ -37,7 +89,7 @@
unwind_decompress (void *ddata)
{
struct decompress_unwind_data *data = ddata;
- inflateEnd (data->stream);
+ fn_inflateEnd (data->stream);
/* Delete any uncompressed data already inserted and restore point. */
if (data->start)
@@ -47,6 +99,26 @@
}
}
+DEFUN ("zlib-available-p", Fzlib_available_p, Szlib_available_p, 0, 0, 0,
+ doc: /* Return t if zlib decompression is available in this instance of
Emacs. */)
+ (void)
+{
+#ifdef WINDOWSNT
+ Lisp_Object found = Fassq (Qzlib_dll, Vlibrary_cache);
+ if (CONSP (found))
+ return XCDR (found);
+ else
+ {
+ Lisp_Object status;
+ status = init_zlib_functions () ? Qt : Qnil;
+ Vlibrary_cache = Fcons (Fcons (Qzlib_dll, status), Vlibrary_cache);
+ return status;
+ }
+#else
+ return Qt;
+#endif
+}
+
DEFUN ("decompress-gzipped-region", Fdecompress_gzipped_region,
Sdecompress_gzipped_region,
2, 2, 0,
@@ -80,7 +152,7 @@
stream.next_in = Z_NULL;
/* This magic number apparently means "this is gzip". */
- if (inflateInit2 (&stream, 16 + MAX_WBITS) != Z_OK)
+ if (fn_inflateInit2 (&stream, 16 + MAX_WBITS) != Z_OK)
return Qnil;
unwind_data.start = iend;
@@ -111,7 +183,7 @@
stream.avail_in = avail_in;
stream.next_out = GPT_ADDR;
stream.avail_out = avail_out;
- inflate_status = inflate (&stream, Z_NO_FLUSH);
+ inflate_status = fn_inflate (&stream, Z_NO_FLUSH);
pos_byte += avail_in - stream.avail_in;
decompressed = avail_out - stream.avail_out;
insert_from_gap (decompressed, decompressed, 0);
@@ -137,7 +209,9 @@
void
syms_of_decompress (void)
{
+ DEFSYM (Qzlib_dll, "zlib");
defsubr (&Sdecompress_gzipped_region);
+ defsubr (&Szlib_available_p);
}
#endif /* HAVE_ZLIB */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r113816: Fix build with zlib on MS-Windows.,
Eli Zaretskii <=