Bug 591511 – hb-blob.c does not compile using mingw on windows

Only call mprotect() when available.  For optimal performance, a win32
way to make memory writeable needs to be added.
This commit is contained in:
Behdad Esfahbod 2009-08-12 19:36:29 -04:00
parent a579584594
commit c486ea9c35
1 changed files with 8 additions and 0 deletions

View File

@ -28,8 +28,12 @@
#include "hb-blob.h" #include "hb-blob.h"
#ifdef HAVE_MPROTECT
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif /* HAVE_UNISTD_H */
#include <sys/mman.h> #include <sys/mman.h>
#endif /* HAVE_MPROTECT */
struct _hb_blob_t { struct _hb_blob_t {
hb_reference_count_t ref_count; hb_reference_count_t ref_count;
@ -240,6 +244,7 @@ hb_blob_try_writeable_inplace (hb_blob_t *blob)
hb_mutex_lock (blob->lock); hb_mutex_lock (blob->lock);
#ifdef HAVE_MPROTECT
if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITEABLE) { if (blob->mode == HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITEABLE) {
unsigned int pagesize, mask, length; unsigned int pagesize, mask, length;
const char *addr; const char *addr;
@ -281,6 +286,9 @@ hb_blob_try_writeable_inplace (hb_blob_t *blob)
addr, addr+length, length); addr, addr+length, length);
#endif #endif
} }
#else /* !HAVE_MPROTECT */
#warning "No way to make readonly memory writeable. This is suboptimal."
#endif
done: done:
mode = blob->mode; mode = blob->mode;