Merge android-4.3_r3:
Android 4.3 release 3.0

# gpg: Signature made Tuesday 17 September 2013 01:16:25 AM IST using DSA key ID 9AB10E78
# gpg: Can't check signature: public key not found

* tag 'android-4.3_r3':
  Fix Windows build issues for librsloader.
diff --git a/Android.mk b/Android.mk
index e2410f6..3027f63 100644
--- a/Android.mk
+++ b/Android.mk
@@ -300,6 +300,10 @@
 
 LOCAL_SRC_FILES := $(rsloader_SRC_FILES)
 
+ifdef USE_MINGW
+LOCAL_SRC_FILES += driver/linkloader/lib/mmanWindows.cpp
+endif
+
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
 LOCAL_CFLAGS += $(rs_base_CFLAGS)
diff --git a/driver/linkloader/include/impl/ELFSectionBits.hxx b/driver/linkloader/include/impl/ELFSectionBits.hxx
index bd585d4..c99254b 100644
--- a/driver/linkloader/include/impl/ELFSectionBits.hxx
+++ b/driver/linkloader/include/impl/ELFSectionBits.hxx
@@ -22,7 +22,11 @@
 
 #include <llvm/Support/raw_ostream.h>
 
+#ifndef USE_MINGW       /* TODO create a proper HAVE_MMAN_H */
 #include <sys/mman.h>
+#else
+#include "mmanWindows.h"
+#endif
 
 template <unsigned Bitwidth>
 inline void ELFSectionBits<Bitwidth>::print() const {
diff --git a/driver/linkloader/include/impl/ELFSectionNoBits.hxx b/driver/linkloader/include/impl/ELFSectionNoBits.hxx
index d1a6436..6f9f713 100644
--- a/driver/linkloader/include/impl/ELFSectionNoBits.hxx
+++ b/driver/linkloader/include/impl/ELFSectionNoBits.hxx
@@ -24,8 +24,6 @@
 #include <llvm/Support/Format.h>
 #include <llvm/Support/raw_ostream.h>
 
-#include <sys/mman.h>
-
 template <unsigned Bitwidth>
 template <typename Archiver>
 inline ELFSectionNoBits<Bitwidth> *
diff --git a/driver/linkloader/include/mmanWindows.h b/driver/linkloader/include/mmanWindows.h
new file mode 100644
index 0000000..f9c68ff
--- /dev/null
+++ b/driver/linkloader/include/mmanWindows.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2013, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MMANWINDOWS_H
+#define MMANWINDOWS_H
+
+#ifdef _WIN32
+
+#include <stdlib.h>
+#include <sys/types.h>
+
+// From bionic/libc/include/sys/mman.h
+#ifndef MAP_ANON
+#define MAP_ANON  MAP_ANONYMOUS
+#endif
+
+#define MAP_FAILED ((void *)-1)
+
+#define MREMAP_MAYMOVE  1
+#define MREMAP_FIXED    2
+
+extern void*  mmap(void *, size_t, int, int, int, off_t);
+extern int    munmap(void *, size_t);
+extern int    msync(const void *, size_t, int);
+extern int    mprotect(const void *, size_t, int);
+extern void*  mremap(void *, size_t, size_t, unsigned long);
+
+extern int    mlockall(int);
+extern int    munlockall(void);
+extern int    mlock(const void *, size_t);
+extern int    munlock(const void *, size_t);
+extern int    madvise(const void *, size_t, int);
+
+extern int    mlock(const void *addr, size_t len);
+extern int    munlock(const void *addr, size_t len);
+
+extern int    mincore(void*  start, size_t  length, unsigned char*  vec);
+
+// From bionic/libc/kernel/common/asm-generic/mman-common.h
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
+#define PROT_EXEC 0x4
+#define PROT_SEM 0x8
+#define PROT_NONE 0x0
+
+#define MAP_PRIVATE 0x02
+#define MAP_ANONYMOUS 0x20
+
+#endif  // _WIN32
+
+#endif  // MMANWINDOWS_H
diff --git a/driver/linkloader/lib/MemChunk.cpp b/driver/linkloader/lib/MemChunk.cpp
index 24dcf8e..6a04916 100644
--- a/driver/linkloader/lib/MemChunk.cpp
+++ b/driver/linkloader/lib/MemChunk.cpp
@@ -21,7 +21,11 @@
 
 #include <llvm/Support/raw_ostream.h>
 
+#ifndef USE_MINGW       /* TODO create a proper HAVE_MMAN_H */
 #include <sys/mman.h>
+#else
+#include "mmanWindows.h"
+#endif
 
 #include <stdlib.h>
 
diff --git a/driver/linkloader/lib/StubLayout.cpp b/driver/linkloader/lib/StubLayout.cpp
index 00555ad..bfaf355 100644
--- a/driver/linkloader/lib/StubLayout.cpp
+++ b/driver/linkloader/lib/StubLayout.cpp
@@ -22,7 +22,6 @@
 
 #include <stdint.h>
 #include <stdlib.h>
-#include <sys/mman.h>
 
 StubLayout::StubLayout() : table(NULL), count(0) {
 }
diff --git a/driver/linkloader/lib/mmanWindows.cpp b/driver/linkloader/lib/mmanWindows.cpp
new file mode 100644
index 0000000..1b4d608
--- /dev/null
+++ b/driver/linkloader/lib/mmanWindows.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2013, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef USE_MINGW
+
+#include "mmanWindows.h"
+
+void* mmap(void *, size_t, int, int, int, off_t) {
+  return MAP_FAILED;
+}
+
+int munmap(void *, size_t) {
+  return -1;
+}
+
+int mprotect(const void *, size_t, int) {
+  return -1;
+}
+
+#endif  // USE_MINGW