am 58cbe71c: am 8654b6c6: am 3ff1591c: am 28b127ec: New DevBytes animation demos

* commit '58cbe71cc434d787e54d3b3a1d7d86af9727857c':
  New DevBytes animation demos
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index 32738dd..5847201 100644
--- a/apps/Development/AndroidManifest.xml
+++ b/apps/Development/AndroidManifest.xml
@@ -25,6 +25,7 @@
     <uses-permission android:name="android.permission.DUMP" />
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     <uses-permission android:name="android.permission.HARDWARE_TEST" />
+    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
     <uses-permission android:name="android.permission.REBOOT" />
@@ -117,12 +118,14 @@
             </intent-filter>
         </activity>
 
+    <!--
         <activity android:name="GLSTester" android:label="Google Login Service">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.TEST" />
             </intent-filter>
         </activity>
+    -->
 
         <activity android:name="RunningProcesses" android:label="Running processes">
             <intent-filter>
diff --git a/apps/Development/src/com/android/development/EnterURL.java b/apps/Development/src/com/android/development/EnterURL.java
deleted file mode 100644
index 76b8a34..0000000
--- a/apps/Development/src/com/android/development/EnterURL.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/* //device/apps/Notes/NotesList.java
-**
-** Copyright 2006, 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.
-*/
-package com.android.development;
-
-import android.app.ListActivity;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.os.Bundle;
-import android.text.Editable;
-import android.text.Selection;
-import android.text.format.DateUtils;
-import android.util.AttributeSet;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-import android.graphics.Rect;
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-
-public class EnterURL extends ListActivity
-{
-    private static final int DATABASE_VERSION = 1;
-    public static class UrlEditText extends EditText
-    {
-        public UrlEditText(Context context, AttributeSet attrs)
-        {
-            super(context, attrs);
-        }
-        
-        @Override
-        protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
-        {
-            super.onFocusChanged(focused, direction, previouslyFocusedRect);
-            if (focused) {
-                Editable text = getText();
-                String str = text.toString();
-                int highlightStart = 0;
-                if (str.startsWith("content://")) {
-                    highlightStart = "content://".length();
-                }
-                Selection.setSelection(text, highlightStart, text.length());
-            }
-        }
-    }
-
-    public static class DisplayEditText extends EditText
-    {
-        public DisplayEditText(Context context, AttributeSet attrs)
-        {
-            super(context, attrs);
-        }
-        
-        @Override
-        protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect)
-        {
-            super.onFocusChanged(focused, direction, previouslyFocusedRect);
-            if (focused) {
-                Editable text = getText();
-                Selection.setSelection(text, 0, text.length());
-            }
-        }
-    }
-
-    @Override
-    public View onCreateView(String name, Context context, AttributeSet attrs)
-    {
-        if (name.equals("com.android.development.UrlEditText")) {
-            return new UrlEditText(this, attrs);
-        }
-        if (name.equals("com.android.development.DisplayEditText")) {
-            return new DisplayEditText(this, attrs);
-        }
-        return null;
-    }
-
-    View.OnClickListener mViewItemAction = new View.OnClickListener () {
-        public void onClick(View v)
-        {
-            String url = mUrlField.getText().toString();
-            String display = mDisplayField.getText().toString();
-            viewItem(url, display);
-        }
-    };
-
-    public void onCreate(Bundle icicle)
-    {
-        super.onCreate(icicle);
-        setContentView(R.layout.enter_url);
-
-        // display
-        mDisplayField = (DisplayEditText)findViewById(R.id.display_edit_text);
-        mDisplayField.setOnClickListener(mViewItemAction);
-        // url
-        mUrlField = (UrlEditText)findViewById(R.id.url_edit_text);
-        mUrlField.setOnClickListener(mViewItemAction);
-    }
-
-    public void onStop()
-    {
-        super.onStop();
-
-        if (mCursor != null) {
-            mCursor.deactivate();
-        }
-    }
-
-    public void onResume()
-    {
-        super.onResume();
-
-        // show the history
-        loadPrefs();
-        fillListView();
-        if (mHistory.size() > 0) {
-            ListView lv = this.getListView();
-            lv.setSelection(0);
-            lv.requestFocus();
-        }
-    }
-
-    public boolean onCreateOptionsMenu(Menu menu)
-    {
-        super.onCreateOptionsMenu(menu);
-        menu.add(0, 0, 0, "Clear Bookmarks").setOnMenuItemClickListener(mClearBookmarks);
-        return true;
-    }
-
-    protected void onListItemClick(ListView l, View v, int position, long id)
-    {
-        HistoryEntry he = mHistory.get(position);
-        viewItem(he.url, he.display);
-    }
-
-    private final void viewItem(String url, String display)
-    {
-        // -------------- save this in the history ----------------
-        // look in the history
-        int count = mHistory.size();
-        int i;
-        for (i=0; i<count; i++) {
-            HistoryEntry he = mHistory.get(i);
-            if (he.url.equals(url) && he.display.equals(display)) {
-                he.updateAccessTime();
-                mHistory.remove(i);
-                mHistory.add(0, he);
-                break;
-            }
-        }
-        if (i >= count) {
-            // didn't find it, add it first
-            HistoryEntry he = new HistoryEntry();
-            he.url = url;
-            he.display = display;
-            he.updateAccessTime();
-            mHistory.add(0, he);
-        }
-
-        savePrefs();
-
-        // -------------- view it ---------------------------------
-        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
-        intent.setClass(this, DataList.class);
-        intent.putExtra("display", display);
-        startActivity(intent);
-    }
-
-    MenuItem.OnMenuItemClickListener mClearBookmarks = new MenuItem.OnMenuItemClickListener() {
-        public boolean onMenuItemClick(MenuItem item) {
-            mHistory.clear();
-            savePrefs();
-            fillListView();
-            return true;
-        }
-    };
-
-    private void fillListView()
-    {
-        loadPrefs();
-        ArrayList<HashMap<String, String>> d = new ArrayList<HashMap<String, String>>();
-        int count = mHistory.size();
-        for (int i=0; i<count; i++) {
-            HashMap<String, String> m = new HashMap<String, String>();
-            HistoryEntry he = mHistory.get(i);
-            m.put("title", he.url + " (" + he.display + ")");
-            d.add(m);
-        }
-        setListAdapter(new SimpleAdapter(this, d, R.layout.url_list,
-                                         new String[] {"title"},
-                                         new int[] {android.R.id.text1}));
-    }
-
-    SQLiteDatabase openDB()
-    {
-        SQLiteDatabase db = null;
-        db = openOrCreateDatabase("inspector.db", 0, null);
-        int version = db.getVersion();
-        if (version != DATABASE_VERSION) {
-            db.execSQL("CREATE TABLE History ("
-                        + " url TEXT,"
-                        + " display TEXT,"
-                        + " lastAccessTime TEXT"
-                        + ");");
-            db.execSQL("CREATE TABLE FieldState ("
-                        + " url TEXT,"
-                        + " display TEXT"
-                        + ");");
-            db.setVersion(DATABASE_VERSION);
-        }
-        return db;
-    }
-
-    private void loadPrefs()
-    {
-        SQLiteDatabase db = openDB();
-        Cursor c = db.query("History",
-                            new String[] { "url", "display", "lastAccessTime" },
-                            null, null, null, null, "lastAccessTime DESC");
-        int urlCol = c.getColumnIndex("url");
-        int accessCol = c.getColumnIndex("lastAccessTime");
-        int displayCol = c.getColumnIndex("display");
-        mHistory.clear();
-        while (c.moveToNext()) {
-            HistoryEntry he = new HistoryEntry();
-            he.url = c.getString(urlCol);
-            he.display = c.getString(displayCol);
-            he.lastAccessTime = c.getString(accessCol);
-            mHistory.add(he);
-        }
-
-        c = db.query("FieldState", null, null, null, null, null, null);
-        if (c.moveToNext()) {
-            urlCol = c.getColumnIndex("url");
-            displayCol = c.getColumnIndex("display");
-            mUrlField.setText(c.getString(urlCol));
-            mDisplayField.setText(c.getString(displayCol));
-        } else {
-            mDisplayField.setText("_id");
-            mUrlField.setText("content://");
-        }
-
-        db.close();
-    }
-
-    private void savePrefs()
-    {
-        ContentValues m;
-        HistoryEntry he;
-
-        SQLiteDatabase db = openDB();
-        db.execSQL("DELETE FROM History;");
-        int count = mHistory.size();
-        for (int i=0; i<count; i++) {
-            m = new ContentValues();
-            he = mHistory.get(i);
-            m.put("url", he.url);
-            m.put("display", he.display);
-            m.put("lastAccessTime", he.lastAccessTime);
-            db.insert("History", null, m);
-        }
-
-        db.execSQL("DELETE FROM FieldState");
-        m = new ContentValues();
-        m.put("url", mUrlField.getText().toString());
-        m.put("display", mDisplayField.getText().toString());
-        db.insert("FieldState", null, m);
-
-        db.close();
-    }
-
-    private class HistoryEntry
-    {
-        public String url;
-        public String display;
-        public String lastAccessTime;
-        public void updateAccessTime()
-        {
-            this.lastAccessTime = DateUtils.writeDateTime(
-                                                    new GregorianCalendar());
-        }
-    }
-
-    private ArrayList<HistoryEntry> mHistory = new ArrayList<HistoryEntry>();
-    private UrlEditText mUrlField;
-    private DisplayEditText mDisplayField;
-    private Cursor mCursor;
-}
diff --git a/build/product_sdk.mk b/build/product_sdk.mk
index ad82778..3d54411 100644
--- a/build/product_sdk.mk
+++ b/build/product_sdk.mk
@@ -47,7 +47,6 @@
 	org.eclipse.equinox.common_3.6.0.v20100503 \
 	org.eclipse.core.commands_3.6.0.I20100512-1500 \
 	osgi \
-	swing-worker-1.1 \
 	vgabios-cirrus.bin
 
 :qa!

diff --git a/build/tools/sdk_repo.mk b/build/tools/sdk_repo.mk
index 4e638c2..24e380f 100644
--- a/build/tools/sdk_repo.mk
+++ b/build/tools/sdk_repo.mk
@@ -158,16 +158,17 @@
 # Pickup the most recent xml schema for repository and add-on
 
 SDK_REPO_XSD := \
-	$(lastword \
-	  $(wildcard \
-	    $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-*.xsd \
-	))
+    $(lastword \
+      $(wildcard \
+        $(TOPDIR)prebuilts/devtools/repository/sdk-repository-*.xsd \
+    ))
 
 SDK_ADDON_XSD := \
-	$(lastword \
-	  $(wildcard \
-	    $(TOPDIR)sdk/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-*.xsd \
-	))
+    $(lastword \
+      $(wildcard \
+        $(TOPDIR)prebuilts/devtools/repository/sdk-addon-*.xsd \
+    ))
+
 
 # -----------------------------------------------------------------
 # Rules for sdk addon
diff --git a/build/sdk_only_whitelist.mk b/build/windows_sdk_whitelist.mk
similarity index 94%
rename from build/sdk_only_whitelist.mk
rename to build/windows_sdk_whitelist.mk
index 191e1b4..523883a 100644
--- a/build/sdk_only_whitelist.mk
+++ b/build/windows_sdk_whitelist.mk
@@ -13,11 +13,11 @@
 
 # Note that there are 2 flavors of this file:
 #
-# - The other file: sdk/build/sdk_only_whitelist.mk
+# - The other file: sdk/build/windows_sdk_whitelist.mk
 #   must list all projects that are that are NOT specific to a given platform.
 #   These binaries are the ones typically found in the SDK/tools directory.
 #
-# - This file: development/build/sdk_only_whitelist.mk
+# - This file: development/build/windows_sdk_whitelist.mk
 #   must list all projects that are specific to a given platform. These
 #   projects generate files that are generally locates in SDK/platform-tools,
 #   or SDK/platforms/, etc.
diff --git a/ndk/platforms/README.CRT.TXT b/ndk/platforms/README.CRT.TXT
index c7b2c41..8cc33ed 100644
--- a/ndk/platforms/README.CRT.TXT
+++ b/ndk/platforms/README.CRT.TXT
@@ -15,7 +15,7 @@
   crtbegin_static.[cS]
     This file contains a tiny ELF startup entry point (named '_start')
     that is linked into every Android _static_ executable. These binaries can
-    run on any Linux ARM system, but cannot perform dynamic linking at all.
+    run on any Linux system, but cannot perform dynamic linking at all.
 
     Note that the kernel calls the '_start' entry point directly when it
     launches such an executable. The _start stub is used to call the
diff --git a/ndk/platforms/android-14/arch-arm/symbols/libOpenSLES.so.functions.txt b/ndk/platforms/android-14/arch-arm/symbols/libOpenSLES.so.functions.txt
new file mode 100644
index 0000000..f69a3e5
--- /dev/null
+++ b/ndk/platforms/android-14/arch-arm/symbols/libOpenSLES.so.functions.txt
@@ -0,0 +1,3 @@
+slCreateEngine
+slQueryNumSupportedEngineInterfaces
+slQuerySupportedEngineInterfaces
diff --git a/ndk/platforms/android-14/arch-x86/symbols/libOpenSLES.so.functions.txt b/ndk/platforms/android-14/arch-x86/symbols/libOpenSLES.so.functions.txt
new file mode 100644
index 0000000..f69a3e5
--- /dev/null
+++ b/ndk/platforms/android-14/arch-x86/symbols/libOpenSLES.so.functions.txt
@@ -0,0 +1,3 @@
+slCreateEngine
+slQueryNumSupportedEngineInterfaces
+slQuerySupportedEngineInterfaces
diff --git a/ndk/platforms/android-3/arch-arm/include/asm/socket.h b/ndk/platforms/android-3/arch-arm/include/asm/socket.h
index 1f0050a..0741bad 100644
--- a/ndk/platforms/android-3/arch-arm/include/asm/socket.h
+++ b/ndk/platforms/android-3/arch-arm/include/asm/socket.h
@@ -7,55 +7,73 @@
  ***   structures, and macros generated from the original header, and thus,
  ***   contains no copyrightable information.
  ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
  ****************************************************************************
  ****************************************************************************/
 #ifndef _ASMARM_SOCKET_H
 #define _ASMARM_SOCKET_H
-
 #include <asm/sockios.h>
-
 #define SOL_SOCKET 1
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_DEBUG 1
 #define SO_REUSEADDR 2
 #define SO_TYPE 3
 #define SO_ERROR 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_DONTROUTE 5
 #define SO_BROADCAST 6
 #define SO_SNDBUF 7
 #define SO_RCVBUF 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_SNDBUFFORCE 32
 #define SO_RCVBUFFORCE 33
 #define SO_KEEPALIVE 9
 #define SO_OOBINLINE 10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_NO_CHECK 11
 #define SO_PRIORITY 12
 #define SO_LINGER 13
 #define SO_BSDCOMPAT 14
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PASSCRED 16
 #define SO_PEERCRED 17
 #define SO_RCVLOWAT 18
 #define SO_SNDLOWAT 19
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_RCVTIMEO 20
 #define SO_SNDTIMEO 21
-
 #define SO_SECURITY_AUTHENTICATION 22
 #define SO_SECURITY_ENCRYPTION_TRANSPORT 23
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_SECURITY_ENCRYPTION_NETWORK 24
-
 #define SO_BINDTODEVICE 25
-
 #define SO_ATTACH_FILTER 26
 #define SO_DETACH_FILTER 27
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PEERNAME 28
 #define SO_TIMESTAMP 29
 #define SCM_TIMESTAMP SO_TIMESTAMP
-
 #define SO_ACCEPTCONN 30
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PEERSEC 31
 #define SO_PASSSEC 34
-
+#define SO_TIMESTAMPNS 35
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_MARK 36
+#define SO_TIMESTAMPING 37
+#define SCM_TIMESTAMPING SO_TIMESTAMPING
+#define SO_PROTOCOL 38
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_DOMAIN 39
+#define SO_RXQ_OVFL 40
+#define SO_WIFI_STATUS 41
+#define SCM_WIFI_STATUS SO_WIFI_STATUS
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
diff --git a/ndk/platforms/android-3/arch-arm/include/asm/unistd.h b/ndk/platforms/android-3/arch-arm/include/asm/unistd.h
index 9a30ddc..454ed89 100644
--- a/ndk/platforms/android-3/arch-arm/include/asm/unistd.h
+++ b/ndk/platforms/android-3/arch-arm/include/asm/unistd.h
@@ -7,353 +7,480 @@
  ***   structures, and macros generated from the original header, and thus,
  ***   contains no copyrightable information.
  ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
  ****************************************************************************
  ****************************************************************************/
 #ifndef __ASM_ARM_UNISTD_H
 #define __ASM_ARM_UNISTD_H
-
 #define __NR_OABI_SYSCALL_BASE 0x900000
-
 #if defined(__thumb__) || defined(__ARM_EABI__)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_SYSCALL_BASE 0
 #else
 #define __NR_SYSCALL_BASE __NR_OABI_SYSCALL_BASE
 #endif
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_restart_syscall (__NR_SYSCALL_BASE+ 0)
 #define __NR_exit (__NR_SYSCALL_BASE+ 1)
 #define __NR_fork (__NR_SYSCALL_BASE+ 2)
 #define __NR_read (__NR_SYSCALL_BASE+ 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_write (__NR_SYSCALL_BASE+ 4)
 #define __NR_open (__NR_SYSCALL_BASE+ 5)
 #define __NR_close (__NR_SYSCALL_BASE+ 6)
-
 #define __NR_creat (__NR_SYSCALL_BASE+ 8)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_link (__NR_SYSCALL_BASE+ 9)
 #define __NR_unlink (__NR_SYSCALL_BASE+ 10)
 #define __NR_execve (__NR_SYSCALL_BASE+ 11)
 #define __NR_chdir (__NR_SYSCALL_BASE+ 12)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_time (__NR_SYSCALL_BASE+ 13)
 #define __NR_mknod (__NR_SYSCALL_BASE+ 14)
 #define __NR_chmod (__NR_SYSCALL_BASE+ 15)
 #define __NR_lchown (__NR_SYSCALL_BASE+ 16)
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lseek (__NR_SYSCALL_BASE+ 19)
 #define __NR_getpid (__NR_SYSCALL_BASE+ 20)
 #define __NR_mount (__NR_SYSCALL_BASE+ 21)
 #define __NR_umount (__NR_SYSCALL_BASE+ 22)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setuid (__NR_SYSCALL_BASE+ 23)
 #define __NR_getuid (__NR_SYSCALL_BASE+ 24)
 #define __NR_stime (__NR_SYSCALL_BASE+ 25)
 #define __NR_ptrace (__NR_SYSCALL_BASE+ 26)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_alarm (__NR_SYSCALL_BASE+ 27)
-
 #define __NR_pause (__NR_SYSCALL_BASE+ 29)
 #define __NR_utime (__NR_SYSCALL_BASE+ 30)
-
 #define __NR_access (__NR_SYSCALL_BASE+ 33)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_nice (__NR_SYSCALL_BASE+ 34)
-
 #define __NR_sync (__NR_SYSCALL_BASE+ 36)
 #define __NR_kill (__NR_SYSCALL_BASE+ 37)
 #define __NR_rename (__NR_SYSCALL_BASE+ 38)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mkdir (__NR_SYSCALL_BASE+ 39)
 #define __NR_rmdir (__NR_SYSCALL_BASE+ 40)
 #define __NR_dup (__NR_SYSCALL_BASE+ 41)
 #define __NR_pipe (__NR_SYSCALL_BASE+ 42)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_times (__NR_SYSCALL_BASE+ 43)
-
 #define __NR_brk (__NR_SYSCALL_BASE+ 45)
 #define __NR_setgid (__NR_SYSCALL_BASE+ 46)
 #define __NR_getgid (__NR_SYSCALL_BASE+ 47)
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_geteuid (__NR_SYSCALL_BASE+ 49)
 #define __NR_getegid (__NR_SYSCALL_BASE+ 50)
 #define __NR_acct (__NR_SYSCALL_BASE+ 51)
 #define __NR_umount2 (__NR_SYSCALL_BASE+ 52)
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ioctl (__NR_SYSCALL_BASE+ 54)
 #define __NR_fcntl (__NR_SYSCALL_BASE+ 55)
-
 #define __NR_setpgid (__NR_SYSCALL_BASE+ 57)
-
 #define __NR_umask (__NR_SYSCALL_BASE+ 60)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_chroot (__NR_SYSCALL_BASE+ 61)
 #define __NR_ustat (__NR_SYSCALL_BASE+ 62)
 #define __NR_dup2 (__NR_SYSCALL_BASE+ 63)
 #define __NR_getppid (__NR_SYSCALL_BASE+ 64)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpgrp (__NR_SYSCALL_BASE+ 65)
 #define __NR_setsid (__NR_SYSCALL_BASE+ 66)
 #define __NR_sigaction (__NR_SYSCALL_BASE+ 67)
-
 #define __NR_setreuid (__NR_SYSCALL_BASE+ 70)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setregid (__NR_SYSCALL_BASE+ 71)
 #define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72)
 #define __NR_sigpending (__NR_SYSCALL_BASE+ 73)
 #define __NR_sethostname (__NR_SYSCALL_BASE+ 74)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setrlimit (__NR_SYSCALL_BASE+ 75)
 #define __NR_getrlimit (__NR_SYSCALL_BASE+ 76)  
 #define __NR_getrusage (__NR_SYSCALL_BASE+ 77)
 #define __NR_gettimeofday (__NR_SYSCALL_BASE+ 78)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_settimeofday (__NR_SYSCALL_BASE+ 79)
 #define __NR_getgroups (__NR_SYSCALL_BASE+ 80)
 #define __NR_setgroups (__NR_SYSCALL_BASE+ 81)
 #define __NR_select (__NR_SYSCALL_BASE+ 82)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_symlink (__NR_SYSCALL_BASE+ 83)
-
 #define __NR_readlink (__NR_SYSCALL_BASE+ 85)
 #define __NR_uselib (__NR_SYSCALL_BASE+ 86)
 #define __NR_swapon (__NR_SYSCALL_BASE+ 87)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_reboot (__NR_SYSCALL_BASE+ 88)
 #define __NR_readdir (__NR_SYSCALL_BASE+ 89)
 #define __NR_mmap (__NR_SYSCALL_BASE+ 90)
 #define __NR_munmap (__NR_SYSCALL_BASE+ 91)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_truncate (__NR_SYSCALL_BASE+ 92)
 #define __NR_ftruncate (__NR_SYSCALL_BASE+ 93)
 #define __NR_fchmod (__NR_SYSCALL_BASE+ 94)
 #define __NR_fchown (__NR_SYSCALL_BASE+ 95)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpriority (__NR_SYSCALL_BASE+ 96)
 #define __NR_setpriority (__NR_SYSCALL_BASE+ 97)
-
 #define __NR_statfs (__NR_SYSCALL_BASE+ 99)
 #define __NR_fstatfs (__NR_SYSCALL_BASE+100)
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_socketcall (__NR_SYSCALL_BASE+102)
 #define __NR_syslog (__NR_SYSCALL_BASE+103)
 #define __NR_setitimer (__NR_SYSCALL_BASE+104)
 #define __NR_getitimer (__NR_SYSCALL_BASE+105)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_stat (__NR_SYSCALL_BASE+106)
 #define __NR_lstat (__NR_SYSCALL_BASE+107)
 #define __NR_fstat (__NR_SYSCALL_BASE+108)
-
 #define __NR_vhangup (__NR_SYSCALL_BASE+111)
-
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_syscall (__NR_SYSCALL_BASE+113)  
 #define __NR_wait4 (__NR_SYSCALL_BASE+114)
 #define __NR_swapoff (__NR_SYSCALL_BASE+115)
 #define __NR_sysinfo (__NR_SYSCALL_BASE+116)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ipc (__NR_SYSCALL_BASE+117)
 #define __NR_fsync (__NR_SYSCALL_BASE+118)
 #define __NR_sigreturn (__NR_SYSCALL_BASE+119)
 #define __NR_clone (__NR_SYSCALL_BASE+120)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setdomainname (__NR_SYSCALL_BASE+121)
 #define __NR_uname (__NR_SYSCALL_BASE+122)
-
 #define __NR_adjtimex (__NR_SYSCALL_BASE+124)
 #define __NR_mprotect (__NR_SYSCALL_BASE+125)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sigprocmask (__NR_SYSCALL_BASE+126)
-
 #define __NR_init_module (__NR_SYSCALL_BASE+128)
 #define __NR_delete_module (__NR_SYSCALL_BASE+129)
-
 #define __NR_quotactl (__NR_SYSCALL_BASE+131)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpgid (__NR_SYSCALL_BASE+132)
 #define __NR_fchdir (__NR_SYSCALL_BASE+133)
 #define __NR_bdflush (__NR_SYSCALL_BASE+134)
 #define __NR_sysfs (__NR_SYSCALL_BASE+135)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_personality (__NR_SYSCALL_BASE+136)
-
 #define __NR_setfsuid (__NR_SYSCALL_BASE+138)
 #define __NR_setfsgid (__NR_SYSCALL_BASE+139)
 #define __NR__llseek (__NR_SYSCALL_BASE+140)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getdents (__NR_SYSCALL_BASE+141)
 #define __NR__newselect (__NR_SYSCALL_BASE+142)
 #define __NR_flock (__NR_SYSCALL_BASE+143)
 #define __NR_msync (__NR_SYSCALL_BASE+144)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readv (__NR_SYSCALL_BASE+145)
 #define __NR_writev (__NR_SYSCALL_BASE+146)
 #define __NR_getsid (__NR_SYSCALL_BASE+147)
 #define __NR_fdatasync (__NR_SYSCALL_BASE+148)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR__sysctl (__NR_SYSCALL_BASE+149)
 #define __NR_mlock (__NR_SYSCALL_BASE+150)
 #define __NR_munlock (__NR_SYSCALL_BASE+151)
 #define __NR_mlockall (__NR_SYSCALL_BASE+152)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_munlockall (__NR_SYSCALL_BASE+153)
 #define __NR_sched_setparam (__NR_SYSCALL_BASE+154)
 #define __NR_sched_getparam (__NR_SYSCALL_BASE+155)
 #define __NR_sched_setscheduler (__NR_SYSCALL_BASE+156)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getscheduler (__NR_SYSCALL_BASE+157)
 #define __NR_sched_yield (__NR_SYSCALL_BASE+158)
 #define __NR_sched_get_priority_max (__NR_SYSCALL_BASE+159)
 #define __NR_sched_get_priority_min (__NR_SYSCALL_BASE+160)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_rr_get_interval (__NR_SYSCALL_BASE+161)
 #define __NR_nanosleep (__NR_SYSCALL_BASE+162)
 #define __NR_mremap (__NR_SYSCALL_BASE+163)
 #define __NR_setresuid (__NR_SYSCALL_BASE+164)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getresuid (__NR_SYSCALL_BASE+165)
-
 #define __NR_poll (__NR_SYSCALL_BASE+168)
 #define __NR_nfsservctl (__NR_SYSCALL_BASE+169)
 #define __NR_setresgid (__NR_SYSCALL_BASE+170)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getresgid (__NR_SYSCALL_BASE+171)
 #define __NR_prctl (__NR_SYSCALL_BASE+172)
 #define __NR_rt_sigreturn (__NR_SYSCALL_BASE+173)
 #define __NR_rt_sigaction (__NR_SYSCALL_BASE+174)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigprocmask (__NR_SYSCALL_BASE+175)
 #define __NR_rt_sigpending (__NR_SYSCALL_BASE+176)
 #define __NR_rt_sigtimedwait (__NR_SYSCALL_BASE+177)
 #define __NR_rt_sigqueueinfo (__NR_SYSCALL_BASE+178)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigsuspend (__NR_SYSCALL_BASE+179)
 #define __NR_pread64 (__NR_SYSCALL_BASE+180)
 #define __NR_pwrite64 (__NR_SYSCALL_BASE+181)
 #define __NR_chown (__NR_SYSCALL_BASE+182)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getcwd (__NR_SYSCALL_BASE+183)
 #define __NR_capget (__NR_SYSCALL_BASE+184)
 #define __NR_capset (__NR_SYSCALL_BASE+185)
 #define __NR_sigaltstack (__NR_SYSCALL_BASE+186)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendfile (__NR_SYSCALL_BASE+187)
-
 #define __NR_vfork (__NR_SYSCALL_BASE+190)
 #define __NR_ugetrlimit (__NR_SYSCALL_BASE+191)  
 #define __NR_mmap2 (__NR_SYSCALL_BASE+192)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_truncate64 (__NR_SYSCALL_BASE+193)
 #define __NR_ftruncate64 (__NR_SYSCALL_BASE+194)
 #define __NR_stat64 (__NR_SYSCALL_BASE+195)
 #define __NR_lstat64 (__NR_SYSCALL_BASE+196)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fstat64 (__NR_SYSCALL_BASE+197)
 #define __NR_lchown32 (__NR_SYSCALL_BASE+198)
 #define __NR_getuid32 (__NR_SYSCALL_BASE+199)
 #define __NR_getgid32 (__NR_SYSCALL_BASE+200)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_geteuid32 (__NR_SYSCALL_BASE+201)
 #define __NR_getegid32 (__NR_SYSCALL_BASE+202)
 #define __NR_setreuid32 (__NR_SYSCALL_BASE+203)
 #define __NR_setregid32 (__NR_SYSCALL_BASE+204)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getgroups32 (__NR_SYSCALL_BASE+205)
 #define __NR_setgroups32 (__NR_SYSCALL_BASE+206)
 #define __NR_fchown32 (__NR_SYSCALL_BASE+207)
 #define __NR_setresuid32 (__NR_SYSCALL_BASE+208)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getresuid32 (__NR_SYSCALL_BASE+209)
 #define __NR_setresgid32 (__NR_SYSCALL_BASE+210)
 #define __NR_getresgid32 (__NR_SYSCALL_BASE+211)
 #define __NR_chown32 (__NR_SYSCALL_BASE+212)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setuid32 (__NR_SYSCALL_BASE+213)
 #define __NR_setgid32 (__NR_SYSCALL_BASE+214)
 #define __NR_setfsuid32 (__NR_SYSCALL_BASE+215)
 #define __NR_setfsgid32 (__NR_SYSCALL_BASE+216)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getdents64 (__NR_SYSCALL_BASE+217)
 #define __NR_pivot_root (__NR_SYSCALL_BASE+218)
 #define __NR_mincore (__NR_SYSCALL_BASE+219)
 #define __NR_madvise (__NR_SYSCALL_BASE+220)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fcntl64 (__NR_SYSCALL_BASE+221)
-
 #define __NR_gettid (__NR_SYSCALL_BASE+224)
 #define __NR_readahead (__NR_SYSCALL_BASE+225)
 #define __NR_setxattr (__NR_SYSCALL_BASE+226)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lsetxattr (__NR_SYSCALL_BASE+227)
 #define __NR_fsetxattr (__NR_SYSCALL_BASE+228)
 #define __NR_getxattr (__NR_SYSCALL_BASE+229)
 #define __NR_lgetxattr (__NR_SYSCALL_BASE+230)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fgetxattr (__NR_SYSCALL_BASE+231)
 #define __NR_listxattr (__NR_SYSCALL_BASE+232)
 #define __NR_llistxattr (__NR_SYSCALL_BASE+233)
 #define __NR_flistxattr (__NR_SYSCALL_BASE+234)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_removexattr (__NR_SYSCALL_BASE+235)
 #define __NR_lremovexattr (__NR_SYSCALL_BASE+236)
 #define __NR_fremovexattr (__NR_SYSCALL_BASE+237)
 #define __NR_tkill (__NR_SYSCALL_BASE+238)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sendfile64 (__NR_SYSCALL_BASE+239)
 #define __NR_futex (__NR_SYSCALL_BASE+240)
 #define __NR_sched_setaffinity (__NR_SYSCALL_BASE+241)
 #define __NR_sched_getaffinity (__NR_SYSCALL_BASE+242)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_setup (__NR_SYSCALL_BASE+243)
 #define __NR_io_destroy (__NR_SYSCALL_BASE+244)
 #define __NR_io_getevents (__NR_SYSCALL_BASE+245)
 #define __NR_io_submit (__NR_SYSCALL_BASE+246)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_cancel (__NR_SYSCALL_BASE+247)
 #define __NR_exit_group (__NR_SYSCALL_BASE+248)
 #define __NR_lookup_dcookie (__NR_SYSCALL_BASE+249)
 #define __NR_epoll_create (__NR_SYSCALL_BASE+250)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_ctl (__NR_SYSCALL_BASE+251)
 #define __NR_epoll_wait (__NR_SYSCALL_BASE+252)
 #define __NR_remap_file_pages (__NR_SYSCALL_BASE+253)
-
 #define __NR_set_tid_address (__NR_SYSCALL_BASE+256)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_create (__NR_SYSCALL_BASE+257)
 #define __NR_timer_settime (__NR_SYSCALL_BASE+258)
 #define __NR_timer_gettime (__NR_SYSCALL_BASE+259)
 #define __NR_timer_getoverrun (__NR_SYSCALL_BASE+260)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_delete (__NR_SYSCALL_BASE+261)
 #define __NR_clock_settime (__NR_SYSCALL_BASE+262)
 #define __NR_clock_gettime (__NR_SYSCALL_BASE+263)
 #define __NR_clock_getres (__NR_SYSCALL_BASE+264)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_nanosleep (__NR_SYSCALL_BASE+265)
 #define __NR_statfs64 (__NR_SYSCALL_BASE+266)
 #define __NR_fstatfs64 (__NR_SYSCALL_BASE+267)
 #define __NR_tgkill (__NR_SYSCALL_BASE+268)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_utimes (__NR_SYSCALL_BASE+269)
 #define __NR_arm_fadvise64_64 (__NR_SYSCALL_BASE+270)
 #define __NR_pciconfig_iobase (__NR_SYSCALL_BASE+271)
 #define __NR_pciconfig_read (__NR_SYSCALL_BASE+272)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pciconfig_write (__NR_SYSCALL_BASE+273)
 #define __NR_mq_open (__NR_SYSCALL_BASE+274)
 #define __NR_mq_unlink (__NR_SYSCALL_BASE+275)
 #define __NR_mq_timedsend (__NR_SYSCALL_BASE+276)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_timedreceive (__NR_SYSCALL_BASE+277)
 #define __NR_mq_notify (__NR_SYSCALL_BASE+278)
 #define __NR_mq_getsetattr (__NR_SYSCALL_BASE+279)
 #define __NR_waitid (__NR_SYSCALL_BASE+280)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_socket (__NR_SYSCALL_BASE+281)
 #define __NR_bind (__NR_SYSCALL_BASE+282)
 #define __NR_connect (__NR_SYSCALL_BASE+283)
 #define __NR_listen (__NR_SYSCALL_BASE+284)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_accept (__NR_SYSCALL_BASE+285)
 #define __NR_getsockname (__NR_SYSCALL_BASE+286)
 #define __NR_getpeername (__NR_SYSCALL_BASE+287)
 #define __NR_socketpair (__NR_SYSCALL_BASE+288)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_send (__NR_SYSCALL_BASE+289)
 #define __NR_sendto (__NR_SYSCALL_BASE+290)
 #define __NR_recv (__NR_SYSCALL_BASE+291)
 #define __NR_recvfrom (__NR_SYSCALL_BASE+292)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shutdown (__NR_SYSCALL_BASE+293)
 #define __NR_setsockopt (__NR_SYSCALL_BASE+294)
 #define __NR_getsockopt (__NR_SYSCALL_BASE+295)
 #define __NR_sendmsg (__NR_SYSCALL_BASE+296)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_recvmsg (__NR_SYSCALL_BASE+297)
 #define __NR_semop (__NR_SYSCALL_BASE+298)
 #define __NR_semget (__NR_SYSCALL_BASE+299)
 #define __NR_semctl (__NR_SYSCALL_BASE+300)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgsnd (__NR_SYSCALL_BASE+301)
 #define __NR_msgrcv (__NR_SYSCALL_BASE+302)
 #define __NR_msgget (__NR_SYSCALL_BASE+303)
 #define __NR_msgctl (__NR_SYSCALL_BASE+304)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmat (__NR_SYSCALL_BASE+305)
 #define __NR_shmdt (__NR_SYSCALL_BASE+306)
 #define __NR_shmget (__NR_SYSCALL_BASE+307)
 #define __NR_shmctl (__NR_SYSCALL_BASE+308)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_add_key (__NR_SYSCALL_BASE+309)
 #define __NR_request_key (__NR_SYSCALL_BASE+310)
 #define __NR_keyctl (__NR_SYSCALL_BASE+311)
 #define __NR_semtimedop (__NR_SYSCALL_BASE+312)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vserver (__NR_SYSCALL_BASE+313)
 #define __NR_ioprio_set (__NR_SYSCALL_BASE+314)
 #define __NR_ioprio_get (__NR_SYSCALL_BASE+315)
 #define __NR_inotify_init (__NR_SYSCALL_BASE+316)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317)
 #define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318)
 #define __NR_mbind (__NR_SYSCALL_BASE+319)
 #define __NR_get_mempolicy (__NR_SYSCALL_BASE+320)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_set_mempolicy (__NR_SYSCALL_BASE+321)
-
+#define __NR_openat (__NR_SYSCALL_BASE+322)
+#define __NR_mkdirat (__NR_SYSCALL_BASE+323)
+#define __NR_mknodat (__NR_SYSCALL_BASE+324)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fchownat (__NR_SYSCALL_BASE+325)
+#define __NR_futimesat (__NR_SYSCALL_BASE+326)
+#define __NR_fstatat64 (__NR_SYSCALL_BASE+327)
+#define __NR_unlinkat (__NR_SYSCALL_BASE+328)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_renameat (__NR_SYSCALL_BASE+329)
+#define __NR_linkat (__NR_SYSCALL_BASE+330)
+#define __NR_symlinkat (__NR_SYSCALL_BASE+331)
+#define __NR_readlinkat (__NR_SYSCALL_BASE+332)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fchmodat (__NR_SYSCALL_BASE+333)
+#define __NR_faccessat (__NR_SYSCALL_BASE+334)
+#define __NR_pselect6 (__NR_SYSCALL_BASE+335)
+#define __NR_ppoll (__NR_SYSCALL_BASE+336)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_unshare (__NR_SYSCALL_BASE+337)
+#define __NR_set_robust_list (__NR_SYSCALL_BASE+338)
+#define __NR_get_robust_list (__NR_SYSCALL_BASE+339)
+#define __NR_splice (__NR_SYSCALL_BASE+340)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_arm_sync_file_range (__NR_SYSCALL_BASE+341)
+#define __NR_sync_file_range2 __NR_arm_sync_file_range
+#define __NR_tee (__NR_SYSCALL_BASE+342)
+#define __NR_vmsplice (__NR_SYSCALL_BASE+343)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_move_pages (__NR_SYSCALL_BASE+344)
+#define __NR_getcpu (__NR_SYSCALL_BASE+345)
+#define __NR_epoll_pwait (__NR_SYSCALL_BASE+346)
+#define __NR_kexec_load (__NR_SYSCALL_BASE+347)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_utimensat (__NR_SYSCALL_BASE+348)
+#define __NR_signalfd (__NR_SYSCALL_BASE+349)
+#define __NR_timerfd_create (__NR_SYSCALL_BASE+350)
+#define __NR_eventfd (__NR_SYSCALL_BASE+351)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fallocate (__NR_SYSCALL_BASE+352)
+#define __NR_timerfd_settime (__NR_SYSCALL_BASE+353)
+#define __NR_timerfd_gettime (__NR_SYSCALL_BASE+354)
+#define __NR_signalfd4 (__NR_SYSCALL_BASE+355)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_eventfd2 (__NR_SYSCALL_BASE+356)
+#define __NR_epoll_create1 (__NR_SYSCALL_BASE+357)
+#define __NR_dup3 (__NR_SYSCALL_BASE+358)
+#define __NR_pipe2 (__NR_SYSCALL_BASE+359)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_inotify_init1 (__NR_SYSCALL_BASE+360)
+#define __NR_preadv (__NR_SYSCALL_BASE+361)
+#define __NR_pwritev (__NR_SYSCALL_BASE+362)
+#define __NR_rt_tgsigqueueinfo (__NR_SYSCALL_BASE+363)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_perf_event_open (__NR_SYSCALL_BASE+364)
+#define __NR_recvmmsg (__NR_SYSCALL_BASE+365)
+#define __NR_accept4 (__NR_SYSCALL_BASE+366)
+#define __NR_fanotify_init (__NR_SYSCALL_BASE+367)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fanotify_mark (__NR_SYSCALL_BASE+368)
+#define __NR_prlimit64 (__NR_SYSCALL_BASE+369)
+#define __NR_name_to_handle_at (__NR_SYSCALL_BASE+370)
+#define __NR_open_by_handle_at (__NR_SYSCALL_BASE+371)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_clock_adjtime (__NR_SYSCALL_BASE+372)
+#define __NR_syncfs (__NR_SYSCALL_BASE+373)
+#define __NR_sendmmsg (__NR_SYSCALL_BASE+374)
+#define __NR_setns (__NR_SYSCALL_BASE+375)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_process_vm_readv (__NR_SYSCALL_BASE+376)
+#define __NR_process_vm_writev (__NR_SYSCALL_BASE+377)
 #define __ARM_NR_BASE (__NR_SYSCALL_BASE+0x0f0000)
 #define __ARM_NR_breakpoint (__ARM_NR_BASE+1)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __ARM_NR_cacheflush (__ARM_NR_BASE+2)
 #define __ARM_NR_usr26 (__ARM_NR_BASE+3)
 #define __ARM_NR_usr32 (__ARM_NR_BASE+4)
 #define __ARM_NR_set_tls (__ARM_NR_BASE+5)
-
-#if defined(__ARM_EABI__) && !defined(__KERNEL__)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifdef __ARM_EABI__
 #undef __NR_time
 #undef __NR_umount
 #undef __NR_stime
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_alarm
 #undef __NR_utime
 #undef __NR_getrlimit
 #undef __NR_select
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_readdir
 #undef __NR_mmap
 #undef __NR_socketcall
 #undef __NR_syscall
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #undef __NR_ipc
 #endif
-
 #endif
diff --git a/ndk/platforms/android-3/arch-arm/include/fenv.h b/ndk/platforms/android-3/arch-arm/include/fenv.h
index 534b12c..a96f99e 100644
--- a/ndk/platforms/android-3/arch-arm/include/fenv.h
+++ b/ndk/platforms/android-3/arch-arm/include/fenv.h
@@ -26,193 +26,151 @@
  * $FreeBSD: src/lib/msun/arm/fenv.h,v 1.5 2005/03/16 19:03:45 das Exp $
  */
 
-#ifndef	_FENV_H_
-#define	_FENV_H_
+/*
+ * Rewritten for Android.
+ *
+ * The ARM FPSCR is described here:
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344b/Chdfafia.html
+ */
+
+#ifndef _FENV_H_
+#define _FENV_H_
 
 #include <sys/types.h>
 
 __BEGIN_DECLS
 
-typedef	uint32_t	fenv_t;
-typedef	uint32_t	fexcept_t;
+typedef __uint32_t fenv_t;
+typedef __uint32_t fexcept_t;
 
-/* Exception flags */
-#define	FE_INVALID	0x0001
-#define	FE_DIVBYZERO	0x0002
-#define	FE_OVERFLOW	0x0004
-#define	FE_UNDERFLOW	0x0008
-#define	FE_INEXACT	0x0010
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+/* Exception flags. */
+#define FE_INVALID    0x01
+#define FE_DIVBYZERO  0x02
+#define FE_OVERFLOW   0x04
+#define FE_UNDERFLOW  0x08
+#define FE_INEXACT    0x10
+#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define _FPSCR_ENABLE_SHIFT 8
+#define _FPSCR_ENABLE_MASK (FE_ALL_EXCEPT << _FPSCR_ENABLE_SHIFT)
 
-/* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
+/* Rounding modes. */
+#define FE_TONEAREST  0x0
+#define FE_UPWARD     0x1
+#define FE_DOWNWARD   0x2
+#define FE_TOWARDZERO 0x3
+#define _FPSCR_RMODE_SHIFT 22
 
-/* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
+/* Default floating-point environment. */
+extern const fenv_t __fe_dfl_env;
+#define FE_DFL_ENV (&__fe_dfl_env)
 
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	16
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-
-#ifdef	ARM_HARD_FLOAT
-#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
-#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
-#else
-#define __rfs(__fpsr)
-#define __wfs(__fpsr)
-#endif
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__wfs(__fpsr);
-	return (0);
+static __inline int fegetenv(fenv_t* __envp) {
+  fenv_t _fpscr;
+  __asm__ __volatile__("vmrs %0,fpscr" : "=r" (_fpscr));
+  *__envp = _fpscr;
+  return 0;
 }
 
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	*__flagp = __fpsr & __excepts;
-	return (0);
+static __inline int fesetenv(const fenv_t* __envp) {
+  fenv_t _fpscr = *__envp;
+  __asm__ __volatile__("vmsr fpscr,%0" : :"ri" (_fpscr));
+  return 0;
 }
 
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__fpsr |= *__flagp & __excepts;
-	__wfs(__fpsr);
-	return (0);
+static __inline int feclearexcept(int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  __fpscr &= ~__excepts;
+  fesetenv(&__fpscr);
+  return 0;
 }
 
-static __inline int
-feraiseexcept(int __excepts)
-{
-	fexcept_t __ex = __excepts;
-
-	fesetexceptflag(&__ex, __excepts);	/* XXX */
-	return (0);
+static __inline int fegetexceptflag(fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  *__flagp = __fpscr & __excepts;
+  return 0;
 }
 
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	return (__fpsr & __excepts);
+static __inline int fesetexceptflag(const fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  __fpscr &= ~__excepts;
+  __fpscr |= *__flagp & __excepts;
+  fesetenv(&__fpscr);
+  return 0;
 }
 
-static __inline int
-fegetround(void)
-{
-
-	/*
-	 * Apparently, the rounding mode is specified as part of the
-	 * instruction format on ARM, so the dynamic rounding mode is
-	 * indeterminate.  Some FPUs may differ.
-	 */
-	return (-1);
+static __inline int feraiseexcept(int __excepts) {
+  fexcept_t __ex = __excepts;
+  fesetexceptflag(&__ex, __excepts);
+  return 0;
 }
 
-static __inline int
-fesetround(int __round)
-{
-
-	return (-1);
+static __inline int fetestexcept(int __excepts) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  return (__fpscr & __excepts);
 }
 
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__rfs(__envp);
-	return (0);
+static __inline int fegetround(void) {
+  fenv_t _fpscr;
+  fegetenv(&_fpscr);
+  return ((_fpscr >> _FPSCR_RMODE_SHIFT) & 0x3);
 }
 
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __env;
-
-	__rfs(&__env);
-	*__envp = __env;
-	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__wfs(__env);
-	return (0);
+static __inline int fesetround(int __round) {
+  fenv_t _fpscr;
+  fegetenv(&_fpscr);
+  _fpscr &= ~(0x3 << _FPSCR_RMODE_SHIFT);
+  _fpscr |= (__round << _FPSCR_RMODE_SHIFT);
+  fesetenv(&_fpscr);
+  return 0;
 }
 
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__wfs(*__envp);
-	return (0);
+static __inline int feholdexcept(fenv_t* __envp) {
+  fenv_t __env;
+  fegetenv(&__env);
+  *__envp = __env;
+  __env &= ~(FE_ALL_EXCEPT | _FPSCR_ENABLE_MASK);
+  fesetenv(&__env);
+  return 0;
 }
 
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__wfs(*__envp);
-	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-	return (0);
+static __inline int feupdateenv(const fenv_t* __envp) {
+  fexcept_t __fpscr;
+  fegetenv(&__fpscr);
+  fesetenv(__envp);
+  feraiseexcept(__fpscr & FE_ALL_EXCEPT);
+  return 0;
 }
 
 #if __BSD_VISIBLE
 
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int feenableexcept(int __mask) {
+  fenv_t __old_fpscr, __new_fpscr;
+  fegetenv(&__old_fpscr);
+  __new_fpscr = __old_fpscr | (__mask & FE_ALL_EXCEPT) << _FPSCR_ENABLE_SHIFT;
+  fesetenv(&__new_fpscr);
+  return ((__old_fpscr >> _FPSCR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int fedisableexcept(int __mask) {
+  fenv_t __old_fpscr, __new_fpscr;
+  fegetenv(&__old_fpscr);
+  __new_fpscr = __old_fpscr & ~((__mask & FE_ALL_EXCEPT) << _FPSCR_ENABLE_SHIFT);
+  fesetenv(&__new_fpscr);
+  return ((__old_fpscr >> _FPSCR_ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__rfs(&__fpsr);
-	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
+static __inline int fegetexcept(void) {
+  fenv_t __fpscr;
+  fegetenv(&__fpscr);
+  return ((__fpscr & _FPSCR_ENABLE_MASK) >> _FPSCR_ENABLE_SHIFT);
 }
 
 #endif /* __BSD_VISIBLE */
 
 __END_DECLS
 
-#endif	/* !_FENV_H_ */
+#endif /* !_FENV_H_ */
diff --git a/ndk/platforms/android-3/arch-arm/include/machine/_types.h b/ndk/platforms/android-3/arch-arm/include/machine/_types.h
index 3e779ca..1521a4c 100644
--- a/ndk/platforms/android-3/arch-arm/include/machine/_types.h
+++ b/ndk/platforms/android-3/arch-arm/include/machine/_types.h
@@ -35,17 +35,6 @@
 #ifndef _ARM__TYPES_H_
 #define _ARM__TYPES_H_
 
-
-#if !defined(__ARM_EABI__)
-/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
-#define _SIZE_T
-#define _SSIZE_T
-#define _PTRDIFF_T
-typedef unsigned long  size_t;
-typedef long           ssize_t;
-typedef long           ptrdiff_t;
-#endif
-
 /* 7.18.1.1 Exact-width integer types */
 typedef	__signed char		__int8_t;
 typedef	unsigned char		__uint8_t;
@@ -116,10 +105,4 @@
 typedef	void *			__wctrans_t;
 typedef	void *			__wctype_t;
 
-#ifdef __ARMEB__
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
-#define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
-
 #endif	/* _ARM__TYPES_H_ */
diff --git a/ndk/platforms/android-3/arch-arm/include/machine/endian.h b/ndk/platforms/android-3/arch-arm/include/machine/endian.h
new file mode 100644
index 0000000..7cba3b9
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/include/machine/endian.h
@@ -0,0 +1,89 @@
+/*	$OpenBSD: endian.h,v 1.3 2005/12/13 00:35:23 millert Exp $	*/
+
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _ARM_ENDIAN_H_
+#define _ARM_ENDIAN_H_
+
+#ifdef __GNUC__
+
+/*
+ * REV and REV16 weren't available on ARM5 or ARM4.
+ * We don't include <machine/cpu-features.h> because it pollutes the
+ * namespace with macros like PLD.
+ */
+#if !defined __ARM_ARCH_5__ && !defined __ARM_ARCH_5T__ && \
+    !defined __ARM_ARCH_5TE__ && !defined __ARM_ARCH_5TEJ__ && \
+    !defined __ARM_ARCH_4T__ && !defined __ARM_ARCH_4__
+
+/* According to RealView Assembler User's Guide, REV and REV16 are available
+ * in Thumb code and 16-bit instructions when used in Thumb-2 code.
+ *
+ * REV Rd, Rm
+ *   Rd and Rm must both be Lo registers.
+ *
+ * REV16 Rd, Rm
+ *   Rd and Rm must both be Lo registers.
+ *
+ * The +l constraint takes care of this without constraining us in ARM mode.
+ */
+#define __swap16md(x) ({                                        \
+    register u_int16_t _x = (x);                                \
+    __asm volatile ("rev16 %0, %0" : "+l" (_x));                \
+    _x;                                                         \
+})
+
+#define __swap32md(x) ({                                        \
+    register u_int32_t _x = (x);                                \
+    __asm volatile ("rev %0, %0" : "+l" (_x));                  \
+    _x;                                                         \
+})
+
+#define __swap64md(x) ({                                        \
+    u_int64_t _swap64md_x = (x);                                \
+    (u_int64_t) __swap32md(_swap64md_x >> 32) |                 \
+        (u_int64_t) __swap32md(_swap64md_x & 0xffffffff) << 32; \
+})
+
+/* Tell sys/endian.h we have MD variants of the swap macros.  */
+#define MD_SWAP
+
+#endif  /* __ARM_ARCH__ */
+#endif  /* __GNUC__ */
+
+#if defined(__ARMEB__)
+#define _BYTE_ORDER _BIG_ENDIAN
+#else
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#endif
+#define __STRICT_ALIGNMENT
+#include <sys/types.h>
+#include <sys/endian.h>
+
+#endif  /* !_ARM_ENDIAN_H_ */
diff --git a/ndk/platforms/android-3/arch-arm/lib-bootstrap/crtbegin_dynamic.o b/ndk/platforms/android-3/arch-arm/lib-bootstrap/crtbegin_dynamic.o
new file mode 100644
index 0000000..fdcd6d6
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/lib-bootstrap/crtbegin_dynamic.o
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/lib-bootstrap/crtend_android.o b/ndk/platforms/android-3/arch-arm/lib-bootstrap/crtend_android.o
new file mode 100644
index 0000000..50caf05
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/lib-bootstrap/crtend_android.o
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/lib-bootstrap/libc.so b/ndk/platforms/android-3/arch-arm/lib-bootstrap/libc.so
new file mode 100755
index 0000000..8f73f67
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/lib-bootstrap/libc.so
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/lib-bootstrap/libdl.so b/ndk/platforms/android-3/arch-arm/lib-bootstrap/libdl.so
new file mode 100755
index 0000000..18ddd3b
--- /dev/null
+++ b/ndk/platforms/android-3/arch-arm/lib-bootstrap/libdl.so
Binary files differ
diff --git a/ndk/platforms/android-3/arch-arm/symbols/libc.so.functions.txt b/ndk/platforms/android-3/arch-arm/symbols/libc.so.functions.txt
index 814ce19..4e4b929 100644
--- a/ndk/platforms/android-3/arch-arm/symbols/libc.so.functions.txt
+++ b/ndk/platforms/android-3/arch-arm/symbols/libc.so.functions.txt
@@ -241,7 +241,6 @@
 __rt_sigprocmask
 __rt_sigtimedwait
 __sclose
-__set_errno
 __set_syscall_errno
 __set_tls
 __sflags
diff --git a/ndk/platforms/android-3/include/asm-generic/mman-common.h b/ndk/platforms/android-3/include/asm-generic/mman-common.h
new file mode 100644
index 0000000..157353b
--- /dev/null
+++ b/ndk/platforms/android-3/include/asm-generic/mman-common.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_GENERIC_MMAN_COMMON_H
+#define __ASM_GENERIC_MMAN_COMMON_H
+#define PROT_READ 0x1  
+#define PROT_WRITE 0x2  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PROT_EXEC 0x4  
+#define PROT_SEM 0x8  
+#define PROT_NONE 0x0  
+#define PROT_GROWSDOWN 0x01000000  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PROT_GROWSUP 0x02000000  
+#define MAP_SHARED 0x01  
+#define MAP_PRIVATE 0x02  
+#define MAP_TYPE 0x0f  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_FIXED 0x10  
+#define MAP_ANONYMOUS 0x20  
+#define MAP_UNINITIALIZED 0x0  
+#define MS_ASYNC 1  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MS_INVALIDATE 2  
+#define MS_SYNC 4  
+#define MADV_NORMAL 0  
+#define MADV_RANDOM 1  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_SEQUENTIAL 2  
+#define MADV_WILLNEED 3  
+#define MADV_DONTNEED 4  
+#define MADV_REMOVE 9  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_DONTFORK 10  
+#define MADV_DOFORK 11  
+#define MADV_HWPOISON 100  
+#define MADV_SOFT_OFFLINE 101  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_MERGEABLE 12  
+#define MADV_UNMERGEABLE 13  
+#define MADV_HUGEPAGE 14  
+#define MADV_NOHUGEPAGE 15  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_FILE 0
+#endif
diff --git a/ndk/platforms/android-3/include/asm-generic/mman.h b/ndk/platforms/android-3/include/asm-generic/mman.h
index 98d2783..6eaf900 100644
--- a/ndk/platforms/android-3/include/asm-generic/mman.h
+++ b/ndk/platforms/android-3/include/asm-generic/mman.h
@@ -7,40 +7,30 @@
  ***   structures, and macros generated from the original header, and thus,
  ***   contains no copyrightable information.
  ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _ASM_GENERIC_MMAN_H
-#define _ASM_GENERIC_MMAN_H
-
-#define PROT_READ 0x1  
-#define PROT_WRITE 0x2  
-#define PROT_EXEC 0x4  
-#define PROT_SEM 0x8  
-#define PROT_NONE 0x0  
-#define PROT_GROWSDOWN 0x01000000  
-#define PROT_GROWSUP 0x02000000  
-
-#define MAP_SHARED 0x01  
-#define MAP_PRIVATE 0x02  
-#define MAP_TYPE 0x0f  
-#define MAP_FIXED 0x10  
-#define MAP_ANONYMOUS 0x20  
-
-#define MS_ASYNC 1  
-#define MS_INVALIDATE 2  
-#define MS_SYNC 4  
-
-#define MADV_NORMAL 0  
-#define MADV_RANDOM 1  
-#define MADV_SEQUENTIAL 2  
-#define MADV_WILLNEED 3  
-#define MADV_DONTNEED 4  
-
-#define MADV_REMOVE 9  
-#define MADV_DONTFORK 10  
-#define MADV_DOFORK 11  
-
-#define MAP_ANON MAP_ANONYMOUS
-#define MAP_FILE 0
-
+#ifndef __ASM_GENERIC_MMAN_H
+#define __ASM_GENERIC_MMAN_H
+#include <asm-generic/mman-common.h>
+#define MAP_GROWSDOWN 0x0100  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_DENYWRITE 0x0800  
+#define MAP_EXECUTABLE 0x1000  
+#define MAP_LOCKED 0x2000  
+#define MAP_NORESERVE 0x4000  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MAP_POPULATE 0x8000  
+#define MAP_NONBLOCK 0x10000  
+#define MAP_STACK 0x20000  
+#define MAP_HUGETLB 0x40000  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MCL_CURRENT 1  
+#define MCL_FUTURE 2  
 #endif
diff --git a/ndk/platforms/android-3/include/asm-generic/pgtable-nopmd.h b/ndk/platforms/android-3/include/asm-generic/pgtable-nopmd.h
new file mode 100644
index 0000000..ac3f40c
--- /dev/null
+++ b/ndk/platforms/android-3/include/asm-generic/pgtable-nopmd.h
@@ -0,0 +1,48 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _PGTABLE_NOPMD_H
+#define _PGTABLE_NOPMD_H
+#ifndef __ASSEMBLY__
+#include <asm-generic/pgtable-nopud.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+struct mm_struct;
+#define __PAGETABLE_PMD_FOLDED
+typedef struct { pud_t pud; } pmd_t;
+#define PMD_SHIFT PUD_SHIFT
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTRS_PER_PMD 1
+#define PMD_SIZE (1UL << PMD_SHIFT)
+#define PMD_MASK (~(PMD_SIZE-1))
+#define pmd_ERROR(pmd) (pud_ERROR((pmd).pud))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pud_populate(mm, pmd, pte) do { } while (0)
+#define set_pud(pudptr, pudval) set_pmd((pmd_t *)(pudptr), (pmd_t) { pudval })
+#define pmd_val(x) (pud_val((x).pud))
+#define __pmd(x) ((pmd_t) { __pud(x) } )
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pud_page(pud) (pmd_page((pmd_t){ pud }))
+#define pud_page_vaddr(pud) (pmd_page_vaddr((pmd_t){ pud }))
+#define pmd_alloc_one(mm, address) NULL
+#define __pmd_free_tlb(tlb, x, a) do { } while (0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#undef pmd_addr_end
+#define pmd_addr_end(addr, end) (end)
+#endif
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-3/include/asm-generic/socket.h b/ndk/platforms/android-3/include/asm-generic/socket.h
new file mode 100644
index 0000000..fb3876e
--- /dev/null
+++ b/ndk/platforms/android-3/include/asm-generic/socket.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_GENERIC_SOCKET_H
+#define __ASM_GENERIC_SOCKET_H
+#include <asm/sockios.h>
+#define SOL_SOCKET 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_SNDBUFFORCE 32
+#define SO_RCVBUFFORCE 33
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+#define SO_BSDCOMPAT 14
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef SO_PASSCRED
+#define SO_PASSCRED 16
+#define SO_PEERCRED 17
+#define SO_RCVLOWAT 18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_SNDLOWAT 19
+#define SO_RCVTIMEO 20
+#define SO_SNDTIMEO 21
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_SECURITY_AUTHENTICATION 22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
+#define SO_SECURITY_ENCRYPTION_NETWORK 24
+#define SO_BINDTODEVICE 25
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_ATTACH_FILTER 26
+#define SO_DETACH_FILTER 27
+#define SO_PEERNAME 28
+#define SO_TIMESTAMP 29
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SCM_TIMESTAMP SO_TIMESTAMP
+#define SO_ACCEPTCONN 30
+#define SO_PEERSEC 31
+#define SO_PASSSEC 34
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_TIMESTAMPNS 35
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+#define SO_MARK 36
+#define SO_TIMESTAMPING 37
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SCM_TIMESTAMPING SO_TIMESTAMPING
+#define SO_PROTOCOL 38
+#define SO_DOMAIN 39
+#define SO_RXQ_OVFL 40
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_WIFI_STATUS 41
+#define SCM_WIFI_STATUS SO_WIFI_STATUS
+#endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/asmmacro.h b/ndk/platforms/android-3/include/asm-generic/swab.h
similarity index 77%
rename from ndk/platforms/android-9/arch-mips/include/asm/asmmacro.h
rename to ndk/platforms/android-3/include/asm-generic/swab.h
index e1e9804..8279332 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/asmmacro.h
+++ b/ndk/platforms/android-3/include/asm-generic/swab.h
@@ -16,8 +16,14 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _ASM_ASMMACRO_H
-#define _ASM_ASMMACRO_H
-#include <asm/hazards.h>
+#ifndef _ASM_GENERIC_SWAB_H
+#define _ASM_GENERIC_SWAB_H
+#include <asm/bitsperlong.h>
+#if __BITS_PER_LONG == 32
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#if defined(__GNUC__) && (!defined(__STRICT_ANSI__) || defined(__KERNEL__))
+#define __SWAB_64_THRU_32__
+#endif
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/ndk/platforms/android-3/include/byteswap.h b/ndk/platforms/android-3/include/byteswap.h
index 16d2ad4..74b0e91 100644
--- a/ndk/platforms/android-3/include/byteswap.h
+++ b/ndk/platforms/android-3/include/byteswap.h
@@ -28,7 +28,8 @@
 #ifndef _BYTESWAP_H_
 #define _BYTESWAP_H_
 
-#include <sys/endian.h>
+/* endian.h rather than sys/endian.h so we get the machine-specific file. */
+#include <endian.h>
 
 #define  bswap_16(x)   swap16(x)
 #define  bswap_32(x)   swap32(x)
diff --git a/ndk/platforms/android-3/include/dirent.h b/ndk/platforms/android-3/include/dirent.h
index 55eef7b..f0a1e17 100644
--- a/ndk/platforms/android-3/include/dirent.h
+++ b/ndk/platforms/android-3/include/dirent.h
@@ -51,28 +51,29 @@
  * who assume to be able to access it directly. sad...
  */
 struct dirent {
-    uint64_t         d_ino;
-    int64_t          d_off;
-    unsigned short   d_reclen;
-    unsigned char    d_type;
-    char             d_name[256];
+  uint64_t         d_ino;
+  int64_t          d_off;
+  unsigned short   d_reclen;
+  unsigned char    d_type;
+  char             d_name[256];
 };
 
-typedef struct DIR  DIR;
+typedef struct DIR DIR;
+
+extern  DIR*             opendir(const char* dirpath);
+extern  DIR*             fdopendir(int fd);
+extern  struct dirent*   readdir(DIR* dirp);
+extern  int              readdir_r(DIR*  dirp, struct dirent* entry, struct dirent** result);
+extern  int              closedir(DIR* dirp);
+extern  void             rewinddir(DIR* dirp);
+extern  int              dirfd(DIR* dirp);
+extern  int              alphasort(const struct dirent** a, const struct dirent** b);
+extern  int              scandir(const char* dir, struct dirent*** namelist,
+                                 int(*filter)(const struct dirent*),
+                                 int(*compar)(const struct dirent**,
+                                              const struct dirent**));
 
 extern  int              getdents(unsigned int, struct dirent*, unsigned int);
-extern  DIR*             opendir(const char*  dirpath);
-extern  DIR*             fdopendir(int fd);
-extern  struct dirent*   readdir(DIR*  dirp);
-extern  int              readdir_r(DIR*  dirp, struct dirent *entry, struct dirent **result);
-extern  int              closedir(DIR*  dirp);
-extern  void             rewinddir(DIR *dirp);
-extern  int              dirfd(DIR* dirp);
-extern  int              alphasort(const void *a, const void *b);
-extern  int              scandir(const char *dir, struct dirent ***namelist,
-                                 int(*filter)(const struct dirent *),
-                                 int(*compar)(const struct dirent **, 
-                                              const struct dirent **));
 
 __END_DECLS
 
diff --git a/ndk/platforms/android-3/include/elf.h b/ndk/platforms/android-3/include/elf.h
index 8a86a63..cb8ffb7 100644
--- a/ndk/platforms/android-3/include/elf.h
+++ b/ndk/platforms/android-3/include/elf.h
@@ -52,7 +52,22 @@
     AT_SECURE = 23
 };
 
+#include <stdint.h>
 #include <sys/exec_elf.h>
 
+typedef struct {
+  uint32_t a_type;
+  union {
+    uint32_t a_val;
+  } a_un;
+} Elf32_auxv_t;
+
+typedef struct {
+  uint64_t a_type;
+  union {
+    uint64_t a_val;
+  } a_un;
+} Elf64_auxv_t;
+
 #endif /* _ELF_H */
 
diff --git a/ndk/platforms/android-3/include/errno.h b/ndk/platforms/android-3/include/errno.h
index 2b2685a..b97f6d2 100644
--- a/ndk/platforms/android-3/include/errno.h
+++ b/ndk/platforms/android-3/include/errno.h
@@ -36,20 +36,24 @@
 /* on Linux, ENOTSUP and EOPNOTSUPP are defined as the same error code
  * even if 1000.3 states that they should be different
  */
-#ifndef  ENOTUP
+#ifndef  ENOTSUP
 #define  ENOTSUP  EOPNOTSUPP
 #endif
 
-/* internal function that should *only* be called from system calls */
-/* use errno = xxxx instead in C code                               */
-extern int    __set_errno(int  error);
-
 /* internal function returning the address of the thread-specific errno */
 extern volatile int*   __errno(void);
 
 /* a macro expanding to the errno l-value */
 #define  errno   (*__errno())
 
+/* internal function that should *only* be called from system calls */
+/* use errno = xxxx instead in C code                               */
+static __inline__ int __attribute__((deprecated)) 
+__set_errno(int n) {
+  errno = n;
+  return -1;
+}
+
 __END_DECLS
 
 #endif /* _ERRNO_H */
diff --git a/ndk/platforms/android-3/include/limits.h b/ndk/platforms/android-3/include/limits.h
index 1de8ea6..b9d4354 100644
--- a/ndk/platforms/android-3/include/limits.h
+++ b/ndk/platforms/android-3/include/limits.h
@@ -89,7 +89,24 @@
 #include <sys/syslimits.h>
 #endif
 
+/* GLibc compatibility definitions.
+   Note that these are defined by GCC's <limits.h>
+   only when __GNU_LIBRARY__ is defined, i.e. when
+   targetting GLibc. */
+#ifndef LONG_LONG_MIN
+#define LONG_LONG_MIN  LLONG_MIN
+#endif
+
+#ifndef LONG_LONG_MAX
+#define LONG_LONG_MAX  LLONG_MAX
+#endif
+
+#ifndef ULONG_LONG_MAX
+#define ULONG_LONG_MAX  ULLONG_MAX
+#endif
+
 #ifndef PAGESIZE
+#include <asm/page.h>
 #define  PAGESIZE  PAGE_SIZE
 #endif
 
diff --git a/ndk/platforms/android-3/include/linux/icmp.h b/ndk/platforms/android-3/include/linux/icmp.h
index c5b58bb..d69a0e2 100644
--- a/ndk/platforms/android-3/include/linux/icmp.h
+++ b/ndk/platforms/android-3/include/linux/icmp.h
@@ -66,7 +66,7 @@
  } echo;
  __u32 gateway;
  struct {
- __u16 __unused_field;
+ __u16 __linux_unused;
  __u16 mtu;
  } frag;
  } un;
diff --git a/ndk/platforms/android-3/include/linux/stddef.h b/ndk/platforms/android-3/include/linux/stddef.h
index 5412f47..cca408c 100644
--- a/ndk/platforms/android-3/include/linux/stddef.h
+++ b/ndk/platforms/android-3/include/linux/stddef.h
@@ -7,25 +7,24 @@
  ***   structures, and macros generated from the original header, and thus,
  ***   contains no copyrightable information.
  ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
  ****************************************************************************
  ****************************************************************************/
 #ifndef _LINUX_STDDEF_H
 #define _LINUX_STDDEF_H
-
 #include <linux/compiler.h>
-
 #undef NULL
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifdef __cplusplus
 #define NULL 0
 #else
 #define NULL ((void *)0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-
-#undef offsetof
-#ifdef __compiler_offsetof
-#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
-#else
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
 #endif
diff --git a/ndk/platforms/android-3/include/linux/sysctl.h b/ndk/platforms/android-3/include/linux/sysctl.h
index 329e561..730c740 100644
--- a/ndk/platforms/android-3/include/linux/sysctl.h
+++ b/ndk/platforms/android-3/include/linux/sysctl.h
@@ -28,7 +28,7 @@
  size_t __user *oldlenp;
  void __user *newval;
  size_t newlen;
- unsigned long __unused[4];
+ unsigned long __linux_unused[4];
 };
 
 enum
diff --git a/ndk/platforms/android-3/include/pthread.h b/ndk/platforms/android-3/include/pthread.h
index 2a6029d..ae55782 100644
--- a/ndk/platforms/android-3/include/pthread.h
+++ b/ndk/platforms/android-3/include/pthread.h
@@ -235,9 +235,4 @@
 } /* extern "C" */
 #endif
 
-/************ TO FIX ************/
-
-#define LONG_LONG_MAX __LONG_LONG_MAX__
-#define LONG_LONG_MIN (-__LONG_LONG_MAX__ - 1)
-
 #endif /* _PTHREAD_H_ */
diff --git a/ndk/platforms/android-3/include/resolv.h b/ndk/platforms/android-3/include/resolv.h
index 4247d68..7c34012 100644
--- a/ndk/platforms/android-3/include/resolv.h
+++ b/ndk/platforms/android-3/include/resolv.h
@@ -34,6 +34,7 @@
 #include <sys/socket.h>
 #include <stdio.h>
 #include <arpa/nameser.h>
+#include <netinet/in.h>
 
 __BEGIN_DECLS
 
diff --git a/ndk/platforms/android-3/include/stdint.h b/ndk/platforms/android-3/include/stdint.h
index 49879cb..c3e29dd 100644
--- a/ndk/platforms/android-3/include/stdint.h
+++ b/ndk/platforms/android-3/include/stdint.h
@@ -226,12 +226,6 @@
 #  define UINTMAX_C(c)	UINT64_C(c)
 #endif
 
-/* size_t is defined by the GCC-specific <stddef.h> */
-#ifndef _SSIZE_T_DEFINED_
-#define _SSIZE_T_DEFINED_
-typedef long int  ssize_t;
-#endif
-
 #define _BITSIZE 32
 
 /* Keep the kernel from trying to define these types... */
diff --git a/ndk/platforms/android-3/include/stdio.h b/ndk/platforms/android-3/include/stdio.h
index 273f630..a56faa2 100644
--- a/ndk/platforms/android-3/include/stdio.h
+++ b/ndk/platforms/android-3/include/stdio.h
@@ -39,7 +39,7 @@
 #define	_STDIO_H_
 
 #include <sys/cdefs.h>
-#include <sys/_types.h>
+#include <sys/types.h>
 
 /* va_list and size_t must be defined by stdio.h according to Posix */
 #define __need___va_list
@@ -49,30 +49,9 @@
 #define __need_size_t
 #include <stddef.h>
 
+#define __need_NULL
 #include <stddef.h>
 
-#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
-#include <sys/types.h>	/* XXX should be removed */
-#endif
-
-#ifndef	_SIZE_T_DEFINED_
-#define	_SIZE_T_DEFINED_
-typedef	unsigned long    size_t;
-#endif
-
-#ifndef	_OFF_T_DEFINED_
-#define	_OFF_T_DEFINED_
-typedef	long    off_t;
-#endif
-
-#ifndef NULL
-#ifdef 	__GNUG__
-#define	NULL	__null
-#else
-#define	NULL	0L
-#endif
-#endif
-
 #define	_FSTDIO			/* Define for new stdio with functions. */
 
 typedef off_t fpos_t;		/* stdio file position type */
diff --git a/ndk/platforms/android-3/include/sys/endian.h b/ndk/platforms/android-3/include/sys/endian.h
index 00f4839..2a0c658 100644
--- a/ndk/platforms/android-3/include/sys/endian.h
+++ b/ndk/platforms/android-3/include/sys/endian.h
@@ -37,6 +37,7 @@
 #define _SYS_ENDIAN_H_
 
 #include <sys/cdefs.h>
+#include <machine/endian.h>
 #include <machine/_types.h>
 
 #define _LITTLE_ENDIAN	1234
diff --git a/ndk/platforms/android-3/include/sys/limits.h b/ndk/platforms/android-3/include/sys/limits.h
index 41d02ff..5b127eb 100644
--- a/ndk/platforms/android-3/include/sys/limits.h
+++ b/ndk/platforms/android-3/include/sys/limits.h
@@ -169,7 +169,8 @@
 
 #undef   _POSIX_PROCESS_SHARED           /* we don't support process-shared synchronization */
 #undef   _POSIX_THREAD_SAFE_FUNCTIONS    /* most functions are, but not everything yet */
-#define  _POSIX_CHOWN_RESTRICTED    1    /* yes, chown requires appropriate priviledges */
+#define  _POSIX_CHOWN_RESTRICTED    1    /* yes, chown requires appropriate privileges */
+#define  _POSIX_MONOTONIC_CLOCK     0    /* the monotonic clock may be available; ask sysconf */
 #define  _POSIX_NO_TRUNC            1    /* very long pathnames generate an error */
 #define  _POSIX_SAVED_IDS           1    /* saved user ids is a Linux feature */
 #define  _POSIX_JOB_CONTROL         1    /* job control is a Linux feature */
diff --git a/ndk/platforms/android-3/include/sys/sysconf.h b/ndk/platforms/android-3/include/sys/sysconf.h
index 2fc1b08..0a46e7a 100644
--- a/ndk/platforms/android-3/include/sys/sysconf.h
+++ b/ndk/platforms/android-3/include/sys/sysconf.h
@@ -127,8 +127,9 @@
 #define _SC_NPROCESSORS_ONLN            0x0061
 #define _SC_PHYS_PAGES                  0x0062
 #define _SC_AVPHYS_PAGES                0x0063
+#define _SC_MONOTONIC_CLOCK             0x0064
 
-extern int sysconf (int  name);
+extern int sysconf(int name);
 
 __END_DECLS
 
diff --git a/ndk/platforms/android-3/include/sys/types.h b/ndk/platforms/android-3/include/sys/types.h
index 33fe30e..15ecb37 100644
--- a/ndk/platforms/android-3/include/sys/types.h
+++ b/ndk/platforms/android-3/include/sys/types.h
@@ -85,12 +85,6 @@
 typedef  .... pthread_t;
 #endif
 
-#ifndef _SIZE_T_DEFINED_
-#define _SIZE_T_DEFINED_
-typedef unsigned int  size_t;
-#endif
-
-/* size_t is defined by the GCC-specific <stddef.h> */
 #ifndef _SSIZE_T_DEFINED_
 #define _SSIZE_T_DEFINED_
 typedef long int  ssize_t;
diff --git a/ndk/platforms/android-3/include/wchar.h b/ndk/platforms/android-3/include/wchar.h
index e2feb60..9a6ce1d 100644
--- a/ndk/platforms/android-3/include/wchar.h
+++ b/ndk/platforms/android-3/include/wchar.h
@@ -50,7 +50,7 @@
 
 __BEGIN_DECLS
 
-typedef int                     wint_t;
+typedef __WINT_TYPE__           wint_t;
 typedef struct { int  dummy; }  mbstate_t;
 
 typedef enum {
diff --git a/ndk/platforms/android-4/samples/san-angeles/jni/app-android.c b/ndk/platforms/android-4/samples/san-angeles/jni/app-android.c
index 0e552a7..399d896 100644
--- a/ndk/platforms/android-4/samples/san-angeles/jni/app-android.c
+++ b/ndk/platforms/android-4/samples/san-angeles/jni/app-android.c
@@ -22,6 +22,8 @@
 #include <time.h>
 #include <android/log.h>
 #include <stdint.h>
+#include "importgl.h"
+#include "app.h"
 
 int   gAppAlive   = 1;
 
@@ -47,9 +49,7 @@
 {
     importGLInit();
     appInit();
-    gAppAlive    = 1;
-    sDemoStopped = 0;
-    sTimeOffsetInit = 0;
+    gAppAlive  = 1;
 }
 
 void
@@ -71,19 +71,44 @@
 /* This is called to indicate to the render loop that it should
  * stop as soon as possible.
  */
+
+void _pause()
+{
+  /* we paused the animation, so store the current
+   * time in sTimeStopped for future nativeRender calls */
+    sDemoStopped = 1;
+    sTimeStopped = _getTime();
+}
+
+void _resume()
+{
+  /* we resumed the animation, so adjust the time offset
+   * to take care of the pause interval. */
+    sDemoStopped = 0;
+    sTimeOffset -= _getTime() - sTimeStopped;
+}
+
+
+void
+Java_com_example_SanAngeles_DemoGLSurfaceView_nativeTogglePauseResume( JNIEnv*  env )
+{
+    sDemoStopped = !sDemoStopped;
+    if (sDemoStopped)
+        _pause();
+    else
+        _resume();
+}
+
 void
 Java_com_example_SanAngeles_DemoGLSurfaceView_nativePause( JNIEnv*  env )
 {
-    sDemoStopped = !sDemoStopped;
-    if (sDemoStopped) {
-        /* we paused the animation, so store the current
-         * time in sTimeStopped for future nativeRender calls */
-        sTimeStopped = _getTime();
-    } else {
-        /* we resumed the animation, so adjust the time offset
-         * to take care of the pause interval. */
-        sTimeOffset -= _getTime() - sTimeStopped;
-    }
+    _pause();
+}
+
+void
+Java_com_example_SanAngeles_DemoGLSurfaceView_nativeResume( JNIEnv*  env )
+{
+    _resume();
 }
 
 /* Call to render the next GL frame */
diff --git a/ndk/platforms/android-4/samples/san-angeles/src/com/example/SanAngeles/DemoActivity.java b/ndk/platforms/android-4/samples/san-angeles/src/com/example/SanAngeles/DemoActivity.java
index 696be78..076b8a7 100644
--- a/ndk/platforms/android-4/samples/san-angeles/src/com/example/SanAngeles/DemoActivity.java
+++ b/ndk/platforms/android-4/samples/san-angeles/src/com/example/SanAngeles/DemoActivity.java
@@ -86,14 +86,29 @@
 
     public boolean onTouchEvent(final MotionEvent event) {
         if (event.getAction() == MotionEvent.ACTION_DOWN) {
-            nativePause();
+            nativeTogglePauseResume();
         }
         return true;
     }
 
+   @Override
+    public void onPause() {
+        super.onPause();
+        nativePause();
+    }
+
+   @Override
+    public void onResume() {
+        super.onResume();
+        nativeResume();
+    }
+
+
     DemoRenderer mRenderer;
 
     private static native void nativePause();
+    private static native void nativeResume();
+    private static native void nativeTogglePauseResume();
 }
 
 class DemoRenderer implements GLSurfaceView.Renderer {
diff --git a/ndk/platforms/android-5/arch-arm/symbols/libc.so.functions.txt b/ndk/platforms/android-5/arch-arm/symbols/libc.so.functions.txt
index 9608503..22616d4 100644
--- a/ndk/platforms/android-5/arch-arm/symbols/libc.so.functions.txt
+++ b/ndk/platforms/android-5/arch-arm/symbols/libc.so.functions.txt
@@ -273,7 +273,6 @@
 __rt_sigprocmask
 __rt_sigtimedwait
 __sclose
-__set_errno
 __set_syscall_errno
 __set_tls
 __sflags
diff --git a/ndk/platforms/android-5/include/GLES2/gl2.h b/ndk/platforms/android-5/include/GLES2/gl2.h
index e1d3b87..c139c25 100644
--- a/ndk/platforms/android-5/include/GLES2/gl2.h
+++ b/ndk/platforms/android-5/include/GLES2/gl2.h
@@ -528,7 +528,7 @@
 GL_APICALL void         GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
 GL_APICALL void         GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
 GL_APICALL void         GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
-GL_APICALL int          GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
+GL_APICALL GLint        GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
 GL_APICALL void         GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
 GL_APICALL void         GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
 GL_APICALL GLenum       GL_APIENTRY glGetError (void);
@@ -547,7 +547,7 @@
 GL_APICALL void         GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
 GL_APICALL void         GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
 GL_APICALL void         GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
-GL_APICALL int          GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
+GL_APICALL GLint        GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
 GL_APICALL void         GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
 GL_APICALL void         GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
 GL_APICALL void         GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
diff --git a/ndk/platforms/android-5/include/pthread.h b/ndk/platforms/android-5/include/pthread.h
index a20a52d..ba40fa1 100644
--- a/ndk/platforms/android-5/include/pthread.h
+++ b/ndk/platforms/android-5/include/pthread.h
@@ -262,9 +262,4 @@
 } /* extern "C" */
 #endif
 
-/************ TO FIX ************/
-
-#define LONG_LONG_MAX __LONG_LONG_MAX__
-#define LONG_LONG_MIN (-__LONG_LONG_MAX__ - 1)
-
 #endif /* _PTHREAD_H_ */
diff --git a/ndk/platforms/android-8/arch-arm/symbols/libc.so.functions.txt b/ndk/platforms/android-8/arch-arm/symbols/libc.so.functions.txt
index 88dd1b7..917498f 100644
--- a/ndk/platforms/android-8/arch-arm/symbols/libc.so.functions.txt
+++ b/ndk/platforms/android-8/arch-arm/symbols/libc.so.functions.txt
@@ -284,7 +284,6 @@
 __rt_sigprocmask
 __rt_sigtimedwait
 __sclose
-__set_errno
 __set_syscall_errno
 __set_tls
 __setresuid
diff --git a/ndk/platforms/android-8/include/android/bitmap.h b/ndk/platforms/android-8/include/android/bitmap.h
index 5078277..6e18763 100644
--- a/ndk/platforms/android-8/include/android/bitmap.h
+++ b/ndk/platforms/android-8/include/android/bitmap.h
@@ -24,11 +24,14 @@
 extern "C" {
 #endif
 
-#define ANDROID_BITMAP_RESUT_SUCCESS            0
+#define ANDROID_BITMAP_RESULT_SUCCESS            0
 #define ANDROID_BITMAP_RESULT_BAD_PARAMETER     -1
 #define ANDROID_BITMAP_RESULT_JNI_EXCEPTION     -2
 #define ANDROID_BITMAP_RESULT_ALLOCATION_FAILED -3
 
+/* Backward compatibility: this macro used to be misspelled. */
+#define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS
+
 enum AndroidBitmapFormat {
     ANDROID_BITMAP_FORMAT_NONE      = 0,
     ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
diff --git a/ndk/platforms/android-8/include/pthread.h b/ndk/platforms/android-8/include/pthread.h
index f7a596a..7741fcf 100644
--- a/ndk/platforms/android-8/include/pthread.h
+++ b/ndk/platforms/android-8/include/pthread.h
@@ -267,9 +267,4 @@
 } /* extern "C" */
 #endif
 
-/************ TO FIX ************/
-
-#define LONG_LONG_MAX __LONG_LONG_MAX__
-#define LONG_LONG_MIN (-__LONG_LONG_MAX__ - 1)
-
 #endif /* _PTHREAD_H_ */
diff --git a/ndk/platforms/android-8/include/stdio.h b/ndk/platforms/android-8/include/stdio.h
index c38ed5a..172c8d0 100644
--- a/ndk/platforms/android-8/include/stdio.h
+++ b/ndk/platforms/android-8/include/stdio.h
@@ -39,7 +39,7 @@
 #define	_STDIO_H_
 
 #include <sys/cdefs.h>
-#include <sys/_types.h>
+#include <sys/types.h>
 
 /* va_list and size_t must be defined by stdio.h according to Posix */
 #define __need___va_list
@@ -49,30 +49,9 @@
 #define __need_size_t
 #include <stddef.h>
 
+#define __need_NULL
 #include <stddef.h>
 
-#if __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE
-#include <sys/types.h>	/* XXX should be removed */
-#endif
-
-#ifndef	_SIZE_T_DEFINED_
-#define	_SIZE_T_DEFINED_
-typedef	unsigned long    size_t;
-#endif
-
-#ifndef	_OFF_T_DEFINED_
-#define	_OFF_T_DEFINED_
-typedef	long    off_t;
-#endif
-
-#ifndef NULL
-#ifdef 	__GNUG__
-#define	NULL	__null
-#else
-#define	NULL	0L
-#endif
-#endif
-
 #define	_FSTDIO			/* Define for new stdio with functions. */
 
 typedef off_t fpos_t;		/* stdio file position type */
diff --git a/ndk/platforms/android-8/include/wchar.h b/ndk/platforms/android-8/include/wchar.h
index 97e1b5c..b9c7b0b 100644
--- a/ndk/platforms/android-8/include/wchar.h
+++ b/ndk/platforms/android-8/include/wchar.h
@@ -50,7 +50,7 @@
 
 __BEGIN_DECLS
 
-typedef int                     wint_t;
+typedef __WINT_TYPE__           wint_t;
 typedef struct { int  dummy; }  mbstate_t;
 
 typedef enum {
diff --git a/ndk/platforms/android-8/samples/bitmap-plasma/jni/plasma.c b/ndk/platforms/android-8/samples/bitmap-plasma/jni/plasma.c
index 79cd66d..d5f98fb 100644
--- a/ndk/platforms/android-8/samples/bitmap-plasma/jni/plasma.c
+++ b/ndk/platforms/android-8/samples/bitmap-plasma/jni/plasma.c
@@ -187,7 +187,6 @@
 
 static void fill_plasma( AndroidBitmapInfo*  info, void*  pixels, double  t )
 {
-    Fixed ft  = FIXED_FROM_FLOAT(t/1000.);
     Fixed yt1 = FIXED_FROM_FLOAT(t/1230.);
     Fixed yt2 = yt1;
     Fixed xt10 = FIXED_FROM_FLOAT(t/3000.);
diff --git a/ndk/platforms/android-9/arch-arm/symbols/libc.so.functions.txt b/ndk/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
index c1c4358..99eb2d4 100644
--- a/ndk/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
+++ b/ndk/platforms/android-9/arch-arm/symbols/libc.so.functions.txt
@@ -288,7 +288,6 @@
 __rt_sigprocmask
 __rt_sigtimedwait
 __sclose
-__set_errno
 __set_syscall_errno
 __set_tls
 __setresuid
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/cpu-features.h b/ndk/platforms/android-9/arch-mips/include/asm/cpu-features.h
index b3642c2..50ce572 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/cpu-features.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/cpu-features.h
@@ -161,26 +161,45 @@
 #define cpu_has_userlocal (cpu_data[0].options & MIPS_CPU_ULRI)
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef cpu_has_nofpuex
+#define cpu_has_nofpuex (cpu_data[0].options & MIPS_CPU_NOFPUEX)
+#endif
+#ifndef cpu_has_64bits
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
+#endif
+#ifndef cpu_has_64bit_zero_reg
+#define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
+#ifndef cpu_has_64bit_gp_regs
+#define cpu_has_64bit_gp_regs 0
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef cpu_has_64bit_addresses
+#define cpu_has_64bit_addresses 0
+#endif
 #ifndef cpu_has_vint
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define cpu_has_vint 0
 #endif
 #ifndef cpu_has_veic
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define cpu_has_veic 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #ifndef cpu_has_inclusive_pcaches
 #define cpu_has_inclusive_pcaches (cpu_data[0].options & MIPS_CPU_INCLUSIVE_CACHES)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef cpu_dcache_line_size
 #define cpu_dcache_line_size() cpu_data[0].dcache.linesz
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef cpu_icache_line_size
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define cpu_icache_line_size() cpu_data[0].icache.linesz
 #endif
 #ifndef cpu_scache_line_size
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define cpu_scache_line_size() cpu_data[0].scache.linesz
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/elf.h b/ndk/platforms/android-9/arch-mips/include/asm/elf.h
index 6ccb622..6f79694 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/elf.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/elf.h
@@ -186,29 +186,33 @@
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define elf_check_arch(hdr)  ({   int __res = 1;   struct elfhdr *__h = (hdr);     if (__h->e_machine != EM_MIPS)   __res = 0;   if (__h->e_ident[EI_CLASS] != ELFCLASS32)   __res = 0;   if ((__h->e_flags & EF_MIPS_ABI2) != 0)   __res = 0;   if (((__h->e_flags & EF_MIPS_ABI) != 0) &&   ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32))   __res = 0;     __res;  })
+#define ELF_CLASS ELFCLASS32
 #ifdef __MIPSEB__
 #define ELF_DATA ELFDATA2MSB
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #elif __MIPSEL__
 #define ELF_DATA ELFDATA2LSB
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 #define ELF_ARCH EM_MIPS
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
 struct mips_abi;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SET_PERSONALITY(ex, ibcs2)  do {   if (ibcs2)   set_personality(PER_SVR4);   set_personality(PER_LINUX);     current->thread.abi = &mips_abi;  } while (0)
 struct task_struct;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELF_CORE_COPY_REGS(elf_regs, regs)   elf_dump_regs((elf_greg_t *)&(elf_regs), regs);
 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs)   dump_task_fpu(tsk, elf_fpregs)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define USE_ELF_CORE_DUMP
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELF_EXEC_PAGESIZE PAGE_SIZE
 #define ELF_HWCAP (0)
 #define ELF_PLATFORM (NULL)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ELF_PLAT_INIT(_r, load_addr) do {   _r->regs[1] = _r->regs[2] = _r->regs[3] = _r->regs[4] = 0;   _r->regs[5] = _r->regs[6] = _r->regs[7] = _r->regs[8] = 0;   _r->regs[9] = _r->regs[10] = _r->regs[11] = _r->regs[12] = 0;   _r->regs[13] = _r->regs[14] = _r->regs[15] = _r->regs[16] = 0;   _r->regs[17] = _r->regs[18] = _r->regs[19] = _r->regs[20] = 0;   _r->regs[21] = _r->regs[22] = _r->regs[23] = _r->regs[24] = 0;   _r->regs[25] = _r->regs[26] = _r->regs[27] = _r->regs[28] = 0;   _r->regs[30] = _r->regs[31] = 0;  } while (0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #ifndef ELF_ET_DYN_BASE
 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/fcntl.h b/ndk/platforms/android-9/arch-mips/include/asm/fcntl.h
index 2686340..73de4ad 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/fcntl.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/fcntl.h
@@ -43,6 +43,18 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define F_SETLKW64 35
 #endif
+struct flock {
+ short l_type;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ short l_whence;
+ off_t l_start;
+ off_t l_len;
+ long l_sysid;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __kernel_pid_t l_pid;
+ long pad[4];
+};
+#define HAVE_ARCH_STRUCT_FLOCK
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <asm-generic/fcntl.h>
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/mach-generic/spaces.h b/ndk/platforms/android-9/arch-mips/include/asm/mach-generic/spaces.h
index cbda237..0ec1f57 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/mach-generic/spaces.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/mach-generic/spaces.h
@@ -23,8 +23,19 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define PHYS_OFFSET _AC(0, UL)
 #endif
-#ifndef PAGE_OFFSET
-#define PAGE_OFFSET (CAC_BASE + PHYS_OFFSET)
+#define CAC_BASE _AC(0x80000000, UL)
+#define IO_BASE _AC(0xa0000000, UL)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define UNCAC_BASE _AC(0xa0000000, UL)
+#ifndef MAP_BASE
+#define MAP_BASE _AC(0xc0000000, UL)
+#endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#ifndef HIGHMEM_START
+#define HIGHMEM_START _AC(0x20000000, UL)
+#endif
+#ifndef PAGE_OFFSET
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PAGE_OFFSET (CAC_BASE + PHYS_OFFSET)
 #endif
 #endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/mman.h b/ndk/platforms/android-9/arch-mips/include/asm/mman.h
index 9e51c67..cb42c6a 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/mman.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/mman.h
@@ -47,22 +47,33 @@
 #define MAP_POPULATE 0x10000  
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAP_NONBLOCK 0x20000  
+#define MAP_STACK 0x40000  
+#define MAP_HUGETLB 0x80000  
 #define MS_ASYNC 0x0001  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MS_INVALIDATE 0x0002  
 #define MS_SYNC 0x0004  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MCL_CURRENT 1  
 #define MCL_FUTURE 2  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_NORMAL 0  
 #define MADV_RANDOM 1  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_SEQUENTIAL 2  
 #define MADV_WILLNEED 3  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_DONTNEED 4  
 #define MADV_REMOVE 9  
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MADV_DONTFORK 10  
 #define MADV_DOFORK 11  
-#define MAP_FILE 0
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_MERGEABLE 12  
+#define MADV_UNMERGEABLE 13  
+#define MADV_HWPOISON 100  
+#define MADV_HUGEPAGE 14  
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MADV_NOHUGEPAGE 15  
+#define MADV_DONTDUMP 16  
+#define MADV_DODUMP 17  
+#define MAP_FILE 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/module.h b/ndk/platforms/android-9/arch-mips/include/asm/module.h
index 45808e9..dd24290 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/module.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/module.h
@@ -49,8 +49,20 @@
  Elf64_Byte r_type;
  Elf64_Sxword r_addend;
 } Elf64_Mips_Rela;
+#define Elf_Shdr Elf32_Shdr
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define Elf_Sym Elf32_Sym
+#define Elf_Ehdr Elf32_Ehdr
+#define Elf_Addr Elf32_Addr
+#define Elf_Mips_Rel Elf32_Rel
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define Elf_Mips_Rela Elf32_Rela
+#define ELF_MIPS_R_SYM(rel) ELF32_R_SYM(rel.r_info)
+#define ELF_MIPS_R_TYPE(rel) ELF32_R_TYPE(rel.r_info)
 #error MODULE_PROC_FAMILY undefined for your processor configuration
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define MODULE_KERNEL_TYPE "32BIT "
 #define MODULE_KERNEL_SMTC ""
 #define MODULE_ARCH_VERMAGIC   MODULE_PROC_FAMILY MODULE_KERNEL_TYPE MODULE_KERNEL_SMTC
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/msgbuf.h b/ndk/platforms/android-9/arch-mips/include/asm/msgbuf.h
index 31a1887..d81da73 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/msgbuf.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/msgbuf.h
@@ -21,18 +21,21 @@
 struct msqid64_ds {
  struct ipc64_perm msg_perm;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned long __unused1;
  __kernel_time_t msg_stime;
+ unsigned long __unused2;
  __kernel_time_t msg_rtime;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned long __unused3;
  __kernel_time_t msg_ctime;
  unsigned long msg_cbytes;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long msg_qnum;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long msg_qbytes;
  __kernel_pid_t msg_lspid;
  __kernel_pid_t msg_lrpid;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused4;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long __unused5;
 };
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/pgalloc.h b/ndk/platforms/android-9/arch-mips/include/asm/pgalloc.h
index e3ef3b8..0f16346 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/pgalloc.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/pgalloc.h
@@ -24,6 +24,8 @@
 #include <linux/sched.h>
 #define pmd_pgtable(pmd) pmd_page(pmd)
 #define __pte_free_tlb(tlb,pte)  do {   pgtable_page_dtor(pte);   tlb_remove_page((tlb), pte);  } while (0)
-#define check_pgt_cache() do { } while (0)
+#define pmd_free(mm, x) do { } while (0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __pmd_free_tlb(tlb, x) do { } while (0)
+#define check_pgt_cache() do { } while (0)
 #endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/pgtable-32.h b/ndk/platforms/android-9/arch-mips/include/asm/pgtable-32.h
new file mode 100644
index 0000000..f005083
--- /dev/null
+++ b/ndk/platforms/android-9/arch-mips/include/asm/pgtable-32.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ***   To edit the content of this header, modify the corresponding
+ ***   source file (e.g. under external/kernel-headers/original/) then
+ ***   run bionic/libc/kernel/tools/update_all.py
+ ***
+ ***   Any manual change here will be lost the next time this script will
+ ***   be run. You've been warned!
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_PGTABLE_32_H
+#define _ASM_PGTABLE_32_H
+#include <asm/addrspace.h>
+#include <asm/page.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <linux/linkage.h>
+#include <asm/cachectl.h>
+#include <asm/fixmap.h>
+#include <asm-generic/pgtable-nopmd.h>
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PGDIR_SHIFT (2 * PAGE_SHIFT + PTE_ORDER - PTE_T_LOG2)
+#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
+#define PGDIR_MASK (~(PGDIR_SIZE-1))
+#define __PGD_ORDER (32 - 3 * PAGE_SHIFT + PGD_T_LOG2 + PTE_T_LOG2)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PGD_ORDER (__PGD_ORDER >= 0 ? __PGD_ORDER : 0)
+#define PUD_ORDER aieeee_attempt_to_allocate_pud
+#define PMD_ORDER 1
+#define PTE_ORDER 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTRS_PER_PGD (USER_PTRS_PER_PGD * 2)
+#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
+#define USER_PTRS_PER_PGD (0x80000000UL/PGDIR_SIZE)
+#define FIRST_USER_ADDRESS 0
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define VMALLOC_START MAP_BASE
+#define PKMAP_BASE (0xfe000000UL)
+#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
+#define pte_ERROR(e)   printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pgd_ERROR(e)   printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
+#define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK)
+#define pte_page(x) pfn_to_page(pte_pfn(x))
+#define pte_pfn(x) ((unsigned long)((x).pte >> _PFN_SHIFT))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pfn_pte(pfn, prot) __pte(((unsigned long long)(pfn) << _PFN_SHIFT) | pgprot_val(prot))
+#define __pgd_offset(address) pgd_index(address)
+#define __pud_offset(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
+#define __pmd_offset(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pgd_offset_k(address) pgd_offset(&init_mm, address)
+#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
+#define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
+#define __pte_offset(address)   (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pte_offset(dir, address)   ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
+#define pte_offset_kernel(dir, address)   ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
+#define pte_offset_map(dir, address)   ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
+#define pte_unmap(pte) ((void)(pte))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __swp_type(x) (((x).val >> 8) & 0x1f)
+#define __swp_offset(x) ((x).val >> 13)
+#define __swp_entry(type,offset)   ((swp_entry_t) { ((type) << 8) | ((offset) << 13) })
+#define PTE_FILE_MAX_BITS 28
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pte_to_pgoff(_pte) ((((_pte).pte >> 1) & 0x7) |   (((_pte).pte >> 2) & 0x8) |   (((_pte).pte >> 8) << 4))
+#define pgoff_to_pte(off) ((pte_t) { (((off) & 0x7) << 1) |   (((off) & 0x8) << 2) |   (((off) >> 4) << 8) |   _PAGE_FILE })
+#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
+#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/pgtable.h b/ndk/platforms/android-9/arch-mips/include/asm/pgtable.h
index ceb4343..46a5ba1 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/pgtable.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/pgtable.h
@@ -18,61 +18,62 @@
  ****************************************************************************/
 #ifndef _ASM_PGTABLE_H
 #define _ASM_PGTABLE_H
+#include <asm/pgtable-32.h>
 #include <asm/io.h>
-#include <asm/pgtable-bits.h>
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <asm/pgtable-bits.h>
 struct mm_struct;
 struct vm_area_struct;
 #define PAGE_NONE __pgprot(_PAGE_PRESENT | _CACHE_CACHABLE_NONCOHERENT)
-#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE |   _page_cachable_default)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE |   _page_cachable_default)
 #define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_READ |   _page_cachable_default)
 #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_READ |   _page_cachable_default)
 #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | __READABLE | __WRITEABLE |   _PAGE_GLOBAL | _page_cachable_default)
-#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE |   _page_cachable_default)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PAGE_USERIO __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE |   _page_cachable_default)
 #define PAGE_KERNEL_UNCACHED __pgprot(_PAGE_PRESENT | __READABLE |   __WRITEABLE | _PAGE_GLOBAL | _CACHE_UNCACHED)
 #define __P000 __pgprot(0)
 #define __P001 __pgprot(0)
-#define __P010 __pgprot(0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __P010 __pgprot(0)
 #define __P011 __pgprot(0)
 #define __P100 __pgprot(0)
 #define __P101 __pgprot(0)
-#define __P110 __pgprot(0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __P110 __pgprot(0)
 #define __P111 __pgprot(0)
 #define __S000 __pgprot(0)
 #define __S001 __pgprot(0)
-#define __S010 __pgprot(0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __S010 __pgprot(0)
 #define __S011 __pgprot(0)
 #define __S100 __pgprot(0)
 #define __S101 __pgprot(0)
-#define __S110 __pgprot(0)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __S110 __pgprot(0)
 #define __S111 __pgprot(0)
 #define ZERO_PAGE(vaddr)   (virt_to_page((void *)(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))))
 #define pmd_phys(pmd) virt_to_phys((void *)pmd_val(pmd))
-#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define pmd_page(pmd) (pfn_to_page(pmd_phys(pmd) >> PAGE_SHIFT))
 #define pmd_page_vaddr(pmd) pmd_val(pmd)
 #define pte_none(pte) (!(pte_val(pte) & ~_PAGE_GLOBAL))
 #define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
-#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
 #define set_pmd(pmdptr, pmdval) do { *(pmdptr) = (pmdval); } while(0)
 #define PGD_T_LOG2 (__builtin_ffs(sizeof(pgd_t)) - 1)
 #define PMD_T_LOG2 (__builtin_ffs(sizeof(pmd_t)) - 1)
-#define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTE_T_LOG2 (__builtin_ffs(sizeof(pte_t)) - 1)
 #define pgprot_noncached pgprot_noncached
 #define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
 #define kern_addr_valid(addr) (1)
-#define io_remap_pfn_range(vma, vaddr, pfn, size, prot)   remap_pfn_range(vma, vaddr, pfn, size, prot)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define io_remap_pfn_range(vma, vaddr, pfn, size, prot)   remap_pfn_range(vma, vaddr, pfn, size, prot)
 #include <asm-generic/pgtable.h>
 #define HAVE_ARCH_UNMAPPED_AREA
 #define pgtable_cache_init() do { } while (0)
-#endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/processor.h b/ndk/platforms/android-9/arch-mips/include/asm/processor.h
index 3563121..fe9ee76 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/processor.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/processor.h
@@ -29,61 +29,65 @@
 #include <asm/prefetch.h>
 #include <asm/system.h>
 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
-#define NUM_FPU_REGS 32
+#define TASK_SIZE 0x7fff8000UL
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define STACK_TOP TASK_SIZE
+#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~(PAGE_SIZE))
+#define NUM_FPU_REGS 32
 typedef __u64 fpureg_t;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct mips_fpu_struct {
  fpureg_t fpr[NUM_FPU_REGS];
  unsigned int fcr31;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define NUM_DSP_REGS 6
 typedef __u32 dspreg_t;
 struct mips_dsp_state {
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  dspreg_t dspr[NUM_DSP_REGS];
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned int dspcontrol;
 };
 #define INIT_CPUMASK {   {0,}  }
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 typedef struct {
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long seg;
 } mm_segment_t;
 #define ARCH_MIN_TASKALIGN 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct mips_abi;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct thread_struct {
  unsigned long reg16;
  unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long reg29, reg30, reg31;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long cp0_status;
  struct mips_fpu_struct fpu;
  struct mips_dsp_state dsp;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long cp0_badvaddr;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long cp0_baduaddr;
  unsigned long error_code;
  unsigned long trap_no;
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long irix_trampoline;
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
  unsigned long irix_oldctx;
  struct mips_abi *abi;
 };
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define FPAFF_INIT
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define INIT_THREAD {       .reg16 = 0,   .reg17 = 0,   .reg18 = 0,   .reg19 = 0,   .reg20 = 0,   .reg21 = 0,   .reg22 = 0,   .reg23 = 0,   .reg29 = 0,   .reg30 = 0,   .reg31 = 0,       .cp0_status = 0,       .fpu = {   .fpr = {0,},   .fcr31 = 0,   },       FPAFF_INIT       .dsp = {   .dspr = {0, },   .dspcontrol = 0,   },       .cp0_badvaddr = 0,   .cp0_baduaddr = 0,   .error_code = 0,   .trap_no = 0,   .irix_trampoline = 0,   .irix_oldctx = 0,  }
 struct task_struct;
 #define release_thread(thread) do { } while(0)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define prepare_to_copy(tsk) do { } while (0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32)
 #define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk) - 1)
 #define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status)
 #define cpu_relax() barrier()
 #define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/ptrace.h b/ndk/platforms/android-9/arch-mips/include/asm/ptrace.h
index 2b71e70..43cfcf1 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/ptrace.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/ptrace.h
@@ -33,29 +33,31 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define ACX 78
 struct pt_regs {
+ unsigned long pad0[6];
  unsigned long regs[32];
- unsigned long cp0_status;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned long cp0_status;
  unsigned long hi;
  unsigned long lo;
  unsigned long cp0_badvaddr;
- unsigned long cp0_cause;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ unsigned long cp0_cause;
  unsigned long cp0_epc;
 } __attribute__ ((aligned (8)));
 #define PTRACE_GETREGS 12
-#define PTRACE_SETREGS 13
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTRACE_SETREGS 13
 #define PTRACE_GETFPREGS 14
 #define PTRACE_SETFPREGS 15
 #define PTRACE_OLDSETOPTIONS 21
-#define PTRACE_GET_THREAD_AREA 25
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTRACE_GET_THREAD_AREA 25
 #define PTRACE_SET_THREAD_AREA 26
 #define PTRACE_PEEKTEXT_3264 0xc0
 #define PTRACE_PEEKDATA_3264 0xc1
-#define PTRACE_POKETEXT_3264 0xc2
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define PTRACE_POKETEXT_3264 0xc2
 #define PTRACE_POKEDATA_3264 0xc3
 #define PTRACE_GET_THREAD_AREA_3264 0xc4
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/reg.h b/ndk/platforms/android-9/arch-mips/include/asm/reg.h
index 9174e27..1b8e8ee 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/reg.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/reg.h
@@ -18,57 +18,54 @@
  ****************************************************************************/
 #ifndef __ASM_MIPS_REG_H
 #define __ASM_MIPS_REG_H
-#ifdef WANT_COMPAT_REG_H
 #define EF_R0 6
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R1 7
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R2 8
 #define EF_R3 9
 #define EF_R4 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R5 11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R6 12
 #define EF_R7 13
 #define EF_R8 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R9 15
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R10 16
 #define EF_R11 17
 #define EF_R12 18
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R13 19
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R14 20
 #define EF_R15 21
 #define EF_R16 22
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R17 23
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R18 24
 #define EF_R19 25
 #define EF_R20 26
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R21 27
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R22 28
 #define EF_R23 29
 #define EF_R24 30
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R25 31
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R26 32
 #define EF_R27 33
 #define EF_R28 34
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R29 35
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_R30 36
 #define EF_R31 37
 #define EF_LO 38
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_HI 39
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_CP0_EPC 40
 #define EF_CP0_BADVADDR 41
 #define EF_CP0_STATUS 42
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_CP0_CAUSE 43
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define EF_UNUSED0 44
 #define EF_SIZE 180
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/resource.h b/ndk/platforms/android-9/arch-mips/include/asm/resource.h
index e841072..1374d7d 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/resource.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/resource.h
@@ -24,6 +24,7 @@
 #define RLIMIT_RSS 7  
 #define RLIMIT_NPROC 8  
 #define RLIMIT_MEMLOCK 9  
-#include <asm-generic/resource.h>
+#define RLIM_INFINITY 0x7fffffffUL
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <asm-generic/resource.h>
 #endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/siginfo.h b/ndk/platforms/android-9/arch-mips/include/asm/siginfo.h
index f3e508a..8fdbf77 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/siginfo.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/siginfo.h
@@ -24,73 +24,75 @@
 #define HAVE_ARCH_SIGINFO_T
 #define HAVE_ARCH_COPY_SIGINFO
 struct siginfo;
-#include <asm-generic/siginfo.h>
+#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#include <asm-generic/siginfo.h>
 typedef struct siginfo {
  int si_signo;
  int si_code;
- int si_errno;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ int si_errno;
  int __pad0[SI_MAX_SIZE / sizeof(int) - SI_PAD_SIZE - 3];
  union {
  int _pad[SI_PAD_SIZE];
- struct {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ struct {
  pid_t _pid;
  __ARCH_SI_UID_T _uid;
  } _kill;
- struct {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ struct {
  timer_t _tid;
  int _overrun;
  char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
- sigval_t _sigval;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ sigval_t _sigval;
  int _sys_private;
  } _timer;
  struct {
- pid_t _pid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ pid_t _pid;
  __ARCH_SI_UID_T _uid;
  sigval_t _sigval;
  } _rt;
- struct {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ struct {
  pid_t _pid;
  __ARCH_SI_UID_T _uid;
  int _status;
- clock_t _utime;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ clock_t _utime;
  clock_t _stime;
  } _sigchld;
  struct {
- pid_t _pid;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ pid_t _pid;
  clock_t _utime;
  int _status;
  clock_t _stime;
- } _irix_sigchld;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ } _irix_sigchld;
  struct {
  void __user *_addr;
 #ifdef __ARCH_SI_TRAPNO
- int _trapno;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ int _trapno;
 #endif
  } _sigfault;
  struct {
- __ARCH_SI_BAND_T _band;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+ __ARCH_SI_BAND_T _band;
  int _fd;
  } _sigpoll;
  } _sifields;
-} siginfo_t;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+} siginfo_t;
 #undef SI_ASYNCIO
 #undef SI_TIMER
 #undef SI_MESGQ
-#define SI_ASYNCIO -2  
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SI_ASYNCIO -2  
 #define SI_TIMER __SI_CODE(__SI_TIMER, -3)  
 #define SI_MESGQ __SI_CODE(__SI_MESGQ, -4)  
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/socket.h b/ndk/platforms/android-9/arch-mips/include/asm/socket.h
index ff8a3ba..4dbbe85 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/socket.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/socket.h
@@ -42,30 +42,39 @@
 #define SO_RCVTIMEO 0x1006  
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_ACCEPTCONN 0x1009
+#define SO_PROTOCOL 0x1028  
+#define SO_DOMAIN 0x1029  
 #define SO_NO_CHECK 11
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PRIORITY 12
 #define SO_BSDCOMPAT 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PASSCRED 17
 #define SO_PEERCRED 18
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_SECURITY_AUTHENTICATION 22
 #define SO_SECURITY_ENCRYPTION_TRANSPORT 23
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_SECURITY_ENCRYPTION_NETWORK 24
 #define SO_BINDTODEVICE 25
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_ATTACH_FILTER 26
 #define SO_DETACH_FILTER 27
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PEERNAME 28
 #define SO_TIMESTAMP 29
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SCM_TIMESTAMP SO_TIMESTAMP
 #define SO_PEERSEC 30
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_SNDBUFFORCE 31
 #define SO_RCVBUFFORCE 33
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SO_PASSSEC 34
 #define SO_TIMESTAMPNS 35
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS
 #define SO_MARK 36
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SO_TIMESTAMPING 37
+#define SCM_TIMESTAMPING SO_TIMESTAMPING
+#define SO_RXQ_OVFL 40
+#define SO_WIFI_STATUS 41
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define SCM_WIFI_STATUS SO_WIFI_STATUS
 #endif
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/string.h b/ndk/platforms/android-9/arch-mips/include/asm/string.h
index 856f61b..6f375a3 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/string.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/string.h
@@ -18,8 +18,16 @@
  ****************************************************************************/
 #ifndef _ASM_STRING_H
 #define _ASM_STRING_H
+#ifndef IN_STRING_C
+#define __HAVE_ARCH_STRCPY
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __HAVE_ARCH_STRNCPY
+#define __HAVE_ARCH_STRCMP
+#endif
+#define __HAVE_ARCH_STRNCMP
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __HAVE_ARCH_MEMSET
 #define __HAVE_ARCH_MEMCPY
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __HAVE_ARCH_MEMMOVE
 #endif
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/uaccess.h b/ndk/platforms/android-9/arch-mips/include/asm/uaccess.h
index 3703af3..96025d3 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/uaccess.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/uaccess.h
@@ -23,35 +23,45 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #include <linux/thread_info.h>
 #include <asm-generic/uaccess.h>
+#define __UA_LIMIT 0x80000000UL
+#define __UA_ADDR ".word"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __UA_LA "la"
+#define __UA_ADDU "addu"
+#define __UA_t0 "$8"
+#define __UA_t1 "$9"
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define KERNEL_DS ((mm_segment_t) { 0UL })
 #define USER_DS ((mm_segment_t) { __UA_LIMIT })
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define VERIFY_READ 0
 #define VERIFY_WRITE 1
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define get_ds() (KERNEL_DS)
 #define get_fs() (current_thread_info()->addr_limit)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define set_fs(x) (current_thread_info()->addr_limit = (x))
 #define segment_eq(a, b) ((a).seg == (b).seg)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __ua_size(size)   ((__builtin_constant_p(size) && (signed long) (size) > 0) ? 0 : (size))
 #define __access_mask get_fs().seg
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __access_ok(addr, size, mask)   (((signed long)((mask) & ((addr) | ((addr) + (size)) | __ua_size(size)))) == 0)
 #define access_ok(type, addr, size)   likely(__access_ok((unsigned long)(addr), (size), __access_mask))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define put_user(x,ptr)   __put_user_check((x), (ptr), sizeof(*(ptr)))
 #define get_user(x,ptr)   __get_user_check((x), (ptr), sizeof(*(ptr)))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __put_user(x,ptr)   __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
 #define __get_user(x,ptr)   __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct __large_struct { unsigned long buf[100]; };
 #define __m(x) (*(struct __large_struct __user *)(x))
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __GET_USER_DW(val, ptr) __get_user_asm_ll32(val, ptr)
 #define __get_user_common(val, size, ptr)  do {   switch (size) {   case 1: __get_user_asm(val, "lb", ptr); break;   case 2: __get_user_asm(val, "lh", ptr); break;   case 4: __get_user_asm(val, "lw", ptr); break;   case 8: __GET_USER_DW(val, ptr); break;   default: __get_user_unknown(); break;   }  } while (0)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __get_user_nocheck(x, ptr, size)  ({   long __gu_err;     __get_user_common((x), size, ptr);   __gu_err;  })
 #define __get_user_check(x, ptr, size)  ({   long __gu_err = -EFAULT;   const __typeof__(*(ptr)) __user * __gu_ptr = (ptr);     if (likely(access_ok(VERIFY_READ, __gu_ptr, size)))   __get_user_common((x), size, __gu_ptr);     __gu_err;  })
 #define __get_user_asm(val, insn, addr)  {   long __gu_tmp;     __asm__ __volatile__(   "1:	" insn "	%1, %3				\n"   "2:							\n"   "	.section .fixup,\"ax\"				\n"   "3:	li	%0, %4					\n"   "	j	2b					\n"   "	.previous					\n"   "	.section __ex_table,\"a\"			\n"   "	"__UA_ADDR "\t1b, 3b				\n"   "	.previous					\n"   : "=r" (__gu_err), "=r" (__gu_tmp)   : "0" (0), "o" (__m(addr)), "i" (-EFAULT));     (val) = (__typeof__(*(addr))) __gu_tmp;  }
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __get_user_asm_ll32(val, addr)  {   union {   unsigned long long l;   __typeof__(*(addr)) t;   } __gu_tmp;     __asm__ __volatile__(   "1:	lw	%1, (%3)				\n"   "2:	lw	%D1, 4(%3)				\n"   "3:	.section	.fixup,\"ax\"			\n"   "4:	li	%0, %4					\n"   "	move	%1, $0					\n"   "	move	%D1, $0					\n"   "	j	3b					\n"   "	.previous					\n"   "	.section	__ex_table,\"a\"		\n"   "	" __UA_ADDR "	1b, 4b				\n"   "	" __UA_ADDR "	2b, 4b				\n"   "	.previous					\n"   : "=r" (__gu_err), "=&r" (__gu_tmp.l)   : "0" (0), "r" (addr), "i" (-EFAULT));     (val) = __gu_tmp.t;  }
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __PUT_USER_DW(ptr) __put_user_asm_ll32(ptr)
 #define __put_user_nocheck(x, ptr, size)  ({   __typeof__(*(ptr)) __pu_val;   long __pu_err = 0;     __pu_val = (x);   switch (size) {   case 1: __put_user_asm("sb", ptr); break;   case 2: __put_user_asm("sh", ptr); break;   case 4: __put_user_asm("sw", ptr); break;   case 8: __PUT_USER_DW(ptr); break;   default: __put_user_unknown(); break;   }   __pu_err;  })
 #define __put_user_check(x, ptr, size)  ({   __typeof__(*(ptr)) __user *__pu_addr = (ptr);   __typeof__(*(ptr)) __pu_val = (x);   long __pu_err = -EFAULT;     if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) {   switch (size) {   case 1: __put_user_asm("sb", __pu_addr); break;   case 2: __put_user_asm("sh", __pu_addr); break;   case 4: __put_user_asm("sw", __pu_addr); break;   case 8: __PUT_USER_DW(__pu_addr); break;   default: __put_user_unknown(); break;   }   }   __pu_err;  })
 #define __put_user_asm(insn, ptr)  {   __asm__ __volatile__(   "1:	" insn "	%z2, %3		# __put_user_asm\n"   "2:							\n"   "	.section	.fixup,\"ax\"			\n"   "3:	li	%0, %4					\n"   "	j	2b					\n"   "	.previous					\n"   "	.section	__ex_table,\"a\"		\n"   "	" __UA_ADDR "	1b, 3b				\n"   "	.previous					\n"   : "=r" (__pu_err)   : "0" (0), "Jr" (__pu_val), "o" (__m(ptr)),   "i" (-EFAULT));  }
diff --git a/ndk/platforms/android-9/arch-mips/include/asm/unistd.h b/ndk/platforms/android-9/arch-mips/include/asm/unistd.h
index 38e84cc..4a8744f 100644
--- a/ndk/platforms/android-9/arch-mips/include/asm/unistd.h
+++ b/ndk/platforms/android-9/arch-mips/include/asm/unistd.h
@@ -433,749 +433,814 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pipe2 (__NR_Linux + 328)
 #define __NR_inotify_init1 (__NR_Linux + 329)
-#define __NR_Linux_syscalls 329
+#define __NR_preadv (__NR_Linux + 330)
+#define __NR_pwritev (__NR_Linux + 331)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_rt_tgsigqueueinfo (__NR_Linux + 332)
+#define __NR_perf_event_open (__NR_Linux + 333)
+#define __NR_accept4 (__NR_Linux + 334)
+#define __NR_recvmmsg (__NR_Linux + 335)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fanotify_init (__NR_Linux + 336)
+#define __NR_fanotify_mark (__NR_Linux + 337)
+#define __NR_prlimit64 (__NR_Linux + 338)
+#define __NR_name_to_handle_at (__NR_Linux + 339)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_open_by_handle_at (__NR_Linux + 340)
+#define __NR_clock_adjtime (__NR_Linux + 341)
+#define __NR_syncfs (__NR_Linux + 342)
+#define __NR_sendmmsg (__NR_Linux + 343)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_setns (__NR_Linux + 344)
+#define __NR_process_vm_readv (__NR_Linux + 345)
+#define __NR_process_vm_writev (__NR_Linux + 346)
+#define __NR_Linux_syscalls 346
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #endif
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_O32_Linux 4000
-#define __NR_O32_Linux_syscalls 329
+#define __NR_O32_Linux_syscalls 346
 #if _MIPS_SIM == _MIPS_SIM_ABI64
-#define __NR_Linux 5000
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_Linux 5000
 #define __NR_read (__NR_Linux + 0)
 #define __NR_write (__NR_Linux + 1)
 #define __NR_open (__NR_Linux + 2)
-#define __NR_close (__NR_Linux + 3)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_close (__NR_Linux + 3)
 #define __NR_stat (__NR_Linux + 4)
 #define __NR_fstat (__NR_Linux + 5)
 #define __NR_lstat (__NR_Linux + 6)
-#define __NR_poll (__NR_Linux + 7)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_poll (__NR_Linux + 7)
 #define __NR_lseek (__NR_Linux + 8)
 #define __NR_mmap (__NR_Linux + 9)
 #define __NR_mprotect (__NR_Linux + 10)
-#define __NR_munmap (__NR_Linux + 11)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_munmap (__NR_Linux + 11)
 #define __NR_brk (__NR_Linux + 12)
 #define __NR_rt_sigaction (__NR_Linux + 13)
 #define __NR_rt_sigprocmask (__NR_Linux + 14)
-#define __NR_ioctl (__NR_Linux + 15)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_ioctl (__NR_Linux + 15)
 #define __NR_pread64 (__NR_Linux + 16)
 #define __NR_pwrite64 (__NR_Linux + 17)
 #define __NR_readv (__NR_Linux + 18)
-#define __NR_writev (__NR_Linux + 19)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_writev (__NR_Linux + 19)
 #define __NR_access (__NR_Linux + 20)
 #define __NR_pipe (__NR_Linux + 21)
 #define __NR__newselect (__NR_Linux + 22)
-#define __NR_sched_yield (__NR_Linux + 23)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sched_yield (__NR_Linux + 23)
 #define __NR_mremap (__NR_Linux + 24)
 #define __NR_msync (__NR_Linux + 25)
 #define __NR_mincore (__NR_Linux + 26)
-#define __NR_madvise (__NR_Linux + 27)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_madvise (__NR_Linux + 27)
 #define __NR_shmget (__NR_Linux + 28)
 #define __NR_shmat (__NR_Linux + 29)
 #define __NR_shmctl (__NR_Linux + 30)
-#define __NR_dup (__NR_Linux + 31)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_dup (__NR_Linux + 31)
 #define __NR_dup2 (__NR_Linux + 32)
 #define __NR_pause (__NR_Linux + 33)
 #define __NR_nanosleep (__NR_Linux + 34)
-#define __NR_getitimer (__NR_Linux + 35)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_getitimer (__NR_Linux + 35)
 #define __NR_setitimer (__NR_Linux + 36)
 #define __NR_alarm (__NR_Linux + 37)
 #define __NR_getpid (__NR_Linux + 38)
-#define __NR_sendfile (__NR_Linux + 39)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sendfile (__NR_Linux + 39)
 #define __NR_socket (__NR_Linux + 40)
 #define __NR_connect (__NR_Linux + 41)
 #define __NR_accept (__NR_Linux + 42)
-#define __NR_sendto (__NR_Linux + 43)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sendto (__NR_Linux + 43)
 #define __NR_recvfrom (__NR_Linux + 44)
 #define __NR_sendmsg (__NR_Linux + 45)
 #define __NR_recvmsg (__NR_Linux + 46)
-#define __NR_shutdown (__NR_Linux + 47)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_shutdown (__NR_Linux + 47)
 #define __NR_bind (__NR_Linux + 48)
 #define __NR_listen (__NR_Linux + 49)
 #define __NR_getsockname (__NR_Linux + 50)
-#define __NR_getpeername (__NR_Linux + 51)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_getpeername (__NR_Linux + 51)
 #define __NR_socketpair (__NR_Linux + 52)
 #define __NR_setsockopt (__NR_Linux + 53)
 #define __NR_getsockopt (__NR_Linux + 54)
-#define __NR_clone (__NR_Linux + 55)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_clone (__NR_Linux + 55)
 #define __NR_fork (__NR_Linux + 56)
 #define __NR_execve (__NR_Linux + 57)
 #define __NR_exit (__NR_Linux + 58)
-#define __NR_wait4 (__NR_Linux + 59)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_wait4 (__NR_Linux + 59)
 #define __NR_kill (__NR_Linux + 60)
 #define __NR_uname (__NR_Linux + 61)
 #define __NR_semget (__NR_Linux + 62)
-#define __NR_semop (__NR_Linux + 63)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_semop (__NR_Linux + 63)
 #define __NR_semctl (__NR_Linux + 64)
 #define __NR_shmdt (__NR_Linux + 65)
 #define __NR_msgget (__NR_Linux + 66)
-#define __NR_msgsnd (__NR_Linux + 67)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_msgsnd (__NR_Linux + 67)
 #define __NR_msgrcv (__NR_Linux + 68)
 #define __NR_msgctl (__NR_Linux + 69)
 #define __NR_fcntl (__NR_Linux + 70)
-#define __NR_flock (__NR_Linux + 71)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_flock (__NR_Linux + 71)
 #define __NR_fsync (__NR_Linux + 72)
 #define __NR_fdatasync (__NR_Linux + 73)
 #define __NR_truncate (__NR_Linux + 74)
-#define __NR_ftruncate (__NR_Linux + 75)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_ftruncate (__NR_Linux + 75)
 #define __NR_getdents (__NR_Linux + 76)
 #define __NR_getcwd (__NR_Linux + 77)
 #define __NR_chdir (__NR_Linux + 78)
-#define __NR_fchdir (__NR_Linux + 79)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fchdir (__NR_Linux + 79)
 #define __NR_rename (__NR_Linux + 80)
 #define __NR_mkdir (__NR_Linux + 81)
 #define __NR_rmdir (__NR_Linux + 82)
-#define __NR_creat (__NR_Linux + 83)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_creat (__NR_Linux + 83)
 #define __NR_link (__NR_Linux + 84)
 #define __NR_unlink (__NR_Linux + 85)
 #define __NR_symlink (__NR_Linux + 86)
-#define __NR_readlink (__NR_Linux + 87)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_readlink (__NR_Linux + 87)
 #define __NR_chmod (__NR_Linux + 88)
 #define __NR_fchmod (__NR_Linux + 89)
 #define __NR_chown (__NR_Linux + 90)
-#define __NR_fchown (__NR_Linux + 91)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fchown (__NR_Linux + 91)
 #define __NR_lchown (__NR_Linux + 92)
 #define __NR_umask (__NR_Linux + 93)
 #define __NR_gettimeofday (__NR_Linux + 94)
-#define __NR_getrlimit (__NR_Linux + 95)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_getrlimit (__NR_Linux + 95)
 #define __NR_getrusage (__NR_Linux + 96)
 #define __NR_sysinfo (__NR_Linux + 97)
 #define __NR_times (__NR_Linux + 98)
-#define __NR_ptrace (__NR_Linux + 99)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_ptrace (__NR_Linux + 99)
 #define __NR_getuid (__NR_Linux + 100)
 #define __NR_syslog (__NR_Linux + 101)
 #define __NR_getgid (__NR_Linux + 102)
-#define __NR_setuid (__NR_Linux + 103)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_setuid (__NR_Linux + 103)
 #define __NR_setgid (__NR_Linux + 104)
 #define __NR_geteuid (__NR_Linux + 105)
 #define __NR_getegid (__NR_Linux + 106)
-#define __NR_setpgid (__NR_Linux + 107)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_setpgid (__NR_Linux + 107)
 #define __NR_getppid (__NR_Linux + 108)
 #define __NR_getpgrp (__NR_Linux + 109)
 #define __NR_setsid (__NR_Linux + 110)
-#define __NR_setreuid (__NR_Linux + 111)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_setreuid (__NR_Linux + 111)
 #define __NR_setregid (__NR_Linux + 112)
 #define __NR_getgroups (__NR_Linux + 113)
 #define __NR_setgroups (__NR_Linux + 114)
-#define __NR_setresuid (__NR_Linux + 115)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_setresuid (__NR_Linux + 115)
 #define __NR_getresuid (__NR_Linux + 116)
 #define __NR_setresgid (__NR_Linux + 117)
 #define __NR_getresgid (__NR_Linux + 118)
-#define __NR_getpgid (__NR_Linux + 119)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_getpgid (__NR_Linux + 119)
 #define __NR_setfsuid (__NR_Linux + 120)
 #define __NR_setfsgid (__NR_Linux + 121)
 #define __NR_getsid (__NR_Linux + 122)
-#define __NR_capget (__NR_Linux + 123)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_capget (__NR_Linux + 123)
 #define __NR_capset (__NR_Linux + 124)
 #define __NR_rt_sigpending (__NR_Linux + 125)
 #define __NR_rt_sigtimedwait (__NR_Linux + 126)
-#define __NR_rt_sigqueueinfo (__NR_Linux + 127)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_rt_sigqueueinfo (__NR_Linux + 127)
 #define __NR_rt_sigsuspend (__NR_Linux + 128)
 #define __NR_sigaltstack (__NR_Linux + 129)
 #define __NR_utime (__NR_Linux + 130)
-#define __NR_mknod (__NR_Linux + 131)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_mknod (__NR_Linux + 131)
 #define __NR_personality (__NR_Linux + 132)
 #define __NR_ustat (__NR_Linux + 133)
 #define __NR_statfs (__NR_Linux + 134)
-#define __NR_fstatfs (__NR_Linux + 135)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fstatfs (__NR_Linux + 135)
 #define __NR_sysfs (__NR_Linux + 136)
 #define __NR_getpriority (__NR_Linux + 137)
 #define __NR_setpriority (__NR_Linux + 138)
-#define __NR_sched_setparam (__NR_Linux + 139)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sched_setparam (__NR_Linux + 139)
 #define __NR_sched_getparam (__NR_Linux + 140)
 #define __NR_sched_setscheduler (__NR_Linux + 141)
 #define __NR_sched_getscheduler (__NR_Linux + 142)
-#define __NR_sched_get_priority_max (__NR_Linux + 143)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sched_get_priority_max (__NR_Linux + 143)
 #define __NR_sched_get_priority_min (__NR_Linux + 144)
 #define __NR_sched_rr_get_interval (__NR_Linux + 145)
 #define __NR_mlock (__NR_Linux + 146)
-#define __NR_munlock (__NR_Linux + 147)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_munlock (__NR_Linux + 147)
 #define __NR_mlockall (__NR_Linux + 148)
 #define __NR_munlockall (__NR_Linux + 149)
 #define __NR_vhangup (__NR_Linux + 150)
-#define __NR_pivot_root (__NR_Linux + 151)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_pivot_root (__NR_Linux + 151)
 #define __NR__sysctl (__NR_Linux + 152)
 #define __NR_prctl (__NR_Linux + 153)
 #define __NR_adjtimex (__NR_Linux + 154)
-#define __NR_setrlimit (__NR_Linux + 155)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_setrlimit (__NR_Linux + 155)
 #define __NR_chroot (__NR_Linux + 156)
 #define __NR_sync (__NR_Linux + 157)
 #define __NR_acct (__NR_Linux + 158)
-#define __NR_settimeofday (__NR_Linux + 159)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_settimeofday (__NR_Linux + 159)
 #define __NR_mount (__NR_Linux + 160)
 #define __NR_umount2 (__NR_Linux + 161)
 #define __NR_swapon (__NR_Linux + 162)
-#define __NR_swapoff (__NR_Linux + 163)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_swapoff (__NR_Linux + 163)
 #define __NR_reboot (__NR_Linux + 164)
 #define __NR_sethostname (__NR_Linux + 165)
 #define __NR_setdomainname (__NR_Linux + 166)
-#define __NR_create_module (__NR_Linux + 167)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_create_module (__NR_Linux + 167)
 #define __NR_init_module (__NR_Linux + 168)
 #define __NR_delete_module (__NR_Linux + 169)
 #define __NR_get_kernel_syms (__NR_Linux + 170)
-#define __NR_query_module (__NR_Linux + 171)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_query_module (__NR_Linux + 171)
 #define __NR_quotactl (__NR_Linux + 172)
 #define __NR_nfsservctl (__NR_Linux + 173)
 #define __NR_getpmsg (__NR_Linux + 174)
-#define __NR_putpmsg (__NR_Linux + 175)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_putpmsg (__NR_Linux + 175)
 #define __NR_afs_syscall (__NR_Linux + 176)
 #define __NR_reserved177 (__NR_Linux + 177)
 #define __NR_gettid (__NR_Linux + 178)
-#define __NR_readahead (__NR_Linux + 179)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_readahead (__NR_Linux + 179)
 #define __NR_setxattr (__NR_Linux + 180)
 #define __NR_lsetxattr (__NR_Linux + 181)
 #define __NR_fsetxattr (__NR_Linux + 182)
-#define __NR_getxattr (__NR_Linux + 183)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_getxattr (__NR_Linux + 183)
 #define __NR_lgetxattr (__NR_Linux + 184)
 #define __NR_fgetxattr (__NR_Linux + 185)
 #define __NR_listxattr (__NR_Linux + 186)
-#define __NR_llistxattr (__NR_Linux + 187)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_llistxattr (__NR_Linux + 187)
 #define __NR_flistxattr (__NR_Linux + 188)
 #define __NR_removexattr (__NR_Linux + 189)
 #define __NR_lremovexattr (__NR_Linux + 190)
-#define __NR_fremovexattr (__NR_Linux + 191)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fremovexattr (__NR_Linux + 191)
 #define __NR_tkill (__NR_Linux + 192)
 #define __NR_reserved193 (__NR_Linux + 193)
 #define __NR_futex (__NR_Linux + 194)
-#define __NR_sched_setaffinity (__NR_Linux + 195)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sched_setaffinity (__NR_Linux + 195)
 #define __NR_sched_getaffinity (__NR_Linux + 196)
 #define __NR_cacheflush (__NR_Linux + 197)
 #define __NR_cachectl (__NR_Linux + 198)
-#define __NR_sysmips (__NR_Linux + 199)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sysmips (__NR_Linux + 199)
 #define __NR_io_setup (__NR_Linux + 200)
 #define __NR_io_destroy (__NR_Linux + 201)
 #define __NR_io_getevents (__NR_Linux + 202)
-#define __NR_io_submit (__NR_Linux + 203)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_io_submit (__NR_Linux + 203)
 #define __NR_io_cancel (__NR_Linux + 204)
 #define __NR_exit_group (__NR_Linux + 205)
 #define __NR_lookup_dcookie (__NR_Linux + 206)
-#define __NR_epoll_create (__NR_Linux + 207)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_epoll_create (__NR_Linux + 207)
 #define __NR_epoll_ctl (__NR_Linux + 208)
 #define __NR_epoll_wait (__NR_Linux + 209)
 #define __NR_remap_file_pages (__NR_Linux + 210)
-#define __NR_rt_sigreturn (__NR_Linux + 211)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_rt_sigreturn (__NR_Linux + 211)
 #define __NR_set_tid_address (__NR_Linux + 212)
 #define __NR_restart_syscall (__NR_Linux + 213)
 #define __NR_semtimedop (__NR_Linux + 214)
-#define __NR_fadvise64 (__NR_Linux + 215)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fadvise64 (__NR_Linux + 215)
 #define __NR_timer_create (__NR_Linux + 216)
 #define __NR_timer_settime (__NR_Linux + 217)
 #define __NR_timer_gettime (__NR_Linux + 218)
-#define __NR_timer_getoverrun (__NR_Linux + 219)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_timer_getoverrun (__NR_Linux + 219)
 #define __NR_timer_delete (__NR_Linux + 220)
 #define __NR_clock_settime (__NR_Linux + 221)
 #define __NR_clock_gettime (__NR_Linux + 222)
-#define __NR_clock_getres (__NR_Linux + 223)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_clock_getres (__NR_Linux + 223)
 #define __NR_clock_nanosleep (__NR_Linux + 224)
 #define __NR_tgkill (__NR_Linux + 225)
 #define __NR_utimes (__NR_Linux + 226)
-#define __NR_mbind (__NR_Linux + 227)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_mbind (__NR_Linux + 227)
 #define __NR_get_mempolicy (__NR_Linux + 228)
 #define __NR_set_mempolicy (__NR_Linux + 229)
 #define __NR_mq_open (__NR_Linux + 230)
-#define __NR_mq_unlink (__NR_Linux + 231)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_mq_unlink (__NR_Linux + 231)
 #define __NR_mq_timedsend (__NR_Linux + 232)
 #define __NR_mq_timedreceive (__NR_Linux + 233)
 #define __NR_mq_notify (__NR_Linux + 234)
-#define __NR_mq_getsetattr (__NR_Linux + 235)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_mq_getsetattr (__NR_Linux + 235)
 #define __NR_vserver (__NR_Linux + 236)
 #define __NR_waitid (__NR_Linux + 237)
 #define __NR_add_key (__NR_Linux + 239)
-#define __NR_request_key (__NR_Linux + 240)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_request_key (__NR_Linux + 240)
 #define __NR_keyctl (__NR_Linux + 241)
 #define __NR_set_thread_area (__NR_Linux + 242)
 #define __NR_inotify_init (__NR_Linux + 243)
-#define __NR_inotify_add_watch (__NR_Linux + 244)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_inotify_add_watch (__NR_Linux + 244)
 #define __NR_inotify_rm_watch (__NR_Linux + 245)
 #define __NR_migrate_pages (__NR_Linux + 246)
 #define __NR_openat (__NR_Linux + 247)
-#define __NR_mkdirat (__NR_Linux + 248)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_mkdirat (__NR_Linux + 248)
 #define __NR_mknodat (__NR_Linux + 249)
 #define __NR_fchownat (__NR_Linux + 250)
 #define __NR_futimesat (__NR_Linux + 251)
-#define __NR_newfstatat (__NR_Linux + 252)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_newfstatat (__NR_Linux + 252)
 #define __NR_unlinkat (__NR_Linux + 253)
 #define __NR_renameat (__NR_Linux + 254)
 #define __NR_linkat (__NR_Linux + 255)
-#define __NR_symlinkat (__NR_Linux + 256)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_symlinkat (__NR_Linux + 256)
 #define __NR_readlinkat (__NR_Linux + 257)
 #define __NR_fchmodat (__NR_Linux + 258)
 #define __NR_faccessat (__NR_Linux + 259)
-#define __NR_pselect6 (__NR_Linux + 260)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_pselect6 (__NR_Linux + 260)
 #define __NR_ppoll (__NR_Linux + 261)
 #define __NR_unshare (__NR_Linux + 262)
 #define __NR_splice (__NR_Linux + 263)
-#define __NR_sync_file_range (__NR_Linux + 264)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sync_file_range (__NR_Linux + 264)
 #define __NR_tee (__NR_Linux + 265)
 #define __NR_vmsplice (__NR_Linux + 266)
 #define __NR_move_pages (__NR_Linux + 267)
-#define __NR_set_robust_list (__NR_Linux + 268)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_set_robust_list (__NR_Linux + 268)
 #define __NR_get_robust_list (__NR_Linux + 269)
 #define __NR_kexec_load (__NR_Linux + 270)
 #define __NR_getcpu (__NR_Linux + 271)
-#define __NR_epoll_pwait (__NR_Linux + 272)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_epoll_pwait (__NR_Linux + 272)
 #define __NR_ioprio_set (__NR_Linux + 273)
 #define __NR_ioprio_get (__NR_Linux + 274)
 #define __NR_utimensat (__NR_Linux + 275)
-#define __NR_signalfd (__NR_Linux + 276)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_signalfd (__NR_Linux + 276)
 #define __NR_timerfd (__NR_Linux + 277)
 #define __NR_eventfd (__NR_Linux + 278)
 #define __NR_fallocate (__NR_Linux + 279)
-#define __NR_timerfd_create (__NR_Linux + 280)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_timerfd_create (__NR_Linux + 280)
 #define __NR_timerfd_gettime (__NR_Linux + 281)
 #define __NR_timerfd_settime (__NR_Linux + 282)
 #define __NR_signalfd4 (__NR_Linux + 283)
-#define __NR_eventfd2 (__NR_Linux + 284)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_eventfd2 (__NR_Linux + 284)
 #define __NR_epoll_create1 (__NR_Linux + 285)
 #define __NR_dup3 (__NR_Linux + 286)
 #define __NR_pipe2 (__NR_Linux + 287)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_init1 (__NR_Linux + 288)
+#define __NR_preadv (__NR_Linux + 289)
+#define __NR_pwritev (__NR_Linux + 290)
+#define __NR_rt_tgsigqueueinfo (__NR_Linux + 291)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __NR_Linux_syscalls 288
+#define __NR_perf_event_open (__NR_Linux + 292)
+#define __NR_accept4 (__NR_Linux + 293)
+#define __NR_recvmmsg (__NR_Linux + 294)
+#define __NR_fanotify_init (__NR_Linux + 295)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fanotify_mark (__NR_Linux + 296)
+#define __NR_prlimit64 (__NR_Linux + 297)
+#define __NR_name_to_handle_at (__NR_Linux + 298)
+#define __NR_open_by_handle_at (__NR_Linux + 299)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_clock_adjtime (__NR_Linux + 300)
+#define __NR_syncfs (__NR_Linux + 301)
+#define __NR_sendmmsg (__NR_Linux + 302)
+#define __NR_setns (__NR_Linux + 303)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_process_vm_readv (__NR_Linux + 304)
+#define __NR_process_vm_writev (__NR_Linux + 305)
+#define __NR_Linux_syscalls 305
 #endif
-#define __NR_64_Linux 5000
-#define __NR_64_Linux_syscalls 288
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_64_Linux 5000
+#define __NR_64_Linux_syscalls 305
 #if _MIPS_SIM == _MIPS_SIM_NABI32
 #define __NR_Linux 6000
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_read (__NR_Linux + 0)
 #define __NR_write (__NR_Linux + 1)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_open (__NR_Linux + 2)
 #define __NR_close (__NR_Linux + 3)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_stat (__NR_Linux + 4)
 #define __NR_fstat (__NR_Linux + 5)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lstat (__NR_Linux + 6)
 #define __NR_poll (__NR_Linux + 7)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lseek (__NR_Linux + 8)
 #define __NR_mmap (__NR_Linux + 9)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mprotect (__NR_Linux + 10)
 #define __NR_munmap (__NR_Linux + 11)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_brk (__NR_Linux + 12)
 #define __NR_rt_sigaction (__NR_Linux + 13)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigprocmask (__NR_Linux + 14)
 #define __NR_ioctl (__NR_Linux + 15)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pread64 (__NR_Linux + 16)
 #define __NR_pwrite64 (__NR_Linux + 17)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readv (__NR_Linux + 18)
 #define __NR_writev (__NR_Linux + 19)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_access (__NR_Linux + 20)
 #define __NR_pipe (__NR_Linux + 21)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR__newselect (__NR_Linux + 22)
 #define __NR_sched_yield (__NR_Linux + 23)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mremap (__NR_Linux + 24)
 #define __NR_msync (__NR_Linux + 25)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mincore (__NR_Linux + 26)
 #define __NR_madvise (__NR_Linux + 27)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmget (__NR_Linux + 28)
 #define __NR_shmat (__NR_Linux + 29)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_shmctl (__NR_Linux + 30)
 #define __NR_dup (__NR_Linux + 31)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_dup2 (__NR_Linux + 32)
 #define __NR_pause (__NR_Linux + 33)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_nanosleep (__NR_Linux + 34)
 #define __NR_getitimer (__NR_Linux + 35)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setitimer (__NR_Linux + 36)
 #define __NR_alarm (__NR_Linux + 37)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpid (__NR_Linux + 38)
 #define __NR_sendfile (__NR_Linux + 39)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_socket (__NR_Linux + 40)
 #define __NR_connect (__NR_Linux + 41)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_accept (__NR_Linux + 42)
 #define __NR_sendto (__NR_Linux + 43)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_recvfrom (__NR_Linux + 44)
 #define __NR_sendmsg (__NR_Linux + 45)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_recvmsg (__NR_Linux + 46)
 #define __NR_shutdown (__NR_Linux + 47)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_bind (__NR_Linux + 48)
 #define __NR_listen (__NR_Linux + 49)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsockname (__NR_Linux + 50)
 #define __NR_getpeername (__NR_Linux + 51)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_socketpair (__NR_Linux + 52)
 #define __NR_setsockopt (__NR_Linux + 53)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsockopt (__NR_Linux + 54)
 #define __NR_clone (__NR_Linux + 55)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fork (__NR_Linux + 56)
 #define __NR_execve (__NR_Linux + 57)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_exit (__NR_Linux + 58)
 #define __NR_wait4 (__NR_Linux + 59)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_kill (__NR_Linux + 60)
 #define __NR_uname (__NR_Linux + 61)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semget (__NR_Linux + 62)
 #define __NR_semop (__NR_Linux + 63)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_semctl (__NR_Linux + 64)
 #define __NR_shmdt (__NR_Linux + 65)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgget (__NR_Linux + 66)
 #define __NR_msgsnd (__NR_Linux + 67)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_msgrcv (__NR_Linux + 68)
 #define __NR_msgctl (__NR_Linux + 69)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fcntl (__NR_Linux + 70)
 #define __NR_flock (__NR_Linux + 71)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fsync (__NR_Linux + 72)
 #define __NR_fdatasync (__NR_Linux + 73)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_truncate (__NR_Linux + 74)
 #define __NR_ftruncate (__NR_Linux + 75)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getdents (__NR_Linux + 76)
 #define __NR_getcwd (__NR_Linux + 77)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_chdir (__NR_Linux + 78)
 #define __NR_fchdir (__NR_Linux + 79)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rename (__NR_Linux + 80)
 #define __NR_mkdir (__NR_Linux + 81)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rmdir (__NR_Linux + 82)
 #define __NR_creat (__NR_Linux + 83)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_link (__NR_Linux + 84)
 #define __NR_unlink (__NR_Linux + 85)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_symlink (__NR_Linux + 86)
 #define __NR_readlink (__NR_Linux + 87)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_chmod (__NR_Linux + 88)
 #define __NR_fchmod (__NR_Linux + 89)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_chown (__NR_Linux + 90)
 #define __NR_fchown (__NR_Linux + 91)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lchown (__NR_Linux + 92)
 #define __NR_umask (__NR_Linux + 93)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_gettimeofday (__NR_Linux + 94)
 #define __NR_getrlimit (__NR_Linux + 95)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getrusage (__NR_Linux + 96)
 #define __NR_sysinfo (__NR_Linux + 97)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_times (__NR_Linux + 98)
 #define __NR_ptrace (__NR_Linux + 99)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getuid (__NR_Linux + 100)
 #define __NR_syslog (__NR_Linux + 101)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getgid (__NR_Linux + 102)
 #define __NR_setuid (__NR_Linux + 103)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setgid (__NR_Linux + 104)
 #define __NR_geteuid (__NR_Linux + 105)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getegid (__NR_Linux + 106)
 #define __NR_setpgid (__NR_Linux + 107)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getppid (__NR_Linux + 108)
 #define __NR_getpgrp (__NR_Linux + 109)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setsid (__NR_Linux + 110)
 #define __NR_setreuid (__NR_Linux + 111)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setregid (__NR_Linux + 112)
 #define __NR_getgroups (__NR_Linux + 113)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setgroups (__NR_Linux + 114)
 #define __NR_setresuid (__NR_Linux + 115)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getresuid (__NR_Linux + 116)
 #define __NR_setresgid (__NR_Linux + 117)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getresgid (__NR_Linux + 118)
 #define __NR_getpgid (__NR_Linux + 119)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setfsuid (__NR_Linux + 120)
 #define __NR_setfsgid (__NR_Linux + 121)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getsid (__NR_Linux + 122)
 #define __NR_capget (__NR_Linux + 123)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_capset (__NR_Linux + 124)
 #define __NR_rt_sigpending (__NR_Linux + 125)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigtimedwait (__NR_Linux + 126)
 #define __NR_rt_sigqueueinfo (__NR_Linux + 127)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_rt_sigsuspend (__NR_Linux + 128)
 #define __NR_sigaltstack (__NR_Linux + 129)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_utime (__NR_Linux + 130)
 #define __NR_mknod (__NR_Linux + 131)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_personality (__NR_Linux + 132)
 #define __NR_ustat (__NR_Linux + 133)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_statfs (__NR_Linux + 134)
 #define __NR_fstatfs (__NR_Linux + 135)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sysfs (__NR_Linux + 136)
 #define __NR_getpriority (__NR_Linux + 137)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setpriority (__NR_Linux + 138)
 #define __NR_sched_setparam (__NR_Linux + 139)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getparam (__NR_Linux + 140)
 #define __NR_sched_setscheduler (__NR_Linux + 141)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getscheduler (__NR_Linux + 142)
 #define __NR_sched_get_priority_max (__NR_Linux + 143)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_get_priority_min (__NR_Linux + 144)
 #define __NR_sched_rr_get_interval (__NR_Linux + 145)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mlock (__NR_Linux + 146)
 #define __NR_munlock (__NR_Linux + 147)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mlockall (__NR_Linux + 148)
 #define __NR_munlockall (__NR_Linux + 149)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vhangup (__NR_Linux + 150)
 #define __NR_pivot_root (__NR_Linux + 151)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR__sysctl (__NR_Linux + 152)
 #define __NR_prctl (__NR_Linux + 153)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_adjtimex (__NR_Linux + 154)
 #define __NR_setrlimit (__NR_Linux + 155)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_chroot (__NR_Linux + 156)
 #define __NR_sync (__NR_Linux + 157)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_acct (__NR_Linux + 158)
 #define __NR_settimeofday (__NR_Linux + 159)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mount (__NR_Linux + 160)
 #define __NR_umount2 (__NR_Linux + 161)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_swapon (__NR_Linux + 162)
 #define __NR_swapoff (__NR_Linux + 163)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_reboot (__NR_Linux + 164)
 #define __NR_sethostname (__NR_Linux + 165)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setdomainname (__NR_Linux + 166)
 #define __NR_create_module (__NR_Linux + 167)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_init_module (__NR_Linux + 168)
 #define __NR_delete_module (__NR_Linux + 169)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_get_kernel_syms (__NR_Linux + 170)
 #define __NR_query_module (__NR_Linux + 171)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_quotactl (__NR_Linux + 172)
 #define __NR_nfsservctl (__NR_Linux + 173)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getpmsg (__NR_Linux + 174)
 #define __NR_putpmsg (__NR_Linux + 175)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_afs_syscall (__NR_Linux + 176)
 #define __NR_reserved177 (__NR_Linux + 177)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_gettid (__NR_Linux + 178)
 #define __NR_readahead (__NR_Linux + 179)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_setxattr (__NR_Linux + 180)
 #define __NR_lsetxattr (__NR_Linux + 181)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fsetxattr (__NR_Linux + 182)
 #define __NR_getxattr (__NR_Linux + 183)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lgetxattr (__NR_Linux + 184)
 #define __NR_fgetxattr (__NR_Linux + 185)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_listxattr (__NR_Linux + 186)
 #define __NR_llistxattr (__NR_Linux + 187)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_flistxattr (__NR_Linux + 188)
 #define __NR_removexattr (__NR_Linux + 189)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lremovexattr (__NR_Linux + 190)
 #define __NR_fremovexattr (__NR_Linux + 191)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_tkill (__NR_Linux + 192)
 #define __NR_reserved193 (__NR_Linux + 193)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_futex (__NR_Linux + 194)
 #define __NR_sched_setaffinity (__NR_Linux + 195)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_sched_getaffinity (__NR_Linux + 196)
 #define __NR_cacheflush (__NR_Linux + 197)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_cachectl (__NR_Linux + 198)
 #define __NR_sysmips (__NR_Linux + 199)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_setup (__NR_Linux + 200)
 #define __NR_io_destroy (__NR_Linux + 201)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_getevents (__NR_Linux + 202)
 #define __NR_io_submit (__NR_Linux + 203)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_io_cancel (__NR_Linux + 204)
 #define __NR_exit_group (__NR_Linux + 205)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_lookup_dcookie (__NR_Linux + 206)
 #define __NR_epoll_create (__NR_Linux + 207)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_ctl (__NR_Linux + 208)
 #define __NR_epoll_wait (__NR_Linux + 209)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_remap_file_pages (__NR_Linux + 210)
 #define __NR_rt_sigreturn (__NR_Linux + 211)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fcntl64 (__NR_Linux + 212)
 #define __NR_set_tid_address (__NR_Linux + 213)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_restart_syscall (__NR_Linux + 214)
 #define __NR_semtimedop (__NR_Linux + 215)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fadvise64 (__NR_Linux + 216)
 #define __NR_statfs64 (__NR_Linux + 217)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fstatfs64 (__NR_Linux + 218)
 #define __NR_sendfile64 (__NR_Linux + 219)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_create (__NR_Linux + 220)
 #define __NR_timer_settime (__NR_Linux + 221)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_gettime (__NR_Linux + 222)
 #define __NR_timer_getoverrun (__NR_Linux + 223)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timer_delete (__NR_Linux + 224)
 #define __NR_clock_settime (__NR_Linux + 225)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_gettime (__NR_Linux + 226)
 #define __NR_clock_getres (__NR_Linux + 227)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_clock_nanosleep (__NR_Linux + 228)
 #define __NR_tgkill (__NR_Linux + 229)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_utimes (__NR_Linux + 230)
 #define __NR_mbind (__NR_Linux + 231)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_get_mempolicy (__NR_Linux + 232)
 #define __NR_set_mempolicy (__NR_Linux + 233)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_open (__NR_Linux + 234)
 #define __NR_mq_unlink (__NR_Linux + 235)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_timedsend (__NR_Linux + 236)
 #define __NR_mq_timedreceive (__NR_Linux + 237)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mq_notify (__NR_Linux + 238)
 #define __NR_mq_getsetattr (__NR_Linux + 239)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_vserver (__NR_Linux + 240)
 #define __NR_waitid (__NR_Linux + 241)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_add_key (__NR_Linux + 243)
 #define __NR_request_key (__NR_Linux + 244)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_keyctl (__NR_Linux + 245)
 #define __NR_set_thread_area (__NR_Linux + 246)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_init (__NR_Linux + 247)
 #define __NR_inotify_add_watch (__NR_Linux + 248)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_inotify_rm_watch (__NR_Linux + 249)
 #define __NR_migrate_pages (__NR_Linux + 250)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_openat (__NR_Linux + 251)
 #define __NR_mkdirat (__NR_Linux + 252)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_mknodat (__NR_Linux + 253)
 #define __NR_fchownat (__NR_Linux + 254)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_futimesat (__NR_Linux + 255)
 #define __NR_newfstatat (__NR_Linux + 256)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_unlinkat (__NR_Linux + 257)
 #define __NR_renameat (__NR_Linux + 258)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_linkat (__NR_Linux + 259)
 #define __NR_symlinkat (__NR_Linux + 260)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_readlinkat (__NR_Linux + 261)
 #define __NR_fchmodat (__NR_Linux + 262)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_faccessat (__NR_Linux + 263)
 #define __NR_pselect6 (__NR_Linux + 264)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ppoll (__NR_Linux + 265)
 #define __NR_unshare (__NR_Linux + 266)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_splice (__NR_Linux + 267)
 #define __NR_sync_file_range (__NR_Linux + 268)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_tee (__NR_Linux + 269)
 #define __NR_vmsplice (__NR_Linux + 270)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_move_pages (__NR_Linux + 271)
 #define __NR_set_robust_list (__NR_Linux + 272)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_get_robust_list (__NR_Linux + 273)
 #define __NR_kexec_load (__NR_Linux + 274)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_getcpu (__NR_Linux + 275)
 #define __NR_epoll_pwait (__NR_Linux + 276)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_ioprio_set (__NR_Linux + 277)
 #define __NR_ioprio_get (__NR_Linux + 278)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_utimensat (__NR_Linux + 279)
 #define __NR_signalfd (__NR_Linux + 280)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timerfd (__NR_Linux + 281)
 #define __NR_eventfd (__NR_Linux + 282)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_fallocate (__NR_Linux + 283)
 #define __NR_timerfd_create (__NR_Linux + 284)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_timerfd_gettime (__NR_Linux + 285)
 #define __NR_timerfd_settime (__NR_Linux + 286)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_signalfd4 (__NR_Linux + 287)
 #define __NR_eventfd2 (__NR_Linux + 288)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_epoll_create1 (__NR_Linux + 289)
 #define __NR_dup3 (__NR_Linux + 290)
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_pipe2 (__NR_Linux + 291)
 #define __NR_inotify_init1 (__NR_Linux + 292)
-#define __NR_Linux_syscalls 292
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_preadv (__NR_Linux + 293)
+#define __NR_pwritev (__NR_Linux + 294)
+#define __NR_rt_tgsigqueueinfo (__NR_Linux + 295)
+#define __NR_perf_event_open (__NR_Linux + 296)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_accept4 (__NR_Linux + 297)
+#define __NR_recvmmsg (__NR_Linux + 298)
+#define __NR_getdents64 (__NR_Linux + 299)
+#define __NR_fanotify_init (__NR_Linux + 300)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_fanotify_mark (__NR_Linux + 301)
+#define __NR_prlimit64 (__NR_Linux + 302)
+#define __NR_name_to_handle_at (__NR_Linux + 303)
+#define __NR_open_by_handle_at (__NR_Linux + 304)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_clock_adjtime (__NR_Linux + 305)
+#define __NR_syncfs (__NR_Linux + 306)
+#define __NR_sendmmsg (__NR_Linux + 307)
+#define __NR_setns (__NR_Linux + 308)
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_process_vm_readv (__NR_Linux + 309)
+#define __NR_process_vm_writev (__NR_Linux + 310)
+#define __NR_Linux_syscalls 310
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_N32_Linux 6000
-#define __NR_N32_Linux_syscalls 292
+#define __NR_N32_Linux_syscalls 310
 #endif
diff --git a/ndk/platforms/android-9/arch-mips/include/fenv.h b/ndk/platforms/android-9/arch-mips/include/fenv.h
index 583d002..ed69cf8 100644
--- a/ndk/platforms/android-9/arch-mips/include/fenv.h
+++ b/ndk/platforms/android-9/arch-mips/include/fenv.h
@@ -23,198 +23,203 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/msun/mips/fenv.h,v 1.1 2008/04/26 12:20:29 imp Exp $
+ * $FreeBSD: src/lib/msun/arm/fenv.h,v 1.5 2005/03/16 19:03:45 das Exp $
  */
 
-#ifndef	_FENV_H_
-#define	_FENV_H_
+/*
+   Rewritten for Android.
+*/
 
-#include <sys/cdefs.h>
-#include <sys/_types.h>
+/* MIPS FPU floating point control register bits.
+ *
+ * 31-25  -> floating point conditions code bits set by FP compare
+ *           instructions
+ * 24     -> flush denormalized results to zero instead of
+ *           causing unimplemented operation exception.
+ * 23     -> Condition bit
+ * 22     -> In conjunction with FS detects denormalized
+ *           operands and replaces them internally with 0.
+ * 21     -> In conjunction with FS forces denormalized operands
+ *           to the closest normalized value.
+ * 20-18  -> reserved (read as 0, write with 0)
+ * 17     -> cause bit for unimplemented operation
+ * 16     -> cause bit for invalid exception
+ * 15     -> cause bit for division by zero exception
+ * 14     -> cause bit for overflow exception
+ * 13     -> cause bit for underflow exception
+ * 12     -> cause bit for inexact exception
+ * 11     -> enable exception for invalid exception
+ * 10     -> enable exception for division by zero exception
+ *  9     -> enable exception for overflow exception
+ *  8     -> enable exception for underflow exception
+ *  7     -> enable exception for inexact exception
+ *  6     -> flag invalid exception
+ *  5     -> flag division by zero exception
+ *  4     -> flag overflow exception
+ *  3     -> flag underflow exception
+ *  2     -> flag inexact exception
+ *  1-0   -> rounding control
+ *
+ *
+ * Rounding Control:
+ * 00 - rounding to nearest (RN)
+ * 01 - rounding toward zero (RZ)
+ * 10 - rounding (up) toward plus infinity (RP)
+ * 11 - rounding (down)toward minus infinity (RM)
+ */
+
+#ifndef _FENV_H_
+#define _FENV_H_
+
+#include <sys/types.h>
 
 __BEGIN_DECLS
 
-typedef	__uint32_t	fenv_t;
-typedef	__uint32_t	fexcept_t;
+typedef __uint32_t    fenv_t;
+typedef __uint32_t    fexcept_t;
 
 /* Exception flags */
-#define	FE_INVALID	0x0001
-#define	FE_DIVBYZERO	0x0002
-#define	FE_OVERFLOW	0x0004
-#define	FE_UNDERFLOW	0x0008
-#define	FE_INEXACT	0x0010
-#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
-			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define FE_INVALID      0x40
+#define FE_DIVBYZERO    0x20
+#define FE_OVERFLOW     0x10
+#define FE_UNDERFLOW    0x08
+#define FE_INEXACT      0x04
+#define FE_ALL_EXCEPT   (FE_DIVBYZERO | FE_INEXACT | \
+                         FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
+#define _FCSR_CAUSE_SHIFT  10
+#define _ENABLE_SHIFT 5
+#define _FCSR_ENABLE_MASK (FE_ALL_EXCEPT << _ENABLE_SHIFT)
 
 /* Rounding modes */
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
+#define FE_TONEAREST    0x0000
+#define FE_TOWARDZERO   0x0001
+#define FE_UPWARD       0x0002
+#define FE_DOWNWARD     0x0003
+#define _FCSR_RMODE_SHIFT 0
+#define _FCSR_RMASK       0x3
 /* Default floating-point environment */
-extern const fenv_t	__fe_dfl_env;
-#define	FE_DFL_ENV	(&__fe_dfl_env)
+extern const fenv_t    __fe_dfl_env;
+#define FE_DFL_ENV    (&__fe_dfl_env)
 
-/* We need to be able to map status flag positions to mask flag positions */
-#define _FPUSW_SHIFT	16
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-
-#ifdef	ARM_HARD_FLOAT
-#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
-#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
-#else
-#define __rfs(__fpsr)
-#define __wfs(__fpsr)
+static __inline int fegetenv(fenv_t* __envp) {
+   fenv_t _fcsr = 0;
+#ifdef  __mips_hard_float
+   __asm__ __volatile__("cfc1 %0,$31" : "=r" (_fcsr));
 #endif
-
-static __inline int
-feclearexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__wfs(__fpsr);
-	return (0);
+   *__envp = _fcsr;
+   return 0;
 }
 
-static __inline int
-fegetexceptflag(fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	*__flagp = __fpsr & __excepts;
-	return (0);
+static __inline int fesetenv(const fenv_t* __envp) {
+  fenv_t _fcsr = *__envp;
+#ifdef  __mips_hard_float
+  __asm__ __volatile__("ctc1 %0,$31" : : "r" (_fcsr));
+#endif
+  return 0;
 }
 
-static __inline int
-fesetexceptflag(const fexcept_t *__flagp, int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__fpsr &= ~__excepts;
-	__fpsr |= *__flagp & __excepts;
-	__wfs(__fpsr);
-	return (0);
+static __inline int feclearexcept(int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~(__excepts | (__excepts << _FCSR_CAUSE_SHIFT));
+  fesetenv(&__fcsr);
+  return 0;
 }
 
-static __inline int
-feraiseexcept(int __excepts)
-{
-	fexcept_t __ex = __excepts;
-
-	fesetexceptflag(&__ex, __excepts);	/* XXX */
-	return (0);
+static __inline int fegetexceptflag(fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  *__flagp = __fcsr & __excepts & FE_ALL_EXCEPT;
+  return 0;
 }
 
-static __inline int
-fetestexcept(int __excepts)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	return (__fpsr & __excepts);
+static __inline int fesetexceptflag(const fexcept_t* __flagp, int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~__excepts;
+  __fcsr |= *__flagp & __excepts;
+  fesetenv(&__fcsr);
+  return 0;
 }
 
-static __inline int
-fegetround(void)
-{
-
-	/*
-	 * Apparently, the rounding mode is specified as part of the
-	 * instruction format on ARM, so the dynamic rounding mode is
-	 * indeterminate.  Some FPUs may differ.
-	 */
-	return (-1);
+static __inline int feraiseexcept(int __excepts) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  /* Cause bit needs to be set as well for generating the exception*/
+  __fcsr |= __excepts | (__excepts << _FCSR_CAUSE_SHIFT);
+  fesetenv(&__fcsr);
+  return 0;
 }
 
-static __inline int
-fesetround(int __round)
-{
-
-	return (-1);
+static __inline int fetestexcept(int __excepts) {
+  fexcept_t __FCSR;
+  fegetenv(&__FCSR);
+  return (__FCSR & __excepts & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fegetenv(fenv_t *__envp)
-{
-
-	__rfs(__envp);
-	return (0);
+static __inline int fegetround(void) {
+  fenv_t _fcsr;
+  fegetenv(&_fcsr);
+  return (_fcsr & _FCSR_RMASK);
 }
 
-static __inline int
-feholdexcept(fenv_t *__envp)
-{
-	fenv_t __env;
-
-	__rfs(&__env);
-	*__envp = __env;
-	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
-	__wfs(__env);
-	return (0);
+static __inline int fesetround(int __round) {
+  fenv_t _fcsr;
+  fegetenv(&_fcsr);
+  _fcsr &= ~_FCSR_RMASK;
+  _fcsr |= (__round & _FCSR_RMASK ) ;
+  fesetenv(&_fcsr);
+  return 0;
 }
 
-static __inline int
-fesetenv(const fenv_t *__envp)
-{
-
-	__wfs(*__envp);
-	return (0);
+static __inline int feholdexcept(fenv_t* __envp) {
+  fenv_t __env;
+  fegetenv(&__env);
+  *__envp = __env;
+  __env &= ~(FE_ALL_EXCEPT | _FCSR_ENABLE_MASK);
+  fesetenv(&__env);
+  return 0;
 }
 
-static __inline int
-feupdateenv(const fenv_t *__envp)
-{
-	fexcept_t __fpsr;
-
-	__rfs(&__fpsr);
-	__wfs(*__envp);
-	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-	return (0);
+static __inline int feupdateenv(const fenv_t* __envp) {
+  fexcept_t __fcsr;
+  fegetenv(&__fcsr);
+  fesetenv(__envp);
+  feraiseexcept(__fcsr & FE_ALL_EXCEPT);
+  return 0;
 }
 
 #if __BSD_VISIBLE
 
-static __inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int feenableexcept(int __mask) {
+  fenv_t __old_fcsr, __new_fcsr;
+  fegetenv(&__old_fcsr);
+  __new_fcsr = __old_fcsr | (__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT;
+  fesetenv(&__new_fcsr);
+  return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	__rfs(&__old_fpsr);
-	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
-	__wfs(__new_fpsr);
-	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
+static __inline int fedisableexcept(int __mask) {
+  fenv_t __old_fcsr, __new_fcsr;
+  fegetenv(&__old_fcsr);
+  __new_fcsr = __old_fcsr & ~((__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT);
+  fesetenv(&__new_fcsr);
+  return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
 }
 
-static __inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	__rfs(&__fpsr);
-	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
+static __inline int fegetexcept(void) {
+  fenv_t __fcsr;
+  fegetenv(&__fcsr);
+  return ((__fcsr & _FCSR_ENABLE_MASK) >> _ENABLE_SHIFT);
 }
 
 #endif /* __BSD_VISIBLE */
 
 __END_DECLS
 
-#endif	/* !_FENV_H_ */
-
+#endif /* !_FENV_H_ */
diff --git a/ndk/platforms/android-9/arch-mips/include/machine/_types.h b/ndk/platforms/android-9/arch-mips/include/machine/_types.h
index 1cc6c21..05f79ef 100644
--- a/ndk/platforms/android-9/arch-mips/include/machine/_types.h
+++ b/ndk/platforms/android-9/arch-mips/include/machine/_types.h
@@ -105,8 +105,6 @@
 typedef float			__float_t;
 typedef long long		__off_t;
 typedef long			__ptrdiff_t;
-/*typedef	unsigned long		__size_t;*/
-typedef	long			__ssize_t;
 typedef	int			__time_t;
 typedef int			__timer_t;
 #if defined(__GNUC__) && __GNUC__ >= 3
@@ -124,12 +122,6 @@
 typedef	void *			__wctrans_t;
 typedef	void *			__wctype_t;
 
-#ifdef __MIPSEB__
-#define _BYTE_ORDER _BIG_ENDIAN
-#else
-#define _BYTE_ORDER _LITTLE_ENDIAN
-#endif
-
 #if defined(_KERNEL)
 typedef struct label_t {
 	__register_t val[14];
diff --git a/ndk/platforms/android-9/arch-mips/include/machine/endian.h b/ndk/platforms/android-9/arch-mips/include/machine/endian.h
new file mode 100644
index 0000000..41a9004
--- /dev/null
+++ b/ndk/platforms/android-9/arch-mips/include/machine/endian.h
@@ -0,0 +1,70 @@
+/*	$OpenBSD: endian.h,v 1.5 2006/02/27 23:35:59 miod Exp $ */
+
+/*
+ * Copyright (c) 2001-2002 Opsycon AB  (www.opsycon.se / www.opsycon.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _MIPS64_ENDIAN_H_
+#define _MIPS64_ENDIAN_H_
+
+#ifdef __GNUC__
+
+#if defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
+#define __swap16md(x) ({					\
+    register uint16_t _x = (x);					\
+    register uint16_t _r;					\
+    __asm volatile ("wsbh %0, %1" : "=r" (_r) : "r" (_x));	\
+    _r;								\
+})
+
+#define __swap32md(x) ({					\
+    register uint32_t _x = (x);					\
+    register uint32_t _r;					\
+    __asm volatile ("wsbh %0, %1; rotr %0, %0, 16" : "=r" (_r) : "r" (_x)); \
+    _r;								\
+})
+
+#define __swap64md(x) ({					\
+    uint64_t _swap64md_x = (x);					\
+    (uint64_t) __swap32md(_swap64md_x >> 32) |			\
+        (uint64_t) __swap32md(_swap64md_x & 0xffffffff) << 32;	\
+})
+
+/* Tell sys/endian.h we have MD variants of the swap macros.  */
+#define MD_SWAP
+
+#endif  /* __mips32r2__ */
+#endif  /* __GNUC__ */
+
+#if defined(__MIPSEB__)
+#define _BYTE_ORDER _BIG_ENDIAN
+#else
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#endif
+#define __STRICT_ALIGNMENT
+#include <sys/types.h>
+#include <sys/endian.h>
+
+#endif /* _MIPS64_ENDIAN_H_ */
diff --git a/ndk/platforms/android-9/arch-mips/lib-bootstrap/crtbegin_dynamic.o b/ndk/platforms/android-9/arch-mips/lib-bootstrap/crtbegin_dynamic.o
new file mode 100644
index 0000000..d3c366b
--- /dev/null
+++ b/ndk/platforms/android-9/arch-mips/lib-bootstrap/crtbegin_dynamic.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/lib-bootstrap/crtend_android.o b/ndk/platforms/android-9/arch-mips/lib-bootstrap/crtend_android.o
new file mode 100644
index 0000000..6936f73
--- /dev/null
+++ b/ndk/platforms/android-9/arch-mips/lib-bootstrap/crtend_android.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/lib-bootstrap/libc.so b/ndk/platforms/android-9/arch-mips/lib-bootstrap/libc.so
new file mode 100755
index 0000000..8462482
--- /dev/null
+++ b/ndk/platforms/android-9/arch-mips/lib-bootstrap/libc.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/lib-bootstrap/libdl.so b/ndk/platforms/android-9/arch-mips/lib-bootstrap/libdl.so
new file mode 100755
index 0000000..62d382e
--- /dev/null
+++ b/ndk/platforms/android-9/arch-mips/lib-bootstrap/libdl.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-mips/symbols/libc.so.functions.txt b/ndk/platforms/android-9/arch-mips/symbols/libc.so.functions.txt
index 1c72ae9..b8a9554 100644
--- a/ndk/platforms/android-9/arch-mips/symbols/libc.so.functions.txt
+++ b/ndk/platforms/android-9/arch-mips/symbols/libc.so.functions.txt
@@ -159,7 +159,6 @@
 __rt_sigprocmask
 __rt_sigtimedwait
 __sclose
-__set_errno
 __set_syscall_errno
 __set_thread_area
 __set_tls
diff --git a/ndk/platforms/android-9/arch-x86/include/asm/socket.h b/ndk/platforms/android-9/arch-x86/include/asm/socket.h
index b520169..50a9874 100644
--- a/ndk/platforms/android-9/arch-x86/include/asm/socket.h
+++ b/ndk/platforms/android-9/arch-x86/include/asm/socket.h
@@ -16,54 +16,4 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _ASM_SOCKET_H
-#define _ASM_SOCKET_H
-#include <asm/sockios.h>
-#define SOL_SOCKET 1
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_DEBUG 1
-#define SO_REUSEADDR 2
-#define SO_TYPE 3
-#define SO_ERROR 4
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_DONTROUTE 5
-#define SO_BROADCAST 6
-#define SO_SNDBUF 7
-#define SO_RCVBUF 8
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_SNDBUFFORCE 32
-#define SO_RCVBUFFORCE 33
-#define SO_KEEPALIVE 9
-#define SO_OOBINLINE 10
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_NO_CHECK 11
-#define SO_PRIORITY 12
-#define SO_LINGER 13
-#define SO_BSDCOMPAT 14
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_PASSCRED 16
-#define SO_PEERCRED 17
-#define SO_RCVLOWAT 18
-#define SO_SNDLOWAT 19
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_RCVTIMEO 20
-#define SO_SNDTIMEO 21
-#define SO_SECURITY_AUTHENTICATION 22
-#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_SECURITY_ENCRYPTION_NETWORK 24
-#define SO_BINDTODEVICE 25
-#define SO_ATTACH_FILTER 26
-#define SO_DETACH_FILTER 27
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_PEERNAME 28
-#define SO_TIMESTAMP 29
-#define SCM_TIMESTAMP SO_TIMESTAMP
-#define SO_ACCEPTCONN 30
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define SO_PEERSEC 31
-#define SO_PASSSEC 34
-#define SO_TIMESTAMPNS 35
-#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
-/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#endif
+#include <asm-generic/socket.h>
diff --git a/ndk/platforms/android-9/arch-x86/include/asm/unistd_32.h b/ndk/platforms/android-9/arch-x86/include/asm/unistd_32.h
index 4536585..b2193a2 100644
--- a/ndk/platforms/android-9/arch-x86/include/asm/unistd_32.h
+++ b/ndk/platforms/android-9/arch-x86/include/asm/unistd_32.h
@@ -16,8 +16,8 @@
  ***
  ****************************************************************************
  ****************************************************************************/
-#ifndef _ASM_I386_UNISTD_H_
-#define _ASM_I386_UNISTD_H_
+#ifndef _ASM_X86_UNISTD_32_H
+#define _ASM_X86_UNISTD_32_H
 #define __NR_restart_syscall 0
 #define __NR_exit 1
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
@@ -417,9 +417,35 @@
 #define __NR_utimensat 320
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define __NR_signalfd 321
-#define __NR_timerfd 322
+#define __NR_timerfd_create 322
 #define __NR_eventfd 323
 #define __NR_fallocate 324
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define __NR_perf_event_open 364
+#define __NR_timerfd_settime 325
+#define __NR_timerfd_gettime 326
+#define __NR_signalfd4 327
+#define __NR_eventfd2 328
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_epoll_create1 329
+#define __NR_dup3 330
+#define __NR_pipe2 331
+#define __NR_inotify_init1 332
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_preadv 333
+#define __NR_pwritev 334
+#define __NR_rt_tgsigqueueinfo 335
+#define __NR_perf_event_open 336
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_recvmmsg 337
+#define __NR_fanotify_init 338
+#define __NR_fanotify_mark 339
+#define __NR_prlimit64 340
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_name_to_handle_at 341
+#define __NR_open_by_handle_at 342
+#define __NR_clock_adjtime 343
+#define __NR_syncfs 344
+/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
+#define __NR_sendmmsg 345
+#define __NR_setns 346
 #endif
diff --git a/ndk/platforms/android-9/arch-x86/include/fenv.h b/ndk/platforms/android-9/arch-x86/include/fenv.h
index 4e322b7..c0421c0 100644
--- a/ndk/platforms/android-9/arch-x86/include/fenv.h
+++ b/ndk/platforms/android-9/arch-x86/include/fenv.h
@@ -29,8 +29,7 @@
 #ifndef	_FENV_H_
 #define	_FENV_H_
 
-#include <sys/cdefs.h>
-#include <sys/_types.h>
+#include <sys/types.h>
 
 __BEGIN_DECLS
 
diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
index d3d9eeb..d217822 100644
--- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h
+++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
@@ -35,29 +35,6 @@
 #ifndef _I386__TYPES_H_
 #define _I386__TYPES_H_
 
-/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
-#ifndef _SIZE_T_DEFINED_
-#  define _SIZE_T_DEFINED_
-#  ifdef __ANDROID__
-     typedef unsigned int  size_t;
-#  else
-     typedef unsigned long  size_t;
-#  endif
-#endif
-#if !defined(_SSIZE_T) && !defined(_SSIZE_T_DEFINED_)
-#define _SSIZE_T
-#define _SSIZE_T_DEFINED_
-typedef long int       ssize_t;
-#endif
-#ifndef _PTRDIFF_T
-#define _PTRDIFF_T
-#  ifdef __ANDROID__
-     typedef int            ptrdiff_t;
-#  else
-     typedef long           ptrdiff_t;
-#  endif
-#endif
-
 /* 7.18.1.1 Exact-width integer types */
 typedef	__signed char		__int8_t;
 typedef	unsigned char		__uint8_t;
diff --git a/ndk/platforms/android-9/arch-x86/include/endian.h b/ndk/platforms/android-9/arch-x86/include/machine/endian.h
similarity index 98%
rename from ndk/platforms/android-9/arch-x86/include/endian.h
rename to ndk/platforms/android-9/arch-x86/include/machine/endian.h
index 4a70536..e7ad257 100644
--- a/ndk/platforms/android-9/arch-x86/include/endian.h
+++ b/ndk/platforms/android-9/arch-x86/include/machine/endian.h
@@ -65,6 +65,7 @@
 #endif	/* __GNUC__ */
 
 #define _BYTE_ORDER _LITTLE_ENDIAN
+#include <sys/types.h>
 #include <sys/endian.h>
 
 #endif /* _I386_ENDIAN_H_ */
diff --git a/ndk/platforms/android-9/arch-x86/lib-bootstrap/crtbegin_dynamic.o b/ndk/platforms/android-9/arch-x86/lib-bootstrap/crtbegin_dynamic.o
new file mode 100644
index 0000000..19ebcb9
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib-bootstrap/crtbegin_dynamic.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib-bootstrap/crtend_android.o b/ndk/platforms/android-9/arch-x86/lib-bootstrap/crtend_android.o
new file mode 100644
index 0000000..173dad3
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib-bootstrap/crtend_android.o
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib-bootstrap/libc.so b/ndk/platforms/android-9/arch-x86/lib-bootstrap/libc.so
new file mode 100755
index 0000000..2b729fc
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib-bootstrap/libc.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib-bootstrap/libdl.so b/ndk/platforms/android-9/arch-x86/lib-bootstrap/libdl.so
new file mode 100755
index 0000000..e328e30
--- /dev/null
+++ b/ndk/platforms/android-9/arch-x86/lib-bootstrap/libdl.so
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/lib/libc.a b/ndk/platforms/android-9/arch-x86/lib/libc.a
index 90220b0..29b1726 100644
--- a/ndk/platforms/android-9/arch-x86/lib/libc.a
+++ b/ndk/platforms/android-9/arch-x86/lib/libc.a
Binary files differ
diff --git a/ndk/platforms/android-9/arch-x86/symbols/libc.so.functions.txt b/ndk/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
index 121dc51..2c7a608 100644
--- a/ndk/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
+++ b/ndk/platforms/android-9/arch-x86/symbols/libc.so.functions.txt
@@ -155,7 +155,6 @@
 __rt_sigprocmask
 __rt_sigtimedwait
 __sclose
-__set_errno
 __set_syscall_errno
 __set_thread_area
 __set_tls
@@ -761,8 +760,10 @@
 sigaltstack
 sigblock
 siginterrupt
+siglongjmp
 sigpending
 sigprocmask
+sigsetjmp
 sigsetmask
 sigsuspend
 sigwait
diff --git a/ndk/platforms/android-9/include/SLES/OpenSLES_AndroidConfiguration.h b/ndk/platforms/android-9/include/SLES/OpenSLES_AndroidConfiguration.h
index bff6410..ad9cad6 100644
--- a/ndk/platforms/android-9/include/SLES/OpenSLES_AndroidConfiguration.h
+++ b/ndk/platforms/android-9/include/SLES/OpenSLES_AndroidConfiguration.h
@@ -19,6 +19,7 @@
 
 #ifdef __cplusplus
 extern "C" {
+#endif
 
 /*---------------------------------------------------------------------------*/
 /* Android AudioRecorder configuration                                       */
@@ -63,6 +64,7 @@
 
 
 
+#ifdef __cplusplus
 }
 #endif /* __cplusplus */
 
diff --git a/ndk/platforms/android-9/include/android/bitmap.h b/ndk/platforms/android-9/include/android/bitmap.h
index 160e34a..fabb7f4 100644
--- a/ndk/platforms/android-9/include/android/bitmap.h
+++ b/ndk/platforms/android-9/include/android/bitmap.h
@@ -23,11 +23,14 @@
 
 __BEGIN_DECLS
 
-#define ANDROID_BITMAP_RESUT_SUCCESS            0
+#define ANDROID_BITMAP_RESULT_SUCCESS            0
 #define ANDROID_BITMAP_RESULT_BAD_PARAMETER     -1
 #define ANDROID_BITMAP_RESULT_JNI_EXCEPTION     -2
 #define ANDROID_BITMAP_RESULT_ALLOCATION_FAILED -3
 
+/* Backward compatibility: this macro used to be misspelled. */
+#define ANDROID_BITMAP_RESUT_SUCCESS ANDROID_BITMAP_RESULT_SUCCESS
+
 enum AndroidBitmapFormat {
     ANDROID_BITMAP_FORMAT_NONE      = 0,
     ANDROID_BITMAP_FORMAT_RGBA_8888 = 1,
diff --git a/ndk/platforms/android-9/include/pthread.h b/ndk/platforms/android-9/include/pthread.h
index 4baf82f..c3f055e 100644
--- a/ndk/platforms/android-9/include/pthread.h
+++ b/ndk/platforms/android-9/include/pthread.h
@@ -42,9 +42,13 @@
     int volatile value;
 } pthread_mutex_t;
 
-#define  PTHREAD_MUTEX_INITIALIZER             {0}
-#define  PTHREAD_RECURSIVE_MUTEX_INITIALIZER   {0x4000}
-#define  PTHREAD_ERRORCHECK_MUTEX_INITIALIZER  {0x8000}
+#define  __PTHREAD_MUTEX_INIT_VALUE            0
+#define  __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE  0x4000
+#define  __PTHREAD_ERRORCHECK_MUTEX_INIT_VALUE 0x8000
+
+#define  PTHREAD_MUTEX_INITIALIZER             {__PTHREAD_MUTEX_INIT_VALUE}
+#define  PTHREAD_RECURSIVE_MUTEX_INITIALIZER   {__PTHREAD_RECURSIVE_MUTEX_INIT_VALUE}
+#define  PTHREAD_ERRORCHECK_MUTEX_INITIALIZER  {__PTHREAD_ERRORCHECK_MUTEX_INIT_VALUE}
 
 enum {
     PTHREAD_MUTEX_NORMAL = 0,
@@ -306,9 +310,4 @@
 } /* extern "C" */
 #endif
 
-/************ TO FIX ************/
-
-#define LONG_LONG_MAX __LONG_LONG_MAX__
-#define LONG_LONG_MIN (-__LONG_LONG_MAX__ - 1)
-
 #endif /* _PTHREAD_H_ */
diff --git a/ndk/platforms/android-9/include/sys/cdefs.h b/ndk/platforms/android-9/include/sys/cdefs.h
index 849e2b8..92035d4 100644
--- a/ndk/platforms/android-9/include/sys/cdefs.h
+++ b/ndk/platforms/android-9/include/sys/cdefs.h
@@ -79,7 +79,7 @@
 #define	___STRING(x)	__STRING(x)
 #define	___CONCAT(x,y)	__CONCAT(x,y)
 
-#if __STDC__ || defined(__cplusplus)
+#if defined(__STDC__) || defined(__cplusplus)
 #define	__P(protos)	protos		/* full-blown ANSI C */
 #define	__CONCAT(x,y)	x ## y
 #define	__STRING(x)	#x
@@ -213,7 +213,7 @@
  * C99 defines the restrict type qualifier keyword, which was made available
  * in GCC 2.92.
  */
-#if __STDC_VERSION__ >= 199901L
+#if defined(__STDC__VERSION__) && __STDC_VERSION__ >= 199901L
 #define	__restrict	restrict
 #else
 #if !__GNUC_PREREQ__(2, 92)
@@ -225,7 +225,7 @@
  * C99 defines __func__ predefined identifier, which was made available
  * in GCC 2.95.
  */
-#if !(__STDC_VERSION__ >= 199901L)
+#if !defined(__STDC_VERSION__) || !(__STDC_VERSION__ >= 199901L)
 #if __GNUC_PREREQ__(2, 6)
 #define	__func__	__PRETTY_FUNCTION__
 #elif __GNUC_PREREQ__(2, 4)
@@ -497,5 +497,6 @@
 #endif
 
 #define  __BIONIC__   1
+#include <android/api-level.h>
 
 #endif /* !_SYS_CDEFS_H_ */
diff --git a/ndk/platforms/android-9/include/wchar.h b/ndk/platforms/android-9/include/wchar.h
index 86d6d73..fea648c 100644
--- a/ndk/platforms/android-9/include/wchar.h
+++ b/ndk/platforms/android-9/include/wchar.h
@@ -51,7 +51,7 @@
 
 __BEGIN_DECLS
 
-typedef int                     wint_t;
+typedef __WINT_TYPE__           wint_t;
 typedef struct { int  dummy; }  mbstate_t;
 
 typedef enum {
diff --git a/ndk/platforms/android-9/samples/native-audio/jni/native-audio-jni.c b/ndk/platforms/android-9/samples/native-audio/jni/native-audio-jni.c
index 105c64a..5e7946b 100644
--- a/ndk/platforms/android-9/samples/native-audio/jni/native-audio-jni.c
+++ b/ndk/platforms/android-9/samples/native-audio/jni/native-audio-jni.c
@@ -125,6 +125,7 @@
         // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
         // which for this code example would indicate a programming error
         assert(SL_RESULT_SUCCESS == result);
+        (void)result;
     }
 }
 
@@ -153,24 +154,29 @@
     // create engine
     result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // realize the engine
     result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the engine interface, which is needed in order to create other objects
     result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // create output mix, with environmental reverb specified as a non-required interface
     const SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB};
     const SLboolean req[1] = {SL_BOOLEAN_FALSE};
     result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // realize the output mix
     result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the environmental reverb interface
     // this could fail if the environmental reverb effect is not available,
@@ -181,6 +187,7 @@
     if (SL_RESULT_SUCCESS == result) {
         result = (*outputMixEnvironmentalReverb)->SetEnvironmentalReverbProperties(
                 outputMixEnvironmentalReverb, &reverbSettings);
+        (void)result;
     }
     // ignore unsuccessful result codes for environmental reverb, as it is optional for this example
 
@@ -212,43 +219,51 @@
     result = (*engineEngine)->CreateAudioPlayer(engineEngine, &bqPlayerObject, &audioSrc, &audioSnk,
             3, ids, req);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // realize the player
     result = (*bqPlayerObject)->Realize(bqPlayerObject, SL_BOOLEAN_FALSE);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the play interface
     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_PLAY, &bqPlayerPlay);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the buffer queue interface
     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_BUFFERQUEUE,
             &bqPlayerBufferQueue);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // register callback on the buffer queue
     result = (*bqPlayerBufferQueue)->RegisterCallback(bqPlayerBufferQueue, bqPlayerCallback, NULL);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the effect send interface
     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_EFFECTSEND,
             &bqPlayerEffectSend);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
 #if 0   // mute/solo is not supported for sources that are known to be mono, as this is
     // get the mute/solo interface
     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_MUTESOLO, &bqPlayerMuteSolo);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 #endif
 
     // get the volume interface
     result = (*bqPlayerObject)->GetInterface(bqPlayerObject, SL_IID_VOLUME, &bqPlayerVolume);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // set the player's state to playing
     result = (*bqPlayerPlay)->SetPlayState(bqPlayerPlay, SL_PLAYSTATE_PLAYING);
     assert(SL_RESULT_SUCCESS == result);
-
+    (void)result;
 }
 
 
@@ -259,7 +274,7 @@
     SLresult result;
 
     // convert Java string to UTF-8
-    const jbyte *utf8 = (*env)->GetStringUTFChars(env, uri, NULL);
+    const char *utf8 = (*env)->GetStringUTFChars(env, uri, NULL);
     assert(NULL != utf8);
 
     // configure audio source
@@ -280,6 +295,7 @@
     // note that an invalid URI is not detected here, but during prepare/prefetch on Android,
     // or possibly during Realize on other platforms
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // release the Java string and UTF-8
     (*env)->ReleaseStringUTFChars(env, uri, utf8);
@@ -296,18 +312,22 @@
     // get the play interface
     result = (*uriPlayerObject)->GetInterface(uriPlayerObject, SL_IID_PLAY, &uriPlayerPlay);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the seek interface
     result = (*uriPlayerObject)->GetInterface(uriPlayerObject, SL_IID_SEEK, &uriPlayerSeek);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the mute/solo interface
     result = (*uriPlayerObject)->GetInterface(uriPlayerObject, SL_IID_MUTESOLO, &uriPlayerMuteSolo);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the volume interface
     result = (*uriPlayerObject)->GetInterface(uriPlayerObject, SL_IID_VOLUME, &uriPlayerVolume);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     return JNI_TRUE;
 }
@@ -327,7 +347,7 @@
         result = (*uriPlayerPlay)->SetPlayState(uriPlayerPlay, isPlaying ?
             SL_PLAYSTATE_PLAYING : SL_PLAYSTATE_PAUSED);
         assert(SL_RESULT_SUCCESS == result);
-
+        (void)result;
     }
 
 }
@@ -346,7 +366,7 @@
         result = (*uriPlayerSeek)->SetLoop(uriPlayerSeek, (SLboolean) isLooping, 0,
                 SL_TIME_UNKNOWN);
         assert(SL_RESULT_SUCCESS == result);
-
+        (void)result;
     }
 
 }
@@ -372,6 +392,7 @@
     if (NULL != muteSoloItf) {
         result = (*muteSoloItf)->SetChannelMute(muteSoloItf, chan, mute);
         assert(SL_RESULT_SUCCESS == result);
+        (void)result;
     }
 }
 
@@ -383,6 +404,7 @@
     if (NULL != muteSoloItf) {
         result = (*muteSoloItf)->SetChannelSolo(muteSoloItf, chan, solo);
         assert(SL_RESULT_SUCCESS == result);
+        (void)result;
     }
 }
 
@@ -425,6 +447,7 @@
     if (NULL != volumeItf) {
         result = (*volumeItf)->SetVolumeLevel(volumeItf, millibel);
         assert(SL_RESULT_SUCCESS == result);
+        (void)result;
     }
 }
 
@@ -436,6 +459,7 @@
     if (NULL != volumeItf) {
         result = (*volumeItf)->SetMute(volumeItf, mute);
         assert(SL_RESULT_SUCCESS == result);
+        (void)result;
     }
 }
 
@@ -447,6 +471,7 @@
     if (NULL != volumeItf) {
         result = (*volumeItf)->EnableStereoPosition(volumeItf, enable);
         assert(SL_RESULT_SUCCESS == result);
+        (void)result;
     }
 }
 
@@ -458,6 +483,7 @@
     if (NULL != volumeItf) {
         result = (*volumeItf)->SetStereoPosition(volumeItf, permille);
         assert(SL_RESULT_SUCCESS == result);
+        (void)result;
     }
 }
 
@@ -487,7 +513,6 @@
 jboolean Java_com_example_nativeaudio_NativeAudio_selectClip(JNIEnv* env, jclass clazz, jint which,
         jint count)
 {
-    short *oldBuffer = nextBuffer;
     switch (which) {
     case 0:     // CLIP_NONE
         nextBuffer = (short *) NULL;
@@ -545,13 +570,13 @@
     SLresult result;
 
     // convert Java string to UTF-8
-    const jbyte *utf8 = (*env)->GetStringUTFChars(env, filename, NULL);
+    const char *utf8 = (*env)->GetStringUTFChars(env, filename, NULL);
     assert(NULL != utf8);
 
     // use asset manager to open asset by filename
     AAssetManager* mgr = AAssetManager_fromJava(env, assetManager);
     assert(NULL != mgr);
-    AAsset* asset = AAssetManager_open(mgr, (const char *) utf8, AASSET_MODE_UNKNOWN);
+    AAsset* asset = AAssetManager_open(mgr, utf8, AASSET_MODE_UNKNOWN);
 
     // release the Java string and UTF-8
     (*env)->ReleaseStringUTFChars(env, filename, utf8);
@@ -582,30 +607,37 @@
     result = (*engineEngine)->CreateAudioPlayer(engineEngine, &fdPlayerObject, &audioSrc, &audioSnk,
             3, ids, req);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // realize the player
     result = (*fdPlayerObject)->Realize(fdPlayerObject, SL_BOOLEAN_FALSE);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the play interface
     result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_PLAY, &fdPlayerPlay);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the seek interface
     result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_SEEK, &fdPlayerSeek);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the mute/solo interface
     result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_MUTESOLO, &fdPlayerMuteSolo);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the volume interface
     result = (*fdPlayerObject)->GetInterface(fdPlayerObject, SL_IID_VOLUME, &fdPlayerVolume);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // enable whole file looping
     result = (*fdPlayerSeek)->SetLoop(fdPlayerSeek, SL_BOOLEAN_TRUE, 0, SL_TIME_UNKNOWN);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     return JNI_TRUE;
 }
@@ -624,7 +656,7 @@
         result = (*fdPlayerPlay)->SetPlayState(fdPlayerPlay, isPlaying ?
             SL_PLAYSTATE_PLAYING : SL_PLAYSTATE_PAUSED);
         assert(SL_RESULT_SUCCESS == result);
-
+        (void)result;
     }
 
 }
@@ -666,16 +698,19 @@
     // get the record interface
     result = (*recorderObject)->GetInterface(recorderObject, SL_IID_RECORD, &recorderRecord);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // get the buffer queue interface
     result = (*recorderObject)->GetInterface(recorderObject, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
             &recorderBufferQueue);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // register callback on the buffer queue
     result = (*recorderBufferQueue)->RegisterCallback(recorderBufferQueue, bqRecorderCallback,
             NULL);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     return JNI_TRUE;
 }
@@ -689,8 +724,10 @@
     // in case already recording, stop recording and clear buffer queue
     result = (*recorderRecord)->SetRecordState(recorderRecord, SL_RECORDSTATE_STOPPED);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
     result = (*recorderBufferQueue)->Clear(recorderBufferQueue);
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // the buffer is not valid for playback yet
     recorderSize = 0;
@@ -702,11 +739,12 @@
     // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
     // which for this code example would indicate a programming error
     assert(SL_RESULT_SUCCESS == result);
+    (void)result;
 
     // start recording
     result = (*recorderRecord)->SetRecordState(recorderRecord, SL_RECORDSTATE_RECORDING);
     assert(SL_RESULT_SUCCESS == result);
-
+    (void)result;
 }
 
 
diff --git a/ndk/platforms/android-9/samples/native-plasma/jni/plasma.c b/ndk/platforms/android-9/samples/native-plasma/jni/plasma.c
index 01ec644..6175033 100644
--- a/ndk/platforms/android-9/samples/native-plasma/jni/plasma.c
+++ b/ndk/platforms/android-9/samples/native-plasma/jni/plasma.c
@@ -192,7 +192,6 @@
 
 static void fill_plasma(ANativeWindow_Buffer* buffer, double  t)
 {
-    Fixed ft  = FIXED_FROM_FLOAT(t/1000.);
     Fixed yt1 = FIXED_FROM_FLOAT(t/1230.);
     Fixed yt2 = yt1;
     Fixed xt10 = FIXED_FROM_FLOAT(t/3000.);
@@ -407,7 +406,7 @@
     stats_endFrame(&engine->stats);
 }
 
-static int engine_term_display(struct engine* engine) {
+static void engine_term_display(struct engine* engine) {
     engine->animating = 0;
 }
 
diff --git a/ndk/samples/module-exports/jni/bar/bar.c b/ndk/samples/module-exports/jni/bar/bar.c
index 71b21d2..155241d 100644
--- a/ndk/samples/module-exports/jni/bar/bar.c
+++ b/ndk/samples/module-exports/jni/bar/bar.c
@@ -1,4 +1,5 @@
 #include "bar.h"
+#include "foo.h"
 
 int  bar(int  x)
 {
diff --git a/ndk/sources/android/libportable/Android.mk b/ndk/sources/android/libportable/Android.mk
index 86b097c..63428e5 100644
--- a/ndk/sources/android/libportable/Android.mk
+++ b/ndk/sources/android/libportable/Android.mk
@@ -26,47 +26,68 @@
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
 
-LOCAL_CFLAGS := -I $(LOCAL_PATH)/common/include
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/common/include
+
+# Uncomment the next line to easily enable Lib-Portable logging during development.
+# LOCAL_CFLAGS += -DLOG_NDEBUG=0
 
 ifeq ($(TARGET_ARCH),mips)
 libportable_arch_src_files += \
+			arch-mips/clone.c \
+			arch-mips/epoll.c \
+			arch-mips/errno.c \
+			arch-mips/eventfd.c \
+			arch-mips/fcntl.c \
+			arch-mips/filefd.c \
+			arch-mips/flags.c \
+			arch-mips/inotify.c \
 			arch-mips/ioctl.c \
 			arch-mips/mmap.c \
-			arch-mips/resource.c \
-			arch-mips/stat.c \
-			arch-mips/statfs.c \
 			arch-mips/open.c \
 			arch-mips/poll.c \
+			arch-mips/pipe.c \
+			arch-mips/pthread.c \
+			arch-mips/resource.c \
+			arch-mips/signal.c \
 			arch-mips/socket.c \
 			arch-mips/sockopt.c \
-			arch-mips/fcntl.c \
-			arch-mips/epoll.c \
-			arch-mips/errno.c
+			arch-mips/stat.c \
+			arch-mips/statfs.c \
+			arch-mips/syscall.c \
+			arch-mips/timer.c \
+			arch-mips/timerfd.c \
+			arch-mips/waitpid.c \
+			arch-mips/fenv.c
+
+libportable_arch_src_files += \
+			arch-mips/_setjmp.S \
+			arch-mips/setjmp.S \
+			arch-mips/sigsetjmp.S
+
 endif
 
 ifeq ($(TARGET_ARCH),arm)
 libportable_arch_src_files += \
-			arch-arm/stat.c \
-			arch-arm/socket.c \
-			arch-arm/sockopt.c \
-			arch-arm/epoll.c \
-			arch-arm/errno.c
+			arch-arm/unwind.c \
+			arch-arm/fenv.c
 endif
 
 ifeq ($(TARGET_ARCH),x86)
 libportable_arch_src_files += \
-			arch-x86/ioctl.c \
-			arch-x86/stat.c \
-			arch-x86/open.c \
-			arch-x86/socket.c \
-			arch-x86/sockopt.c \
-			arch-x86/fcntl.c \
 			arch-x86/epoll.c \
-			arch-x86/errno.c
+			arch-x86/fcntl.c \
+			arch-x86/ioctl.c \
+			arch-x86/open.c \
+			arch-x86/stat.c \
+			arch-x86/fenv.c
 endif
 
 LOCAL_SRC_FILES := \
         $(libportable_common_src_files) \
         $(libportable_arch_src_files)
 
+LOCAL_WHOLE_STATIC_LIBRARIES += cpufeatures
+
+LOCAL_SHARED_LIBRARIES += liblog
+
 include $(BUILD_SHARED_LIBRARY)
diff --git a/ndk/sources/android/libportable/arch-arm/epoll.c b/ndk/sources/android/libportable/arch-arm/epoll.c
deleted file mode 100644
index f703ba1..0000000
--- a/ndk/sources/android/libportable/arch-arm/epoll.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-#include <sys/epoll.h>
-
-int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
-{
-    return epoll_ctl(epfd, op, fd, event);
-}
-
-int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
-{
-    return epoll_wait(epfd, events, max, timeout);
-}
-
diff --git a/ndk/sources/android/libportable/arch-arm/errno.c b/ndk/sources/android/libportable/arch-arm/errno.c
deleted file mode 100644
index ffa5998..0000000
--- a/ndk/sources/android/libportable/arch-arm/errno.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-extern volatile int*   __errno(void);
-volatile int* __errno_portable()
-{
-  return __errno();
-}
diff --git a/ndk/sources/android/libportable/arch-arm/fenv.c b/ndk/sources/android/libportable/arch-arm/fenv.c
new file mode 100644
index 0000000..71f370d
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-arm/fenv.c
@@ -0,0 +1,104 @@
+/*
+ * 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 __ARM_ARCH_7A__
+
+#include <portability.h>
+#include <fenv.h>
+#include <fenv_portable.h>
+
+int WRAP(fegetenv)(fenv_t* __envp) {
+    fenv_t _fpscr;
+    __asm__ __volatile__("vmrs %0,fpscr" : "=r" (_fpscr));
+    *__envp = _fpscr;
+    return 0;
+}
+
+int WRAP(fesetenv)(const fenv_t* __envp) {
+    fenv_t _fpscr = *__envp;
+    __asm__ __volatile__("vmsr fpscr,%0" : :"ri" (_fpscr));
+    return 0;
+}
+
+int WRAP(feclearexcept)(int __excepts) {
+    fexcept_t __fpscr;
+    WRAP(fegetenv)(&__fpscr);
+    __fpscr &= ~__excepts;
+    WRAP(fesetenv)(&__fpscr);
+    return 0;
+}
+
+int WRAP(fegetexceptflag)(fexcept_t* __flagp, int __excepts) {
+    fexcept_t __fpscr;
+    WRAP(fegetenv)(&__fpscr);
+    *__flagp = __fpscr & __excepts;
+    return 0;
+}
+
+int WRAP(fesetexceptflag)(const fexcept_t* __flagp, int __excepts) {
+    fexcept_t __fpscr;
+    WRAP(fegetenv)(&__fpscr);
+    __fpscr &= ~__excepts;
+    __fpscr |= *__flagp & __excepts;
+    WRAP(fesetenv)(&__fpscr);
+    return 0;
+}
+
+int WRAP(feraiseexcept)(int __excepts) {
+    fexcept_t __ex = __excepts;
+    WRAP(fesetexceptflag)(&__ex, __excepts);
+    return 0;
+}
+
+int WRAP(fetestexcept)(int __excepts) {
+    fexcept_t __fpscr;
+    WRAP(fegetenv)(&__fpscr);
+    return (__fpscr & __excepts);
+}
+
+int WRAP(fegetround)(void) {
+    fenv_t _fpscr;
+    WRAP(fegetenv)(&_fpscr);
+    return ((_fpscr >> _FPSCR_RMODE_SHIFT) & 0x3);
+}
+
+int WRAP(fesetround)(int __round) {
+    fenv_t _fpscr;
+    WRAP(fegetenv)(&_fpscr);
+    _fpscr &= ~(0x3 << _FPSCR_RMODE_SHIFT);
+    _fpscr |= (__round << _FPSCR_RMODE_SHIFT);
+    WRAP(fesetenv)(&_fpscr);
+    return 0;
+}
+
+int WRAP(feholdexcept)(fenv_t* __envp) {
+    fenv_t __env;
+    WRAP(fegetenv)(&__env);
+    *__envp = __env;
+    __env &= ~(FE_ALL_EXCEPT | _FPSCR_ENABLE_MASK);
+    WRAP(fesetenv)(&__env);
+    return 0;
+}
+
+int WRAP(feupdateenv)(const fenv_t* __envp) {
+    fexcept_t __fpscr;
+    WRAP(fegetenv)(&__fpscr);
+    WRAP(fesetenv)(__envp);
+    WRAP(feraiseexcept)(__fpscr & FE_ALL_EXCEPT);
+    return 0;
+}
+
+#endif /* __ARM_ARCH_7A__ */
diff --git a/ndk/sources/android/libportable/arch-arm/socket.c b/ndk/sources/android/libportable/arch-arm/socket.c
deleted file mode 100644
index 7e7ca9b..0000000
--- a/ndk/sources/android/libportable/arch-arm/socket.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/linux-syscalls.h>
-
-int socket_portable(int domain, int type, int protocol) {
-    return socket(domain, type, protocol);
-}
diff --git a/ndk/sources/android/libportable/arch-arm/sockopt.c b/ndk/sources/android/libportable/arch-arm/sockopt.c
deleted file mode 100644
index c86ded3..0000000
--- a/ndk/sources/android/libportable/arch-arm/sockopt.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-extern int setsockopt(int, int, int, const void *, socklen_t);
-int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
-{
-    return setsockopt(s, level, optname, optval, optlen);
-}
-
-extern int getsockopt (int, int, int, void *, socklen_t *);
-int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
-{
-    return getsockopt(s, level, optname, optval, optlen);
-}
diff --git a/ndk/sources/android/libportable/arch-arm/stat.c b/ndk/sources/android/libportable/arch-arm/stat.c
deleted file mode 100644
index 20a34ad..0000000
--- a/ndk/sources/android/libportable/arch-arm/stat.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-#include <stat_portable.h>
-
-/* Note: The Portable Header will define stat to stat_portable */
-int stat_portable(const char *path, struct stat_portable *s)
-{
-   return stat(path, s);
-}
-
-int fstat_portable(int fd, struct stat_portable *s)
-{
-    return fstat(fd, s);
-}   
-
-int lstat_portable(const char *path, struct stat_portable *s)
-{
-    return lstat(path, s);
-}
-
-int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
-{
-    return fstatat(dirfd, path, s, flags);
-}
diff --git a/ndk/sources/android/libportable/arch-arm/unwind.c b/ndk/sources/android/libportable/arch-arm/unwind.c
new file mode 100644
index 0000000..99f2dac
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-arm/unwind.c
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+#include <portability.h>
+#include <stdint.h>
+
+struct _Unwind_Context;
+
+typedef enum {
+  _UVRSC_CORE = 0,  // integer register
+  _UVRSC_VFP = 1, // vfp
+  _UVRSC_WMMXD = 3, // Intel WMMX data register
+  _UVRSC_WMMXC = 4  // Intel WMMX control register
+} _Unwind_VRS_RegClass;
+
+typedef enum {
+  _UVRSD_UINT32 = 0,
+  _UVRSD_VFPX = 1,
+  _UVRSD_UINT64 = 3,
+  _UVRSD_FLOAT = 4,
+  _UVRSD_DOUBLE = 5
+} _Unwind_VRS_DataRepresentation;
+
+typedef enum {
+  _UVRSR_OK = 0,
+  _UVRSR_NOT_IMPLEMENTED = 1,
+  _UVRSR_FAILED = 2
+} _Unwind_VRS_Result;
+
+_Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *context,
+                                   _Unwind_VRS_RegClass regclass,
+                                   uint32_t regno,
+                                   _Unwind_VRS_DataRepresentation representation,
+                                   void* valuep);
+
+_Unwind_VRS_Result _Unwind_VRS_Set(struct _Unwind_Context *context,
+                                   _Unwind_VRS_RegClass regclass,
+                                   uint32_t regno,
+                                   _Unwind_VRS_DataRepresentation representation,
+                                   void* valuep);
+
+#define UNWIND_POINTER_REG  12
+#define UNWIND_STACK_REG    13
+#define UNWIND_IP_REG       15
+
+uint64_t WRAP(_Unwind_GetGR)(struct _Unwind_Context* ctx, int index) {
+  uint32_t val;
+  _Unwind_VRS_Get(ctx, _UVRSC_CORE, index, _UVRSD_UINT32, &val);
+  return (uint64_t)val;
+}
+
+void WRAP(_Unwind_SetGR)(struct _Unwind_Context* ctx, int index, uint64_t new_value) {
+  uint32_t val = (uint32_t)new_value;
+  _Unwind_VRS_Set(ctx, _UVRSC_CORE, index, _UVRSD_UINT32, &val);
+}
+
+uint64_t WRAP(_Unwind_GetIP)(struct _Unwind_Context* ctx) {
+  return WRAP(_Unwind_GetGR)(ctx, UNWIND_IP_REG) & ~1; // thumb bit
+}
+
+void WRAP(_Unwind_SetIP)(struct _Unwind_Context* ctx, uintptr_t new_value) {
+  uint32_t val = (uint32_t)new_value;
+  // Propagate thumb bit to instruction pointer
+  uint32_t thumbState = WRAP(_Unwind_GetGR)(ctx, UNWIND_IP_REG) & 1;
+  uint64_t new_val = (uint64_t)(val | thumbState);
+  WRAP(_Unwind_SetGR)(ctx, UNWIND_IP_REG, new_val);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/_setjmp.S b/ndk/sources/android/libportable/arch-mips/_setjmp.S
new file mode 100644
index 0000000..bceeff7
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/_setjmp.S
@@ -0,0 +1,193 @@
+/* Derived from: $OpenBSD: _setjmp.S,v 1.4 2005/08/07 16:40:15 espie Exp $ */
+
+/*
+ * Copyright (c) 2002 Opsycon AB  (www.opsycon.se / www.opsycon.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Opsycon AB nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <machine/asm.h>
+#include <machine/regnum.h>
+
+#include "jboffsets.h"
+
+/*
+ * _setjmp, _longjmp (not restoring signal state)
+ *
+ * XXX FPSET should probably be taken from SR setting. hmmm...
+ *  GPOFF and FRAMESIZE must be the same for both _setjmp and _longjmp!
+ *
+ */
+
+FRAMESZ= MKFSIZ(0,4)
+GPOFF= FRAMESZ-2*REGSZ
+
+#define FPREG64_S(FPR, OFF, BASE)       \
+        swc1    FPR, OFF(BASE)  ;       \
+        mfhc1   t0, FPR         ;       \
+        sw      t0, OFF+4(BASE) ;
+
+#define FPREG64_L(FPR, OFF, BASE)       \
+        lw      t0, OFF+4(BASE) ;       \
+        lw      t1, OFF(BASE)   ;       \
+        mtc1    t1, FPR         ;       \
+        mthc1   t0, FPR         ;       \
+
+LEAF(_setjmp_portable, FRAMESZ)
+        PTR_SUBU sp, FRAMESZ
+        SETUP_GP64(GPOFF, _setjmp)
+        SAVE_GP(GPOFF)
+        .set    noreorder
+#if defined(__mips64)
+        dli     v0, MAGIC__SETJMP
+#else
+        li      v0, MAGIC__SETJMP
+#endif
+        REG_S   v0, JB_MAGIC(a0)
+        REG_S   s0, JB_S0(a0)
+        REG_S   s1, JB_S1(a0)
+        REG_S   s2, JB_S2(a0)
+        REG_S   s3, JB_S3(a0)
+        REG_S   s4, JB_S4(a0)
+        REG_S   s5, JB_S5(a0)
+        REG_S   s6, JB_S6(a0)
+        REG_S   s7, JB_S7(a0)
+        REG_S   s8, JB_S8(a0)
+        REG_L   v0, GPOFF(sp)
+        REG_S   v0, JB_GP(a0)
+        PTR_ADDU v0, sp, FRAMESZ
+        REG_S   v0, JB_SP(a0)
+        REG_S   ra, JB_PC(a0)
+
+#if !defined(SOFTFLOAT)
+        /*
+         * Would be nice if we could tell if the FP registers are currently being used;
+         * Assume they are, and use pointer to jmp_buf in a0 to save FP registers and the
+         * jmp_buf.fpused flag.
+         */
+        li      v0, 1                           # v0 = 1
+        REG_S   v0, JB_FPUSED(a0)               # a0->jb_fpused = v0:1
+        cfc1    v0, $31
+#if _MIPS_FPSET == 32
+        FPREG64_S($f20, JB_F20, a0)
+        FPREG64_S($f21, JB_F21, a0)
+        FPREG64_S($f22, JB_F22, a0)
+        FPREG64_S($f23, JB_F23, a0)
+        FPREG64_S($f24, JB_F24, a0)
+        FPREG64_S($f25, JB_F25, a0)
+        FPREG64_S($f26, JB_F26, a0)
+        FPREG64_S($f27, JB_F27, a0)
+        FPREG64_S($f28, JB_F28, a0)
+        FPREG64_S($f29, JB_F29, a0)
+        FPREG64_S($f30, JB_F30, a0)
+        FPREG64_S($f31, JB_F31, a0)
+#else
+        swc1    $f20, JB_F20(a0)
+        swc1    $f21, JB_F21(a0)
+        swc1    $f22, JB_F22(a0)
+        swc1    $f23, JB_F23(a0)
+        swc1    $f24, JB_F24(a0)
+        swc1    $f25, JB_F25(a0)
+        swc1    $f26, JB_F26(a0)
+        swc1    $f27, JB_F27(a0)
+        swc1    $f28, JB_F28(a0)
+        swc1    $f29, JB_F29(a0)
+        swc1    $f30, JB_F30(a0)
+        swc1    $f31, JB_F31(a0)
+#endif
+        REG_S   v0, JB_FSR(a0)
+#endif /* !SOFTFLOAT */
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+        j       ra
+         move   v0, zero
+END(_setjmp_portable)
+
+LEAF(_longjmp_portable, FRAMESZ)
+        PTR_SUBU sp, FRAMESZ
+        SETUP_GP64(GPOFF, _longjmp)
+        SAVE_GP(GPOFF)
+        .set    noreorder
+        REG_L   v0, JB_MAGIC(a0)
+        bne     v0, MAGIC__SETJMP, botch                # jump if error
+        REG_L   ra, JB_PC(a0)
+        REG_L   v0, JB_FSR(a0)
+        REG_L   s0, JB_S0(a0)
+        REG_L   s1, JB_S1(a0)
+        REG_L   s2, JB_S2(a0)
+        REG_L   s3, JB_S3(a0)
+        REG_L   s4, JB_S4(a0)
+        REG_L   s5, JB_S5(a0)
+        REG_L   s6, JB_S6(a0)
+        REG_L   s7, JB_S7(a0)
+        REG_L   s8, JB_S8(a0)
+        REG_L   gp, JB_GP(a0)
+        REG_L   sp, JB_SP(a0)
+#if !defined(SOFTFLOAT)
+        ctc1    v0, $31
+#if _MIPS_FPSET == 32
+        FPREG64_L($f20, JB_F20, a0)
+        FPREG64_L($f21, JB_F21, a0)
+        FPREG64_L($f22, JB_F22, a0)
+        FPREG64_L($f23, JB_F23, a0)
+        FPREG64_L($f24, JB_F24, a0)
+        FPREG64_L($f25, JB_F25, a0)
+        FPREG64_L($f26, JB_F26, a0)
+        FPREG64_L($f27, JB_F27, a0)
+        FPREG64_L($f28, JB_F28, a0)
+        FPREG64_L($f29, JB_F29, a0)
+        FPREG64_L($f30, JB_F30, a0)
+        FPREG64_L($f31, JB_F31, a0)
+#else
+        lwc1    $f20, JB_F20(a0)
+        lwc1    $f21, JB_F21(a0)
+        lwc1    $f22, JB_F22(a0)
+        lwc1    $f23, JB_F23(a0)
+        lwc1    $f24, JB_F24(a0)
+        lwc1    $f25, JB_F25(a0)
+        lwc1    $f26, JB_F26(a0)
+        lwc1    $f27, JB_F27(a0)
+        lwc1    $f28, JB_F28(a0)
+        lwc1    $f29, JB_F29(a0)
+        lwc1    $f30, JB_F30(a0)
+        lwc1    $f31, JB_F31(a0)
+#endif
+#endif /* !SOFTFLOAT */
+        bne     a1, zero, 1f
+         nop
+        li      a1, 1                   # never return 0!
+1:
+        j       ra
+         move   v0, a1
+
+botch:
+        jal     longjmperror
+        nop
+        jal     abort
+        nop
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+END(_longjmp_portable)
diff --git a/ndk/sources/android/libportable/arch-mips/clone.c b/ndk/sources/android/libportable/arch-mips/clone.c
new file mode 100644
index 0000000..7498ef6
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/clone.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#define _GNU_SOURCE
+#include <portability.h>
+#include <sched.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <signal_portable.h>
+#include <portability.h>
+#include <stdio.h>
+#include <errno.h>
+#include <filefd_portable.h>
+
+#define PORTABLE_TAG "clone_portable"
+#include <log_portable.h>
+
+
+/*
+ * This function maps the clone function call defined in:
+ *      $TOP/bionic/libc/bionic/bionic_clone.c
+ *
+ * which calls the __bionic_clone() system call which is defined in:
+ *      $TOP/bionic/libc/unistd/arch-mips/bionic/clone.S
+ *
+ * We have to map the low byte of the 'flags' parameter which
+ * contains the number of the termination signal sent to the
+ * parent when the child dies.
+ *
+ * Note that if this signal is specified as anything other than
+ * SIGCHLD, then the parent process must specify the __WALL or
+ * __WCLONE options when waiting for the child with wait(2).
+ *
+ * If no signal is specified, then the parent process is not
+ * signaled when the child terminates.
+ */
+int WRAP(clone)(int (*fn)(void *), void *child_stack, int port_flags, void *arg, ...)
+{
+    va_list     args;
+    int         ret;
+    int         mips_flags;
+    void        *new_tls = NULL;
+    int         *child_tidptr = NULL;
+    int         *parent_tidptr = NULL;
+    int         mips_term_signum;
+    char        *mips_term_signame;
+    int         portable_term_signum;
+    char        *portable_term_signame;
+    int         cloning_vm = ((port_flags & CLONE_VM) == CLONE_VM);
+    int         cloning_files = ((port_flags & CLONE_FILES) == CLONE_FILES);
+    int         cloning_sighand = ((port_flags & CLONE_SIGHAND) == CLONE_SIGHAND);
+
+    ALOGV(" ");
+    ALOGV("%s(fn:%p, child_stack:%p, port_flags:0x%x, arg:%p, ...) {", __func__,
+              fn,    child_stack,    port_flags,      arg);
+
+    /* Shared file descriptor table requires shared memory. */
+    if (cloning_files != cloning_vm) {
+        ALOGE("%s: cloning_files:%d != cloning_vm:%d) ...", __func__,
+                   cloning_files,      cloning_vm);
+
+        ALOGE("%s: ... port_flags:0x%x Not Supported by Lib-Portable!", __func__,
+                       port_flags);
+    }
+
+    /* Shared signal handler table requires shared memory. */
+    if (cloning_sighand != cloning_vm) {
+        ALOGE("%s: cloning_sighand:%d != cloning_vm:%d) ...",  __func__,
+                   cloning_sighand,      cloning_vm);
+
+        ALOGE("%s: ... port_flags:0x%x Not Supported by Lib-Portable!", __func__,
+                       port_flags);
+    }
+
+    /* Extract optional parameters - they are cumulative. */
+    va_start(args, arg);
+    if (port_flags & (CLONE_PARENT_SETTID|CLONE_SETTLS|CLONE_CHILD_SETTID)) {
+        parent_tidptr = va_arg(args, int*);
+    }
+    if (port_flags & (CLONE_SETTLS|CLONE_CHILD_SETTID)) {
+        new_tls = va_arg(args, void*);
+    }
+    if (port_flags & CLONE_CHILD_SETTID) {
+        child_tidptr = va_arg(args, int*);
+    }
+    va_end(args);
+
+    /*
+     * Map the LSB of the flags as explained above.
+     */
+    portable_term_signum = port_flags & 0xFF;
+    if (portable_term_signum == 0) {
+        mips_flags = port_flags;
+    } else {
+        portable_term_signame = map_portable_signum_to_name(portable_term_signum);
+        ALOGV("%s: portable_term_signum:0x%x:'%s'", __func__,
+                   portable_term_signum, portable_term_signame);
+        mips_term_signum = signum_pton(portable_term_signum);
+        mips_term_signame = map_mips_signum_to_name(mips_term_signum);
+        ALOGV("%s: mips_term_signum:0x%x:'%s'", __func__,
+                   mips_term_signum, mips_term_signame);
+        mips_flags = (port_flags & ~0xFF) | (mips_term_signum & 0xFF);
+    }
+    ALOGV("%s: clone(%p, %p, 0x%x, %p, %p, %p, %p);", __func__,
+           fn, child_stack, mips_flags, arg, parent_tidptr, new_tls, child_tidptr);
+
+    ret = REAL(clone)(fn, child_stack, mips_flags, arg, parent_tidptr,
+                new_tls, child_tidptr);
+
+    if (ret > 0) {
+        /*
+         * Disable mapping in the parent if the child could interfere
+         * and make things even worse than skipping the signal and
+         * file read mapping.
+         */
+        if (cloning_files != cloning_vm) {
+            filefd_disable_mapping();
+        }
+        if (cloning_sighand != cloning_vm) {
+            signal_disable_mapping();
+        }
+    }
+
+    ALOGV("%s: return(ret:%d); }", __func__, ret);
+    return ret;
+}
diff --git a/ndk/sources/android/libportable/arch-mips/epoll.c b/ndk/sources/android/libportable/arch-mips/epoll.c
index f703ba1..ef75695 100644
--- a/ndk/sources/android/libportable/arch-mips/epoll.c
+++ b/ndk/sources/android/libportable/arch-mips/epoll.c
@@ -14,15 +14,16 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <sys/epoll.h>
 
-int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
+int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event *event)
 {
-    return epoll_ctl(epfd, op, fd, event);
+    return REAL(epoll_ctl)(epfd, op, fd, event);
 }
 
-int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
+int WRAP(epoll_wait)(int epfd, struct epoll_event *events, int max, int timeout)
 {
-    return epoll_wait(epfd, events, max, timeout);
+    return REAL(epoll_wait)(epfd, events, max, timeout);
 }
 
diff --git a/ndk/sources/android/libportable/arch-mips/errno.c b/ndk/sources/android/libportable/arch-mips/errno.c
index 7372c67..14e2925 100644
--- a/ndk/sources/android/libportable/arch-mips/errno.c
+++ b/ndk/sources/android/libportable/arch-mips/errno.c
@@ -14,16 +14,22 @@
  * limitations under the License.
  */
 
+#include <portability.h>
+#include <pthread.h>
+#include <string.h>
 #include <errno.h>
 #include <errno_portable.h>
 
+#define PORTABLE_TAG "errno_portable"
+#include <log_portable.h>
+
 #if ENAMETOOLONG==ENAMETOOLONG_PORTABLE
 #error Bad build environment
 #endif
 
-static inline int mips_change_errno(int mips_errno)
+__hidden int errno_ntop(int native_errno)
 {
-    switch (mips_errno) {
+    switch (native_errno) {
       case ENAMETOOLONG: return ENAMETOOLONG_PORTABLE;
       case ENOLCK: return ENOLCK_PORTABLE;
       case ENOSYS: return ENOSYS_PORTABLE;
@@ -121,14 +127,244 @@
       case EOWNERDEAD: return EOWNERDEAD_PORTABLE;
       case ENOTRECOVERABLE: return ENOTRECOVERABLE_PORTABLE;
     }
-    return mips_errno;
+    return native_errno;
 }
 
-extern volatile int*   __errno(void);
-volatile int* __errno_portable()
+__hidden int errno_pton(int portable_errno)
 {
-  /* Note that writing to static_errno will not affect the underlying system. */
-  static int static_errno;
-  static_errno = mips_change_errno(*__errno());
-  return &static_errno;
+    switch (portable_errno) {
+      case ENAMETOOLONG_PORTABLE: return ENAMETOOLONG;
+      case ENOLCK_PORTABLE: return ENOLCK;
+      case ENOSYS_PORTABLE: return ENOSYS;
+      case ENOTEMPTY_PORTABLE: return ENOTEMPTY;
+      case ELOOP_PORTABLE: return ELOOP;
+      case EWOULDBLOCK_PORTABLE: return EWOULDBLOCK;
+      case ENOMSG_PORTABLE: return ENOMSG;
+      case EIDRM_PORTABLE: return EIDRM;
+      case ECHRNG_PORTABLE: return ECHRNG;
+      case EL2NSYNC_PORTABLE: return EL2NSYNC;
+      case EL3HLT_PORTABLE: return EL3HLT;
+      case EL3RST_PORTABLE: return EL3RST;
+      case ELNRNG_PORTABLE: return ELNRNG;
+      case EUNATCH_PORTABLE: return EUNATCH;
+      case ENOCSI_PORTABLE: return ENOCSI;
+      case EL2HLT_PORTABLE: return EL2HLT;
+      case EBADE_PORTABLE: return EBADE;
+      case EBADR_PORTABLE: return EBADR;
+      case EXFULL_PORTABLE: return EXFULL;
+      case ENOANO_PORTABLE: return ENOANO;
+      case EBADRQC_PORTABLE: return EBADRQC;
+      case EBADSLT_PORTABLE: return EBADSLT;
+      case EDEADLOCK_PORTABLE: return EDEADLOCK;
+      case EBFONT_PORTABLE: return EBFONT;
+      case ENOSTR_PORTABLE: return ENOSTR;
+      case ENODATA_PORTABLE: return ENODATA;
+      case ETIME_PORTABLE: return ETIME;
+      case ENOSR_PORTABLE: return ENOSR;
+      case ENONET_PORTABLE: return ENONET;
+      case ENOPKG_PORTABLE: return ENOPKG;
+      case EREMOTE_PORTABLE: return EREMOTE;
+      case ENOLINK_PORTABLE: return ENOLINK;
+      case EADV_PORTABLE: return EADV;
+      case ESRMNT_PORTABLE: return ESRMNT;
+      case ECOMM_PORTABLE: return ECOMM;
+      case EPROTO_PORTABLE: return EPROTO;
+      case EMULTIHOP_PORTABLE: return EMULTIHOP;
+      case EDOTDOT_PORTABLE: return EDOTDOT;
+      case EBADMSG_PORTABLE: return EBADMSG;
+      case EOVERFLOW_PORTABLE: return EOVERFLOW;
+      case ENOTUNIQ_PORTABLE: return ENOTUNIQ;
+      case EBADFD_PORTABLE: return EBADFD;
+      case EREMCHG_PORTABLE: return EREMCHG;
+      case ELIBACC_PORTABLE: return ELIBACC;
+      case ELIBBAD_PORTABLE: return ELIBBAD;
+      case ELIBSCN_PORTABLE: return ELIBSCN;
+      case ELIBMAX_PORTABLE: return ELIBMAX;
+      case ELIBEXEC_PORTABLE: return ELIBEXEC;
+      case EILSEQ_PORTABLE: return EILSEQ;
+      case ERESTART_PORTABLE: return ERESTART;
+      case ESTRPIPE_PORTABLE: return ESTRPIPE;
+      case EUSERS_PORTABLE: return EUSERS;
+      case ENOTSOCK_PORTABLE: return ENOTSOCK;
+      case EDESTADDRREQ_PORTABLE: return EDESTADDRREQ;
+      case EMSGSIZE_PORTABLE: return EMSGSIZE;
+      case EPROTOTYPE_PORTABLE: return EPROTOTYPE;
+      case ENOPROTOOPT_PORTABLE: return ENOPROTOOPT;
+      case EPROTONOSUPPORT_PORTABLE: return EPROTONOSUPPORT;
+      case ESOCKTNOSUPPORT_PORTABLE: return ESOCKTNOSUPPORT;
+      case EOPNOTSUPP_PORTABLE: return EOPNOTSUPP;
+      case EPFNOSUPPORT_PORTABLE: return EPFNOSUPPORT;
+      case EAFNOSUPPORT_PORTABLE: return EAFNOSUPPORT;
+      case EADDRINUSE_PORTABLE: return EADDRINUSE;
+      case EADDRNOTAVAIL_PORTABLE: return EADDRNOTAVAIL;
+      case ENETDOWN_PORTABLE: return ENETDOWN;
+      case ENETUNREACH_PORTABLE: return ENETUNREACH;
+      case ENETRESET_PORTABLE: return ENETRESET;
+      case ECONNABORTED_PORTABLE: return ECONNABORTED;
+      case ECONNRESET_PORTABLE: return ECONNRESET;
+      case ENOBUFS_PORTABLE: return ENOBUFS;
+      case EISCONN_PORTABLE: return EISCONN;
+      case ENOTCONN_PORTABLE: return ENOTCONN;
+      case ESHUTDOWN_PORTABLE: return ESHUTDOWN;
+      case ETOOMANYREFS_PORTABLE: return ETOOMANYREFS;
+      case ETIMEDOUT_PORTABLE: return ETIMEDOUT;
+      case ECONNREFUSED_PORTABLE: return ECONNREFUSED;
+      case EHOSTDOWN_PORTABLE: return EHOSTDOWN;
+      case EHOSTUNREACH_PORTABLE: return EHOSTUNREACH;
+      case EALREADY_PORTABLE: return EALREADY;
+      case EINPROGRESS_PORTABLE: return EINPROGRESS;
+      case ESTALE_PORTABLE: return ESTALE;
+      case EUCLEAN_PORTABLE: return EUCLEAN;
+      case ENOTNAM_PORTABLE: return ENOTNAM;
+      case ENAVAIL_PORTABLE: return ENAVAIL;
+      case EISNAM_PORTABLE: return EISNAM;
+      case EREMOTEIO_PORTABLE: return EREMOTEIO;
+      case EDQUOT_PORTABLE: return EDQUOT;
+      case ENOMEDIUM_PORTABLE: return ENOMEDIUM;
+      case EMEDIUMTYPE_PORTABLE: return EMEDIUMTYPE;
+      case ECANCELED_PORTABLE: return ECANCELED;
+      case ENOKEY_PORTABLE: return ENOKEY;
+      case EKEYEXPIRED_PORTABLE: return EKEYEXPIRED;
+      case EKEYREVOKED_PORTABLE: return EKEYREVOKED;
+      case EKEYREJECTED_PORTABLE: return EKEYREJECTED;
+      case EOWNERDEAD_PORTABLE: return EOWNERDEAD;
+      case ENOTRECOVERABLE_PORTABLE: return ENOTRECOVERABLE;
+    }
+    return portable_errno;
+}
+
+/* Key for the thread-specific portable errno */
+static pthread_key_t errno_key;
+
+/* Once-only initialisation of the key */
+static pthread_once_t errno_key_once = PTHREAD_ONCE_INIT;
+
+/* Free the thread-specific portable errno */
+static void errno_key_destroy(void *buf)
+{
+    if (buf)
+        free(buf);
+}
+
+/* Allocate the key */
+static void errno_key_create(void)
+{
+    pthread_key_create(&errno_key, errno_key_destroy);
+}
+
+struct errno_state {
+    int pshadow;                /* copy of last portable errno */
+    int perrno;                 /* portable errno that may be modified by app */
+};
+
+/* Return the thread-specific portable errno */
+static struct errno_state *errno_key_data(void)
+{
+    struct errno_state *data;
+    static struct errno_state errno_state;
+
+    pthread_once(&errno_key_once, errno_key_create);
+    data = (struct errno_state *)pthread_getspecific(errno_key);
+    if (data == NULL) {
+        data = malloc(sizeof(struct errno_state));
+        pthread_setspecific(errno_key, data);
+    }
+    if (data == NULL)
+        data = &errno_state;
+    return data;
+}
+
+/*
+ * Attempt to return a thread specific location containnig the portable errno.
+ * This can be assigned to without affecting the native errno. If the key
+ * allocation fails fall back to using the native errno location.
+ */
+volatile int* WRAP(__errno)()
+{
+    struct errno_state *p;
+    int save_errno;
+
+    /* pthread_* calls may modify errno so use a copy */
+    save_errno = *REAL(__errno)();
+
+    p = errno_key_data();
+
+    ALOGV(" ");
+    ALOGV("%s(): { save_errno = errno:%d, (p:%p)->{pshadow:%d, perrno:%d}", __func__,
+                   save_errno,             p,   p->pshadow, p->perrno);
+
+    if (save_errno == 0 && p->pshadow != p->perrno) {
+        /*
+         * portable errno has changed but native hasn't
+         * - copy portable error back to native
+         */
+        p->pshadow = p->perrno;
+        save_errno = errno_pton(p->perrno);
+    }
+    else if (save_errno != 0 && p->pshadow == p->perrno) {
+        /*
+         * Native errno has changed but portable hasn't
+         * - copy native error to portable.
+         */
+        p->pshadow = p->perrno = errno_ntop(save_errno);
+        save_errno = 0;
+    }
+    else if (save_errno != 0 && p->pshadow != p->perrno) {
+        /*
+         * Both native and portable errno values have changed
+         * so give priority to native errno
+         * - copy native error to portable
+         */
+        p->pshadow = p->perrno = errno_ntop(save_errno);
+        save_errno = 0;
+    }
+
+    ALOGV("%s: new save_errno:%d p:%p->{pshadow:%d, perrno:%d}", __func__,
+                   save_errno,   p,  p->pshadow, p->perrno);
+
+    *REAL(__errno)() = save_errno;
+
+    ALOGV("%s: return (&p->perrno):%p; }", __func__, &p->perrno);
+
+    /* return pointer to the modifiable portable errno value */
+    return &p->perrno;
+}
+
+
+/* set portable errno */
+void WRAP(__set_errno)(int portable_errno)
+{
+    struct errno_state *p;
+    int save_errno;
+
+    /* pthread_* calls may modify errno so use a copy */
+    save_errno = *REAL(__errno)();
+
+    p = errno_key_data();
+
+    ALOGV("%s(): { save_errno = errno:%d, p:%p->{pshadow:%d, perrno:%d}", __func__,
+                   save_errno,            p,  p->pshadow, p->perrno);
+
+    p->pshadow = p->perrno = portable_errno;
+
+    save_errno = errno_pton(portable_errno);
+
+    ALOGV("%s: new save_errno:%d, p:%p->{pshadow:%d, perrno:%d}", __func__,
+                   save_errno,    p,  p->pshadow, p->perrno);
+
+    *REAL(__errno)() = save_errno;
+
+    ALOGV("%s: return; }", __func__);
+}
+
+extern char* REAL(strerror)(int);
+char *WRAP(strerror)(int errnum)
+{
+    return REAL(strerror)(errno_pton(errnum));
+}
+
+/* BSD style strerror_r */
+int WRAP(strerror_r)(int errnum, char *buf, size_t buflen)
+{
+    return REAL(strerror_r)(errno_pton(errnum), buf, buflen);
 }
diff --git a/ndk/sources/android/libportable/arch-mips/eventfd.c b/ndk/sources/android/libportable/arch-mips/eventfd.c
new file mode 100644
index 0000000..35285d9
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/eventfd.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <asm/unistd-portable.h>
+#include <asm/unistd.h>
+
+#include <fcntl_portable.h>
+#include <sys/eventfd.h>
+#include <eventfd_portable.h>
+#include <filefd_portable.h>
+
+#define PORTABLE_TAG "eventfd_portable"
+#include <log_portable.h>
+
+
+/* NOTE: LTP defaults to using O_NONBLOCK even if EFD_NONBLOCK is defined */
+
+
+/*
+ * Portable to Native event flags mapper.
+ */
+static inline int efd_flags_pton(int portable_flags)
+{
+    int native_flags = 0;
+
+    ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags);
+
+    if (portable_flags & EFD_NONBLOCK_PORTABLE) {
+        native_flags |= EFD_NONBLOCK;
+        portable_flags &= ~EFD_NONBLOCK_PORTABLE;
+    }
+
+    if (portable_flags & EFD_CLOEXEC_PORTABLE) {
+        native_flags |= EFD_CLOEXEC;
+        portable_flags &= EFD_CLOEXEC_PORTABLE;
+    }
+
+    if (portable_flags & EFD_SEMAPHORE_PORTABLE) {
+        native_flags |= EFD_SEMAPHORE;
+        portable_flags &= EFD_SEMAPHORE_PORTABLE;
+    }
+
+    if (portable_flags != 0) {
+        ALOGW("%s: portable_flags:0x%x != 0; Unsupported Flags being used!",
+        __func__,  portable_flags);
+    }
+    ALOGV("%s: return(native_flags:%d); }", __func__, native_flags);
+    return native_flags;
+}
+
+
+/*
+ * In the original eventfd() the portable_flags were unused up to
+ * linux 2.6.26 and had to be zero. Android simply uses the
+ * new eventfd2 system call number, so it likely best to just use
+ * the Android eventfd() for both eventfd and eventfd2 system calls.
+ */
+int WRAP(eventfd)(unsigned int initval, int portable_flags) {
+    int rv;
+    int native_flags;
+
+    ALOGV(" ");
+    ALOGV("%s(initval:%u, portable_flags:%d) {", __func__,
+              initval,    portable_flags);
+
+    native_flags = efd_flags_pton(portable_flags);
+
+    rv = REAL(eventfd)(initval, native_flags);
+    if (rv >= 0) {
+        if (native_flags & EFD_CLOEXEC) {
+            filefd_CLOEXEC_enabled(rv);
+        }
+        filefd_opened(rv, EVENT_FD_TYPE);
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/fcntl.c b/ndk/sources/android/libportable/arch-mips/fcntl.c
index 31874b5..174b027 100644
--- a/ndk/sources/android/libportable/arch-mips/fcntl.c
+++ b/ndk/sources/android/libportable/arch-mips/fcntl.c
@@ -14,48 +14,426 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <fcntl.h>
+#include <errno.h>
 #include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <errno_portable.h>
+#include <portability.h>
 #include <fcntl_portable.h>
+#include <filefd_portable.h>
+
+#include <portability.h>
 
 #if F_GETLK_PORTABLE==F_GETLK
 #error Bad build environment
 #endif
 
-static inline int mips_change_cmd(int cmd)
+#define PORTABLE_TAG "fcntl_portable"
+#include <log_portable.h>
+
+static char *map_portable_cmd_to_name(int cmd)
 {
+    char *name;
+
     switch(cmd) {
-    case F_GETLK_PORTABLE:
-        return F_GETLK;
-    case F_SETLK_PORTABLE:
-        return F_SETLK;
-    case F_SETLKW_PORTABLE:
-        return F_SETLKW;
-    case F_SETOWN_PORTABLE:
-        return F_SETOWN;
-    case F_GETOWN_PORTABLE:
-        return F_GETOWN;
-    case F_GETLK64_PORTABLE:
-        return F_GETLK64;
-    case F_SETLK64_PORTABLE:
-        return F_SETLK64;
-    case F_SETLKW64_PORTABLE:
-        return F_SETLKW64;
+    case F_DUPFD_PORTABLE:              name = "F_DUPFD_PORTABLE";              break;  /* 0 */
+    case F_GETFD_PORTABLE:              name = "F_GETFD_PORTABLE";              break;  /* 1 */
+    case F_SETFD_PORTABLE:              name = "F_SETFD_PORTABLE";              break;  /* 2 */
+    case F_GETFL_PORTABLE:              name = "F_GETFL_PORTABLE";              break;  /* 3 */
+    case F_SETFL_PORTABLE:              name = "F_SETFL_PORTABLE";              break;  /* 4 */
+    case F_GETLK_PORTABLE:              name = "F_GETLK_PORTABLE";              break;  /* 5 */
+    case F_SETLK_PORTABLE:              name = "F_SETLK_PORTABLE";              break;  /* 6 */
+    case F_SETLKW_PORTABLE:             name = "F_SETLKW_PORTABLE";             break;  /* 7 */
+    case F_SETOWN_PORTABLE:             name = "F_SETOWN_PORTABLE";             break;  /* 8 */
+    case F_GETOWN_PORTABLE:             name = "F_GETOWN_PORTABLE";             break;  /* 9 */
+    case F_SETSIG_PORTABLE:             name = "F_SETSIG_PORTABLE";             break;  /* 10 */
+    case F_GETSIG_PORTABLE:             name = "F_GETSIG_PORTABLE";             break;  /* 11 */
+    case F_GETLK64_PORTABLE:            name = "F_GETLK64_PORTABLE";            break;  /* 12 */
+    case F_SETLK64_PORTABLE:            name = "F_SETLK64_PORTABLE";            break;  /* 13 */
+    case F_SETLKW64_PORTABLE:           name = "F_SETLKW64_PORTABLE";           break;  /* 14 */
+    case F_SETLEASE_PORTABLE:           name = "F_SETLEASE_PORTABLE";           break;  /* 1024 */
+    case F_GETLEASE_PORTABLE:           name = "F_GETLEASE_PORTABLE";           break;  /* 1025 */
+    case F_NOTIFY_PORTABLE:             name = "F_NOTIFY_PORTABLE";             break;  /* 1026 */
+    case F_CANCELLK_PORTABLE:           name = "F_CANCELLK_PORTABLE";           break;  /* 1029 */
+    case F_DUPFD_CLOEXEC_PORTABLE:      name = "F_DUPFD_CLOEXEC_PORTABLE";      break;  /* 1030 */
+    default:                            name = "<UNKNOWN>";                     break;
     }
-    return cmd;
+    return name;
+}
+
+
+/*
+ * Maps a fcntl portable cmd to a native command.
+ */
+static int fcntl_cmd_pton(int portable_cmd)
+{
+    int native_cmd;
+    char *error_msg = NULL;
+
+    switch(portable_cmd) {
+    case F_DUPFD_PORTABLE:      /* 0 --> 0 */
+        native_cmd =  F_DUPFD;
+        break;
+
+    case F_GETFD_PORTABLE:      /* 1 --> 1 */
+        native_cmd = F_GETFD;
+        break;
+
+    case F_SETFD_PORTABLE:      /* 2 --> 2 */
+        native_cmd = F_SETFD;
+        break;
+
+    case F_GETFL_PORTABLE:      /* 3 --> 3 */
+        native_cmd = F_GETFL;
+        break;
+
+    case F_SETFL_PORTABLE:      /* 4 --> 4 */
+        native_cmd = F_SETFL;
+        break;
+
+    case F_GETLK_PORTABLE:      /* 5 --> 14 */
+        native_cmd = F_GETLK;
+        break;
+
+    case F_SETLK_PORTABLE:      /* 6 --> 6 */
+        native_cmd = F_SETLK;
+        break;
+
+    case F_SETLKW_PORTABLE:     /* 7 --> 7 */
+        native_cmd = F_SETLKW;
+        break;
+
+    case F_SETOWN_PORTABLE:     /* 8 --> 24 */
+        native_cmd = F_SETOWN;
+        break;
+
+    case F_GETOWN_PORTABLE:     /* 9 --> 23 */
+        native_cmd = F_GETOWN;
+        break;
+
+    case F_SETSIG_PORTABLE:     /* 10 --> 10 */
+        native_cmd = F_SETSIG;
+        break;
+
+    case F_GETSIG_PORTABLE:     /* 11 --> 11 */
+        native_cmd = F_GETSIG;
+        break;
+
+    case F_GETLK64_PORTABLE:    /* 12 --> 33 */
+        native_cmd = F_GETLK64;
+        break;
+
+    case F_SETLK64_PORTABLE:    /* 13 --> 34 */
+        native_cmd = F_SETLK64;
+        break;
+
+    case F_SETLKW64_PORTABLE:   /* 14 --> 35 */
+        native_cmd = F_SETLKW64;
+        break;
+
+    case F_SETLEASE_PORTABLE:   /* 1024 --> 1024 */
+        native_cmd =  F_SETLEASE;
+        break;
+
+    case F_GETLEASE_PORTABLE:   /* 1025 --> 1025 */
+        native_cmd = F_GETLEASE;
+        break;
+
+    case F_NOTIFY_PORTABLE:      /* 1026 --> 1026 */
+        native_cmd = F_NOTIFY;
+        break;
+
+    case F_CANCELLK_PORTABLE:      /* 1029 --> void */
+        error_msg = "Case F_CANCELLK_PORTABLE: Not supported by MIPS. ";
+        native_cmd = portable_cmd;
+        break;
+
+    case F_DUPFD_CLOEXEC_PORTABLE: /* 1030 --> VOID; Not currently used by Bionic */
+        error_msg = "Case F_DUPFD_CLOEXEC_PORTABLE: Not supported by MIPS. ";
+        native_cmd = portable_cmd;
+        break;
+
+    default:
+        error_msg = "Case Default: Command Not Supported. ";
+        native_cmd = portable_cmd;
+        break;
+    }
+
+done:
+    if (error_msg != NULL) {
+        ALOGE("%s(portable_cmd:%d:0x%x): %sreturn(native_cmd:%d:0x%x);", __func__,
+                  portable_cmd, portable_cmd, error_msg, native_cmd, native_cmd);
+    } else {
+        ALOGV("%s(portable_cmd:%d:0x%x): return(native_cmd:%d:0x%x);", __func__,
+                  portable_cmd, portable_cmd,   native_cmd, native_cmd);
+    }
+    return native_cmd;
+}
+
+
+static int fcntl_flags_pton(int flags)
+{
+    int mipsflags = flags & O_ACCMODE_PORTABLE;
+
+    if (flags & O_CREAT_PORTABLE)
+        mipsflags |= O_CREAT;
+    if (flags & O_EXCL_PORTABLE)
+        mipsflags |= O_EXCL;
+    if (flags & O_NOCTTY_PORTABLE)
+        mipsflags |= O_NOCTTY;
+    if (flags & O_TRUNC_PORTABLE)
+        mipsflags |= O_TRUNC;
+    if (flags & O_APPEND_PORTABLE)
+        mipsflags |= O_APPEND;
+    if (flags & O_NONBLOCK_PORTABLE)
+        mipsflags |= O_NONBLOCK;
+    if (flags & O_SYNC_PORTABLE)
+        mipsflags |= O_SYNC;
+    if (flags & FASYNC_PORTABLE)
+        mipsflags |= FASYNC;
+    if (flags & O_DIRECT_PORTABLE)
+        mipsflags |= O_DIRECT;
+    if (flags & O_LARGEFILE_PORTABLE)
+        mipsflags |= O_LARGEFILE;
+    if (flags & O_DIRECTORY_PORTABLE)
+        mipsflags |= O_DIRECTORY;
+    if (flags & O_NOFOLLOW_PORTABLE)
+        mipsflags |= O_NOFOLLOW;
+    if (flags & O_NOATIME_PORTABLE)
+        mipsflags |= O_NOATIME;
+    if (flags & O_NDELAY_PORTABLE)
+        mipsflags |= O_NDELAY;
+
+    ALOGV("%s(flags:0x%x): return(mipsflags:0x%x);", __func__,
+              flags,              mipsflags);
+
+    return mipsflags;
+}
+
+static int fcntl_flags_ntop(int flags)
+{
+    int portableflags = flags & O_ACCMODE_PORTABLE;
+
+    if (flags & O_CREAT)
+        portableflags |= O_CREAT_PORTABLE;
+    if (flags & O_EXCL)
+        portableflags |= O_EXCL_PORTABLE;
+    if (flags & O_NOCTTY)
+        portableflags |= O_NOCTTY_PORTABLE;
+    if (flags & O_TRUNC)
+        portableflags |= O_TRUNC_PORTABLE;
+    if (flags & O_APPEND)
+        portableflags |= O_APPEND_PORTABLE;
+    if (flags & O_NONBLOCK)
+        portableflags |= O_NONBLOCK_PORTABLE;
+    if (flags & O_SYNC)
+        portableflags |= O_SYNC_PORTABLE;
+    if (flags & FASYNC)
+        portableflags |= FASYNC_PORTABLE;
+    if (flags & O_DIRECT)
+        portableflags |= O_DIRECT_PORTABLE;
+    if (flags & O_LARGEFILE)
+        portableflags |= O_LARGEFILE_PORTABLE;
+    if (flags & O_DIRECTORY)
+        portableflags |= O_DIRECTORY_PORTABLE;
+    if (flags & O_NOFOLLOW)
+        portableflags |= O_NOFOLLOW_PORTABLE;
+    if (flags & O_NOATIME)
+        portableflags |= O_NOATIME_PORTABLE;
+    if (flags & O_NDELAY)
+        portableflags |= O_NDELAY_PORTABLE;
+
+    ALOGV("%s(flags:0x%x): return(portableflags:0x%x);", __func__,
+              flags,              portableflags);
+
+    return portableflags;
 }
 
 extern int __fcntl64(int, int, void *);
 
-int fcntl_portable(int fd, int cmd, ...)
+/*
+ * For 32 bit flocks we are converting a portable/ARM struct flock to a MIPS struct flock:
+ *
+ * MIPS:                        ARM:
+ *     struct flock {           struct flock_portable {
+ *       short l_type;            short l_type;
+ *
+ *       short l_whence;          short l_whence;
+ *       off_t l_start;           loff_t l_start;
+ *       off_t l_len;             loff_t l_len;
+ *       long l_sysid;
+ *
+ *       __kernel_pid_t l_pid;    pid_t l_pid;
+ *       long pad[4];
+ *     };                       }
+ *
+ * which have identically sized structure members:
+ *
+ * For a 64 bit flocks we only have to deal with
+ * a four byte padding in the ARM/Portable structure:
+ *
+ *    MIPS:                     ARM:
+ *        struct flock64 {      struct flock64_portable {
+ *        short l_type;           short l_type;
+ *        short l_whence;         short l_whence;
+ *                                unsigned char __padding[4];   <----  NOTE
+ *        loff_t l_start;         loff_t l_start;
+ *        loff_t l_len;           loff_t l_len;
+ *        pid_t l_pid;            pid_t l_pid;
+ *      }                       }
+ */
+int WRAP(fcntl)(int fd, int portable_cmd, ...)
 {
+    int flags;
     va_list ap;
-    void * arg;
+    void *arg;
+    int mips_cmd;
+    int result = 0;
+    struct flock flock;                                 /* Native MIPS structure */
+    struct flock64 flock64;                             /* Native MIPS structure */
+    char *portable_cmd_name = map_portable_cmd_to_name(portable_cmd);
+    struct flock_portable *flock_portable = NULL;
+    struct flock64_portable *flock64_portable = NULL;
 
-    va_start(ap, cmd);
+    ALOGV(" ");
+    ALOGV("%s(fd:%d, portable_cmd:%d:'%s', ...) {",  __func__,
+              fd,    portable_cmd,
+                     portable_cmd_name);
+
+
+    va_start(ap, portable_cmd);
     arg = va_arg(ap, void *);
     va_end(ap);
 
-    return __fcntl64(fd, mips_change_cmd(cmd), arg);
+    mips_cmd = fcntl_cmd_pton(portable_cmd);
+    switch(mips_cmd) {
+    case F_GETLK:
+    case F_SETLK:
+    case F_SETLKW:
+        flock_portable = (struct flock_portable *) arg;
+
+        if (invalid_pointer(flock_portable)) {
+            ALOGE("%s: flock_portable:%p == {NULL||-1}", __func__, flock_portable);
+            *REAL(__errno)() = EFAULT;
+            result = -1;
+            goto done;
+        }
+
+        /*
+         * Lock type and Whence are the same for all ARCHs
+         *      (F_RDLCK:0,   F_WRLCK:1,  F_UNLCK:2)
+         *      (SEEK_SET:0, SEEK_CUR:1, SEEK_END:2)
+         */
+        flock.l_type = flock_portable->l_type;
+        flock.l_whence = flock_portable->l_whence;
+        flock.l_start = (off_t) flock_portable->l_start;
+        flock.l_len =  (off_t) flock_portable->l_len;
+        flock.l_sysid = 0L;
+        flock.l_pid = flock_portable->l_pid;    /* Perhaps 0 would be better */
+
+        result = __fcntl64(fd, mips_cmd, (void *) &flock);
+
+        flock_portable->l_type = flock.l_type;
+        flock_portable->l_whence = flock.l_whence;
+        flock_portable->l_start = flock.l_start;
+        flock_portable->l_len = flock.l_len;
+        flock_portable->l_pid = flock.l_pid;
+        break;
+
+    case F_GETLK64:
+    case F_SETLK64:
+    case F_SETLKW64:
+        flock64_portable = (struct flock64_portable *) arg;
+
+        if (invalid_pointer(flock_portable)) {
+            ALOGE("%s: flock_portable:%p == {NULL||-1}", __func__, flock_portable);
+            *REAL(__errno)() = EFAULT;
+            result = -1;
+            goto done;
+        }
+
+        /*
+         * Lock type and Whence are the same for all ARCHs
+         *      (F_RDLCK:0,   F_WRLCK:1,  F_UNLCK:2)
+         *      (SEEK_SET:0, SEEK_CUR:1, SEEK_END:2)
+         */
+        flock64.l_type = flock64_portable->l_type;
+        flock64.l_whence = flock64_portable->l_whence;
+        flock64.l_start = (off_t) flock64_portable->l_start;
+        flock64.l_len =  (off_t) flock64_portable->l_len;
+        flock64.l_pid = flock64_portable->l_pid;        /* Perhaps 0 would be better */
+
+        result = __fcntl64(fd, mips_cmd, (void *) &flock);
+
+        flock64_portable->l_type = flock64.l_type;
+        flock64_portable->l_whence = flock64.l_whence;
+        flock64_portable->l_start = flock64.l_start;
+        flock64_portable->l_len = flock64.l_len;
+        flock64_portable->l_pid = flock64.l_pid;
+        break;
+
+    case F_SETFL:
+        flags = fcntl_flags_pton((int)arg);
+        result = __fcntl64(fd, mips_cmd, (void *)flags);
+        break;
+
+    case F_GETFL:
+        result = __fcntl64(fd, mips_cmd, arg);
+        if (result != -1)
+            result = fcntl_flags_ntop(result);
+        break;
+
+    case F_DUPFD:
+    case F_GETFD:
+    case F_SETFD:
+    case F_SETOWN:
+    case F_GETOWN:
+    case F_SETSIG:
+    case F_GETSIG:
+    case F_SETLEASE:
+    case F_GETLEASE:
+    case F_NOTIFY:
+        ALOGV("%s: Calling __fcntl64(fd:%d, mips_cmd:0x%x, arg:%p);", __func__,
+                                     fd,    mips_cmd,      arg);
+
+        result = __fcntl64(fd, mips_cmd, arg);
+
+        if (result < 0) {
+            ALOGV("%s: result = %d = __fcntl64(fd:%d, mips_cmd:0x%x, arg:%p);", __func__,
+                       result,                 fd,    mips_cmd,      arg);
+        } else {
+            if (mips_cmd == F_SETFD) {
+                /*
+                 * File descriptor flag bits got set or cleared.
+                 */
+                flags = (int)arg;
+                if (flags & FD_CLOEXEC) {
+                    filefd_CLOEXEC_enabled(fd);
+                } else {
+                    filefd_CLOEXEC_disabled(fd);
+                }
+            }
+        }
+        break;
+
+    default:
+        /*
+         * This is likely a rare situation, abort() would hang fcntl13 LTP test.
+         */
+        ALOGE("%s: mips_cmd:%d doesn't appear to be supported;", __func__,
+                   mips_cmd);
+
+        ALOGV("%s: Assume it doesn't need to be mapped!", __func__);
+
+        result = __fcntl64(fd, mips_cmd, arg);
+    }
+
+done:
+    ALOGV("%s: return(result:%d); }", __func__, result);
+    return result;
 }
 
diff --git a/ndk/sources/android/libportable/arch-mips/fenv.c b/ndk/sources/android/libportable/arch-mips/fenv.c
new file mode 100644
index 0000000..d7b600f
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/fenv.c
@@ -0,0 +1,208 @@
+/*
+ * 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.
+ */
+
+#include <portability.h>
+#include <sys/types.h>
+#include <fenv.h>
+#include <fenv_portable.h>
+
+static inline int mips_change_except(int flags)
+{
+    int mipsflags = 0;
+    int exception = flags & FE_ALL_EXCEPT_PORTABLE;
+
+    // exception flags
+    if (exception & FE_INVALID_PORTABLE)
+        mipsflags |= FE_INVALID;
+    if (exception & FE_DIVBYZERO_PORTABLE)
+        mipsflags |= FE_DIVBYZERO;
+    if (exception & FE_OVERFLOW_PORTABLE)
+        mipsflags |= FE_OVERFLOW;
+    if (exception & FE_UNDERFLOW_PORTABLE)
+        mipsflags |= FE_UNDERFLOW;
+    if (exception & FE_INEXACT_PORTABLE)
+        mipsflags |= FE_INEXACT;
+
+    return mipsflags;
+}
+
+static inline int mips_change_rounding(int flags)
+{
+    int mipsflags = 0;
+    int rounding = flags & 0x03;
+
+    // rounding flags
+    switch(rounding)
+    {
+      case FE_TONEAREST_PORTABLE:
+        mipsflags = FE_TONEAREST;
+        break;
+      case FE_DOWNWARD_PORTABLE:
+        mipsflags = FE_DOWNWARD;
+        break;
+      case FE_UPWARD_PORTABLE:
+        mipsflags = FE_UPWARD;
+        break;
+      case FE_TOWARDZERO_PORTABLE:
+        mipsflags = FE_TOWARDZERO;
+        break;
+    }
+    return mipsflags;
+}
+
+static inline int mips_get_except(int mipsflags)
+{
+    int flags = 0;
+    int exception = mipsflags & FE_ALL_EXCEPT;
+
+    // exception flags
+    if (exception & FE_INVALID)
+        flags |= FE_INVALID_PORTABLE;
+    if (exception & FE_DIVBYZERO)
+        flags |= FE_DIVBYZERO_PORTABLE;
+    if (exception & FE_OVERFLOW)
+        flags |= FE_OVERFLOW_PORTABLE;
+    if (exception & FE_UNDERFLOW)
+        flags |= FE_UNDERFLOW_PORTABLE;
+    if (exception & FE_INEXACT)
+        flags |= FE_INEXACT_PORTABLE;
+    return flags;
+}
+
+static inline int mips_get_rounding(int mipsflags)
+{
+    int flags = 0;
+    int rounding = mipsflags & _FCSR_RMASK;
+
+    // rounding flags
+    switch(rounding)
+    {
+      case FE_TONEAREST:
+        flags = FE_TONEAREST_PORTABLE;
+        break;
+      case FE_DOWNWARD:
+        flags = FE_DOWNWARD_PORTABLE;
+        break;
+      case FE_UPWARD:
+        flags = FE_UPWARD_PORTABLE;
+        break;
+      case FE_TOWARDZERO:
+        flags = FE_TOWARDZERO_PORTABLE;
+        break;
+    }
+    return flags;
+}
+
+int WRAP(fegetenv)(fenv_t* __envp) {
+   fenv_t _fcsr = 0;
+#ifdef  __mips_hard_float
+   __asm__ __volatile__("cfc1 %0,$31" : "=r" (_fcsr));
+#endif
+   *__envp = _fcsr;
+   return 0;
+}
+
+int WRAP(fesetenv)(const fenv_t* __envp) {
+  fenv_t _fcsr = *__envp;
+#ifdef  __mips_hard_float
+  __asm__ __volatile__("ctc1 %0,$31" : : "r" (_fcsr));
+#endif
+  return 0;
+}
+
+int WRAP(feclearexcept)(int __excepts) {
+  __excepts = mips_change_except(__excepts);
+  fexcept_t __fcsr;
+  WRAP(fegetenv)(&__fcsr);
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~(__excepts | (__excepts << _FCSR_CAUSE_SHIFT));
+  WRAP(fesetenv)(&__fcsr);
+  return 0;
+}
+
+int WRAP(fegetexceptflag)(fexcept_t* __flagp, int __excepts) {
+  __excepts = mips_change_except(__excepts);
+  fexcept_t __fcsr;
+  WRAP(fegetenv)(&__fcsr);
+  *__flagp = mips_get_except(__fcsr & __excepts & FE_ALL_EXCEPT);
+  return 0;
+}
+
+int WRAP(fesetexceptflag)(const fexcept_t* __flagp, int __excepts) {
+  int __flagp_ = mips_change_except(*__flagp);
+  __excepts = mips_change_except(__excepts);
+  fexcept_t __fcsr;
+  WRAP(fegetenv)(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  __fcsr &= ~__excepts;
+  __fcsr |= __flagp_ & __excepts;
+  WRAP(fesetenv)(&__fcsr);
+  return 0;
+}
+
+int WRAP(feraiseexcept)(int __excepts) {
+  __excepts = mips_change_except(__excepts);
+  fexcept_t __fcsr;
+  WRAP(fegetenv)(&__fcsr);
+  /* Ensure that flags are all legal */
+  __excepts &= FE_ALL_EXCEPT;
+  /* Cause bit needs to be set as well for generating the exception*/
+  __fcsr |= __excepts | (__excepts << _FCSR_CAUSE_SHIFT);
+  WRAP(fesetenv)(&__fcsr);
+  return 0;
+}
+
+int WRAP(fetestexcept)(int __excepts) {
+   __excepts = mips_change_except(__excepts);
+  fexcept_t __FCSR;
+  WRAP(fegetenv)(&__FCSR);
+  return mips_get_except(__FCSR & __excepts & FE_ALL_EXCEPT);
+}
+
+int WRAP(fegetround)(void) {
+  fenv_t _fcsr;
+  WRAP(fegetenv)(&_fcsr);
+  return mips_get_rounding(_fcsr & _FCSR_RMASK);
+}
+
+int WRAP(fesetround)(int __round) {
+  __round = mips_change_rounding(__round);
+  fenv_t _fcsr;
+  WRAP(fegetenv)(&_fcsr);
+  _fcsr &= ~_FCSR_RMASK;
+  _fcsr |= (__round & _FCSR_RMASK );
+  WRAP(fesetenv)(&_fcsr);
+  return 0;
+}
+
+int WRAP(feholdexcept)(fenv_t* __envp) {
+  fenv_t __env;
+  WRAP(fegetenv)(&__env);
+  *__envp = __env;
+  __env &= ~(FE_ALL_EXCEPT | _FCSR_ENABLE_MASK);
+  WRAP(fesetenv)(&__env);
+  return 0;
+}
+
+int WRAP(feupdateenv)(const fenv_t* __envp) {
+  fexcept_t __fcsr;
+  WRAP(fegetenv)(&__fcsr);
+  WRAP(fesetenv)(__envp);
+  WRAP(feraiseexcept)(__fcsr & FE_ALL_EXCEPT);
+  return 0;
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/filefd.c b/ndk/sources/android/libportable/arch-mips/filefd.c
new file mode 100644
index 0000000..d80eb3d
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/filefd.c
@@ -0,0 +1,502 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <errno_portable.h>
+#include <filefd_portable.h>
+#include <signal_portable.h>
+#include <sys/atomics.h>
+
+#define PORTABLE_TAG "filefd_portable"
+#include <log_portable.h>
+
+/*
+ * Maintaining a list of special file descriptors in lib-portable:
+ * ---------------------------------------------------------------
+ *
+ * These are file descriptors which were opened with system calls
+ * which make it possible to read kernel data structures via the
+ * read system call. See man pages for:
+ *      signalfd(2)
+ *      eventfd(2)
+ *      timerfd_create(2)
+ *
+ * The files conditioned with signalfd(2) need to have their reads
+ * intercepted to correct signal numbers. This is done using this table
+ * of mapped files.
+ *
+ * The signalfd(2) semantics are maintained across execve(2) by exporting
+ * and importing environment variables for file descriptors that are not
+ * marked as close-on-execute. For example testing import code with:
+ * Eg:
+ *      export ANDROID_PORTABLE_MAPPED_FILE_DESCRIPTORS=10,17
+ *      export ANDROID_PORTABLE_MAPPED_FILE_TYPES=2,1
+ *
+ *      Where
+ *          filefd_mapped_file[10] = SIGNAL_FD_TYPE:2
+ *          filefd_FD_CLOEXEC_file[10] = 0;
+ *      and
+ *          filefd_mapped_file[17] = EVENT_FD_TYPE:1
+ *          filefd_FD_CLOEXEC_file[17] = 0;
+ *
+ * A table of CLOEXEC_files is maintained via call-backs
+ * in open_portable() and fcntl_portable() which indicates
+ * the files with close-on-execute semantics.
+ *
+ * The signalfd(2) fork(2) and thread semantics are not
+ * affected by the mapping of signalfd() file descriptor reads.
+ *
+ * This algorithm requires that threads have the same sharing
+ * attributes for file descriptors and memory and will be disabled
+ * by a call from clone() if the environment is unsuitable for it's use.
+ */
+
+static char *fd_env_name = "ANDROID_PORTABLE_MAPPED_FILE_DESCRIPTORS";
+static char *type_env_name = "ANDROID_PORTABLE_MAPPED_FILE_TYPES";
+static enum filefd_type filefd_mapped_file[__FD_SETSIZE];
+static int  filefd_FD_CLOEXEC_file[__FD_SETSIZE];
+
+static volatile int filefd_mapped_files = 0;
+static volatile int filefd_enabled = 1;
+
+/*
+ * Assuming sizeof(int)==4, and __FD_SETSIZE < 10000 each token will
+ * occupy a maximum of 5 characters (4 digits + delimiter:','). The tokens
+ * are the numbers above, a file descriptor (0..9999), and the filefd_type's
+ * which are a single digit.
+ *
+ * The arrays used to manipulate the environment variables are allocated using
+ * malloc to avoid overrunning the stack.
+ */
+#if __FD_SETSIZE >= 10000
+#error MAX_ENV_SIZE must be increased
+#endif
+
+#define MAX_ENV_SIZE (__FD_SETSIZE * 5)
+
+static int export_fd_env()
+{
+    const int max_env_size = MAX_ENV_SIZE;
+    int type_env_bytes_remaining = max_env_size;
+    char *type_env_allocated = NULL, *type_env;
+    int fd_env_bytes_remaining = max_env_size;
+    char *fd_env_allocated = NULL, *fd_env;
+    int exported_file_descriptors = 0;
+    enum filefd_type fd_type;
+    int overwrite = 1;
+    int fd_count = 0;
+    int saved_errno;
+    int fd_cloexec;
+    int len;
+    int rv1;
+    int rv2;
+    int rv;
+    int fd;
+
+    ALOGV("%s:() {", __func__);
+
+    saved_errno = *REAL(__errno)();
+
+    type_env_allocated = malloc(max_env_size);
+    fd_env_allocated = malloc(max_env_size);
+    if (type_env_allocated == NULL || fd_env_allocated == NULL) {
+        ALOGE("%s: type_env_allocated:%p, fd_env_allocated:%p; FIXME!", __func__,
+                   type_env_allocated,    fd_env_allocated);
+
+        rv = -1;
+        goto done;
+    } else {
+        ALOGV("%s: type_env_allocated:%p, fd_env_allocated:%p;", __func__,
+                   type_env_allocated,    fd_env_allocated);
+    }
+
+    type_env = type_env_allocated;
+    fd_env = fd_env_allocated;
+
+    for (fd = 0; fd < __FD_SETSIZE; fd++) {
+        fd_type = filefd_mapped_file[fd];
+        if (fd_type != UNUSED_FD_TYPE) {
+            ++fd_count;
+            ALOGV("%s: fd_type = %d = filefd_mapped_file[fd:%d]; ++fdcount:%d;", __func__,
+                       fd_type,                          fd,       fd_count);
+
+            fd_cloexec = filefd_FD_CLOEXEC_file[fd];
+            ALOGV("%s: fd_cloexec = %d = filefd_FD_CLOEXEC_file[fd:%d];", __func__,
+                       fd_cloexec,                              fd);
+
+            if (fd_cloexec == 0) {
+                rv = snprintf(fd_env, fd_env_bytes_remaining, "%d,", fd);
+                ASSERT(rv > 0);
+                fd_env += rv;
+                fd_env_bytes_remaining -= rv;
+                rv = snprintf(type_env, type_env_bytes_remaining, "%d,", filefd_mapped_file[fd]);
+                ASSERT(rv > 0);
+                type_env += rv;
+                type_env_bytes_remaining -= rv;
+                exported_file_descriptors++;
+            }
+
+            /*
+             * There is a chance of inconsistent results here if
+             * another thread is updating the array while it was
+             * being copied, but this code is only run during exec
+             * so the state of the file descriptors that the child
+             * sees will be inconsistent anyway.
+             */
+            if (fd_count == filefd_mapped_files)
+                break;
+        }
+    }
+    if (fd_count != filefd_mapped_files) {
+        ALOGE("%s: fd_count:%d != filefd_mapped_files:%d; [Likely Race; add futex?]", __func__,
+                   fd_count,      filefd_mapped_files);
+
+    }
+    if (exported_file_descriptors == 0) {
+        rv1 = unsetenv(fd_env_name);
+        rv2 = unsetenv(type_env_name);
+        if (rv1 != 0 || rv2 != 0) {
+            ALOGV("%s: Note: unsetenv() failed!", __func__);
+        }
+        rv = 0;
+    } else {
+        if (fd_env > fd_env_allocated) {
+            fd_env--;                           /* backup fd_env to last ',' */
+        }
+        *fd_env = '\0';
+
+        if (type_env > type_env_allocated) {
+            type_env--;                         /* backup type_env to last ',' */
+        }
+        *type_env = '\0';
+
+        rv = setenv(fd_env_name, fd_env_allocated, overwrite);
+        if (rv != 0) {
+            ALOGE("%s: rv:%d = setenv(fd_env_name:'%s', fd_env_allocated:'%s' ...);", __func__,
+                       rv,            fd_env_name,      fd_env_allocated);
+        } else {
+            ALOGV("%s: rv:%d = setenv(fd_env_name:'%s', fd_env_allocated:'%s' ...);", __func__,
+                       rv,            fd_env_name,      fd_env_allocated);
+        }
+        if (rv != 0) goto done;
+
+        rv = setenv(type_env_name, type_env_allocated, overwrite);
+
+        if (rv != 0) {
+            ALOGE("%s: rv:%d = setenv(type_env_name:'%s', type_env_allocated:'%s' ...);",
+            __func__,  rv,            type_env_name,      type_env_allocated);
+        } else {
+            ALOGV("%s: rv:%d = setenv(type_env_name:'%s', type_env_allocated:'%s' ...);",
+            __func__,  rv,            type_env_name,      type_env_allocated);
+        }
+    }
+
+done:
+    if (type_env_allocated)
+        free(type_env_allocated);
+
+    if (fd_env_allocated)
+        free(fd_env_allocated);
+
+    *REAL(__errno)() = saved_errno;
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+static int import_fd_env(int verify)
+{
+    char *type_env_allocated = NULL;
+    char *fd_env_allocated = NULL;
+    char *type_token_saved_ptr;
+    char *fd_token_saved_ptr;
+    enum filefd_type fd_type;
+    char *type_env, *fd_env;
+    int saved_errno;
+    char *type_token;
+    char *fd_token;
+    int rv = 0;
+    int fd;
+
+    ALOGV("%s:(verify:%d) {", __func__, verify);
+
+    saved_errno = *REAL(__errno)();
+
+    /*
+     * get file descriptor environment pointer and make a
+     * a copy of the string.
+     */
+    fd_env = getenv(fd_env_name);
+    if (fd_env == NULL) {
+        ALOGV("%s: fd_env = NULL = getenv('%s');", __func__,
+                                   fd_env_name);
+        goto done;
+    } else {
+        ALOGV("%s: fd_env = '%s' = getenv('%s');", __func__,
+                   fd_env,         fd_env_name);
+
+        fd_env_allocated = malloc(strlen(fd_env)+1);
+        if (fd_env_allocated == NULL) {
+            ALOGE("%s: fd_env_allocated = NULL; malloc failed", __func__);
+            goto done;
+        }
+        strcpy(fd_env_allocated, fd_env);
+    }
+
+    /*
+     * get file descriptor environment pointer and make a copy of
+     * the string to our stack.
+     */
+    type_env = getenv(type_env_name);
+    if (type_env == NULL) {
+        ALOGV("%s: type_env = NULL = getenv(type_env_name:'%s');", __func__,
+                                            type_env_name);
+        goto done;
+    } else {
+        ALOGV("%s: type_env = '%s' = getenv(type_env_name:'%s');", __func__,
+                   type_env,                type_env_name);
+
+        type_env_allocated = malloc(strlen(type_env)+1);
+        if (type_env_allocated == NULL) {
+            ALOGE("%s: type_env_allocated = NULL; malloc failed", __func__);
+            goto done;
+        }
+        strcpy(type_env_allocated, type_env);
+    }
+
+    /*
+     * Setup strtok_r(), use it to parse the env tokens, and
+     * initialise the filefd_mapped_file array.
+     */
+    fd_token = strtok_r(fd_env_allocated, ",", &fd_token_saved_ptr);
+    type_token = strtok_r(type_env_allocated, ",", &type_token_saved_ptr);
+    while (fd_token && type_token) {
+        fd = atoi(fd_token);
+        ASSERT(fd >= 0 );
+        ASSERT(fd < __FD_SETSIZE);
+
+        fd_type = (enum filefd_type) atoi(type_token);
+        ASSERT(fd_type > UNUSED_FD_TYPE);
+        ASSERT(fd_type < MAX_FD_TYPE);
+
+        if (fd >= 0 && fd < __FD_SETSIZE) {
+            if (fd_type > UNUSED_FD_TYPE && fd_type < MAX_FD_TYPE) {
+                if (verify) {
+                    ASSERT(filefd_mapped_file[fd] == fd_type);
+                    ALOGV("%s: filefd_mapped_file[fd:%d] == fd_type:%d;", __func__,
+                                                  fd,       fd_type);
+                } else {
+                    ASSERT(filefd_mapped_file[fd] == UNUSED_FD_TYPE);
+
+                    __atomic_inc(&filefd_mapped_files);
+                    ALOGV("%s: ++filefd_mapped_files:%d;", __func__,
+                                 filefd_mapped_files);
+
+                    filefd_mapped_file[fd] = fd_type;
+                    ALOGV("%s: filefd_mapped_file[fd:%d] = fd_type:%d;", __func__,
+                                                  fd,      fd_type);
+                }
+            }
+        }
+
+        fd_token = strtok_r(NULL, ",", &fd_token_saved_ptr);
+        type_token = strtok_r(NULL, ",", &type_token_saved_ptr);
+    }
+
+done:
+    if (type_env_allocated)
+        free(type_env_allocated);
+    if (fd_env_allocated)
+        free(fd_env_allocated);
+
+    *REAL(__errno)() = saved_errno;
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+/*
+ * This function will get run by the linker when the library is loaded.
+ */
+static void __attribute__ ((constructor)) linker_import_fd_env(void)
+{
+    int rv;
+    int verify_consistancy = 0;
+
+    ALOGV(" ");
+    ALOGV("%s() {", __func__);
+
+    rv = import_fd_env(verify_consistancy);     /* File type table not verified. */
+
+    ALOGV("%s: }", __func__);
+}
+
+
+__hidden void filefd_opened(int fd, enum filefd_type fd_type)
+{
+    ALOGV("%s(fd:%d) {", __func__, fd);
+
+    if (fd >= 0 && fd < __FD_SETSIZE) {
+        if (filefd_mapped_file[fd] == UNUSED_FD_TYPE) {
+            __atomic_inc(&filefd_mapped_files);
+            filefd_mapped_file[fd] = fd_type;
+        }
+        ASSERT(filefd_mapped_file[fd] == fd_type);
+    }
+
+    ALOGV("%s: }", __func__);
+}
+
+__hidden void filefd_closed(int fd)
+{
+    ALOGV("%s(fd:%d) {", __func__, fd);
+
+    if (fd >= 0 && fd < __FD_SETSIZE) {
+        if (filefd_mapped_file[fd] != UNUSED_FD_TYPE) {
+            filefd_mapped_file[fd] = UNUSED_FD_TYPE;
+            filefd_FD_CLOEXEC_file[fd] = 0;
+            __atomic_dec(&filefd_mapped_files);
+        }
+    }
+    ALOGV("%s: }", __func__);
+}
+
+
+__hidden void filefd_CLOEXEC_enabled(int fd)
+{
+    ALOGV("%s:(fd:%d) {", __func__, fd);
+
+    if (fd >= 0 && fd < __FD_SETSIZE) {
+        filefd_FD_CLOEXEC_file[fd] = 1;
+    }
+
+    ALOGV("%s: }", __func__);
+}
+
+__hidden void filefd_CLOEXEC_disabled(int fd)
+{
+    ALOGV("%s:(fd:%d) {", __func__, fd);
+
+    if (fd >= 0 && fd < __FD_SETSIZE) {
+        filefd_FD_CLOEXEC_file[fd] = 0;
+    }
+
+    ALOGV("%s: }", __func__);
+}
+
+
+__hidden void filefd_disable_mapping()
+{
+    ALOGV("%s:() {", __func__);
+
+    filefd_enabled = 0;
+
+    ALOGV("%s: }", __func__);
+}
+
+
+int WRAP(close)(int fd)
+{
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(fd:%d) {", __func__, fd);
+
+    rv = REAL(close)(fd);
+    filefd_closed(fd);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(read)(int fd, void *buf, size_t count)
+{
+    int rv;
+    enum filefd_type fd_type;
+
+    ALOGV(" ");
+    ALOGV("%s(fd:%d, buf:0x%p, count:%d) {", __func__,
+              fd,    buf,      count);
+
+    fd_type = filefd_mapped_file[fd];
+    ALOGV("%s:fd_type:%d", __func__,
+              fd_type);
+
+    switch (fd_type) {
+    /* Reads on these descriptors are portable; no need to be mapped. */
+    case UNUSED_FD_TYPE:
+    case EVENT_FD_TYPE:
+    case INOTIFY_FD_TYPE:
+    case TIMER_FD_TYPE:
+        rv = REAL(read)(fd, buf, count);
+        break;
+
+    /* The read() of a signalfd() file descriptor needs to be mapped. */
+    case SIGNAL_FD_TYPE:
+        if (filefd_enabled) {
+            rv = read_signalfd_mapper(fd, buf, count);
+        } else {
+            rv = REAL(read)(fd, buf, count);
+        }
+        break;
+
+    default:
+        ALOGE("Unknown fd_type:%d!", fd_type);
+        rv = REAL(read)(fd, buf, count);
+        break;
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+/*
+ * Export PORTABLE environment variables before execve().
+ * Tries a second time if it detects an extremely unlikely
+ * race condition.
+ */
+int WRAP(execve)(const char *filename, char *const argv[],  char *const envp[])
+{
+    int rv;
+    int mapped_files = filefd_mapped_files;
+    int verify_consistancy = 1;
+
+    ALOGV(" ");
+    ALOGV("%s(filename:%p, argv:%p, envp:%p) {", __func__,
+              filename,    argv,    envp);
+
+    export_fd_env();
+
+    if (mapped_files != filefd_mapped_files) {
+        export_fd_env();
+    }
+    import_fd_env(verify_consistancy);          /* File type table consistancy verified. */
+
+    rv = REAL(execve)(filename, argv, envp);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/flags.c b/ndk/sources/android/libportable/arch-mips/flags.c
new file mode 100644
index 0000000..f18b8d9
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/flags.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <fcntl_portable.h>
+
+#define PORTABLE_TAG "flags_portable"
+#include <log_portable.h>
+
+
+/* __sflags is an internal bionic routine but the symbol is exported and there are callers... */
+extern int __sflags(const char *, int *);
+
+int
+WRAP(__sflags)(const char *mode, int *optr)
+{
+    int rv;
+    int nflags, pflags;
+
+    ALOGV(" ");
+    ALOGV("%s(mode:%p, optr:%p) {", __func__, mode, optr);
+
+    rv = __sflags(mode, &nflags);
+
+    /* error - no change to *optr */
+    if (rv == 0)
+        goto done;
+
+    pflags = nflags & O_ACCMODE;
+    if (nflags & O_CREAT)
+        pflags |= O_CREAT_PORTABLE;
+    if (nflags & O_TRUNC)
+        pflags |= O_TRUNC_PORTABLE;
+    if (nflags & O_APPEND)
+        pflags |= O_APPEND_PORTABLE;
+
+    /* Set *optr to portable flags */
+    *optr = pflags;
+
+done:
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
diff --git a/ndk/sources/android/libportable/arch-mips/inotify.c b/ndk/sources/android/libportable/arch-mips/inotify.c
new file mode 100644
index 0000000..76b1cac
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/inotify.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <asm/unistd.h>
+#include <asm/unistd-portable.h>
+
+#include <fcntl_portable.h>
+#include <inotify_portable.h>
+
+#include <filefd_portable.h>
+
+
+#define PORTABLE_TAG "inotify_portable"
+#include <log_portable.h>
+
+extern int syscall(int, ...);
+
+
+/*
+ * NOTE: LTP defaults to using O_CLOEXEC for IN_CLOEXEC,
+ *       and 02000000 if O_CLOEXEC isn't defined.
+ */
+
+
+/*
+ * Portable to Native event flags mapper.
+ */
+static inline int in_flags_pton(int portable_flags)
+{
+    int native_flags = 0;
+
+    ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags);
+
+    if (portable_flags & IN_NONBLOCK_PORTABLE) {
+        native_flags |= IN_NONBLOCK;
+    }
+
+    if (portable_flags & IN_CLOEXEC_PORTABLE) {
+        native_flags |= IN_CLOEXEC;
+    }
+
+    ALOGV("%s: return(native_flags:%d); }", __func__, native_flags);
+    return native_flags;
+}
+
+
+int WRAP(inotify_init1)(int portable_flags) {
+    int rv;
+    int native_flags;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_flags:%d) {", __func__,
+              portable_flags);
+
+    native_flags = in_flags_pton(portable_flags);
+
+    rv = syscall(__NR_inotify_init1, native_flags);
+    if (rv >= 0) {
+        if (native_flags & IN_CLOEXEC) {
+            filefd_CLOEXEC_enabled(rv);
+        }
+        filefd_opened(rv, INOTIFY_FD_TYPE);
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/ioctl.c b/ndk/sources/android/libportable/arch-mips/ioctl.c
index cbd517f..7e82a6a 100644
--- a/ndk/sources/android/libportable/arch-mips/ioctl.c
+++ b/ndk/sources/android/libportable/arch-mips/ioctl.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <stdarg.h>
 #include <sys/ioctl.h>
 #include <ioctls_portable.h>
@@ -213,7 +214,7 @@
 }
 
 extern int __ioctl(int, int, void *);
-int ioctl_portable(int fd, int request, ...)
+int WRAP(ioctl)(int fd, int request, ...)
 {
     va_list ap;
     void * arg;
diff --git a/ndk/sources/android/libportable/arch-mips/jboffsets.h b/ndk/sources/android/libportable/arch-mips/jboffsets.h
new file mode 100644
index 0000000..b43d77a
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/jboffsets.h
@@ -0,0 +1,46 @@
+#ifndef _JBOFFSETS_H_
+#define _JBOFFSETS_H_
+
+/*
+ * Normally the same layout is used for saving the registers in jmp_buf
+ * as that used in struct sigcontext. For portability all of the registers need
+ * to be stored in the space available in a portable jmp_buf so this code
+ * packs the register together.
+ */
+
+#define JB_MASK         (0*REGSZ)
+#define JB_PC           (1*REGSZ)
+#define JB_MAGIC        (2*REGSZ)
+#define JB_S0           (3*REGSZ)
+#define JB_S1           (4*REGSZ)
+#define JB_S2           (5*REGSZ)
+#define JB_S3           (6*REGSZ)
+#define JB_S4           (7*REGSZ)
+#define JB_S5           (8*REGSZ)
+#define JB_S6           (9*REGSZ)
+#define JB_S7           (10*REGSZ)
+#define JB_S8           (11*REGSZ)
+#define JB_GP           (12*REGSZ)
+#define JB_SP           (13*REGSZ)
+#define JB_SAVEMASK     (14*REGSZ)
+#define JB_FPUSED       (15*REGSZ)
+#define JB_FSR          (16*REGSZ)
+#define JB_FPBASE       (18*REGSZ)
+#define JB_F20          (JB_FPBASE+0*REGSZ_FP)
+#define JB_F21          (JB_FPBASE+1*REGSZ_FP)
+#define JB_F22          (JB_FPBASE+2*REGSZ_FP)
+#define JB_F23          (JB_FPBASE+3*REGSZ_FP)
+#define JB_F24          (JB_FPBASE+4*REGSZ_FP)
+#define JB_F25          (JB_FPBASE+5*REGSZ_FP)
+#define JB_F26          (JB_FPBASE+6*REGSZ_FP)
+#define JB_F27          (JB_FPBASE+7*REGSZ_FP)
+#define JB_F28          (JB_FPBASE+8*REGSZ_FP)
+#define JB_F29          (JB_FPBASE+9*REGSZ_FP)
+#define JB_F30          (JB_FPBASE+10*REGSZ_FP)
+#define JB_F31          (JB_FPBASE+11*REGSZ_FP)
+
+/* Use different magic numbers to avoid misuse of native vs portable contexts */
+#define MAGIC_SETJMP    0xACEDBEAD
+#define MAGIC__SETJMP   0xBEAD1CAB
+
+#endif /* _JBOFFSETS_H_ */
diff --git a/ndk/sources/android/libportable/arch-mips/mmap.c b/ndk/sources/android/libportable/arch-mips/mmap.c
index d165e2b..f2c3a1a 100644
--- a/ndk/sources/android/libportable/arch-mips/mmap.c
+++ b/ndk/sources/android/libportable/arch-mips/mmap.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <unistd.h>
 #include <errno.h>
 #include <sys/mman.h>
@@ -23,71 +24,106 @@
 #error Bad build environment
 #endif
 
-static inline int mips_change_prot(int prot)
+#define PORTABLE_TAG "mmap_portable"
+#include <log_portable.h>
+
+static inline int mmap_prot_pton(int portable_prot)
 {
+    int native_prot = portable_prot;
+
+    ALOGV("%s(portable_prot:0x%x) {", __func__, portable_prot);
+
     /* Only PROT_SEM is different */
-    if (prot & PROT_SEM_PORTABLE) {
-        prot &= ~PROT_SEM_PORTABLE;
-        prot |= PROT_SEM;
+    if (portable_prot & PROT_SEM_PORTABLE) {
+        native_prot &= ~PROT_SEM_PORTABLE;
+        native_prot |= PROT_SEM;
     }
 
-    return prot;
+    ALOGV("%s: return(native_prot:0x%x); }", __func__, native_prot);
+    return native_prot;
 }
 
-static inline int mips_change_flags(int flags)
+
+static inline int mmap_flags_pton(int portable_flags)
 {
-    int mipsflags = 0;
-    if (flags & MAP_SHARED_PORTABLE)
-       mipsflags |= MAP_SHARED;
-    if (flags & MAP_PRIVATE_PORTABLE)
-       mipsflags |= MAP_PRIVATE;
-    if (flags & MAP_FIXED_PORTABLE)
-       mipsflags |= MAP_FIXED;
-    if (flags & MAP_ANONYMOUS_PORTABLE)
-       mipsflags |= MAP_ANONYMOUS;
-    if (flags & MAP_GROWSDOWN_PORTABLE)
-       mipsflags |= MAP_GROWSDOWN;
-    if (flags & MAP_DENYWRITE_PORTABLE)
-       mipsflags |= MAP_DENYWRITE;
-    if (flags & MAP_EXECUTABLE_PORTABLE)
-       mipsflags |= MAP_EXECUTABLE;
-    if (flags & MAP_LOCKED_PORTABLE)
-       mipsflags |= MAP_LOCKED;
-    if (flags & MAP_NORESERVE_PORTABLE)
-       mipsflags |= MAP_NORESERVE;
-    if (flags & MAP_POPULATE_PORTABLE)
-       mipsflags |= MAP_POPULATE;
-    if (flags & MAP_NONBLOCK_PORTABLE)
-       mipsflags |= MAP_NONBLOCK;
+    int native_flags = 0;
 
-    return mipsflags;
-}
+    ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags);
 
-#define  MMAP2_SHIFT  12
-extern void *__mmap2(void *, size_t, int, int, int, size_t);
-void *mmap_portable(void *addr, size_t size, int prot, int flags, int fd, long offset)
-{
-    void *ret;
-    int mips_prot, mips_flags;
-
-    if (offset & ((1UL << MMAP2_SHIFT)-1)) {
-        errno = EINVAL;
-        return MAP_FAILED;
+    if (portable_flags & MAP_SHARED_PORTABLE) {
+       native_flags |= MAP_SHARED;
+    }
+    if (portable_flags & MAP_PRIVATE_PORTABLE) {
+       native_flags |= MAP_PRIVATE;
+    }
+    if (portable_flags & MAP_FIXED_PORTABLE) {
+       native_flags |= MAP_FIXED;
+    }
+    if (portable_flags & MAP_ANONYMOUS_PORTABLE) {
+       native_flags |= MAP_ANONYMOUS;
+    }
+    if (portable_flags & MAP_GROWSDOWN_PORTABLE) {
+       native_flags |= MAP_GROWSDOWN;
+    }
+    if (portable_flags & MAP_DENYWRITE_PORTABLE) {
+       native_flags |= MAP_DENYWRITE;
+    }
+    if (portable_flags & MAP_EXECUTABLE_PORTABLE) {
+       native_flags |= MAP_EXECUTABLE;
+    }
+    if (portable_flags & MAP_LOCKED_PORTABLE) {
+       native_flags |= MAP_LOCKED;
+    }
+    if (portable_flags & MAP_NORESERVE_PORTABLE) {
+       native_flags |= MAP_NORESERVE;
+    }
+    if (portable_flags & MAP_POPULATE_PORTABLE) {
+       native_flags |= MAP_POPULATE;
+    }
+    if (portable_flags & MAP_NONBLOCK_PORTABLE) {
+       native_flags |= MAP_NONBLOCK;
     }
 
-    mips_prot = mips_change_prot(prot);
-    mips_flags = mips_change_flags(flags);
-    ret = __mmap2(addr, size, mips_prot, mips_flags, fd,
-                  (size_t)offset >> MMAP2_SHIFT);
-
-    if (ret && (mips_flags & (MAP_PRIVATE | MAP_ANONYMOUS)))
-            madvise(ret, size, MADV_MERGEABLE);
-
-    return ret;
+    ALOGV("%s: return(native_flags:0x%x); }", __func__, native_flags);
+    return native_flags;
 }
 
-extern int    mprotect(const void *, size_t, int);
-int mprotect_portable(const void *addr, size_t size, int prot)
+extern void* REAL(mmap)(void *, size_t, int, int, int, off_t);
+void *WRAP(mmap)(void *addr, size_t size, int prot, int flags, int fd, long byte_offset)
 {
-    return mprotect(addr, size, mips_change_prot(prot));
+    int native_prot, native_flags;
+    int saved_errno;
+    void *ret_addr;
+
+    ALOGV(" ");
+    ALOGV("%s(addr:%p, size:%d, prot:0x%x, flags:0x%x, fd:%d, byte_offset:0x%lx) {", __func__,
+              addr,    size,    prot,      flags,      fd,    byte_offset);
+
+    native_prot = mmap_prot_pton(prot);
+    native_flags = mmap_flags_pton(flags);
+
+    ret_addr = REAL(mmap)(addr, size, native_prot, native_flags, fd, byte_offset);
+
+    ALOGV("%s: return(ret_addr:%p); }", __func__, ret_addr);
+    return ret_addr;
+}
+
+
+extern int mprotect(const void *, size_t, int);
+
+int WRAP(mprotect)(const void *addr, size_t size, int portable_prot)
+{
+    int rv;
+    int native_prot;
+
+    ALOGV(" ");
+    ALOGV("%s(addr:%p, size:%d, portable_prot:0x%x); {", __func__,
+              addr,    size,    portable_prot);
+
+    native_prot = mmap_prot_pton(portable_prot);
+
+    rv = REAL(mprotect)(addr, size, native_prot);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
 }
diff --git a/ndk/sources/android/libportable/arch-mips/open.c b/ndk/sources/android/libportable/arch-mips/open.c
index 2f4dcd7..99ed7f9 100644
--- a/ndk/sources/android/libportable/arch-mips/open.c
+++ b/ndk/sources/android/libportable/arch-mips/open.c
@@ -14,59 +14,78 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdarg.h>
+#include <portability.h>
 #include <fcntl_portable.h>
+#include <filefd_portable.h>
+
+#define PORTABLE_TAG "open_portable"
+#include <log_portable.h>
 
 
 #if O_CREAT_PORTABLE==O_CREAT
 #error Bad build environment
 #endif
 
-static inline int mips_change_flags(int flags)
+
+static inline int open_flags_pton(int flags)
 {
     int mipsflags = flags & O_ACCMODE_PORTABLE;
-    if (flags & O_CREAT_PORTABLE)
-	mipsflags |= O_CREAT;
-    if (flags & O_EXCL_PORTABLE)
-	mipsflags |= O_EXCL;
-    if (flags & O_NOCTTY_PORTABLE)
-	mipsflags |= O_NOCTTY;
-    if (flags & O_TRUNC_PORTABLE)
-	mipsflags |= O_TRUNC;
-    if (flags & O_APPEND_PORTABLE)
-	mipsflags |= O_APPEND;
-    if (flags & O_NONBLOCK_PORTABLE)
-	mipsflags |= O_NONBLOCK;
-    if (flags & O_SYNC_PORTABLE)
-	mipsflags |= O_SYNC;
-    if (flags & FASYNC_PORTABLE)
-	mipsflags |= FASYNC;
-    if (flags & O_DIRECT_PORTABLE)
-	mipsflags |= O_DIRECT;
-    if (flags & O_LARGEFILE_PORTABLE)
-	mipsflags |= O_LARGEFILE;
-    if (flags & O_DIRECTORY_PORTABLE)
-	mipsflags |= O_DIRECTORY;
-    if (flags & O_NOFOLLOW_PORTABLE)
-	mipsflags |= O_NOFOLLOW;
-    if (flags & O_NOATIME_PORTABLE)
-	mipsflags |= O_NOATIME;
-    if (flags & O_NDELAY_PORTABLE)
-	mipsflags |= O_NDELAY;
 
+    ALOGV("%s(flags:0x%x) {", __func__, flags);
+
+    if (flags & O_CREAT_PORTABLE)
+        mipsflags |= O_CREAT;
+    if (flags & O_EXCL_PORTABLE)
+        mipsflags |= O_EXCL;
+    if (flags & O_NOCTTY_PORTABLE)
+        mipsflags |= O_NOCTTY;
+    if (flags & O_TRUNC_PORTABLE)
+        mipsflags |= O_TRUNC;
+    if (flags & O_APPEND_PORTABLE)
+        mipsflags |= O_APPEND;
+    if (flags & O_NONBLOCK_PORTABLE)
+        mipsflags |= O_NONBLOCK;
+    if (flags & O_SYNC_PORTABLE)
+        mipsflags |= O_SYNC;
+    if (flags & FASYNC_PORTABLE)
+        mipsflags |= FASYNC;
+    if (flags & O_DIRECT_PORTABLE)
+        mipsflags |= O_DIRECT;
+    if (flags & O_LARGEFILE_PORTABLE)
+        mipsflags |= O_LARGEFILE;
+    if (flags & O_DIRECTORY_PORTABLE)
+        mipsflags |= O_DIRECTORY;
+    if (flags & O_NOFOLLOW_PORTABLE)
+        mipsflags |= O_NOFOLLOW;
+    if (flags & O_NOATIME_PORTABLE)
+        mipsflags |= O_NOATIME;
+    if (flags & O_NDELAY_PORTABLE)
+        mipsflags |= O_NDELAY;
+
+    ALOGV("%s: return(mipsflags:0x%x); }", __func__, mipsflags);
     return mipsflags;
 }
 
+
 extern int  __open(const char*, int, int);
-int open_portable(const char *pathname, int flags, ...)
+
+int WRAP(open)(const char *pathname, int flags, ...)
 {
     mode_t  mode = 0;
+    int native_flags;
+    int fd;
+
+    ALOGV(" ");
+    ALOGV("%s(pathname:%p, flags:0x%x, ...) {", __func__,
+              pathname,    flags);
+
     flags |= O_LARGEFILE_PORTABLE;
 
-    if (flags & O_CREAT_PORTABLE)
-    {
+    if (flags & O_CREAT_PORTABLE) {
         va_list  args;
 
         va_start(args, flags);
@@ -74,18 +93,40 @@
         va_end(args);
     }
 
-    return __open(pathname, mips_change_flags(flags), mode);
+    native_flags = open_flags_pton(flags);
+
+    fd = __open(pathname, native_flags, mode);
+    if (fd == -1) {
+        /* Can't print pathname as a string, might be bogus */
+        ALOGV("%s: fd = %d = __open(pathname:%p, native_flags:0x%x, mode:0x%x);", __func__,
+                   fd,              pathname,    native_flags,      mode);
+    } else {
+        if (flags & O_CLOEXEC) {
+            filefd_CLOEXEC_enabled(fd);
+        } else {
+            filefd_CLOEXEC_disabled(fd);
+        }
+    }
+    ALOGV("%s: return(fd:%d); }", __func__, fd);
+    return fd;
 }
 
+
 extern int  __openat(int, const char*, int, int);
-int openat_portable(int fd, const char *pathname, int flags, ...)
+
+int WRAP(openat)(int dirfd, const char *pathname, int flags, ...)
 {
     mode_t  mode = 0;
+    int native_flags;
+    int fd;
+
+    ALOGV(" ");
+    ALOGV("%s(dirfd:%d, pathname:0x%p, flags:0x%x, ...) {", __func__,
+              dirfd,    pathname,      flags);
 
     flags |= O_LARGEFILE_PORTABLE;
 
-    if (flags & O_CREAT_PORTABLE)
-    {
+    if (flags & O_CREAT_PORTABLE) {
         va_list  args;
 
         va_start(args, flags);
@@ -93,5 +134,20 @@
         va_end(args);
     }
 
-    return __openat(fd, pathname, mips_change_flags(flags), mode);
+    native_flags = open_flags_pton(flags);
+
+    fd = __openat(dirfd, pathname, native_flags, mode);
+
+    if (fd == -1) {
+        ALOGV("%s: fd = %d = __open(pathname:0x%p, native_flags:0x%x, mode:0x%d);", __func__,
+                   fd,              pathname,      native_flags,      mode);
+    } else {
+        if (flags & O_CLOEXEC) {
+            filefd_CLOEXEC_enabled(fd);
+        } else {
+            filefd_CLOEXEC_disabled(fd);
+        }
+    }
+    ALOGV("%s: return(fd:%d); }", __func__, fd);
+    return fd;
 }
diff --git a/ndk/sources/android/libportable/arch-mips/pipe.c b/ndk/sources/android/libportable/arch-mips/pipe.c
new file mode 100644
index 0000000..fa80266
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/pipe.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#define _GNU_SOURCE             /* GLibc compatibility to declare pipe2(2) */
+#include <portability.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <portability.h>
+#include <asm/unistd.h>
+#include <asm/unistd-portable.h>
+
+#include <fcntl_portable.h>
+#include <asm/unistd-portable.h>
+#include <asm/unistd.h>
+#include <filefd_portable.h>
+
+
+#define PORTABLE_TAG "pipe_portable"
+#include <log_portable.h>
+
+extern int syscall(int, ...);
+
+
+/* NOTE: LTP defaults to using O_NONBLOCK even if O_NONBLOCK is defined */
+
+
+/*
+ * Portable to Native event flags mapper.
+ */
+static inline int tdf_flags_pton(int portable_flags)
+{
+    int native_flags = 0;
+
+    ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags);
+
+    if (portable_flags & O_NONBLOCK_PORTABLE) {
+        native_flags |= O_NONBLOCK;
+    }
+
+    if (portable_flags & O_CLOEXEC_PORTABLE) {
+        native_flags |= O_CLOEXEC;
+    }
+
+    ALOGV("%s: return(native_flags:%d); }", __func__, native_flags);
+    return native_flags;
+}
+
+
+int WRAP(pipe2)(int pipefd[2], int portable_flags) {
+    int native_flags;
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(pipefd[2]:%p, portable_flags:0x%x) {", __func__,
+              pipefd,       portable_flags);
+
+    native_flags = tdf_flags_pton(portable_flags);
+
+    rv = REAL(pipe2)(pipefd, native_flags);
+    if (rv >= 0) {
+        ALOGV("%s: pipe2() returned pipefd[0]:%d, pipefd[1]:%d", __func__,
+                                    pipefd[0],    pipefd[1]);
+
+        if (native_flags & O_CLOEXEC) {
+            filefd_CLOEXEC_enabled(pipefd[0]);
+            filefd_CLOEXEC_enabled(pipefd[1]);
+        }
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/poll.c b/ndk/sources/android/libportable/arch-mips/poll.c
index 955c094..3f97176 100644
--- a/ndk/sources/android/libportable/arch-mips/poll.c
+++ b/ndk/sources/android/libportable/arch-mips/poll.c
@@ -14,9 +14,63 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <poll.h>
 #include <poll_portable.h>
 
+/*
+ *_XOPEN_SOURCE added the ability to not only poll for data coming in or out
+ * but now also the ability to poll for high priority input and output. Though
+ * the normal priority is equivalent to the original I/O it was assigned new bits:
+ *       POLLIN  Equivalent to POLLRDNORM
+ *       POLLOUT Equivalent to POLLWRNORM
+ *
+ * The Linux kernel sets both POLLIN and POLLRDNORM when data is available and sets
+ * both POLLOUT and POLLWRNORM when data can be written; so the new priority BAND bits
+ * just supplement the meaning of the prior POLLIN and POLLOUT bits as well as the
+ * new POLLRDNORM and POLLWRNORM bits.
+ *
+ * The DECNet Protocol can set the poll in  priority flag, POLLRDBAND.
+ * ATM as well as a whole bunch of other protocols can set the poll out priority flag,
+ * POLLWRBAND.
+ *
+ * MIPS and SPARC likely assigned the new XOPEN poll out event flags in UNIX well before
+ * UNIX was ported to X86.  It appears that Intel chose different bits and that was
+ * established by Linus as the the generic case and later also chosen by ARM.
+ *
+ *     POLLWRNORM:0x100 -  MIPS used POLLOUT:0x0004, which is equivalent in meaning.
+ *
+ *     POLLWRBAND:0x200 -  MIPS used 0x0100. which is POLLWRNORM:0x100.
+ *
+ * Summary:
+ * ========
+ *    Both Normal and Priority flags can be mapped to MIPS flags (left to right below).
+ *    Only the Priority poll out flag can be mapped back to portable because MIPS
+ *    is using the same number as POLLOUT for POLLWRNORM (right to left below).
+ *
+ *                    ARM/GENERIC/PORTABLE           MIPS
+ *                    ====================          ======
+ *      POLLIN          0x0001                      0x0001
+ *      POLLPRI         0x0002                      0x0002
+ *      POLLOUT         0x0004 <-----+              0x0004
+ *      POLLERR         0x0008        \             0x0008
+ *      POLLHUP         0x0010         \            0x0010
+ *      POLLNVAL        0x0020          \           0x0020
+ *      POLLRDNORM      0x0040           \          0x0040
+ *      POLLRDBAND      0x0080            \         0x0080
+ *      POLLWRNORM      0x0100  -----------+<---->  0x0004
+ *      POLLWRBAND      0x0200 <----------------->  0x0100
+ *      POLLMSG         0x0400                      0x0400
+ *      POLLREMOVE      0x1000                      0x1000
+ *      POLLRDHUP       0x2000                      0x2000
+ *
+ *  The loss of the high priority notice for the polling
+ *  of output data is likely minor as it was only being used
+ *  in DECNet. Also, the poll system call and device poll
+ *  implementations processes POLLOUT and POLLWRNORM event
+ *  flags the same.
+ */
+
 #if POLLWRNORM_PORTABLE==POLLWRNORM
 #error Bad build environment
 #endif
@@ -38,7 +92,10 @@
 
 static inline short change_mips_events(short mips_events)
 {
-    /* MIPS POLLWRNORM equals POLLOUT that is the same as POLLOUT_PORTABLE, so we just update POLLWRBNAD_PORTABLE. */
+    /*
+     * MIPS POLLWRNORM equals MIPS POLLOUT, which is the same as POLLOUT_PORTABLE;
+     * so we just map POLLWRBAND to POLLWRBAND_PORTABLE.
+     */
     if (mips_events & POLLWRBAND) {
         mips_events &= ~POLLWRBAND;
         mips_events |= POLLWRBAND_PORTABLE;
@@ -49,7 +106,7 @@
 
 extern int poll(struct pollfd *, nfds_t, long);
 
-int poll_portable(struct pollfd *fds, nfds_t nfds, long timeout)
+int WRAP(poll)(struct pollfd *fds, nfds_t nfds, long timeout)
 {
   nfds_t i;
   int ret;
@@ -57,7 +114,7 @@
   for (i = 0; i < nfds; i++)
       fds->events = mips_change_portable_events(fds->events);
 
-  ret = poll(fds, nfds, timeout);
+  ret = REAL(poll)(fds, nfds, timeout);
 
   for (i = 0; i < nfds; i++) {
       fds->events = change_mips_events(fds->events);
diff --git a/ndk/sources/android/libportable/arch-mips/pthread.c b/ndk/sources/android/libportable/arch-mips/pthread.c
new file mode 100644
index 0000000..41d9478
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/pthread.c
@@ -0,0 +1,314 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <pthread.h>
+#include <time.h>
+#include <signal.h>
+#include <signal_portable.h>
+#include <errno.h>
+#include <errno_portable.h>
+
+#define PORTABLE_TAG "pthread_portable"
+#include <log_portable.h>
+
+/*
+ * Macros for STRIP_PARENS() which is used below in PTHREAD_WRAPPER(); cpp magic from:
+ *      http://boost.2283326.n4.nabble.com/preprocessor-removing-parentheses-td2591973.html
+ */
+#define CAT(x, y) CAT_I(x, y)
+#define CAT_I(x, y) x ## y
+
+#define APPLY(macro, args) APPLY_I(macro, args)
+#define APPLY_I(macro, args) macro args
+
+#define STRIP_PARENS(x) EVAL((STRIP_PARENS_I x), x)
+#define STRIP_PARENS_I(...) 1,1
+
+#define EVAL(test, x) EVAL_I(test, x)
+#define EVAL_I(test, x) MAYBE_STRIP_PARENS(TEST_ARITY test, x)
+
+#define TEST_ARITY(...) APPLY(TEST_ARITY_I, (__VA_ARGS__, 2, 1))
+#define TEST_ARITY_I(a,b,c,...) c
+
+#define MAYBE_STRIP_PARENS(cond, x) MAYBE_STRIP_PARENS_I(cond, x)
+#define MAYBE_STRIP_PARENS_I(cond, x) CAT(MAYBE_STRIP_PARENS_, cond)(x)
+
+#define MAYBE_STRIP_PARENS_1(x) x
+#define MAYBE_STRIP_PARENS_2(x) APPLY(MAYBE_STRIP_PARENS_2_I, x)
+#define MAYBE_STRIP_PARENS_2_I(...) __VA_ARGS__
+
+/*
+ * Call pthread function and convert return value (a native errno) to portable error number.
+ */
+#define PTHREAD_WRAPPER(fn, DECLARGS, CALLARGS, fmt)            \
+    int WRAP(fn) DECLARGS                                       \
+    {                                                           \
+        int rv, portable_rv;                                    \
+                                                                \
+        ALOGV(" ");                                             \
+        ALOGV("%s" fmt, __func__, STRIP_PARENS(CALLARGS));      \
+        rv = REAL(fn) CALLARGS;                                 \
+        portable_rv = errno_ntop(rv);                           \
+        ALOGV("%s: return(portable_rv:%d); rv:%d;", __func__,   \
+                          portable_rv,     rv);                 \
+        return portable_rv;                                     \
+    }
+
+PTHREAD_WRAPPER(pthread_attr_init, (pthread_attr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_destroy, (pthread_attr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_setdetachstate, (pthread_attr_t *attr, int state), (attr, state),
+                "(attr:%p, state:%d)");
+
+PTHREAD_WRAPPER(pthread_attr_getdetachstate, (pthread_attr_t const *attr, int *state),
+                (attr, state), "(attr:%p, state:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), (attr, policy),
+                "(attr:%p, policy:%d)");
+
+PTHREAD_WRAPPER(pthread_attr_getschedpolicy, (pthread_attr_t const *attr, int *policy),
+                (attr, policy), "(attr:%p, policy:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_setschedparam,
+                (pthread_attr_t *attr, struct sched_param const *param), (attr, param),
+                "(attr:%p, param:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_getschedparam,
+                (pthread_attr_t const *attr, struct sched_param *param), (attr, param),
+                "(attr:%p, param:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_setstacksize, (pthread_attr_t *attr, size_t stack_size),
+                (attr, stack_size), "(attr:%p, stack_size:%d)");
+
+PTHREAD_WRAPPER(pthread_attr_getstacksize, (pthread_attr_t const *attr, size_t *stack_size),
+                (attr, stack_size), "(attr:%p, stack_size:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_setstack, (pthread_attr_t *attr, void *stackaddr, size_t stack_size),
+                (attr, stackaddr, stack_size), "(attr:%p, stackaddr:%p, stack_size:%d)");
+
+PTHREAD_WRAPPER(pthread_attr_getstack, (pthread_attr_t const *attr, void **stackaddr,
+                size_t *stack_size), (attr, stackaddr, stack_size),
+                "(attr:%p, stackaddr:%p stack_size:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_setguardsize, (pthread_attr_t *attr, size_t guard_size),
+                (attr, guard_size), "(attr:%p, guard_size:%d)");
+
+PTHREAD_WRAPPER(pthread_attr_getguardsize, (pthread_attr_t const *attr, size_t *guard_size),
+                (attr, guard_size), "(attr:%p, guard_size:%p)");
+
+PTHREAD_WRAPPER(pthread_attr_setscope, (pthread_attr_t *attr, int scope), (attr, scope),
+                "(attr:%p, scope:%d)");
+
+PTHREAD_WRAPPER(pthread_attr_getscope, (pthread_attr_t const *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_getattr_np, (pthread_t thid, pthread_attr_t *attr), (thid, attr),
+                "(thid:%lx, attr:%p)");
+
+PTHREAD_WRAPPER(pthread_create, (pthread_t *thread, const pthread_attr_t *attr,
+                void *(*start_routine) (void *), void *arg),
+                (thread, attr, start_routine, arg),
+                "(thread:%p attr:%p, start_routine:%p, arg:%p)");
+
+// void pthread_exit(void * retval);
+PTHREAD_WRAPPER(pthread_join, (pthread_t thid, void **ret_val), (thid, ret_val),
+                "(thid:%lx, ret_val:%p)");
+
+PTHREAD_WRAPPER(pthread_detach, (pthread_t thid), (thid), "(thid:%lx)");
+
+// pthread_t pthread_self(void);
+// int pthread_equal(pthread_t one, pthread_t two);
+
+PTHREAD_WRAPPER(pthread_getschedparam, (pthread_t thid, int *policy, struct sched_param *param),
+                (thid, policy, param), "(thid:%lx, policy:%p, param:%p)");
+
+PTHREAD_WRAPPER(pthread_setschedparam, (pthread_t thid, int policy,
+                struct sched_param const *param), (thid, policy, param),
+                "(thid:%lx, policy:%d, param:%p)");
+
+PTHREAD_WRAPPER(pthread_mutexattr_init, (pthread_mutexattr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_mutexattr_destroy, (pthread_mutexattr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_mutexattr_gettype, (const pthread_mutexattr_t *attr, int *type),
+                (attr, type), "(attr:%p, type:%p)");
+
+PTHREAD_WRAPPER(pthread_mutexattr_settype, (pthread_mutexattr_t *attr, int type), (attr, type),
+                "(attr:%p, type:%d)");
+
+PTHREAD_WRAPPER(pthread_mutexattr_setpshared, (pthread_mutexattr_t *attr, int pshared),
+                (attr, pshared), "(attr:%p, pshared:%d)");
+
+PTHREAD_WRAPPER(pthread_mutexattr_getpshared, (pthread_mutexattr_t *attr, int *pshared),
+                (attr, pshared), "(attr:%p, pshared:%p)");
+
+PTHREAD_WRAPPER(pthread_mutex_init, (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr),
+                (mutex, attr), "(mutex:%p, attr:%p)");
+
+PTHREAD_WRAPPER(pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)");
+
+PTHREAD_WRAPPER(pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)");
+
+PTHREAD_WRAPPER(pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)");
+
+PTHREAD_WRAPPER(pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), "(mutex:%p)");
+
+#if 0 /* MISSING FROM BIONIC */
+PTHREAD_WRAPPER(pthread_mutex_timedlock, (pthread_mutex_t *mutex, struct timespec *ts),
+                (mutex, ts), "(mutex:%p, ts:%p)");
+#endif /* MISSING */
+
+PTHREAD_WRAPPER(pthread_condattr_init, (pthread_condattr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_condattr_getpshared, (pthread_condattr_t *attr, int *pshared),
+                (attr, pshared), "(attr:%p, pshared:%p)");
+
+PTHREAD_WRAPPER(pthread_condattr_setpshared, (pthread_condattr_t* attr, int pshared),
+                (attr, pshared), "(attr:%p, pshared:%d)");
+
+PTHREAD_WRAPPER(pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_init, (pthread_cond_t *cond, const pthread_condattr_t *attr),
+                (cond, attr), "(cond:%p, attr:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_destroy, (pthread_cond_t *cond), (cond), "(cond:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_broadcast, (pthread_cond_t *cond), (cond), "(cond:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_signal, (pthread_cond_t *cond), (cond), "(cond:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
+                (cond, mutex), "(cond:%p, mutex:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_timedwait, (pthread_cond_t *cond, pthread_mutex_t *mutex,
+                const struct timespec *abstime), (cond, mutex, abstime),
+                "(cond:%p, mutex:%p, abstime:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_timedwait_monotonic_np, (pthread_cond_t *cond,
+                pthread_mutex_t *mutex, const struct timespec *abstime),
+                (cond, mutex, abstime), "(cond:%p, mutex:%p, abstime:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_timedwait_monotonic, (pthread_cond_t *cond, pthread_mutex_t
+                *mutex, const struct timespec *abstime),
+                (cond, mutex, abstime), "(cond:%p, mutex:%p, abstime:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_timedwait_relative_np, (pthread_cond_t *cond, pthread_mutex_t *mutex,
+                const struct timespec *reltime), (cond, mutex, reltime),
+                "(cond:%p, mutex:%p, reltime:%p)");
+
+PTHREAD_WRAPPER(pthread_cond_timeout_np, (pthread_cond_t *cond, pthread_mutex_t *mutex,
+                unsigned msecs), (cond, mutex, msecs), "(cond:%p, mutex:%p, msecs:%u)");
+
+PTHREAD_WRAPPER(pthread_mutex_lock_timeout_np, (pthread_mutex_t *mutex, unsigned msecs),
+                (mutex, msecs), "(mutex:%p, msecs:%u)");
+
+PTHREAD_WRAPPER(pthread_rwlockattr_init, (pthread_rwlockattr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *attr), (attr), "(attr:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlockattr_setpshared, (pthread_rwlockattr_t *attr, int  pshared),
+                (attr, pshared), "(attr:%p, pshared:%d)");
+
+PTHREAD_WRAPPER(pthread_rwlockattr_getpshared, (pthread_rwlockattr_t *attr, int *pshared),
+                (attr, pshared), "(attr:%p, pshared:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_init, (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr),
+                (rwlock, attr), "(rwlock:%p, attr:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_destroy, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_rdlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_tryrdlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_timedrdlock, (pthread_rwlock_t *rwlock,
+                const struct timespec *abs_timeout),
+                (rwlock, abs_timeout), "(rwlock:%p, abs_timeout:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_wrlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_trywrlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_timedwrlock, (pthread_rwlock_t *rwlock,
+                const struct timespec *abs_timeout), (rwlock, abs_timeout),
+                "(rwlock:%p, abs_timeout:%p)");
+
+PTHREAD_WRAPPER(pthread_rwlock_unlock, (pthread_rwlock_t *rwlock), (rwlock), "(rwlock:%p)");
+
+PTHREAD_WRAPPER(pthread_key_create, (pthread_key_t *key, void (*destructor_function)(void *)),
+                (key, destructor_function), "(key:%p, destructor_function:%p)");
+
+PTHREAD_WRAPPER(pthread_key_delete , (pthread_key_t key), (key), "(key:%x)");
+
+PTHREAD_WRAPPER(pthread_setspecific, (pthread_key_t key, const void *value), (key, value),
+                "(key:%x, value:%p)");
+
+// void *pthread_getspecific(pthread_key_t key);
+
+int WRAP(pthread_kill)(pthread_t thread, int portable_signum)
+{
+    char *portable_signame = map_portable_signum_to_name(portable_signum);
+    int mips_signum;
+    int portable_ret, ret;
+
+    ALOGV("%s(thread:%lx, portable_signum:%d)", __func__, thread, portable_signum);
+
+    mips_signum = signum_pton(portable_signum);
+
+    if ((portable_signum != 0) && (mips_signum == 0)) {
+        /* A signal MIPS doesn't support; all we can do is ignore it. */
+        ret = 0;
+    } else {
+        ALOGV("%s: calling pthread_kill(thread:%lx, mips_signum:%d);", __func__,
+                                        thread,     mips_signum);
+        ret = REAL(pthread_kill)(thread, mips_signum);
+    }
+    portable_ret = errno_ntop(ret);
+
+    ALOGV("%s: return portable_ret:%d; ret:%d;", __func__,
+                      portable_ret,    ret);
+
+    return portable_ret;
+}
+
+int WRAP(pthread_sigmask)(int portable_how, const sigset_portable_t *portable_sigset,
+                             sigset_portable_t *portable_oldset)
+{
+    int portable_ret, ret;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_how:%d portable_sigset:%p, portable_oldset:%p)", __func__,
+              portable_how,   portable_sigset,    portable_oldset);
+
+    ret = do_sigmask(portable_how, portable_sigset, portable_oldset, pthread_sigmask, NULL);
+
+    portable_ret = errno_ntop(ret);
+
+    ALOGV("%s: return portable_ret:%d; ret:%d;", __func__,
+                      portable_ret,    ret);
+
+    return portable_ret;
+}
+
+PTHREAD_WRAPPER(pthread_getcpuclockid, (pthread_t tid, clockid_t *clockid), (tid, clockid),
+                "(tid:%lx, clockid:%p)");
+
+PTHREAD_WRAPPER(pthread_once, (pthread_once_t *once_control, void (*init_routine)(void)),
+                (once_control, init_routine), "(once_control:%p, init_routine:%p)");
+
+PTHREAD_WRAPPER(pthread_setname_np, (pthread_t thid, const char *thname), (thid, thname),
+                "(thid:%lx, thname:\"%s\")");
diff --git a/ndk/sources/android/libportable/arch-mips/resource.c b/ndk/sources/android/libportable/arch-mips/resource.c
index 4119e79..91b473d 100644
--- a/ndk/sources/android/libportable/arch-mips/resource.c
+++ b/ndk/sources/android/libportable/arch-mips/resource.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <sys/resource.h>
 #include <resource_portable.h>
 
@@ -38,14 +39,14 @@
     return resource;
 }
 
-extern int getrlimit(int resource, struct rlimit *rlp);
-int getrlimit_portable(int resource, struct rlimit *rlp)
+extern int REAL(getrlimit)(int resource, struct rlimit *rlp);
+int WRAP(getrlimit)(int resource, struct rlimit *rlp)
 {
-    return getrlimit(mips_change_resource(resource), rlp);
+    return REAL(getrlimit)(mips_change_resource(resource), rlp);
 }
 
-extern int setrlimit(int resource, const struct rlimit *rlp);
-int setrlimit_portable(int resource, const struct rlimit *rlp)
+extern int REAL(setrlimit)(int resource, const struct rlimit *rlp);
+int WRAP(setrlimit)(int resource, const struct rlimit *rlp)
 {
-    return setrlimit(mips_change_resource(resource), rlp);
+    return REAL(setrlimit)(mips_change_resource(resource), rlp);
 }
diff --git a/ndk/sources/android/libportable/arch-mips/setjmp.S b/ndk/sources/android/libportable/arch-mips/setjmp.S
new file mode 100644
index 0000000..1532972
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/setjmp.S
@@ -0,0 +1,218 @@
+/* Derived from: $OpenBSD: setjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
+
+/*
+ * Copyright (c) 2001-2002 Opsycon AB  (www.opsycon.se / www.opsycon.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Opsycon AB nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <asm-generic/portability.h>
+#include <machine/asm.h>
+#include <machine/regnum.h>
+
+#include "jboffsets.h"
+
+/*
+ * setjmp, longjmp implementation for libc.
+ */
+
+FRAMESZ= MKFSIZ(2,6)
+A1OFF= FRAMESZ-4*REGSZ
+A0OFF= FRAMESZ-3*REGSZ
+GPOFF= FRAMESZ-2*REGSZ
+RAOFF= FRAMESZ-1*REGSZ
+
+#define FPREG64_S(FPR, OFF, BASE)       \
+        swc1    FPR, OFF(BASE)  ;       \
+        mfhc1   t0, FPR         ;       \
+        sw      t0, OFF+4(BASE) ;
+
+#define FPREG64_L(FPR, OFF, BASE)       \
+        lw      t0, OFF+4(BASE) ;       \
+        lw      t1, OFF(BASE)   ;       \
+        mtc1    t1, FPR         ;       \
+        mthc1   t0, FPR         ;       \
+
+
+
+NON_LEAF(WRAP(setjmp), FRAMESZ, ra)
+        .mask   0x80000000, RAOFF
+        PTR_SUBU sp, FRAMESZ                    # allocate stack frame
+        SETUP_GP64(GPOFF, WRAP(setjmp))
+        SAVE_GP(GPOFF)
+        .set    reorder
+        REG_S   ra, RAOFF(sp)                   # save state
+        REG_S   a0, A0OFF(sp)
+
+        move    a0, zero                        # get current signal mask
+        jal     sigblock
+
+        REG_L   v1, A0OFF(sp)                   # v1 = jmpbuf
+        REG_S   v0, JB_MASK(v1)                 # save sc_mask = sigblock(0)
+
+        REG_L   a0, A0OFF(sp)                   # restore jmpbuf
+        REG_L   ra, RAOFF(sp)
+        REG_S   ra, JB_PC(a0)                   # sc_pc = return address
+#if defined(__mips64)
+        dli     v0, MAGIC_SETJMP
+#else
+        li      v0, MAGIC_SETJMP
+#endif
+        REG_S   v0, JB_MAGIC(a0)
+        REG_S   s0, JB_S0(a0)
+        REG_S   s1, JB_S1(a0)
+        REG_S   s2, JB_S2(a0)
+        REG_S   s3, JB_S3(a0)
+        REG_S   s4, JB_S4(a0)
+        REG_S   s5, JB_S5(a0)
+        REG_S   s6, JB_S6(a0)
+        REG_S   s7, JB_S7(a0)
+        REG_S   s8, JB_S8(a0)
+        REG_L   v0, GPOFF(sp)
+        REG_S   v0, JB_GP(a0)
+        PTR_ADDU v0, sp, FRAMESZ
+        REG_S   v0, JB_SP(a0)
+
+#if !defined(SOFTFLOAT)
+        /*
+         * Would be nice if we could tell if the FP registers are currently being used.
+         * Assume they are, and use pointer to jmp_buf in a0 to save FP registers and the
+         * jmp_buf.fpused flag.
+         */
+        li      v0, 1                           # v0 = 1
+        REG_S   v0, JB_FPUSED(a0)               # a0->jb_fpused = v0:1
+        cfc1    v0, $31
+#if _MIPS_FPSET == 32
+        FPREG64_S($f20, JB_F20, a0)
+        FPREG64_S($f21, JB_F21, a0)
+        FPREG64_S($f22, JB_F22, a0)
+        FPREG64_S($f23, JB_F23, a0)
+        FPREG64_S($f24, JB_F24, a0)
+        FPREG64_S($f25, JB_F25, a0)
+        FPREG64_S($f26, JB_F26, a0)
+        FPREG64_S($f27, JB_F27, a0)
+        FPREG64_S($f28, JB_F28, a0)
+        FPREG64_S($f29, JB_F29, a0)
+        FPREG64_S($f30, JB_F30, a0)
+        FPREG64_S($f31, JB_F31, a0)
+#else
+        swc1    $f20, JB_F20(a0)
+        swc1    $f21, JB_F21(a0)
+        swc1    $f22, JB_F22(a0)
+        swc1    $f23, JB_F23(a0)
+        swc1    $f24, JB_F24(a0)
+        swc1    $f25, JB_F25(a0)
+        swc1    $f26, JB_F26(a0)
+        swc1    $f27, JB_F27(a0)
+        swc1    $f28, JB_F28(a0)
+        swc1    $f29, JB_F29(a0)
+        swc1    $f30, JB_F30(a0)
+        swc1    $f31, JB_F31(a0)
+#endif
+        REG_S   v0, JB_FSR(a0)
+#endif /* !SOFTFLOAT */
+        move    v0, zero
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+        j       ra
+
+botch:
+        jal     longjmperror
+        jal     abort
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+END(WRAP(setjmp))
+
+
+LEAF(WRAP(longjmp), FRAMESZ)
+        PTR_SUBU sp, FRAMESZ
+        SETUP_GP64(GPOFF, WRAP(longjmp))
+        SAVE_GP(GPOFF)
+        .set    reorder
+        sw      a1, A1OFF(sp)
+        sw      a0, A0OFF(sp)
+
+        lw      a0, JB_MASK(a0)
+        jal     sigsetmask
+
+        lw      a0, A0OFF(sp)
+        lw      a1, A1OFF(sp)
+
+        .set    noreorder
+        REG_L   v0, JB_MAGIC(a0)
+        bne     v0, MAGIC_SETJMP, botch         # jump if error
+        REG_L   ra, JB_PC(a0)
+        REG_L   s0, JB_S0(a0)
+        REG_L   s1, JB_S1(a0)
+        REG_L   s2, JB_S2(a0)
+        REG_L   s3, JB_S3(a0)
+        REG_L   s4, JB_S4(a0)
+        REG_L   s5, JB_S5(a0)
+        REG_L   s6, JB_S6(a0)
+        REG_L   s7, JB_S7(a0)
+        REG_L   s8, JB_S8(a0)
+        REG_L   gp, JB_GP(a0)
+        REG_L   sp, JB_SP(a0)
+
+#if !defined(SOFTFLOAT)
+        REG_L   v0, JB_FSR(a0)
+        ctc1    v0, $31
+#if _MIPS_FPSET == 32
+        FPREG64_L($f20, JB_F20, a0)
+        FPREG64_L($f21, JB_F21, a0)
+        FPREG64_L($f22, JB_F22, a0)
+        FPREG64_L($f23, JB_F23, a0)
+        FPREG64_L($f24, JB_F24, a0)
+        FPREG64_L($f25, JB_F25, a0)
+        FPREG64_L($f26, JB_F26, a0)
+        FPREG64_L($f27, JB_F27, a0)
+        FPREG64_L($f28, JB_F28, a0)
+        FPREG64_L($f29, JB_F29, a0)
+        FPREG64_L($f30, JB_F30, a0)
+        FPREG64_L($f31, JB_F31, a0)
+#else
+        lwc1    $f20, JB_F20(a0)
+        lwc1    $f21, JB_F21(a0)
+        lwc1    $f22, JB_F22(a0)
+        lwc1    $f23, JB_F23(a0)
+        lwc1    $f24, JB_F24(a0)
+        lwc1    $f25, JB_F25(a0)
+        lwc1    $f26, JB_F26(a0)
+        lwc1    $f27, JB_F27(a0)
+        lwc1    $f28, JB_F28(a0)
+        lwc1    $f29, JB_F29(a0)
+        lwc1    $f30, JB_F30(a0)
+        lwc1    $f31, JB_F31(a0)
+#endif
+#endif /* !SOFTFLOAT */
+        bne     a1, zero, 1f
+         nop
+        li      a1, 1                   # never return 0!
+1:
+        j       ra
+         move   v0, a1
+
+END(WRAP(longjmp))
diff --git a/ndk/sources/android/libportable/arch-mips/signal.c b/ndk/sources/android/libportable/arch-mips/signal.c
new file mode 100644
index 0000000..4d2d258
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/signal.c
@@ -0,0 +1,1772 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <signal_portable.h>
+#include <portability.h>
+#include <stdio.h>
+#include <errno.h>
+#include <errno_portable.h>
+#include <asm/unistd-portable.h>
+#include <asm/unistd.h>
+#include <signalfd_portable.h>
+#include <filefd_portable.h>
+
+#define PORTABLE_TAG "signal_portable"
+#include <log_portable.h>
+
+
+#if SIGBUS_PORTABLE == SIGBUS
+#error Bad build environment
+#endif
+
+typedef void  (*sig3handler_t)(int, siginfo_t *, void *);
+
+static volatile int signal_handler_mapping_enabled = 1;
+
+extern int syscall(int, ...);
+
+
+__hidden void signal_disable_mapping()
+{
+    ALOGV("%s(): signal_handler_mapping_enabled:%d = 0;", __func__,
+                 signal_handler_mapping_enabled);
+
+    signal_handler_mapping_enabled = 0;
+}
+
+
+/*
+ * The next five hidden functions are not exposed in the
+ * libportable shared object. They are used here and other
+ * functions, like waitpid(), which need to map signal numbers.
+ */
+__hidden char *map_portable_signum_to_name(int portable_signum)
+{
+    char *name;
+
+    switch(portable_signum) {
+    case SIGHUP_PORTABLE:       name = "SIGHUP_PORTABLE:1";             break;
+    case SIGINT_PORTABLE:       name = "SIGINT_PORTABLE:2";             break;
+    case SIGQUIT_PORTABLE:      name = "SIGQUIT_PORTABLE:3";            break;
+    case SIGILL_PORTABLE:       name = "SIGILL_PORTABLE:4";             break;
+    case SIGTRAP_PORTABLE:      name = "SIGTRAP_PORTABLE:5";            break;
+    case SIGABRT_PORTABLE:      name = "SIGABRT_PORTABLE:6";            break;
+    case SIGBUS_PORTABLE:       name = "SIGBUS_PORTABLE:7";             break;
+    case SIGFPE_PORTABLE:       name = "SIGFPE_PORTABLE:8";             break;
+    case SIGKILL_PORTABLE:      name = "SIGKILL_PORTABLE:9";            break;
+    case SIGUSR1_PORTABLE:      name = "SIGUSR1_PORTABLE:10";           break;
+    case SIGSEGV_PORTABLE:      name = "SIGSEGV_PORTABLE:11";           break;
+    case SIGUSR2_PORTABLE:      name = "SIGUSR2_PORTABLE:12";           break;
+    case SIGPIPE_PORTABLE:      name = "SIGPIPE_PORTABLE:13";           break;
+    case SIGALRM_PORTABLE:      name = "SIGALRM_PORTABLE:14";           break;
+    case SIGTERM_PORTABLE:      name = "SIGTERM_PORTABLE:15";           break;
+    case SIGSTKFLT_PORTABLE:    name = "SIGSTKFLT_PORTABLE:16";         break;
+    case SIGCHLD_PORTABLE:      name = "SIGCHLD_PORTABLE:17";           break;
+    case SIGCONT_PORTABLE:      name = "SIGCONT_PORTABLE:18";           break;
+    case SIGSTOP_PORTABLE:      name = "SIGSTOP_PORTABLE:19";           break;
+    case SIGTSTP_PORTABLE:      name = "SIGTSTP_PORTABLE:20";           break;
+    case SIGTTIN_PORTABLE:      name = "SIGTTIN_PORTABLE:21";           break;
+    case SIGTTOU_PORTABLE:      name = "SIGTTOU_PORTABLE:22";           break;
+    case SIGURG_PORTABLE:       name = "SIGURG_PORTABLE:23";            break;
+    case SIGXCPU_PORTABLE:      name = "SIGXCPU_PORTABLE:24";           break;
+    case SIGXFSZ_PORTABLE:      name = "SIGXFSZ_PORTABLE:25";           break;
+    case SIGVTALRM_PORTABLE:    name = "SIGVTALRM_PORTABLE:26";         break;
+    case SIGPROF_PORTABLE:      name = "SIGPROF_PORTABLE:27";           break;
+    case SIGWINCH_PORTABLE:     name = "SIGWINCH_PORTABLE:28";          break;
+    case SIGIO_PORTABLE:        name = "SIGIO_PORTABLE:29";             break;
+    case SIGPWR_PORTABLE:       name = "SIGPWR_PORTABLE:30";            break;
+    case SIGSYS_PORTABLE:       name = "SIGSYS_PORTABLE:31";            break;
+    case SIGRTMIN_PORTABLE:     name = "SIGRTMIN_PORTABLE:32";          break;
+
+    case SIGRT_1_PORTABLE:      name = "SIGRT_1_PORTABLE:33";           break;
+    case SIGRT_2_PORTABLE:      name = "SIGRT_2_PORTABLE:34";           break;
+    case SIGRT_3_PORTABLE:      name = "SIGRT_3_PORTABLE:35";           break;
+    case SIGRT_4_PORTABLE:      name = "SIGRT_4_PORTABLE:36";           break;
+    case SIGRT_5_PORTABLE:      name = "SIGRT_5_PORTABLE:37";           break;
+    case SIGRT_6_PORTABLE:      name = "SIGRT_6_PORTABLE:38";           break;
+    case SIGRT_7_PORTABLE:      name = "SIGRT_7_PORTABLE:39";           break;
+    case SIGRT_8_PORTABLE:      name = "SIGRT_8_PORTABLE:40";           break;
+    case SIGRT_9_PORTABLE:      name = "SIGRT_9_PORTABLE:41";           break;
+    case SIGRT_10_PORTABLE:     name = "SIGRT_10_PORTABLE:42";          break;
+    case SIGRT_11_PORTABLE:     name = "SIGRT_11_PORTABLE:43";          break;
+    case SIGRT_12_PORTABLE:     name = "SIGRT_12_PORTABLE:44";          break;
+    case SIGRT_13_PORTABLE:     name = "SIGRT_13_PORTABLE:45";          break;
+    case SIGRT_14_PORTABLE:     name = "SIGRT_14_PORTABLE:46";          break;
+    case SIGRT_15_PORTABLE:     name = "SIGRT_15_PORTABLE:47";          break;
+    case SIGRT_16_PORTABLE:     name = "SIGRT_16_PORTABLE:48";          break;
+    case SIGRT_17_PORTABLE:     name = "SIGRT_17_PORTABLE:49";          break;
+    case SIGRT_18_PORTABLE:     name = "SIGRT_18_PORTABLE:50";          break;
+    case SIGRT_19_PORTABLE:     name = "SIGRT_19_PORTABLE:51";          break;
+    case SIGRT_20_PORTABLE:     name = "SIGRT_20_PORTABLE:52";          break;
+    case SIGRT_21_PORTABLE:     name = "SIGRT_21_PORTABLE:53";          break;
+    case SIGRT_22_PORTABLE:     name = "SIGRT_22_PORTABLE:54";          break;
+    case SIGRT_23_PORTABLE:     name = "SIGRT_23_PORTABLE:55";          break;
+    case SIGRT_24_PORTABLE:     name = "SIGRT_24_PORTABLE:56";          break;
+    case SIGRT_25_PORTABLE:     name = "SIGRT_25_PORTABLE:57";          break;
+    case SIGRT_26_PORTABLE:     name = "SIGRT_26_PORTABLE:58";          break;
+    case SIGRT_27_PORTABLE:     name = "SIGRT_27_PORTABLE:59";          break;
+    case SIGRT_28_PORTABLE:     name = "SIGRT_28_PORTABLE:60";          break;
+    case SIGRT_29_PORTABLE:     name = "SIGRT_29_PORTABLE:61";          break;
+    case SIGRT_30_PORTABLE:     name = "SIGRT_30_PORTABLE:62";          break;
+    case SIGRT_31_PORTABLE:     name = "SIGRT_31_PORTABLE:63";          break;
+    case SIGRTMAX_PORTABLE:     name = "SIGRTMAX_PORTABLE:64";          break;
+
+    default:                    name = "<<UNKNOWN>>";                   break;
+    }
+    return name;
+}
+
+
+__hidden char *map_mips_signum_to_name(int mips_signum)
+{
+    char *name;
+
+    switch(mips_signum) {
+    case SIGHUP:        name = "SIGHUP:1";      break;
+    case SIGINT:        name = "SIGINT:2";      break;
+    case SIGQUIT:       name = "SIGQUIT:3";     break;
+    case SIGILL:        name = "SIGILL:4";      break;
+    case SIGTRAP:       name = "SIGTRAP:5";     break;
+    case SIGIOT:        name = "SIGIOT:6";      break;
+    case SIGEMT:        name = "SIGEMT:7";      break;
+    case SIGFPE:        name = "SIGFPE:8";      break;
+    case SIGKILL:       name = "SIGKILL:9";     break;
+    case SIGBUS:        name = "SIGBUS:10";     break;
+    case SIGSEGV:       name = "SIGSEGV:11";    break;
+    case SIGSYS:        name = "SIGSYS:12";     break;
+    case SIGPIPE:       name = "SIGPIPE:13";    break;
+    case SIGALRM:       name = "SIGALRM:14";    break;
+    case SIGTERM:       name = "SIGTERM:15";    break;
+    case SIGUSR1:       name = "SIGUSR1:16";    break;
+    case SIGUSR2:       name = "SIGUSR2:17";    break;
+    case SIGCHLD:       name = "SIGCHLD:18";    break;
+    case SIGPWR:        name = "SIGPWR:19";     break;
+    case SIGWINCH:      name = "SIGWINCH:20";   break;
+    case SIGURG:        name = "SIGURG:21";     break;
+    case SIGIO:         name = "SIGIO:22";      break;
+    case SIGSTOP:       name = "SIGSTOP:23";    break;
+    case SIGTSTP:       name = "SIGTSTP:24";    break;
+    case SIGCONT:       name = "SIGCONT:25";    break;
+    case SIGTTIN:       name = "SIGTTIN:26";    break;
+    case SIGTTOU:       name = "SIGTTOU:27";    break;
+    case SIGVTALRM:     name = "SIGVTALRM:28";  break;
+    case SIGPROF:       name = "SIGPROF:29";    break;
+    case SIGXCPU:       name = "SIGXCPU:30";    break;
+    case SIGXFSZ:       name = "SIGXFSZ:31";    break;
+
+    case SIGRTMIN:      name = "SIGRTMIN:32";   break;
+    case SIGRT_1:       name = "SIGRT_1:33";    break;
+    case SIGRT_2:       name = "SIGRT_2:34";    break;
+    case SIGRT_3:       name = "SIGRT_3:35";    break;
+    case SIGRT_4:       name = "SIGRT_4:36";    break;
+    case SIGRT_5:       name = "SIGRT_5:37";    break;
+    case SIGRT_6:       name = "SIGRT_6:38";    break;
+    case SIGRT_7:       name = "SIGRT_7:39";    break;
+    case SIGRT_8:       name = "SIGRT_8:40";    break;
+    case SIGRT_9:       name = "SIGRT_9:41";    break;
+    case SIGRT_10:      name = "SIGRT_10:42";   break;
+    case SIGRT_11:      name = "SIGRT_11:43";   break;
+    case SIGRT_12:      name = "SIGRT_12:44";   break;
+    case SIGRT_13:      name = "SIGRT_13:45";   break;
+    case SIGRT_14:      name = "SIGRT_14:46";   break;
+    case SIGRT_15:      name = "SIGRT_15:47";   break;
+    case SIGRT_16:      name = "SIGRT_16:48";   break;
+    case SIGRT_17:      name = "SIGRT_17:49";   break;
+    case SIGRT_18:      name = "SIGRT_18:50";   break;
+    case SIGRT_19:      name = "SIGRT_19:51";   break;
+    case SIGRT_20:      name = "SIGRT_20:52";   break;
+    case SIGRT_21:      name = "SIGRT_21:53";   break;
+    case SIGRT_22:      name = "SIGRT_22:54";   break;
+    case SIGRT_23:      name = "SIGRT_23:55";   break;
+    case SIGRT_24:      name = "SIGRT_24:56";   break;
+    case SIGRT_25:      name = "SIGRT_25:57";   break;
+    case SIGRT_26:      name = "SIGRT_26:58";   break;
+    case SIGRT_27:      name = "SIGRT_27:59";   break;
+    case SIGRT_28:      name = "SIGRT_28:60";   break;
+    case SIGRT_29:      name = "SIGRT_29:61";   break;
+    case SIGRT_30:      name = "SIGRT_30:62";   break;
+    case SIGRT_31:      name = "SIGRT_31:63";   break;
+    case SIGRT_32:      name = "SIGRT_32:64";   break;
+
+    /* NOTE: SIGRT_33...SIGRTMAX-1 Not printed */
+
+    case SIGRTMAX:      name = "SIGRTMAX:128";  break;
+    default:            name = "<<UNKNOWN>>";   break;
+    }
+    return name;
+}
+
+
+/*
+ * Maps a signal number from portable to native.
+ */
+__hidden int signum_pton(int portable_signum)
+{
+    int mips_signum = -1;
+
+    switch(portable_signum) {
+    case SIGHUP_PORTABLE:               /* 1 */
+        return SIGHUP;
+
+    case SIGINT_PORTABLE:               /* 2 */
+        return SIGINT;
+
+    case SIGQUIT_PORTABLE:              /* 3 */
+        return SIGQUIT;
+
+    case SIGILL_PORTABLE:               /* 4 */
+        return SIGILL;
+
+    case SIGTRAP_PORTABLE:              /* 5 */
+        return SIGTRAP;
+
+    case SIGABRT_PORTABLE:              /* 6 */
+        return SIGABRT;
+
+    case SIGBUS_PORTABLE:               /* 7 --> 10 */
+        return SIGBUS;
+
+    case SIGFPE_PORTABLE:               /* 8 */
+        return SIGFPE;
+
+    case SIGKILL_PORTABLE:              /* 9 */
+        return SIGKILL;
+
+    case SIGUSR1_PORTABLE:              /* 10 --> 16 */
+        return SIGUSR1;
+
+    case SIGSEGV_PORTABLE:              /* 11 */
+        return SIGSEGV;
+
+    case SIGUSR2_PORTABLE:              /* 12 --> 17 */
+        return SIGUSR2;
+
+    case SIGPIPE_PORTABLE:              /* 13 */
+        return SIGPIPE;
+
+    case SIGALRM_PORTABLE:              /* 14 */
+        return SIGALRM;
+
+    case SIGTERM_PORTABLE:              /* 15 */
+        return SIGTERM;
+
+    case SIGSTKFLT_PORTABLE:            /* 16 --> 7 */
+        return SIGEMT;                  /* No native SIGSTKFLT exist  ...
+                                           ... mapping it to SIGEMT. */
+
+    case SIGCHLD_PORTABLE:              /* 17 --> 18 */
+        return SIGCHLD;
+
+    case SIGCONT_PORTABLE:              /* 18 --> 25 */
+        return SIGCONT;
+
+    case SIGSTOP_PORTABLE:              /* 19 --> 23 */
+        return SIGSTOP;
+
+    case SIGTSTP_PORTABLE:              /* 20 --> 24 */
+        return SIGTSTP;
+
+    case SIGTTIN_PORTABLE:              /* 21 --> 26 */
+        return SIGTTIN;
+
+    case SIGTTOU_PORTABLE:              /* 22 --> 27 */
+        return SIGTTOU;
+
+    case SIGURG_PORTABLE:               /* 23 --> 21 */
+        return SIGURG;
+
+    case SIGXCPU_PORTABLE:              /* 24 --> 30 */
+        return SIGXCPU;
+
+    case SIGXFSZ_PORTABLE:              /* 25 --> 31 */
+        return SIGXFSZ;
+
+    case SIGVTALRM_PORTABLE:            /* 26 --> 28 */
+        return SIGVTALRM;
+
+    case SIGPROF_PORTABLE:              /* 27 --> 29 */
+        return SIGPROF;
+
+    case SIGWINCH_PORTABLE:             /* 28 --> 20 */
+        return SIGWINCH;
+
+    case SIGIO_PORTABLE:                /* 29 --> 22 */
+        return SIGIO;
+
+    case SIGPWR_PORTABLE:               /* 30 --> 19 */
+        return SIGPWR;
+
+    case SIGSYS_PORTABLE:               /* 31 --> 12 */
+        return SIGSYS;
+    /*
+     * Mapping lower 32 Real Time signals to identical Native signal numbers.
+     * NOTE: SIGRTMAX_PORTABLE == 64 but SIGRTMAX == 128.
+     */
+    case SIGRTMIN_PORTABLE...SIGRTMAX_PORTABLE:         /* 32 ... 64 */
+        ASSERT(SIGRTMIN_PORTABLE == SIGRTMIN);
+        ASSERT(SIGRTMAX_PORTABLE <= SIGRTMAX);
+        return portable_signum;
+
+    default:
+        ALOGE("%s: switch default: NOTE portable_signum:%d Not supported. Just a Test?",
+              __func__,                 portable_signum);
+        /*
+         * User could be LTP testing with bogus signal numbers,
+         * if so we mimic the test.
+         *
+         * If the signal is just outside the PORTABLE range
+         * we use a signal just outside the Native/MIPS range.
+         */
+        if (portable_signum < 0) {
+            mips_signum = portable_signum;
+        } else if (portable_signum > NSIG_PORTABLE) {
+            mips_signum = (portable_signum - NSIG_PORTABLE) +  NSIG;
+        } else {
+            ALOGE("%s: 0 <= portable_signum:%d <= NSIG_PORTABLE:%d; Not supported, return(0);",
+                  __func__, portable_signum,      NSIG_PORTABLE);
+
+            mips_signum = 0;
+        }
+        break;
+    }
+    ALOGV("%s(portable_signum:%d): return(mips_signum:%d);", __func__,
+              portable_signum,            mips_signum);
+
+    return mips_signum;
+}
+
+
+/*
+ * Maps a signal number from native to portable.
+ */
+__hidden int signum_ntop(int mips_signum)
+{
+    int portable_ssignum = -1;
+
+    switch(mips_signum) {
+    case SIGHUP:                        /* 1 */
+        return SIGHUP_PORTABLE;
+
+    case SIGINT:                        /* 2 */
+        return SIGINT_PORTABLE;
+
+    case SIGQUIT:                       /* 3 */
+        return SIGQUIT_PORTABLE;
+
+    case SIGILL:                        /* 4 */
+        return SIGILL_PORTABLE;
+
+    case SIGTRAP:                       /* 5 */
+        return SIGTRAP_PORTABLE;
+
+    case SIGABRT:                       /* 6 */
+        return SIGABRT_PORTABLE;
+
+    case SIGBUS:                        /* 7 <-- 10 */
+        return SIGBUS_PORTABLE;
+
+    case SIGFPE:                        /* 8 */
+        return SIGFPE_PORTABLE;
+
+    case SIGKILL:                       /* 9 */
+        return SIGKILL_PORTABLE;
+
+    case SIGUSR1:                       /* 10 <-- 16 */
+        return SIGUSR1_PORTABLE;
+
+    case SIGSEGV:                       /* 11 */
+        return SIGSEGV_PORTABLE;
+
+    case SIGUSR2:                       /* 12 <-- 17 */
+        return SIGUSR2_PORTABLE;
+
+    case SIGPIPE:                       /* 13 */
+        return SIGPIPE_PORTABLE;
+
+    case SIGALRM:                       /* 14 */
+        return SIGALRM_PORTABLE;
+
+    case SIGTERM:                       /* 15 */
+        return SIGTERM_PORTABLE;
+
+    case SIGEMT:                        /* 16 <--- 7 */
+        return SIGSTKFLT_PORTABLE;      /* No native SIGSTKFLT exist ...
+                                           ... reverse mapping SIGEMT ...
+                                           ...  back to SIGSTKFLT. */
+
+    case SIGCHLD:                       /* 17 <-- 18 */
+        return SIGCHLD_PORTABLE;
+
+    case SIGCONT:                       /* 18 <-- 15 */
+        return SIGCONT_PORTABLE;
+
+    case SIGSTOP:                       /* 19 <-- 23 */
+        return SIGSTOP_PORTABLE;
+
+    case SIGTSTP:                       /* 20 <-- 24 */
+        return SIGTSTP_PORTABLE;
+
+    case SIGTTIN:                       /* 21 <-- 26 */
+        return SIGTTIN_PORTABLE;
+
+    case SIGTTOU:                       /* 22 <-- 27 */
+        return SIGTTOU_PORTABLE;
+
+    case SIGURG:                        /* 23 <-- 21 */
+        return SIGURG_PORTABLE;
+
+    case SIGXCPU:                       /* 24 <-- 30 */
+        return SIGXCPU_PORTABLE;
+
+    case SIGXFSZ:                       /* 25 <-- 31 */
+        return SIGXFSZ_PORTABLE;
+
+    case SIGVTALRM:                     /* 26 <-- 28 */
+        return SIGVTALRM_PORTABLE;
+
+    case SIGPROF:                       /* 27 <-- 29 */
+        return SIGPROF_PORTABLE;
+
+    case SIGWINCH:                      /* 28 <-- 20 */
+        return SIGWINCH_PORTABLE;
+
+    case SIGIO:                         /* 29 <-- 22 */
+        return SIGIO_PORTABLE;
+
+    case SIGPWR:                        /* 30 <-- 19 */
+        return SIGPWR_PORTABLE;
+
+    case SIGSYS:                        /* 31 <-- 12 */
+        return SIGSYS_PORTABLE;
+
+    /*
+     * Mapping lower 32 Real Time signals to identical Portable signal numbers.
+     * NOTE: SIGRTMAX_PORTABLE == 64 but SIGRTMAX == 128.
+     */
+    case SIGRTMIN...SIGRTMAX_PORTABLE:              /* 32 ... 64 */
+        ASSERT(SIGRTMIN == SIGRTMIN_PORTABLE);
+        ASSERT(SIGRTMAX >= SIGRTMAX_PORTABLE);
+        return mips_signum;
+
+   /*
+    * Mapping upper 63 Native Real Time signals to the last Portable signal number.
+    * Shouldn't even be possible to be using these signals.
+    */
+    case (SIGRTMAX_PORTABLE+1)...SIGRTMAX:          /* 65 ... 128 */
+        ASSERT(SIGRTMIN == SIGRTMIN_PORTABLE);
+        ASSERT(SIGRTMAX >= SIGRTMAX_PORTABLE);
+
+        ALOGE("%s: mips_signum:%d Can't be mapped to a unique portable signal;", __func__,
+                   mips_signum);
+
+        ALOGE("%s: Mapping highest 63 Real Time Signals to the largest RT Portable SigNo.",
+                __func__);
+
+        return SIGRTMAX_PORTABLE;
+
+
+    default:
+        ALOGE("%s: switch default: mips_signum:%d Not supported! return(0);", __func__,
+                                   mips_signum);
+#if 0
+        LOG_FATAL("%s: mips_signum:%d is not portable;", __func__, mips_signum);
+#endif
+        return 0;
+    }
+    return portable_ssignum;
+}
+
+
+/*
+ * Deal with siginfo structure being a bit different.
+ * Need to swap errno and code fields.
+ */
+static void siginfo_pton(siginfo_portable_t *portable_sip, siginfo_t *native_sip)
+{
+
+    ALOGV("%s(portable_sip:%p, native_sip:%p) {", __func__,
+              portable_sip,    native_sip);
+
+    ASSERT(sizeof(siginfo_portable_t) == sizeof(siginfo_t));
+
+    /*
+     * Default to the same structure members,
+     * code and errno are swapped between ARM and MIPS,
+     * and errno needs to be translated.
+     *
+     * The signal number isn't translated, as the kernel
+     * will fill it it when it delivers the signal.
+     */
+
+    *native_sip = *((siginfo_t *)portable_sip);
+    native_sip->si_signo = 0;
+    native_sip->si_code = portable_sip->si_code;
+    native_sip->si_errno = errno_pton(portable_sip->si_errno);
+
+    ALOGV("%s: return; }", __func__);
+}
+
+
+static void siginfo_ntop(siginfo_t *native_sip, siginfo_portable_t *portable_sip)
+{
+
+    ALOGV("%s(native_sip,:%p, portable_sip:%p) {", __func__,
+              native_sip,     portable_sip);
+
+    ASSERT(sizeof(siginfo_portable_t) == sizeof(siginfo_t));
+
+    /*
+     * Structure assignment to default to the same structure members,
+     * as only the code and errno are swapped in position between
+     * ARM and MIPS; errno and signal number also need to be translated.
+     */
+    *portable_sip = *((siginfo_portable_t *)native_sip);
+
+    portable_sip->si_signo = signum_ntop(native_sip->si_signo);
+    portable_sip->si_code = native_sip->si_code;
+    portable_sip->si_errno = errno_ntop(native_sip->si_errno);
+
+    ALOGV("%s: return; }", __func__);
+}
+
+
+/*
+ * Array of signal handlers as the portable users expects they
+ * they have been registered in the kernel. Problem is we need
+ * to have our own handler to map the MIPS signal number to a
+ * portable signal number.
+ */
+static sig3handler_portable_t mips_portable_sighandler[NSIG_PORTABLE + 1] = { NULL };
+
+static void mips_sigaction_handler(int mips_signum, siginfo_t *sip, void *ucp)
+{
+    int portable_signum;
+    char *portable_signame;
+    char *mips_signame = map_mips_signum_to_name(mips_signum);
+    sig3handler_portable_t portable_sighandler;
+    siginfo_portable_t portable_si;
+    siginfo_portable_t *portable_sip;
+
+    ALOGV(" ");
+    ALOGV("%s(mips_signum:%d:'%s', sip:%p, ucp:%p) {", __func__,
+              mips_signum,
+              mips_signame,        sip,    ucp);
+
+    portable_signum = signum_ntop(mips_signum);
+    portable_signame = map_portable_signum_to_name(portable_signum);
+    portable_sighandler = mips_portable_sighandler[portable_signum];
+
+    if (invalid_pointer(portable_sighandler)) {
+        /*
+         * If a portable/ARM application tries to set signals in the signal mask > 32
+         * it results in a signal_handler being set to -1:SIG_ERR. Calling a function
+         * at location -1 doesn't produce very informative Android backtraces on MIPS.
+         */
+        ALOGE("%s: invalid_pointer(portable_sighandler:%p); Likely about to Trap or Bus Error!",
+                __func__,          portable_sighandler);
+
+        ALOGE("%s: HINT: Likely best to use gdbserver and look at sigaction arguments.", __func__);
+    }
+    ASSERT(portable_sighandler != NULL);
+    ASSERT(portable_sighandler != (sig3handler_portable_t) SIG_DFL);
+    ASSERT(portable_sighandler != (sig3handler_portable_t) SIG_IGN);
+
+    if (sip == NULL) {
+        portable_sip = NULL;
+    } else {
+        /* Map signinfo from native to portable format */
+        portable_sip = &portable_si;
+        siginfo_ntop(sip, portable_sip);
+    }
+
+
+    ALOGV("%s: Calling portable_sighandler:%p(portable_signum:%d, portable_sip:%p, ucp:%p);",
+          __func__,    portable_sighandler,   portable_signum,    portable_sip,    ucp);
+
+    portable_sighandler(portable_signum, portable_sip, ucp);
+
+    ALOGV("%s: return; }", __func__);
+}
+
+
+static void mips_sighandler(int mips_signum)
+{
+    int portable_signum;
+    char *portable_signame;
+    char *mips_signame = map_mips_signum_to_name(mips_signum);
+    sig3handler_portable_t portable_sighandler;
+
+    ALOGV(" ");
+    ALOGV("%s(mips_signum:%d:'%s') {", __func__, mips_signum, mips_signame);
+
+    mips_sigaction_handler(mips_signum, NULL, NULL);
+
+    ALOGV("%s: return; }", __func__);
+}
+
+
+static sighandler_t sighandler_pton(sighandler_portable_t portable_handler, int sigaction)
+{
+    sighandler_t mips_handler;
+
+    ALOGV("%s(portable_handler:%p, sigaction:%d) {", __func__,
+              portable_handler,    sigaction);
+
+    switch((int) portable_handler) {
+    case (int) SIG_DFL:
+    case (int) SIG_IGN:
+        mips_handler = portable_handler;
+        break;
+
+    default:    /* NOTE: Includes SIG_ERR:-1 */
+        if (invalid_pointer(portable_handler)) {
+            /*
+             * Calling sigaction() with a bogus signal handler doesn't fail,
+             * so we let the portable cases fail later as the native case would.
+             */
+            ALOGE("%s: invalid_pointer(portable_handler:%p)!", __func__, portable_handler);
+            ALOGE("%s: HINT: Likely to cause a BUS Error ....", __func__);
+            ALOGE("%s: HINT: ... when the signal handler is called!", __func__);
+        }
+
+        /*
+         * Signal Mapping can be disabled in the rare case of the clone
+         * flags not being compatble for VM and file descriptors.
+         */
+        if (signal_handler_mapping_enabled) {
+            if (sigaction)
+                mips_handler = (sighandler_t) mips_sigaction_handler;
+            else
+                mips_handler = (sighandler_t) mips_sighandler;
+        } else {
+            mips_handler = portable_handler;        /* Don't MAP */
+        }
+        break;
+    }
+
+    ALOGV("%s: return(mips_handler:%p); }", __func__, mips_handler);
+    return mips_handler;
+}
+
+
+/*
+ * This function maps the signal number and calls one of the low level mips signal()
+ * functions implemented in libc/unistd/signal.c:
+ *              sysv_signal()
+ *              bsd_signal()
+ *
+ * The last 2 parameters to this static function, mips_signal_fn*, specify which of
+ * these functions to call.  We intercept the above to functions, as well as signal(),
+ * and call the associated *_portable() functions below.
+ *
+ * In addition, we intercept the signal_handler with our own handlers that map the
+ * signal number from the MIPS convention to the PORTABLE/ARM convention.
+ */
+static sighandler_portable_t
+do_signal_portable(int portable_signum, sighandler_portable_t portable_handler,
+                   __sighandler_t (mips_signal_fn)(int, __sighandler_t))
+{
+    char *portable_signame = map_portable_signum_to_name(portable_signum);
+    int mips_signum;
+    sighandler_t mips_handler;
+    sighandler_portable_t rv;
+    sighandler_portable_t prev_portable_handler;
+
+    ALOGV("%s(portable_signum:%d:%s, portable_handler:%p,  mips_signal_fn:%p) {", __func__,
+              portable_signum,
+              portable_signame,      portable_handler,     mips_signal_fn);
+
+    mips_signum = signum_pton(portable_signum);
+
+    if ((portable_signum != 0) && ((mips_signum <= 0) || (mips_signum > NSIG))) {
+        /*
+         * Invalid request; Let the kernel generate the proper return value and set errno.
+         */
+        mips_handler = sighandler_pton(portable_handler, 0);
+        rv = mips_signal_fn(mips_signum, mips_handler);
+    } else {
+        /*
+         * We have a usable signal number, redirect it to our signal handler
+         * if a portable handler was provided so we can convert the signal number.
+         * Save our current mapped signal handler for likely return.
+         */
+        prev_portable_handler = (sighandler_portable_t) mips_portable_sighandler[portable_signum];
+
+        mips_handler = sighandler_pton(portable_handler, 0);
+        if (mips_handler != portable_handler) {
+            mips_portable_sighandler[portable_signum] = (sig3handler_portable_t) portable_handler;
+        }
+        rv = mips_signal_fn(mips_signum, mips_handler);
+
+        if ((rv == (sighandler_portable_t) mips_sighandler) ||
+            (rv == (sighandler_portable_t) mips_sigaction_handler)) {
+
+            rv = (sighandler_t) prev_portable_handler;
+        }
+    }
+
+    ALOGV("%s: return(rv:%p); }", __func__, rv);
+    return rv;
+}
+
+
+/*
+ * signal() can't be called directly, due to an in-line function in signal.h which
+ * redirects the call to bsd_signal(). _signal() is a static function; not to be called
+ * directly. This function isn't actually needed.
+ */
+sighandler_portable_t WRAP(signal)(int portable_signum, sighandler_portable_t handler)
+{
+    sighandler_portable_t rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_signum:%d, handler:%p) {", __func__,
+              portable_signum,    handler);
+
+    /* bsd does a SA_RESTART */
+    rv = do_signal_portable(portable_signum, handler, bsd_signal);
+
+    ALOGV("%s: return(ret:%p); }", __func__, rv);
+    return rv;
+}
+
+
+sighandler_portable_t WRAP(sysv_signal)(int portable_signum, sighandler_portable_t handler)
+{
+    sighandler_portable_t rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_signum:%d, handler:%p) {", __func__,
+              portable_signum,    handler);
+
+    /* sysv does a SA_RESETHAND */
+    rv = do_signal_portable(portable_signum, handler, sysv_signal);
+
+    ALOGV("%s: return(ret:%p); }", __func__, rv);
+    return rv;
+}
+
+
+/*
+ * NOTE:
+ *    handler is either the Bionic
+ *      bsd_signal() signal handler
+ * or
+ *      the sysv_signal() signal handler.
+ */
+
+sighandler_portable_t WRAP(bsd_signal)(int portable_signum, sighandler_portable_t handler)
+{
+    sighandler_portable_t rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_signum:%d, handler:%p) {", __func__,
+              portable_signum,    handler);
+
+    /* bsd does a SA_RESTART */
+    rv = do_signal_portable(portable_signum, handler, bsd_signal);
+
+    ALOGV("%s: return(ret:%p); }", __func__, rv);
+    return rv;
+}
+
+
+static int do_kill(int id, int portable_signum, int (*fn)(int, int))
+{
+    char *portable_signame = map_portable_signum_to_name(portable_signum);
+    int mips_signum;
+    int rv;
+
+    ALOGV("%s(id:%d, portable_signum:%d:'%s', fn:%p) {", __func__,
+              id,    portable_signum,
+                     portable_signame,        fn);
+
+    mips_signum = signum_pton(portable_signum);
+
+    if ((portable_signum != 0) && (mips_signum == 0)) {
+        rv = 0;
+    } else {
+        ALOGV("%s: Calling fn:%p(id:%d, mips_signum:%d);", __func__,
+                           fn,   id,    mips_signum);
+
+        rv =  fn(id, mips_signum);
+    }
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(killpg)(int pgrp, int portable_signum)
+{
+    extern int REAL(killpg)(int pgrp, int sig);
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(pgrp:%d, portable_signum:%d) {", __func__,
+              pgrp,    portable_signum);
+
+    rv = do_kill(pgrp, portable_signum, REAL(killpg));
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(kill)(pid_t pid, int portable_signum)
+{
+    extern int REAL(kill)(pid_t, int);
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(pid:%d, portable_signum:%d) {", __func__,
+              pid,    portable_signum);
+
+    rv = do_kill(pid, portable_signum, REAL(kill));
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(tkill)(int tid, int portable_signum)
+{
+    extern int REAL(tkill)(int, int);
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(tid:%d, portable_signum:%d) {", __func__,
+              tid,    portable_signum);
+
+    rv = do_kill(tid, portable_signum, REAL(tkill));
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+/* tgkill is not exported from android-14 libc.so */
+#if 0
+int WRAP(tgkill)(int tgid, int tid, int portable_signum)
+{
+    extern int tgkill(int, int, int);
+    char *portable_signame = map_portable_signum_to_name(portable_signum);
+    int mips_signum;
+    int rv;
+
+    ALOGV("%s(tgid:%d, tid:%d, portable_signum:%d:'%s') {", __func__,
+              tgid,    tid,    portable_signum, portable_signame);
+
+    mips_signum = signum_pton(portable_signum);
+
+    if ((portable_signum != 0) && (mips_signum == 0))
+        rv = 0;
+    else
+        rv = REAL(tgkill)(tgid, tid, mips_signum);
+
+    ALOGV("%s: return rv:%d; }", __func__, rv);
+    return rv;
+}
+#endif
+
+
+int WRAP(raise)(int portable_signum)
+{
+    char *portable_signame = map_portable_signum_to_name(portable_signum);
+    int mips_signum = signum_pton(portable_signum);
+    int rv;
+
+    ALOGV("%s(portable_signum:%d:'%s') {", __func__, portable_signum, portable_signame);
+
+    if ((portable_signum != 0) && (mips_signum == 0))
+        rv = 0;
+    else
+        rv = REAL(raise)(mips_signum);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+void sigset_pton(sigset_portable_t *portable_sigset, sigset_t *mips_sigset)
+{
+    int portable_signum;
+
+    ASSERT(mips_sigset != NULL);
+
+    ALOGV("%s(portable_sigset:%p, mips_sigset:%p) {", __func__,
+              portable_sigset,    mips_sigset);
+
+    sigemptyset(mips_sigset);
+    if (invalid_pointer((void *)portable_sigset)) {
+        ALOGE("%s: portable_sigset:%p is not valid; returning empty set.", __func__,
+                   portable_sigset);
+        goto done;
+    }
+
+    for(portable_signum = 1; portable_signum <= NSIG_PORTABLE; portable_signum++) {
+
+        if (WRAP(sigismember)(portable_sigset, portable_signum)) {
+            char *portable_signame = map_portable_signum_to_name(portable_signum);
+            int mips_signum = signum_pton(portable_signum);
+            char *mips_signame;
+
+            if (mips_signum != 0) {
+                int err;
+
+                mips_signame = map_mips_signum_to_name(mips_signum);
+                ALOGV("%s: sigaddset(mips_sigset:%p, mips_signum:%d:'%s');", __func__,
+                                     mips_sigset,    mips_signum,
+                                                     mips_signame);
+
+                err = sigaddset(mips_sigset, mips_signum);
+                if (err == -1) {
+                    PERROR("sigaddset");
+                }
+            }
+        }
+    }
+
+done:
+    ALOGV("%s: return; }", __func__);
+    return;
+}
+
+
+void
+sigset_ntop(const sigset_t *const_mips_sigset, sigset_portable_t *portable_sigset)
+{
+    int mips_signum;
+    sigset_t *mips_sigset = (sigset_t *) const_mips_sigset;
+
+    ALOGV("%s(const_mips_sigset:%p, portable_sigset:%p) {", __func__,
+              const_mips_sigset,    portable_sigset);
+
+    ASSERT(mips_sigset != NULL);
+
+    if (invalid_pointer((void *)portable_sigset)) {
+        ALOGE("%s: portable_sigset:%p is not Valid; can't return sigset", __func__,
+                   portable_sigset);
+        goto done;
+    }
+    WRAP(sigemptyset)(portable_sigset);
+
+    for(mips_signum = 1; mips_signum <= NSIG; mips_signum++) {
+        if (sigismember(mips_sigset, mips_signum)) {
+            int portable_signum = signum_ntop(mips_signum);
+
+            if (portable_signum != 0)
+                WRAP(sigaddset)(portable_sigset, portable_signum);
+        }
+    }
+
+done:
+    ALOGV("%s: return; }", __func__);
+    return;
+}
+
+
+static int sigaction_flags_pton(int portable_flags)
+{
+    int mips_flags = 0;
+
+    if (portable_flags & SA_NOCLDSTOP_PORTABLE) {
+        mips_flags |= SA_NOCLDSTOP;
+    }
+    if (portable_flags & SA_NOCLDWAIT_PORTABLE) {
+        mips_flags |= SA_NOCLDWAIT;
+    }
+    if (portable_flags & SA_SIGINFO_PORTABLE) {
+        mips_flags |= SA_SIGINFO;
+    }
+    if (portable_flags & SA_THIRTYTWO_PORTABLE) {
+        ALOGV("%s: SA_THIRTYTWO_PORTABLE isn't SUPPORTED.", __func__);
+    }
+    if (portable_flags & SA_RESTORER_PORTABLE) {
+        mips_flags |= SA_RESTORER;
+    }
+    if (portable_flags & SA_ONSTACK_PORTABLE) {
+        mips_flags |= SA_ONSTACK;
+    }
+    if (portable_flags & SA_RESTART_PORTABLE) {
+        mips_flags |= SA_RESTART;
+    }
+    if (portable_flags & SA_NODEFER_PORTABLE) {
+        mips_flags |= SA_NODEFER;
+    }
+    if (portable_flags & SA_RESETHAND_PORTABLE) {
+        mips_flags |= SA_RESETHAND;
+    }
+
+    ALOGV("%s(portable_flags:0x%x) return(mips_flags:0x%x);", __func__,
+              portable_flags,             mips_flags);
+
+    return mips_flags;
+}
+
+
+int sigaction_flags_ntop(int mips_flags)
+{
+    int portable_flags = 0;
+
+    if (mips_flags & SA_NOCLDSTOP)      portable_flags |= SA_NOCLDSTOP_PORTABLE;
+    if (mips_flags & SA_NOCLDWAIT)      portable_flags |= SA_NOCLDWAIT_PORTABLE;
+    if (mips_flags & SA_SIGINFO)        portable_flags |= SA_SIGINFO_PORTABLE;
+#ifdef SA_THIRTYTWO
+    if (mips_flags & SA_THIRTYTWO)      portable_flags |= SA_THIRTYTWO_PORTABLE;
+#endif
+    if (mips_flags & SA_RESTORER)       portable_flags |= SA_RESTORER_PORTABLE;
+    if (mips_flags & SA_ONSTACK)        portable_flags |= SA_ONSTACK_PORTABLE;
+    if (mips_flags & SA_RESTART)        portable_flags |= SA_RESTART_PORTABLE;
+    if (mips_flags & SA_NODEFER)        portable_flags |= SA_NODEFER_PORTABLE;
+    if (mips_flags & SA_RESETHAND)      portable_flags |= SA_RESETHAND_PORTABLE;
+
+    ALOGV("%s(mips_flags:0x%x) return(portable_flags:0x%x);", __func__,
+              mips_flags,             portable_flags);
+
+    return portable_flags;
+}
+
+
+/*
+ * Called by portable/ARM code, which we map and do MIPS system calls.
+ *
+ * The incoming system call used a Portable/ARM sigaction structure:
+ * ------------------------------------------------------------------
+ *   struct sigaction_portable {
+ *     union {
+ *       __sighandler_portable_t        _sa_handler;
+ *       __sigaction_handler_portable_t _sa_sigaction;
+ *     } _u;
+ *     sigset_portable_t sa_mask;
+ *     unsigned long sa_flags;
+ *     void (*sa_restorer)(void);
+ * };
+ *
+ * A similar, but different, structure is used in the MIPS/Native system call:
+ * ---------------------------------------------------------------------------
+ *    struct sigaction {
+ *      unsigned int sa_flags;
+ *      union {
+ *        __sighandler_t                  sa_handler;
+ *        __sigaction_handler_portable_t _sa_sigaction;
+ *      } __u;
+ *      sigset_t sa_mask;
+ *  };
+ *
+ * This sigaction structure needs to be mapped before the MIPS systems call as well as after for
+ * returning the old/previous sigaction. Also, like signal_portable() above, we need to maintain
+ * a table of signal handlers that our intercepting handler can call after it converts the signal
+ * numbers.
+ */
+static int do_sigaction_portable(int portable_signum, const struct sigaction_portable *act,
+                                 struct sigaction_portable *oldact, sigaction_fn fn,
+                                 rt_sigaction_fn rt_fn)
+{
+    int mips_signum;
+    char *mips_signame;
+    struct sigaction mips_act;
+    struct sigaction *mips_act_ptr;
+    struct sigaction mips_oldact;
+    sighandler_t mips_handler;
+    sighandler_portable_t portable_handler;
+    sig3handler_portable_t prev_portable_handler;
+    char *portable_signame = map_portable_signum_to_name(portable_signum);
+    int rv;
+
+    ALOGV("%s(portable_signum:%d:'%s', act:%p, oldact:%p, fn:%p, rt_fn:%p) {", __func__,
+              portable_signum,
+              portable_signame,        act,    oldact,    fn,    rt_fn);
+
+    mips_signum = signum_pton(portable_signum);
+    mips_signame = map_mips_signum_to_name(mips_signum);
+
+    if ((portable_signum != 0) && (mips_signum == 0)) {
+        /* We got a portable signum that we can't map; Ignore the request */
+        rv = 0;
+        goto done;
+    }
+    if (portable_signum > 0 && portable_signum <= NSIG_PORTABLE)
+        prev_portable_handler = mips_portable_sighandler[portable_signum];
+    else
+        prev_portable_handler = NULL;
+
+    memset(&mips_act, 0, sizeof(mips_act));
+
+    if (invalid_pointer((void *)act)) {
+        mips_act_ptr = (struct sigaction *)act;
+    } else {
+        /*
+         * Make the MIPS version of sigaction, which has no sa_restorer function pointer.
+         * Also the handler will be called with a pointer to a to a sigcontext structure
+         * which is totally non-portable.
+         */
+        sigset_pton(((sigset_portable_t *)&act->sa_mask),
+                                    ((sigset_t *) &mips_act.sa_mask));
+
+        mips_act.sa_flags = sigaction_flags_pton(act->sa_flags);
+
+        if (mips_act.sa_flags & SA_SIGINFO) {
+            /*
+             * Providing the three argument version of a signal handler.
+             */
+            portable_handler = (sighandler_portable_t) act->sa_sigaction_portable;
+            if ((portable_signum <= 0) || (portable_signum > NSIG_PORTABLE)) {
+                /*
+                 * Let the kernel generate the proper return value and set errno.
+                 */
+                mips_act.sa_sigaction = (sig3handler_t) portable_handler;
+            } else {
+                mips_handler = sighandler_pton(portable_handler, 1);
+                if (mips_handler != portable_handler) {
+                    mips_portable_sighandler[portable_signum] =
+                                                       (sig3handler_portable_t) portable_handler;
+                }
+                mips_act.sa_sigaction = (sig3handler_t) mips_handler;
+            }
+        } else {
+            /*
+             * Providing the classic single argument version of a signal handler.
+             */
+            portable_handler = act->sa_handler_portable;
+            if ((portable_signum <= 0) || (portable_signum > NSIG_PORTABLE)) {
+                /*
+                 * Let the kernel generate the proper return value and set errno.
+                 */
+                mips_act.sa_handler = (sighandler_t) portable_handler;
+            } else {
+                mips_handler = sighandler_pton(portable_handler, 1);
+                if (mips_handler != portable_handler) {
+                    mips_portable_sighandler[portable_signum] =
+                                                       (sig3handler_portable_t) portable_handler;
+                }
+                mips_act.sa_handler = mips_handler;
+            }
+        }
+        mips_act_ptr = &mips_act;
+    }
+
+    if (fn != NULL) {
+        ASSERT(rt_fn == NULL);
+        rv = fn(mips_signum, mips_act_ptr, &mips_oldact);
+    } else {
+        ASSERT(rt_fn != NULL);
+        rv = rt_fn(mips_signum, mips_act_ptr, &mips_oldact, sizeof(sigset_t));
+    }
+
+    if (rv == 0 && oldact) {
+        if (mips_oldact.sa_sigaction == (__sigaction_handler_portable_t) mips_sigaction_handler ||
+            mips_oldact.sa_sigaction == (__sigaction_handler_portable_t) mips_sighandler) {
+
+            oldact->sa_sigaction_portable =
+                                        (__sigaction_handler_portable_t) prev_portable_handler;
+        } else {
+            oldact->sa_sigaction_portable =
+                                        (__sigaction_handler_portable_t) mips_oldact.sa_sigaction;
+        }
+        sigset_ntop((sigset_t *) &(mips_oldact.sa_mask),
+                                    (sigset_portable_t *) &(oldact->sa_mask));
+
+        oldact->sa_flags = sigaction_flags_ntop(mips_oldact.sa_flags);
+        oldact->sa_restorer = NULL;
+    }
+
+done:
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(sigaction)(int portable_signum, const struct sigaction_portable *act,
+                       struct sigaction_portable *oldact)
+{
+    extern int REAL(sigaction)(int, const struct sigaction *, struct sigaction *);
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_signum:%d, act:%p, oldact:%p) {", __func__,
+              portable_signum,    act,    oldact);
+
+    rv = do_sigaction_portable(portable_signum, act, oldact, REAL(sigaction), NULL);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+/*
+ * Currently signalfd() isn't supported by bionic with
+ * only the portable syscall.c code using this code by
+ * intercepting the syscall(__NR_signalfd4, ...) in bionic.
+ */
+__hidden int do_signalfd4_portable(int fd, const sigset_portable_t *portable_sigmask,
+                                   int portable_sigsetsize, int portable_flags)
+{
+    sigset_t native_sigmask;
+    int native_sigsetsize = sizeof(native_sigmask);
+    int native_flags = 0;
+    int rv;
+
+    ALOGV("%s(fd:%d, portable_sigmask:%p, portable_sigsetsize:%d, portable_flags:0x%x) {",
+    __func__, fd,    portable_sigmask,    portable_sigsetsize,    portable_flags);
+
+    sigset_pton((sigset_portable_t *)portable_sigmask, &native_sigmask);
+
+    if (portable_flags & SFD_NONBLOCK_PORTABLE) {
+        native_flags |= SFD_NONBLOCK;
+    }
+    if (portable_flags & SFD_CLOEXEC_PORTABLE) {
+        native_flags |= SFD_CLOEXEC;
+    }
+    rv = syscall(__NR_signalfd4, fd, &native_sigmask, native_sigsetsize, native_flags);
+
+    if (rv >= 0) {
+        if (native_flags & SFD_CLOEXEC) {
+            filefd_CLOEXEC_enabled(rv);
+        }
+
+        /*
+         * Reads on this file descriptor must be mapped to be portable.
+         * The mapping should survive a fork and most clones naturally.
+         * For the system call to be completely portable it has to propagate
+         * these mapped files after an execve(). Environment variables have
+         * been added to do that. See filefd.c for details.
+         */
+        filefd_opened(rv, SIGNAL_FD_TYPE);
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+#if 0
+/*
+ * signalfd() isn't available in Bionic yet. When it is, it will be implemented like
+ * the glibc version where the sigsetsize is computed in the bionic code and passed
+ * down to the kernel with __NR_signalfd4.
+ *
+ * This function can't be called from bionic, so there isn't an entry in the experimental
+ * linker.cpp table for testing and this function.
+ */
+int WRAP(signalfd)(int fd, const sigset_portable_t *portable_sigmask, int portable_flags)
+{
+    int portable_sigsetsize = sizeof(sigset_portable_t);
+    int rv;
+
+    ALOGV("%s(fd:%d, portable_sigmask:%p, portable_flags:0x%x) {", __func__,
+              fd,    portable_sigmask,    portable_flags);
+
+    rv = do_signalfd4_portable(fd, portable_sigsetsize, portable_sigmask, portable_flags);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+#endif
+
+
+/*
+ * Called by read_portable() to do signalfd read() mapping.
+ */
+__hidden int read_signalfd_mapper(int fd, void *buf, size_t count)
+{
+    int rv;
+
+    ALOGV("%s(fd:%d, buf:0x%p, count:%d) {", __func__,
+              fd,    buf,      count);
+
+    rv = read(fd, buf, count);
+    if (rv > 0) {
+        int siginfos = rv/sizeof(struct signalfd_siginfo);
+        struct signalfd_siginfo *si = (struct signalfd_siginfo *) buf;
+        int i;
+
+        /* Read signalfd_siginfo structure(s) if read is large enough */
+        for (i = 0; i < siginfos; i++, si++) {
+            int ssi_signo;
+
+            ssi_signo = si->ssi_signo;
+            si->ssi_signo = signum_ntop(si->ssi_signo);
+            ALOGV("%s: si->ssi_signo:%d = signum_ntop(si->ssi_signo:%d); i:%d", __func__,
+                       si->ssi_signo,                     ssi_signo,     i);
+
+            si->ssi_errno = errno_ntop(si->ssi_errno);
+
+            /*
+             * The ssi_codes appear to be generic; defined in
+             * the kernel in include/asm-generic/siginfo.h
+             */
+            if (si->ssi_status > 0 && si->ssi_status <= NSIG) {
+                si->ssi_status = signum_ntop(si->ssi_status);
+            }
+
+            /*
+             * The rest of the struct members, like
+             *  ssi_trapno, ssi_int, ssi_ptr
+             * are not likely worth dealing with.
+             */
+        }
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+int WRAP(sigsuspend)(const sigset_portable_t *portable_sigmask)
+{
+    int rv;
+    sigset_t mips_sigmask;
+
+    ALOGV("%s(portable_sigmask:%p) {", __func__, portable_sigmask);
+
+    if (invalid_pointer((void *)portable_sigmask)) {
+        *REAL(__errno)() = EFAULT;
+        rv = -1;
+    } else {
+        sigset_pton((sigset_portable_t *)portable_sigmask, &mips_sigmask);
+        rv = REAL(sigsuspend)(&mips_sigmask);
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(sigpending)(sigset_portable_t *portable_sigset)
+{
+    int rv;
+    sigset_t mips_sigset;
+
+    ALOGV("%s(portable_sigset:%p) {", __func__,
+              portable_sigset);
+
+    if (invalid_pointer((void *)portable_sigset)) {
+        *REAL(__errno)() = EFAULT;
+        rv = -1;
+    } else {
+        rv = REAL(sigpending)(&mips_sigset);
+        sigset_ntop(&mips_sigset, portable_sigset);
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(sigwait)(const sigset_portable_t *portable_sigset, int *ptr_to_portable_sig)
+{
+    int rv;
+    sigset_t mips_sigset;
+    int mips_sig;
+    int portable_sig;
+
+    ALOGV("%s(portable_sigset:%p, ptr_to_portable_sig:%p) {", __func__,
+              portable_sigset,    ptr_to_portable_sig);
+
+    if (invalid_pointer((void *)portable_sigset)) {
+        *REAL(__errno)() = EFAULT;
+        rv = -1;
+    } else {
+        sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset);
+
+        rv = REAL(sigwait)(&mips_sigset, &mips_sig);
+
+        portable_sig = signum_ntop(mips_sig);
+        *ptr_to_portable_sig = portable_sig;
+    }
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(siginterrupt)(int portable_signum, int flag)
+
+{
+    int rv;
+    int mips_signum;
+
+    ALOGV("%s(portable_signum:%d, flag:0x%x) {", __func__,
+              portable_signum,    flag);
+
+    mips_signum = signum_pton(portable_signum);
+
+    if ((portable_signum != 0) && (mips_signum == 0)) {
+        ALOGE("%s: Unsupported portable_signum:%d; Ignoring.", __func__,
+                               portable_signum);
+        rv = 0;
+    } else {
+        rv = REAL(siginterrupt)(mips_signum, flag);
+    }
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+__hidden int do_sigmask(int portable_how, const sigset_portable_t *portable_sigset,
+                        sigset_portable_t *portable_oldset, sigmask_fn fn,
+                        rt_sigmask_fn rt_fn)
+{
+    int rv;
+    int how;
+    char *how_name;
+    sigset_t mips_sigset, *mips_sigset_p;
+    sigset_t mips_oldset, *mips_oldset_p;
+
+    ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p, fn:%p, rt_fn:%p) {",
+    __func__, portable_how,    portable_sigset,    portable_oldset,    fn,    rt_fn);
+
+    switch(portable_how) {
+    case SIG_BLOCK_PORTABLE:    how = SIG_BLOCK;        how_name = "SIG_BLOCK";         break;
+    case SIG_UNBLOCK_PORTABLE:  how = SIG_UNBLOCK;      how_name = "SIG_UNBLOCK";       break;
+    case SIG_SETMASK_PORTABLE:  how = SIG_SETMASK;      how_name = "SIG_SETMASK";       break;
+
+    default:
+        ALOGE("%s: portable_how:%d NOT SUPPORTED!", __func__, portable_how);
+        how = -1;
+        break;
+    }
+
+    if (invalid_pointer((void *)portable_sigset)) {
+        mips_sigset_p = (sigset_t *) portable_sigset;
+    } else {
+        mips_sigset_p = &mips_sigset;
+        memset(mips_sigset_p, 0, sizeof(mips_sigset));
+        sigemptyset(mips_sigset_p);
+        sigset_pton((sigset_portable_t *)portable_sigset, &mips_sigset);
+    }
+
+    if (invalid_pointer((void *)portable_oldset)) {
+        mips_oldset_p = (sigset_t *) portable_oldset;
+    } else {
+        mips_oldset_p = &mips_oldset;
+        memset(mips_oldset_p, 0, sizeof(mips_oldset));
+        sigemptyset(mips_oldset_p);
+    }
+
+    if (fn != NULL) {
+        ASSERT(rt_fn == NULL);
+        rv = fn(how, mips_sigset_p, mips_oldset_p);
+    } else {
+        ASSERT(rt_fn != NULL);
+        rv = rt_fn(how, mips_sigset_p, mips_oldset_p, sizeof(sigset_t));
+    }
+
+    if (rv == 0 && !invalid_pointer(portable_oldset)) {
+        /* Map returned mips_oldset to portable_oldset for return to caller */
+        sigset_ntop(mips_oldset_p, portable_oldset);
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(sigprocmask)(int portable_how, const sigset_portable_t *portable_sigset,
+                         sigset_portable_t *portable_oldset)
+{
+    extern int REAL(sigprocmask)(int, const sigset_t *, sigset_t *);
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p) {", __func__,
+              portable_how,    portable_sigset,    portable_oldset);
+
+    rv = do_sigmask(portable_how, portable_sigset, portable_oldset, REAL(sigprocmask), NULL);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(__rt_sigaction)(int portable_signum, const struct sigaction_portable *act,
+                            struct sigaction_portable *oldact, size_t sigsetsize)
+{
+    extern int REAL(__rt_sigaction)(int , const struct sigaction *, struct sigaction *, size_t);
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_signum:%d, act:%p, oldset:%p, sigsetsize:%d) {", __func__,
+              portable_signum,    act,    oldact,    sigsetsize);
+
+    /* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */
+    if (sigsetsize != (2* sizeof(long))) {
+        *REAL(__errno)() = EINVAL;
+        rv = -1;
+        goto done;
+    }
+    rv = do_sigaction_portable(portable_signum, act, oldact, NULL, REAL(__rt_sigaction));
+
+done:
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+int WRAP(__rt_sigprocmask)(int portable_how,
+                              const sigset_portable_t *portable_sigset,
+                              sigset_portable_t *portable_oldset,
+                              size_t sigsetsize)
+{
+    extern int REAL(__rt_sigprocmask)(int, const sigset_t *, sigset_t *, size_t);
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_how:%d, portable_sigset:%p, portable_oldset:%p, sigsetsize:%d) {",
+    __func__, portable_how,    portable_sigset,    portable_oldset,    sigsetsize);
+
+    /* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */
+    if (sigsetsize != (2* sizeof(long))) {
+        *REAL(__errno)() = EINVAL;
+        rv = -1;
+        goto done;
+    }
+    rv = do_sigmask(portable_how, portable_sigset, portable_oldset, NULL, REAL(__rt_sigprocmask));
+
+ done:
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+
+    return rv;
+}
+
+
+int WRAP(__rt_sigtimedwait)(const sigset_portable_t *portable_sigset,
+                               siginfo_portable_t *portable_siginfo,
+                               const struct timespec *timeout,
+                               size_t portable_sigsetsize)
+{
+    extern int REAL(__rt_sigtimedwait)(const sigset_t *, siginfo_t *, const struct timespec *, size_t);
+
+    sigset_t native_sigset_struct;
+    sigset_t *native_sigset = &native_sigset_struct;
+    siginfo_t native_siginfo_struct;
+    siginfo_t *native_siginfo;
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_sigset:%p, portable_siginfo:%p, timeout:%p, portable_sigsetsize:%d) {",
+    __func__, portable_sigset,    portable_siginfo,    timeout,    portable_sigsetsize);
+
+    /* NOTE: ARM kernel is expecting sizeof(sigset_t) to be 8 bytes */
+    if (portable_sigsetsize != (2* sizeof(long))) {
+        *REAL(__errno)() = EINVAL;
+        rv = -1;
+        goto done;
+    }
+    if (portable_sigset == NULL) {
+        native_sigset = NULL;
+    } else {
+        sigset_pton((sigset_portable_t *)portable_sigset, native_sigset);
+    }
+    if (portable_siginfo == NULL) {
+        native_siginfo = NULL;
+    } else {
+        native_siginfo = &native_siginfo_struct;
+    }
+    rv = REAL(__rt_sigtimedwait)(native_sigset, native_siginfo, timeout, sizeof(sigset_t));
+    if (rv == 0 && native_siginfo != NULL) {
+        /* Map siginfo struct from native to portable format. */
+        siginfo_ntop(native_siginfo, portable_siginfo);
+    }
+
+done:
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+#ifdef  __NR_rt_sigqueueinfo
+
+#if 0
+/*
+ * sigqueue():
+ *    This function became available in UNIX GLIBC after 1993.
+ *    It's not available in any versions of Android yet, and
+ *    it can't be called via syscall(). It's been useful for
+ *    testing with the LTP by the posix testsuite, and tests
+ *    show that it works fine.
+ *
+ * NOTE:
+ *    Android has in incorrect limit on the number of queueable signals
+ *    defined in libc/unistd/sysconf.c:
+ *
+ *        #define  SYSTEM_SIGQUEUE_MAX    32
+ *
+ *    sigqueue() must return EAGAIN if exceeded and we don't on Android.
+ */
+int WRAP(sigqueue)(pid_t pid, int portable_sig, const union sigval value)
+{
+    siginfo_t native_siginfo;
+    siginfo_t *native_sip;
+    siginfo_portable_t portable_siginfo;
+    siginfo_portable_t *portable_sip;
+    int native_sig;
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(pid:%d, portable_sig:%d, value:%p) {", __func__,
+              pid,    portable_sig,    value.sival_ptr);
+
+    native_sig = signum_pton(portable_sig);
+    native_sip = &native_siginfo;
+
+    portable_sip = &portable_siginfo;
+    portable_sip->si_signo = 0;                 /* Filled in by the kernel */
+    portable_sip->si_code = SI_QUEUE;
+    portable_sip->si_pid = getpid();            /* Process ID of sender */
+    portable_sip->si_uid = getuid();            /* Real UID of sender */
+    portable_sip->si_value = value;             /* Last arg supplied */
+
+    siginfo_pton(portable_sip, native_sip);
+
+    /*
+     * man page says sigqueue() is implemented via rt_sigqueueinfo().
+     */
+    ALOGV("%s: calling syscall(__NR_rt_sigqueueinfo:%d, pid:%d, native_sig:%d, native_sip:%p);",
+           __func__,           __NR_rt_sigqueueinfo,    pid,    native_sig,    native_sip);
+
+    rv = syscall(__NR_rt_sigqueueinfo, pid, native_sig, native_sip);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+#endif
+
+
+/*
+ * Real Time version of sigqueueinfo().
+ */
+int WRAP(rt_sigqueueinfo)(pid_t pid, int portable_sig, siginfo_portable_t *portable_sip)
+{
+    int native_sig;
+    siginfo_t native_siginfo, *native_sip;
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(pid:%d, portable_sig:%d, portable_sip:%p) {", __func__,
+              pid,    portable_sig,    portable_sip);
+
+    native_sig = signum_pton(portable_sig);
+
+    if (portable_sip != NULL) {
+        native_sip = &native_siginfo;
+        siginfo_pton(portable_sip, native_sip);
+    } else {
+        native_sip = NULL;
+    }
+    rv = syscall(__NR_rt_sigqueueinfo, pid, native_sig, native_sip);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+#endif /* __NR_rt_sigqueueinfo */
+
+
+#ifdef __NR_rt_tgsigqueueinfo
+/*
+ * Thread Group flavor of the real time version of sigqueueinfo().
+ */
+int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int portable_sig,
+                               siginfo_portable_t *portable_sip)
+{
+    siginfo_t native_siginfo, *native_sip;
+    int native_sig;
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(tgid:%d, pid:%d, portable_sig:%d, portable_sip:%p) {", __func__,
+              tgid,    pid,    portable_sig,    portable_sip);
+
+    native_sig = signum_pton(portable_sig);
+
+    if (portable_sip != NULL) {
+        native_sip = &native_siginfo;
+        siginfo_pton(portable_sip, native_sip);
+    } else {
+        native_sip = NULL;
+    }
+    rv = syscall(__NR_rt_tgsigqueueinfo, pid, native_sig, native_sip);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+#endif /* __NR_rt_tgsigqueueinfo */
+
+
+/*
+ * ss_flags and ss_size are located in different locations in stack_t structure:
+ *
+ * Incomming ARM/Portable stack_t:                  Outgoing MIPS stack_t:
+ * -------------------------------              ----------------------------
+ *    typedef struct sigaltstack {              typedef struct sigaltstack {
+ *        void __user *ss_sp;                       void *ss_sp;
+ *        int ss_flags;                             size_t ss_size;
+ *        size_t ss_size;                           int ss_flags;
+ *    } stack_t;
+ *
+ */
+int WRAP(sigaltstack)(const portable_stack_t *ss, portable_stack_t *oss)
+{
+    int rv;
+    stack_t new_stack, *mips_ss;
+    stack_t old_stack, *mips_oss;
+
+    ALOGV(" ");
+    ALOGV("%s(ss:%p, oss:%p) {", __func__, ss, oss);
+
+    if (ss == NULL) {
+        mips_ss = NULL;
+    } else {
+        if (invalid_pointer((void *)ss)) {
+            ALOGE("%s: invalid_pointer(ss:%p): Let kernel set proper errno and set return value.",
+                   __func__,           ss);
+
+            mips_ss = (stack_t *) ss;
+        } else {
+            memset(&new_stack, 0, sizeof(stack_t));
+            new_stack.ss_sp = ss->ss_sp;
+            new_stack.ss_flags = ss->ss_flags;
+            new_stack.ss_size = ss->ss_size;
+            mips_ss = &new_stack;
+        }
+    }
+    if (oss == NULL) {
+        mips_oss = NULL;
+    } else {
+        if (invalid_pointer((void *)oss)) {
+            ALOGE("%s: invalid_pointer(oss:%p): Let kernel set proper errno and return value.",
+                   __func__,           oss);
+
+            mips_oss = (stack_t *)oss;
+        } else {
+            memset(&old_stack, 0, sizeof(stack_t));
+            mips_oss = &old_stack;
+        }
+    }
+
+    rv = REAL(sigaltstack)(mips_ss, mips_oss);
+
+    if (!invalid_pointer(oss)) {
+        oss->ss_sp = old_stack.ss_sp;
+        oss->ss_flags = old_stack.ss_flags;
+        oss->ss_size = old_stack.ss_size;
+    }
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+
+    return rv;
+}
diff --git a/ndk/sources/android/libportable/arch-mips/sigsetjmp.S b/ndk/sources/android/libportable/arch-mips/sigsetjmp.S
new file mode 100644
index 0000000..237d46b
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/sigsetjmp.S
@@ -0,0 +1,78 @@
+/* Derived from: $OpenBSD: sigsetjmp.S,v 1.5 2005/08/07 16:40:15 espie Exp $ */
+/*-
+ * Copyright (c) 1991, 1993, 1995,
+ *      The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Havard Eidnes.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <asm-generic/portability.h>
+#include <machine/asm.h>
+#include <machine/regnum.h>
+
+#include "jboffsets.h"
+
+/*
+ * trampolines for sigsetjmp and siglongjmp save and restore mask.
+ */
+FRAMESZ= MKFSIZ(1,1)
+GPOFF= FRAMESZ-2*REGSZ
+
+LEAF(WRAP(sigsetjmp), FRAMESZ)
+        PTR_SUBU sp, FRAMESZ
+        SETUP_GP64(GPOFF, sigsetjmp)
+        .set    reorder
+        REG_S   a1, JB_SAVEMASK(a0)             # save "savemask"
+        bne     a1, 0x0, 1f                     # do saving of signal mask?
+        LA      t9, _setjmp_portable
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+        jr t9
+
+1:      LA      t9, WRAP(setjmp)
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+        jr t9
+END(WRAP(sigsetjmp))
+
+LEAF(WRAP(siglongjmp), FRAMESZ)
+        PTR_SUBU sp, FRAMESZ
+        SETUP_GP64(GPOFF, WRAP(siglongjmp))
+        .set    reorder
+        REG_L   t0, JB_SAVEMASK(a0)             # get "savemask"
+        bne     t0, 0x0, 1f                     # restore signal mask?
+        LA      t9, _longjmp_portable
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+        jr      t9
+1:
+        LA      t9, WRAP(longjmp)
+        RESTORE_GP64
+        PTR_ADDU sp, FRAMESZ
+        jr      t9
+END(WRAP(siglongjmp))
diff --git a/ndk/sources/android/libportable/arch-mips/socket.c b/ndk/sources/android/libportable/arch-mips/socket.c
index 51b8db0..be2c7e6 100644
--- a/ndk/sources/android/libportable/arch-mips/socket.c
+++ b/ndk/sources/android/libportable/arch-mips/socket.c
@@ -14,31 +14,248 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <unistd.h>
 #include <sys/socket.h>
-#include <sys/linux-syscalls.h>
+#include <fcntl.h>
+#include <netdb.h>
+
 #include <socket_portable.h>
+#include <fcntl_portable.h>
+#include <netdb_portable.h>
+#include <portability.h>
+
+#define PORTABLE_TAG "socket_portable"
+#include <log_portable.h>
 
 
 #if SOCK_STREAM==SOCK_STREAM_PORTABLE
 #error Bad build environment
 #endif
 
-static inline int mips_change_type(int type)
+/* LTP defaults to using O_NONBLOCK if SOCK_NONBLOCK is not defined. */
+#ifndef SOCK_NONBLOCK_PORTABLE
+# define SOCK_NONBLOCK_PORTABLE O_NONBLOCK_PORTABLE
+#endif
+#ifndef SOCK_NONBLOCK
+# define SOCK_NONBLOCK O_NONBLOCK
+#endif
+
+/* Current NDK headers do not define SOCK_CLOEXEC or O_CLOEXEC */
+#if !defined(SOCK_CLOEXEC_PORTABLE) && defined(O_CLOEXEC_PORTABLE)
+# define SOCK_CLOEXEC_PORTABLE O_CLOEXEC_PORTABLE
+#endif
+#if !defined(SOCK_CLOEXEC) && defined(O_CLOEXEC)
+# define SOCK_CLOEXEC O_CLOEXEC
+#endif
+
+
+/*
+ * Portable to Native socktype mapper.
+ */
+static inline int socktype_pton(int portable_type)
 {
-    switch (type) {
-      case SOCK_STREAM_PORTABLE: return SOCK_STREAM;
-      case SOCK_DGRAM_PORTABLE: return SOCK_DGRAM;
-      case SOCK_RAW_PORTABLE: return SOCK_RAW;
-      case SOCK_RDM_PORTABLE: return SOCK_RDM;
-      case SOCK_SEQPACKET_PORTABLE: return SOCK_SEQPACKET;
-      case SOCK_PACKET_PORTABLE: return SOCK_PACKET;
+    int native_type = 0;
+
+    ALOGV("%s(portable_type:0x%x) {", __func__, portable_type);
+
+    if (portable_type & SOCK_NONBLOCK_PORTABLE) {
+        native_type |= SOCK_NONBLOCK;
+        portable_type &= ~SOCK_NONBLOCK_PORTABLE;
     }
-    return type;
+
+#if defined(SOCK_CLOEXEC_PORTABLE) && defined(SOCK_CLOEXEC)
+    if (portable_type & SOCK_CLOEXEC_PORTABLE) {
+        native_type |= SOCK_CLOEXEC;
+        portable_type &= ~SOCK_CLOEXEC_PORTABLE;
+    }
+#endif
+
+    switch (portable_type) {
+    case SOCK_STREAM_PORTABLE: native_type |= SOCK_STREAM; break;
+    case SOCK_DGRAM_PORTABLE: native_type |= SOCK_DGRAM; break;
+    case SOCK_RAW_PORTABLE: native_type |= SOCK_RAW; break;
+    case SOCK_RDM_PORTABLE: native_type |= SOCK_RDM; break;
+    case SOCK_SEQPACKET_PORTABLE: native_type |= SOCK_SEQPACKET; break;
+    case SOCK_PACKET_PORTABLE: native_type |= SOCK_PACKET; break;
+    default:
+        ALOGE("%s: case default: native_type:0x%x |= portable_type:0x%x:[UNKNOWN!];", __func__,
+                                 native_type,        portable_type);
+
+        native_type |= portable_type;
+        break;
+    }
+    ALOGV("%s: return(native_type:%d); }", __func__, native_type);
+    return native_type;
 }
 
-extern int socket(int, int, int);
 
-int socket_portable(int domain, int type, int protocol) {
-    return socket(domain, mips_change_type(type), protocol);
+/*
+ * Native to Portable socktype mapper.
+ */
+static inline int socktype_ntop(int native_type)
+{
+    int portable_type = 0;
+
+    ALOGV("%s(native_type:0x%x) {", __func__, native_type);
+
+    if (native_type & SOCK_NONBLOCK) {
+        portable_type |= SOCK_NONBLOCK_PORTABLE;
+        native_type &= ~SOCK_NONBLOCK;
+    }
+
+#if defined(SOCK_CLOEXEC_PORTABLE) && defined(SOCK_CLOEXEC)
+    if (native_type & SOCK_CLOEXEC) {
+        portable_type |= SOCK_CLOEXEC_PORTABLE;
+        native_type &= ~SOCK_CLOEXEC;
+    }
+#endif
+
+    switch (native_type) {
+    case SOCK_STREAM: portable_type |= SOCK_STREAM_PORTABLE; break;
+    case SOCK_DGRAM: portable_type |= SOCK_DGRAM_PORTABLE; break;
+    case SOCK_RAW: portable_type |= SOCK_RAW_PORTABLE; break;
+    case SOCK_RDM: portable_type |= SOCK_RDM_PORTABLE; break;
+    case SOCK_SEQPACKET: portable_type |= SOCK_SEQPACKET_PORTABLE; break;
+    case SOCK_PACKET: portable_type |= SOCK_PACKET_PORTABLE; break;
+    default:
+        portable_type |= native_type;
+        ALOGE("%s: case default: portable_type:0x%x |= native_type:0x%x:[UNKNOWN!];", __func__,
+                                 portable_type,        native_type);
+    }
+    ALOGV("%s: return(portable_type:%d); }", __func__, portable_type);
+    return portable_type;
+}
+
+
+extern int REAL(socket)(int, int, int);
+
+int WRAP(socket)(int domain, int type, int protocol) {
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(domain:%d, type:%d, protocol:%d) {", __func__,
+              domain,    type,    protocol);
+
+    rv = REAL(socket)(domain, socktype_pton(type), protocol);
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+int WRAP(socketpair)(int domain, int type, int protocol, int sv[2]) {
+    int rv;
+
+    ALOGV(" ");
+    ALOGV("%s(domain:%d, type:%d, protocol:%d, sv[2]:%p) {", __func__,
+              domain,    type,    protocol,    sv);
+
+    rv = REAL(socketpair)(domain, socktype_pton(type), protocol, sv);
+
+    if ((rv != 0) || invalid_pointer(sv)) {
+        ALOGV("%s: return(rv:%d); }", __func__,
+                          rv);
+    } else {
+        ALOGV("%s: return(rv:%d); sv[0]:%d; sv[1]:%d;}", __func__,
+                          rv,     sv[0],    sv[1]);
+    }
+    return rv;
+}
+
+#define PRINT_ADDRINFO(p) {                                                                      \
+    ALOGV("%s: p:%p->{ai_flags:%d, ai_family:%d, ai_socktype:%d, ai_protocol:%d, ...", __func__, \
+               p,  p->ai_flags, p->ai_family, p->ai_socktype, p->ai_protocol);                   \
+                                                                                                 \
+    ALOGV("%s: p:%p->{... ai_addrlen:%d, ai_addr:%p, ai_canonname:%p, p->ai_next:%p);", __func__,\
+               p,      p->ai_addrlen, p->ai_addr, p->ai_canonname, p->ai_next);                  \
+}
+
+/*
+ * Returns a list of portable addrinfo structures that are
+ * later made free with a call to the portable version of
+ * freeaddrinfo(); which is written below this function.
+ */
+int WRAP(getaddrinfo)(const char *node, const char *service,
+                 struct addrinfo_portable *portable_hints,
+                 struct addrinfo_portable **portable_results)
+{
+    int rv;
+    struct addrinfo *native_hints;
+    struct addrinfo **native_results, *rp;
+    int saved_portable_socktype;
+
+    ALOGV(" ");
+    ALOGV("%s(node:%p, service:%p, portable_hints:%p, portable_results:%p) {", __func__,
+              node,    service,    portable_hints,    portable_results);
+
+    PRINT_ADDRINFO(portable_hints);
+
+    /*
+     * The only part of the addrinfo structure that needs to be modified
+     * between ARM and MIPS is the socktype;
+     */
+    ASSERT(sizeof(struct addrinfo_portable) == sizeof(struct addrinfo));
+    native_hints = ((struct addrinfo *) portable_hints);
+    if (native_hints != NULL) {
+        saved_portable_socktype = portable_hints->ai_socktype;
+        native_hints->ai_socktype = socktype_pton(saved_portable_socktype);
+    }
+    ASSERT(portable_results != NULL);
+    native_results = (struct addrinfo **) portable_results;
+
+    rv = REAL(getaddrinfo)(node, service, native_hints, native_results);
+
+    if (native_hints != NULL) {
+        portable_hints->ai_socktype = saved_portable_socktype;
+    }
+
+
+    /*
+     * Map socktypes in the return list of addrinfo structures from native to portable.
+     * Assuming getaddrinfo() has left structure writeable and the list is generated
+     * on each call. This seems to be true when looking at the man page and the code
+     * at:
+     *          ./bionic/libc/netbsd/net/getaddrinfo.c
+     */
+    for (rp = *native_results; rp != NULL; rp = rp->ai_next) {
+        PRINT_ADDRINFO(rp);
+        rp->ai_socktype = socktype_ntop(rp->ai_socktype);
+    }
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
+
+/*
+ * Free the results list returned from a previous call
+ * to the portable version of getaddrinfo().
+ */
+void WRAP(freeaddrinfo)(struct addrinfo_portable *portable_results)
+{
+    struct addrinfo *native_results, *rp;
+
+    ALOGV(" ");
+    ALOGV("%s(portable_results:%p) {", __func__, portable_results);
+
+    PRINT_ADDRINFO(portable_results);
+
+    /*
+     * The only part of each addrinfo structure that needs to be modified
+     * between ARM and MIPS is the socktype;
+     *
+     * Map socktypes in the return list of iportable addrinfo structures back to native.
+     * Again, assuming getaddrinfo() has left structure writeable and the list is generated
+     * on each call. This seems to be true when looking at the man page and the code.
+     */
+    ASSERT(sizeof(struct addrinfo_portable) == sizeof(struct addrinfo));
+    native_results = ((struct addrinfo *) portable_results);
+    for (rp = native_results; rp != NULL; rp = rp->ai_next) {
+        PRINT_ADDRINFO(rp);
+        rp->ai_socktype = socktype_pton(rp->ai_socktype);       /* Likely not really necessary */
+    }
+    REAL(freeaddrinfo)(native_results);
+
+    ALOGV("%s: return; }", __func__);
+    return;
 }
diff --git a/ndk/sources/android/libportable/arch-mips/sockopt.c b/ndk/sources/android/libportable/arch-mips/sockopt.c
index fda4049..6c7ec51 100644
--- a/ndk/sources/android/libportable/arch-mips/sockopt.c
+++ b/ndk/sources/android/libportable/arch-mips/sockopt.c
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <socket_portable.h>
 
-
 #if SOL_SOCKET_PORTABLE==SOL_SOCKET
 #error Build environment
 #endif
@@ -27,8 +27,8 @@
 {
     switch (level) {
     case SOL_SOCKET_PORTABLE:
-	level = SOL_SOCKET;
-	break;
+        level = SOL_SOCKET;
+        break;
     }
     return level;
 }
@@ -38,83 +38,83 @@
 {
     switch (optname) {
     case SO_DEBUG_PORTABLE:
-	return SO_DEBUG;
+        return SO_DEBUG;
     case SO_REUSEADDR_PORTABLE:
-	return SO_REUSEADDR;
+        return SO_REUSEADDR;
     case SO_TYPE_PORTABLE:
-	return SO_TYPE;
+        return SO_TYPE;
     case SO_ERROR_PORTABLE:
-	return SO_ERROR;
+        return SO_ERROR;
     case SO_DONTROUTE_PORTABLE:
-	return SO_DONTROUTE;
+        return SO_DONTROUTE;
     case SO_BROADCAST_PORTABLE:
-	return SO_BROADCAST;
+        return SO_BROADCAST;
     case SO_SNDBUF_PORTABLE:
-	return SO_SNDBUF;
+        return SO_SNDBUF;
     case SO_RCVBUF_PORTABLE:
-	return SO_RCVBUF;
+        return SO_RCVBUF;
     case SO_SNDBUFFORCE_PORTABLE:
-	return SO_SNDBUFFORCE;
+        return SO_SNDBUFFORCE;
     case SO_RCVBUFFORCE_PORTABLE:
-	return SO_RCVBUFFORCE;
+        return SO_RCVBUFFORCE;
     case SO_KEEPALIVE_PORTABLE:
-	return SO_KEEPALIVE;
+        return SO_KEEPALIVE;
     case SO_OOBINLINE_PORTABLE:
-	return SO_OOBINLINE;
+        return SO_OOBINLINE;
     case SO_NO_CHECK_PORTABLE:
-	return SO_NO_CHECK;
+        return SO_NO_CHECK;
     case SO_PRIORITY_PORTABLE:
-	return SO_PRIORITY;
+        return SO_PRIORITY;
     case SO_LINGER_PORTABLE:
-	return SO_LINGER;
+        return SO_LINGER;
     case SO_BSDCOMPAT_PORTABLE:
-	return SO_BSDCOMPAT;
+        return SO_BSDCOMPAT;
     case SO_PASSCRED_PORTABLE:
-	return SO_PASSCRED;
+        return SO_PASSCRED;
     case SO_PEERCRED_PORTABLE:
-	return SO_PEERCRED;
+        return SO_PEERCRED;
     case SO_RCVLOWAT_PORTABLE:
-	return SO_RCVLOWAT;
+        return SO_RCVLOWAT;
     case SO_SNDLOWAT_PORTABLE:
-	return SO_SNDLOWAT;
+        return SO_SNDLOWAT;
     case SO_RCVTIMEO_PORTABLE:
-	return SO_RCVTIMEO;
+        return SO_RCVTIMEO;
     case SO_SNDTIMEO_PORTABLE:
-	return SO_SNDTIMEO;
+        return SO_SNDTIMEO;
     case SO_SECURITY_AUTHENTICATION_PORTABLE:
-	return SO_SECURITY_AUTHENTICATION;
+        return SO_SECURITY_AUTHENTICATION;
     case SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE:
-	return SO_SECURITY_ENCRYPTION_TRANSPORT;
+        return SO_SECURITY_ENCRYPTION_TRANSPORT;
     case SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE:
-	return SO_SECURITY_ENCRYPTION_NETWORK;
+        return SO_SECURITY_ENCRYPTION_NETWORK;
     case SO_BINDTODEVICE_PORTABLE:
-	return SO_BINDTODEVICE;
+        return SO_BINDTODEVICE;
     case SO_ATTACH_FILTER_PORTABLE:
-	return SO_ATTACH_FILTER;
+        return SO_ATTACH_FILTER;
     case SO_DETACH_FILTER_PORTABLE:
-	return SO_DETACH_FILTER;
+        return SO_DETACH_FILTER;
     case SO_PEERNAME_PORTABLE:
-	return SO_PEERNAME;
+        return SO_PEERNAME;
     case SO_TIMESTAMP_PORTABLE:
-	return SO_TIMESTAMP;
+        return SO_TIMESTAMP;
     case SO_ACCEPTCONN_PORTABLE:
-	return SO_ACCEPTCONN;
+        return SO_ACCEPTCONN;
     case SO_PEERSEC_PORTABLE:
-	return SO_PEERSEC;
+        return SO_PEERSEC;
     case SO_PASSSEC_PORTABLE:
-	return SO_PASSSEC;
+        return SO_PASSSEC;
     }
     return optname;
 }
 
 extern int setsockopt(int, int, int, const void *, socklen_t);
-int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
+int WRAP(setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen)
 {
-    return setsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
+    return REAL(setsockopt)(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
 }
 
 extern int getsockopt (int, int, int, void *, socklen_t *);
-int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
+int WRAP(getsockopt)(int s, int level, int optname, void *optval, socklen_t *optlen)
 {
-    return getsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
+    return REAL(getsockopt)(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
 }
diff --git a/ndk/sources/android/libportable/arch-mips/stat.c b/ndk/sources/android/libportable/arch-mips/stat.c
index 6af5eee..8706f86 100644
--- a/ndk/sources/android/libportable/arch-mips/stat.c
+++ b/ndk/sources/android/libportable/arch-mips/stat.c
@@ -14,37 +14,64 @@
  * limitations under the License.
  */
 
+#include <portability.h>
+#include <errno.h>
+#include <errno_portable.h>
 #include <stat_portable.h>
 
 /* Note: The Portable Header will define stat to stat_portable */
-int stat_portable(const char *path, struct stat_portable *s)
+int WRAP(stat)(const char *path, struct stat_portable *s)
 {
     struct stat mips_stat;
-    int ret = stat(path, &mips_stat);
+    int ret;
+
+    if (invalid_pointer(s)) {
+        *REAL(__errno)() = EFAULT;
+        return -1;
+    }
+    ret = REAL(stat)(path, &mips_stat);
     stat_ntop(&mips_stat, s);
     return ret;
 }
 
-int fstat_portable(int fd, struct stat_portable *s)
+int WRAP(fstat)(int fd, struct stat_portable *s)
 {
     struct stat mips_stat;
-    int ret = fstat(fd, &mips_stat);
+    int ret;
+
+    if (invalid_pointer(s)) {
+        *REAL(__errno)() = EFAULT;
+        return -1;
+    }
+    ret = REAL(fstat)(fd, &mips_stat);
     stat_ntop(&mips_stat, s);
     return ret;
 }   
 
-int lstat_portable(const char *path, struct stat_portable *s)
+int WRAP(lstat)(const char *path, struct stat_portable *s)
 {
     struct stat mips_stat;
-    int ret = lstat(path, &mips_stat);
+    int ret;
+
+    if (invalid_pointer(s)) {
+        *REAL(__errno)() = EFAULT;
+        return -1;
+    }
+    ret = REAL(lstat)(path, &mips_stat);
     stat_ntop(&mips_stat, s);
     return ret;
 }
 
-int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
+int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags)
 {
     struct stat mips_stat;
-    int ret = fstatat(dirfd, path, &mips_stat, flags);
+    int ret;
+
+    if (invalid_pointer(s)) {
+        *REAL(__errno)() = EFAULT;
+        return -1;
+    }
+    ret = REAL(fstatat)(dirfd, path, &mips_stat, flags);
     stat_ntop(&mips_stat, s);
     return ret;
 }
diff --git a/ndk/sources/android/libportable/arch-mips/statfs.c b/ndk/sources/android/libportable/arch-mips/statfs.c
index cd8b5af..45dfd09 100644
--- a/ndk/sources/android/libportable/arch-mips/statfs.c
+++ b/ndk/sources/android/libportable/arch-mips/statfs.c
@@ -14,8 +14,11 @@
  * limitations under the License.
  */
 
-#include <statfs_portable.h>
+#include <portability.h>
 #include <string.h>
+#include <errno.h>
+#include <errno_portable.h>
+#include <statfs_portable.h>
 
 static inline void statfs_ntop(struct statfs *n_statfs, struct statfs_portable *p_statfs)
 {
@@ -32,18 +35,30 @@
     p_statfs->f_frsize = n_statfs->f_frsize;
 }
 
-int statfs_portable(const char*  path, struct statfs_portable*  stat)
+int WRAP(statfs)(const char*  path, struct statfs_portable*  stat)
 {
     struct statfs mips_stat;
-    int ret = statfs(path, &mips_stat);
+    int ret;
+
+    if (invalid_pointer(stat)) {
+        *REAL(__errno)() = EFAULT;
+        return -1;
+    }
+    ret = REAL(statfs)(path, &mips_stat);
     statfs_ntop(&mips_stat, stat);
     return ret;
 }
 
-int fstatfs_portable(int fd, struct statfs_portable*  stat)
+int WRAP(fstatfs)(int fd, struct statfs_portable*  stat)
 {
     struct statfs mips_stat;
-    int ret = fstatfs(fd, &mips_stat);
+    int ret;
+
+    if (invalid_pointer(stat)) {
+        *REAL(__errno)() = EFAULT;
+        return -1;
+    }
+    ret = REAL(fstatfs)(fd, &mips_stat);
     statfs_ntop(&mips_stat, stat);
     return ret;
 }
diff --git a/ndk/sources/android/libportable/arch-mips/syscall.c b/ndk/sources/android/libportable/arch-mips/syscall.c
new file mode 100644
index 0000000..5e31b80
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/syscall.c
@@ -0,0 +1,640 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <signal.h>
+#include <signal_portable.h>
+#include <time.h>
+#include <errno.h>
+#include <errno_portable.h>
+#include <eventfd_portable.h>
+#include <filefd_portable.h>
+#include <inotify_portable.h>
+#include <timerfd_portable.h>
+#include <asm/unistd-portable.h>
+#include <asm/unistd.h>
+
+#define PORTABLE_TAG "syscall_portable"
+#include <log_portable.h>
+
+#if __NR_gettimeofday_portable == __NR_gettimeofday
+#error "Bad build environment"
+#endif
+
+/*
+ * Minimal syscall support for LTP testing.
+ * These are the system calls that LTP references explicitly.
+ * Not all of them are exported via bionic header so use #ifdef.
+ *
+ * TODO:
+ *    Add existing portable system calls currently redirected from
+ *    experimental Bionic linker code so that calls to them via
+ *    syscall() are also processed. For example, LTP only calls open()
+ *    directly and never does a syscall(__NR_open, ...).
+ */
+
+
+extern int REAL(syscall)(int, ...);
+
+#define MAXARGS 8
+
+int WRAP(syscall)(int portable_number, ...)
+{
+    va_list ap;
+    int native_number, ret;
+    int i, nargs, args[MAXARGS];
+
+    ALOGV(" ");
+    ALOGV("%s(portable_number:%d, ...) {", __func__, portable_number);
+
+    switch (portable_number) {
+#ifdef __NR_add_key_portable
+    case __NR_add_key_portable: native_number = __NR_add_key; break;
+#endif
+
+#ifdef __NR_cacheflush_portable
+    case __NR_cacheflush_portable: {
+        long start, end, flags;
+
+        va_start(ap, portable_number);
+        start = va_arg(ap, long);
+        end = va_arg(ap, long);
+        flags = va_arg(ap, long);
+        va_end(ap);
+
+        ret = cacheflush(start, end, flags);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_capget_portable
+    case __NR_capget_portable: native_number = __NR_capget; break;
+#endif
+
+#ifdef __NR_capset_portable
+    case __NR_capset_portable: native_number = __NR_capset; break;
+#endif
+
+#ifdef __NR_clock_getres_portable
+    case __NR_clock_getres_portable: native_number = __NR_clock_getres; break;
+#endif
+
+#ifdef __NR_clock_nanosleep
+    case __NR_clock_nanosleep_portable: native_number = __NR_clock_nanosleep; break;
+#endif
+
+#ifdef __NR_dup3_portable
+    case __NR_dup3_portable: native_number = __NR_dup3; break;
+#endif
+
+#ifdef __NR_epoll_create_portable
+    case __NR_epoll_create_portable: native_number = __NR_epoll_create; break;
+#endif
+
+#ifdef __NR_epoll_create1_portable
+    case __NR_epoll_create1_portable: native_number = __NR_epoll_create1; break;
+#endif
+
+#ifdef __NR_eventfd_portable
+    /*
+     * Prior to 2.6.27 we only had this system call,
+     * which didn't have a flags argument. The kernel
+     * just provides a zero for flags when this system
+     * call number is used.
+     */
+    case __NR_eventfd_portable: {
+        unsigned int initval;                        /* 64-bit counter initial value */
+        int flags = 0;
+
+        va_start(ap, portable_number);
+
+        initval  = va_arg(ap, int);
+
+        va_end(ap);
+
+        ret = WRAP(eventfd)(initval, flags);      /* Android uses __NR_eventfd2 in eventfd() */
+        goto done;
+    }
+#endif
+
+#ifdef __NR_eventfd2_portable
+    /*
+     * Starting with Linux 2.6.27 a flags argument was added.
+     * Both Bionic and glibc implement the eventfd() now with
+     * the additional flags argument.
+     */
+    case __NR_eventfd2_portable: {
+        unsigned int initval;                        /* 64-bit counter initial value */
+        int flags;
+
+        va_start(ap, portable_number);
+
+        initval  = va_arg(ap, int);
+        flags = va_arg(ap, int);
+
+        va_end(ap);
+
+        ret = WRAP(eventfd)(initval, flags);      /* Android uses __NR_eventfd2 in eventfd() */
+        goto done;
+    }
+#endif
+
+#ifdef __NR_exit_group_portable
+    case __NR_exit_group_portable: native_number = __NR_exit_group; break;
+#endif
+
+#ifdef __NR_faccessat_portable
+    case __NR_faccessat_portable: native_number = __NR_faccessat; break;
+#endif
+
+#ifdef __NR_fallocate_portable
+    case __NR_fallocate_portable: native_number = __NR_fallocate; break;
+#endif
+
+#ifdef __NR_fchmodat_portable
+    case __NR_fchmodat_portable: native_number = __NR_fchmodat; break;
+#endif
+
+#ifdef __NR_fchownat_portable
+    case __NR_fchownat_portable: native_number = __NR_fchownat; break;
+#endif
+
+#ifdef __NR_fstatat64_portable
+    case __NR_fstatat64_portable: native_number = __NR_fstatat64; break;
+#endif
+
+#ifdef __NR_futimesat_portable
+    case __NR_futimesat_portable: native_number = __NR_futimesat; break;
+#endif
+
+#ifdef __NR_getegid_portable
+    case __NR_getegid_portable: native_number = __NR_getegid; break;
+#endif
+
+#ifdef __NR_geteuid_portable
+    case __NR_geteuid_portable: native_number = __NR_geteuid; break;
+#endif
+
+#ifdef __NR_getgid_portable
+    case __NR_getgid_portable: native_number = __NR_getgid; break;
+#endif
+
+#ifdef __NR_get_mempolicy_portable
+    case __NR_get_mempolicy_portable: native_number = __NR_get_mempolicy; break;
+#endif
+
+#ifdef __NR_get_robust_list_portable
+    case __NR_get_robust_list_portable: native_number = __NR_get_robust_list; break;
+#endif
+
+#ifdef __NR_gettid_portable
+    case __NR_gettid_portable: native_number = __NR_gettid; break;
+#endif
+
+#ifdef __NR_gettimeofday_portable
+    case __NR_gettimeofday_portable: native_number = __NR_gettimeofday; break;
+#endif
+
+#ifdef __NR_getuid_portable
+    case __NR_getuid_portable: native_number = __NR_getuid; break;
+#endif
+
+#ifdef __NR_inotify_init_portable
+    case __NR_inotify_init_portable: native_number = __NR_inotify_init; break;
+#endif
+
+#ifdef __NR_inotify_add_watch_portable
+    case __NR_inotify_add_watch_portable: native_number = __NR_inotify_add_watch; break;
+#endif
+
+#ifdef __NR_inotify_init1_portable
+    case __NR_inotify_init1_portable: {
+        int portable_flags;
+
+        va_start(ap, portable_number);
+        portable_flags = va_arg(ap, int);
+        va_end(ap);
+
+        ret = WRAP(inotify_init1)(portable_flags);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_keyctl_portable
+    case __NR_keyctl_portable: native_number = __NR_keyctl; break;
+#endif
+
+#ifdef __NR_linkat
+    case __NR_linkat_portable: native_number = __NR_linkat; break;
+#endif
+
+#ifdef __NR_mbind_portable
+    case __NR_mbind_portable: native_number = __NR_mbind; break;
+#endif
+
+#ifdef __NR_mkdirat_portable
+    case __NR_mkdirat_portable: native_number = __NR_mkdirat; break;
+#endif
+
+#ifdef __NR_mknodat_portable
+    case __NR_mknodat_portable: native_number = __NR_mknodat; break;
+#endif
+
+#ifdef __NR_openat_portable
+    case __NR_openat_portable: native_number = __NR_openat; break;
+#endif
+
+#ifdef __NR_pipe2_portable
+    case __NR_pipe2_portable: {
+        int *pipefd_ptr;
+        int portable_flags;
+
+        va_start(ap, portable_number);
+        pipefd_ptr = va_arg(ap, int *);
+        portable_flags = va_arg(ap, int);
+        va_end(ap);
+
+        ret = WRAP(pipe2)(pipefd_ptr, portable_flags);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_readahead_portable
+    case __NR_readahead_portable: native_number = __NR_readahead; break;
+#endif
+
+#ifdef __NR_readlinkat_portable
+    case __NR_readlinkat_portable: native_number = __NR_readlinkat; break;
+#endif
+
+#ifdef __NR_renameat_portable
+    case __NR_renameat_portable: native_number = __NR_renameat; break;
+#endif
+
+#ifdef __NR_rt_sigaction_portable
+    case __NR_rt_sigaction_portable: {
+        int sig;
+        struct sigaction_portable *act;
+        struct sigaction_portable *oact;
+        size_t sigsetsize;
+
+        va_start(ap, portable_number);
+        sig = va_arg(ap, int);
+        act = va_arg(ap, struct sigaction_portable *);
+        oact = va_arg(ap, struct sigaction_portable *);
+        sigsetsize = va_arg(ap, size_t);
+        va_end(ap);
+        return WRAP(__rt_sigaction)(sig, act, oact, sigsetsize);
+    }
+#endif
+
+#ifdef __NR_rt_sigprocmask_portable
+    case __NR_rt_sigprocmask_portable: {
+        int how;
+        const sigset_portable_t *set;
+        sigset_portable_t *oset;
+        size_t sigsetsize;
+
+        va_start(ap, portable_number);
+        how = va_arg(ap, int);
+        set = va_arg(ap, sigset_portable_t *);
+        oset = va_arg(ap, sigset_portable_t *);
+        sigsetsize = va_arg(ap, size_t);
+        va_end(ap);
+
+        ret = WRAP(__rt_sigprocmask)(how, set, oset, sigsetsize);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_rt_sigtimedwait_portable
+    case __NR_rt_sigtimedwait_portable: {
+        const sigset_portable_t *set;
+        siginfo_portable_t *info;
+        const struct timespec *timeout;
+        size_t sigsetsize;
+
+        va_start(ap, portable_number);
+        set = va_arg(ap, sigset_portable_t *);
+        info = va_arg(ap, siginfo_portable_t *);
+        timeout = va_arg(ap, struct timespec *);
+        sigsetsize = va_arg(ap, size_t);
+        va_end(ap);
+
+        ret = WRAP(__rt_sigtimedwait)(set, info, timeout, sigsetsize);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_rt_sigqueueinfo_portable
+    case __NR_rt_sigqueueinfo_portable: {
+        pid_t pid;
+        int sig;
+        siginfo_portable_t *uinfo;
+
+        va_start(ap, portable_number);
+        pid = va_arg(ap, pid_t);
+        sig = va_arg(ap, int);
+        uinfo = va_arg(ap, siginfo_portable_t *);
+        va_end(ap);
+
+        ret = WRAP(rt_sigqueueinfo)(pid, sig, uinfo);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_setgid_portable
+    case __NR_setgid_portable: native_number = __NR_setgid; break;
+#endif
+
+#ifdef __NR_set_mempolicy_portable
+    case __NR_set_mempolicy_portable: native_number = __NR_set_mempolicy; break;
+#endif
+
+#ifdef __NR_set_robust_list_portable
+    case __NR_set_robust_list_portable: native_number = __NR_set_robust_list; break;
+#endif
+
+#ifdef __NR_set_tid_address_portable
+    case __NR_set_tid_address_portable: native_number = __NR_set_tid_address; break;
+#endif
+
+#ifdef __NR_sgetmask_portable
+    case __NR_sgetmask_portable: native_number = __NR_sgetmask; break;
+#endif
+
+#ifdef __NR_signalfd4_portable
+    case __NR_signalfd4_portable: {
+        int fd;
+        sigset_portable_t *portable_sigmask;
+        int sigsetsize;
+        int flags;
+
+        va_start(ap, portable_number);
+
+        fd = va_arg(ap, int);
+        portable_sigmask = va_arg(ap, sigset_portable_t *);
+        sigsetsize = va_arg(ap, int);
+        flags = va_arg(ap, int);
+
+        va_end(ap);
+
+        ret = do_signalfd4_portable(fd, (const sigset_portable_t *) portable_sigmask, sigsetsize,
+                                    flags);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_socketcall_portable
+    case __NR_socketcall_portable: native_number = __NR_socketcall; break;
+#endif
+
+#ifdef __NR_splice_portable
+    case __NR_splice_portable: native_number = __NR_splice; break;
+#endif
+
+/* REMIND - DOUBLE CHECK THIS ONE */
+#ifdef __NR_ssetmask_portable
+    case __NR_ssetmask_portable: native_number = __NR_ssetmask; break;
+#endif
+
+#ifdef __NR_swapoff_portable
+    case __NR_swapoff_portable: native_number = __NR_swapoff; break;
+#endif
+
+#ifdef __NR_swapon_portable
+    case __NR_swapon_portable: native_number = __NR_swapon; break;
+#endif
+
+#ifdef __NR_symlinkat_portable
+    case __NR_symlinkat_portable: native_number = __NR_symlinkat; break;
+#endif
+
+/*
+ * ARM uses the new, version 2, form of sync_file_range() which
+ * doesn't waste 32 bits between the 32 bit arg and the 64 bit arg.
+ * It does this by moving the last 32 bit arg and placing it with
+ * the 1st 32 bit arg.
+ *
+ * Here's the trivial mapping function in the kernel ARM code:
+ *
+ *   sync_file_range2(int fd, unsigned int flags, loff_t offset, loff_t nbytes) {
+ *       return sys_sync_file_range(fd, offset, nbytes, flags);
+ *   }
+ *
+ * For portability we have to do a similar mapping for the native/MIPS system
+ * call but have to provide the alignment padding expected by the sync_file_range()
+ * system call. We avoid alignment issues while using varargs by avoiding the use
+ * of 64 bit args.
+ */
+#if defined( __NR_arm_sync_file_range_portable)
+    case __NR_arm_sync_file_range_portable: native_number = __NR_sync_file_range; {
+        int fd;
+        int flags;
+        int offset_low, offset_high;
+        int nbytes_low, nbytes_high;
+        int align_fill = 0;
+
+
+        va_start(ap, portable_number);
+        fd = va_arg(ap, int);
+        flags = va_arg(ap, int);
+        offset_low = va_arg(ap, int);
+        offset_high = va_arg(ap, int);
+        nbytes_low = va_arg(ap, int);
+        nbytes_high = va_arg(ap, int);
+        va_end(ap);
+
+        ALOGV("%s: Calling syscall(native_number:%d:'sync_file_range', fd:%d, "
+              "align_fill:0x%x, offset_low:0x%x, offset_high:0x%x, "
+              "nbytes_low:0x%x, nbytes_high:0x%x, flags:0x%x);", __func__,
+              native_number, fd, align_fill, offset_low, offset_high,
+              nbytes_low, nbytes_high, flags);
+
+        ret = REAL(syscall)(native_number, fd, align_fill, offset_low, offset_high,
+                      nbytes_low, nbytes_high, flags);
+
+        goto done;
+    }
+#endif
+
+
+#ifdef __NR__sysctl_portable
+    case __NR__sysctl_portable: native_number = __NR__sysctl; break;
+#endif
+
+#ifdef __NR_sysfs_portable
+    case __NR_sysfs_portable: native_number = __NR_sysfs; break;
+#endif
+
+#ifdef __NR_syslog_portable
+    case __NR_syslog_portable: native_number = __NR_syslog; break;
+#endif
+
+#ifdef __NR_tee_portable
+    case __NR_tee_portable: native_number = __NR_tee; break;
+#endif
+
+#ifdef __NR_timer_create_portable
+    case __NR_timer_create_portable: {
+        clockid_t clockid;
+        struct sigevent *evp;
+        timer_t *timerid;
+
+        va_start(ap, portable_number);
+        clockid = va_arg(ap, clockid_t);
+        evp = va_arg(ap, struct sigevent *);
+        timerid = va_arg(ap, timer_t *);
+        va_end(ap);
+
+        ret = WRAP(timer_create)(clockid, evp, timerid);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_timerfd_create_portable
+    case __NR_timerfd_create_portable: {
+        int clockid;
+        int flags;
+
+        va_start(ap, portable_number);
+        clockid = va_arg(ap, int);              /* clockid is portable */
+        flags = va_arg(ap, int);                /* flags need to be mapped */
+        va_end(ap);
+
+        ret = WRAP(timerfd_create)(clockid, flags);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_timerfd_gettime_portable
+    case __NR_timerfd_gettime_portable: native_number = __NR_timerfd_gettime; break;
+#endif
+
+#ifdef __NR_timerfd_settime_portable
+    case __NR_timerfd_settime_portable: native_number = __NR_timerfd_settime; break;
+#endif
+
+#ifdef __NR_timer_getoverrun_portable
+    case __NR_timer_getoverrun_portable: native_number = __NR_timer_getoverrun; break;
+#endif
+
+#ifdef __NR_timer_gettime_portable
+    case __NR_timer_gettime_portable: native_number = __NR_timer_gettime; break;
+#endif
+
+#ifdef __NR_timer_settime_portable
+    case __NR_timer_settime_portable: native_number = __NR_timer_settime; break;
+#endif
+
+#ifdef __NR_rt_tgsigqueueinfo_portable
+    case __NR_rt_tgsigqueueinfo_portable: {
+        pid_t tgid;
+        pid_t pid;
+        int sig;
+        siginfo_portable_t *uinfo;
+
+        va_start(ap, portable_number);
+        tgid = va_arg(ap, pid_t);
+        pid = va_arg(ap, pid_t);
+        sig = va_arg(ap, int);
+        uinfo = va_arg(ap, siginfo_portable_t *);
+        va_end(ap);
+
+        ret = WRAP(rt_tgsigqueueinfo)(tgid, pid, sig, uinfo);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_tkill_portable
+    case __NR_tkill_portable: {
+        int tid, sig;
+
+        va_start(ap, portable_number);
+        tid = va_arg(ap, int);
+        sig = va_arg(ap, int);
+        va_end(ap);
+
+        ret = WRAP(tkill)(tid, sig);
+        goto done;
+    }
+#endif
+
+#ifdef __NR_uname_portable
+    case __NR_uname_portable: native_number = __NR_uname; break;
+#endif
+
+#ifdef __NR_vmsplice_portable
+    case __NR_vmsplice_portable: native_number = __NR_vmsplice; break;
+#endif
+
+    default:
+        ALOGV("%s(portable_number:%d,  ...): case default; native_number = -1; "
+              "[ERROR: ADD MISSING SYSTEM CALL]", __func__, portable_number);
+
+        native_number = -1;
+        break;
+    }
+
+    ALOGV("%s: native_number = %d", __func__, native_number);
+
+    if (native_number <= 0) {
+        ALOGV("%s: native_number:%d <= 0; ret = -1; [ERROR: FIX SYSTEM CALL]", __func__,
+                   native_number);
+
+        *REAL(__errno)() = ENOSYS;
+        ret = -1;
+        goto done;
+    }
+
+    /*
+     * Get the argument list
+     * This is pretty crappy:
+     *   It assumes that the portable and native arguments are compatible
+     *   It assumes that no more than MAXARGS arguments are passed
+     *
+     * Possible changes:
+     *  o include the argument count for each mapped system call
+     *  o map the syscall into the equivalent library call:
+     *    eg syscall(__NR_gettimeofday_portable, struct timeval *tv, struct timezone *tz) =>
+     *       gettimeofday(struct timeval *tv, struct timezone *tz)
+     *
+     * second option is probably best as it allows argument remapping to take place if needed
+     *
+     */
+    va_start(ap, portable_number);
+    /* For now assume all syscalls take MAXARGS arguments. */
+    nargs = MAXARGS;
+    for (i = 0; i < nargs; i++)
+        args[i] = va_arg(ap, int);
+    va_end(ap);
+
+    ALOGV("%s: Calling syscall(%d, %d, %d, %d, %d, %d, %d, %d, %d);", __func__,
+          native_number, args[0], args[1], args[2], args[3], args[4],
+          args[5], args[6], args[7]);
+
+    ret = REAL(syscall)(native_number, args[0], args[1], args[2], args[3],
+                  args[4], args[5], args[6], args[7]);
+
+done:
+    if (ret == -1) {
+        ALOGV("%s: ret == -1; errno:%d;", __func__, *REAL(__errno)());
+    }
+    ALOGV("%s: return(ret:%d); }", __func__, ret);
+    return ret;
+}
diff --git a/ndk/sources/android/libportable/arch-mips/timer.c b/ndk/sources/android/libportable/arch-mips/timer.c
new file mode 100644
index 0000000..c2844e1
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/timer.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <signal.h>
+#include <signal_portable.h>
+#include <time.h>
+
+int WRAP(timer_create)(clockid_t clockid, struct sigevent *portable_evp,
+                          timer_t *timerid)
+{
+    struct sigevent native_sigevent, *evp = portable_evp;
+
+    if (!invalid_pointer(portable_evp) &&
+        (evp->sigev_notify == SIGEV_SIGNAL ||
+         evp->sigev_notify == SIGEV_THREAD_ID)) {
+
+        native_sigevent = *portable_evp;
+        evp = &native_sigevent;
+        evp->sigev_signo = signum_pton(evp->sigev_signo);
+    }
+    return REAL(timer_create)(clockid, evp, timerid);
+}
diff --git a/ndk/sources/android/libportable/arch-mips/timerfd.c b/ndk/sources/android/libportable/arch-mips/timerfd.c
new file mode 100644
index 0000000..b57c3f2
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/timerfd.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <asm/unistd.h>
+#include <asm/unistd-portable.h>
+
+#include <fcntl_portable.h>
+#include <timerfd_portable.h>
+
+#include <filefd_portable.h>
+
+
+#define PORTABLE_TAG "timerfd_portable"
+#include <log_portable.h>
+
+extern int syscall(int, ...);
+
+
+/* NOTE: LTP defaults to using O_NONBLOCK even if TFD_NONBLOCK is defined */
+
+
+/*
+ * Portable to Native event flags mapper.
+ */
+static inline int tdf_flags_pton(int portable_flags)
+{
+    int native_flags = 0;
+
+    ALOGV("%s(portable_flags:0x%x) {", __func__, portable_flags);
+
+    if (portable_flags & TFD_NONBLOCK_PORTABLE) {
+        native_flags |= TFD_NONBLOCK;
+    }
+
+    if (portable_flags & TFD_CLOEXEC_PORTABLE) {
+        native_flags |= TFD_CLOEXEC;
+    }
+
+    ALOGV("%s: return(native_flags:%d); }", __func__, native_flags);
+    return native_flags;
+}
+
+
+int WRAP(timerfd_create)(int clockid, int portable_flags) {
+    int rv;
+    int native_flags;
+
+    ALOGV(" ");
+    ALOGV("%s(clockid:%d, portable_flags:%d) {", __func__,
+              clockid,    portable_flags);
+
+    native_flags = tdf_flags_pton(portable_flags);
+
+    rv = REAL(syscall)(__NR_timerfd_create, clockid, native_flags);
+    if (rv >= 0) {
+        if (native_flags & TFD_CLOEXEC) {
+            filefd_CLOEXEC_enabled(rv);
+        }
+        filefd_opened(rv, TIMER_FD_TYPE);
+    }
+
+    ALOGV("%s: return(rv:%d); }", __func__, rv);
+    return rv;
+}
+
diff --git a/ndk/sources/android/libportable/arch-mips/waitpid.c b/ndk/sources/android/libportable/arch-mips/waitpid.c
new file mode 100644
index 0000000..77e6283
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-mips/waitpid.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2012, 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.
+ */
+
+#include <portability.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <signal_portable.h>
+#include <stdio.h>
+#include <sys/wait.h>
+
+#define PORTABLE_TAG            "waitpid_portable"
+#include <log_portable.h>
+
+pid_t WRAP(waitpid)(pid_t pid, int *status, int options)
+{
+    pid_t ret;
+
+    ret = REAL(waitpid)(pid, status, options);
+    if (status && ret > 0) {
+        /*
+         * Status layout is identical, so just the signal
+         * number needs to be changed.
+         */
+        if (WIFSIGNALED(*status))
+            *status = (*status & ~0x7f) | signum_ntop(WTERMSIG(*status));
+        else if (WIFSTOPPED(*status))
+            *status = (*status & ~0xff00) | (signum_ntop(WSTOPSIG(*status)) << 8);
+    }
+
+    return ret;
+}
diff --git a/ndk/sources/android/libportable/arch-x86/epoll.c b/ndk/sources/android/libportable/arch-x86/epoll.c
index e2f91f2..c683441 100644
--- a/ndk/sources/android/libportable/arch-x86/epoll.c
+++ b/ndk/sources/android/libportable/arch-x86/epoll.c
@@ -14,23 +14,24 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <sys/epoll.h>
 #include <epoll_portable.h>
 
-int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event_portable *event)
+int WRAP(epoll_ctl)(int epfd, int op, int fd, struct epoll_event_portable *event)
 {
     struct epoll_event x86_epoll_event;
 
     x86_epoll_event.events = event->events;
     x86_epoll_event.data = event->data;
 
-    return epoll_ctl(epfd, op, fd, &x86_epoll_event);
+    return REAL(epoll_ctl)(epfd, op, fd, &x86_epoll_event);
 }
 
-int epoll_wait_portable(int epfd, struct epoll_event_portable *events, int max, int timeout)
+int WRAP(epoll_wait)(int epfd, struct epoll_event_portable *events, int max, int timeout)
 {
     struct epoll_event x86_epoll_event;
-    int ret = epoll_wait(epfd, &x86_epoll_event, max, timeout);
+    int ret = REAL(epoll_wait)(epfd, &x86_epoll_event, max, timeout);
 
     events->events = x86_epoll_event.events;
     events->data = x86_epoll_event.data;
diff --git a/ndk/sources/android/libportable/arch-x86/errno.c b/ndk/sources/android/libportable/arch-x86/errno.c
deleted file mode 100644
index ffa5998..0000000
--- a/ndk/sources/android/libportable/arch-x86/errno.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-extern volatile int*   __errno(void);
-volatile int* __errno_portable()
-{
-  return __errno();
-}
diff --git a/ndk/sources/android/libportable/arch-x86/fcntl.c b/ndk/sources/android/libportable/arch-x86/fcntl.c
index 7561f85..74b14c1 100644
--- a/ndk/sources/android/libportable/arch-x86/fcntl.c
+++ b/ndk/sources/android/libportable/arch-x86/fcntl.c
@@ -14,13 +14,14 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <fcntl_portable.h>
 
 extern int __fcntl64(int, int, void *);
 
-int fcntl_portable(int fd, int cmd, ...)
+int WRAP(fcntl)(int fd, int cmd, ...)
 {
     va_list ap;
     void * arg;
diff --git a/ndk/sources/android/libportable/arch-x86/fenv.c b/ndk/sources/android/libportable/arch-x86/fenv.c
new file mode 100644
index 0000000..adf6f30
--- /dev/null
+++ b/ndk/sources/android/libportable/arch-x86/fenv.c
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ */
+
+
+#include <portability.h>
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <fenv.h>
+#include <fenv_portable.h>
+
+static inline int x86_change_except(int flags)
+{
+    int x86flags = 0;
+    int exception = flags & FE_ALL_EXCEPT_PORTABLE;
+
+    // exception flags
+    if (exception & FE_INVALID_PORTABLE)
+        x86flags |= FE_INVALID;
+    if (exception & FE_DIVBYZERO_PORTABLE)
+        x86flags |= FE_DIVBYZERO;
+    if (exception & FE_OVERFLOW_PORTABLE)
+        x86flags |= FE_OVERFLOW;
+    if (exception & FE_UNDERFLOW_PORTABLE)
+        x86flags |= FE_UNDERFLOW;
+    if (exception & FE_INEXACT_PORTABLE)
+        x86flags |= FE_INEXACT;
+
+    return x86flags;
+}
+
+static inline int x86_change_rounding(int flags)
+{
+    int x86flags = 0;
+    int rounding = flags & 0x03;
+
+    // rounding flags
+    switch(rounding)
+    {
+        case FE_TONEAREST_PORTABLE:
+            x86flags = FE_TONEAREST;
+            break;
+        case FE_DOWNWARD_PORTABLE:
+            x86flags = FE_DOWNWARD;
+            break;
+        case FE_UPWARD_PORTABLE:
+            x86flags = FE_UPWARD;
+            break;
+        case FE_TOWARDZERO_PORTABLE:
+            x86flags = FE_TOWARDZERO;
+            break;
+    }
+    return x86flags;
+}
+
+static inline int x86_get_except(int x86flags)
+{
+    int flags = 0;
+    int exception = x86flags & FE_ALL_EXCEPT;
+
+    // exception flags
+    if (exception & FE_INVALID)
+        flags |= FE_INVALID_PORTABLE;
+    if (exception & FE_DIVBYZERO)
+        flags |= FE_DIVBYZERO_PORTABLE;
+    if (exception & FE_OVERFLOW)
+        flags |= FE_OVERFLOW_PORTABLE;
+    if (exception & FE_UNDERFLOW)
+        flags |= FE_UNDERFLOW_PORTABLE;
+    if (exception & FE_INEXACT)
+        flags |= FE_INEXACT_PORTABLE;
+
+    return flags;
+}
+static inline int x86_get_rounding(int x86flags)
+{
+    int flags = 0;
+    int rounding = x86flags & _ROUND_MASK;
+
+    // rounding flags
+    switch(rounding)
+    {
+        case FE_TONEAREST:
+            flags = FE_TONEAREST_PORTABLE;
+            break;
+        case FE_DOWNWARD:
+            flags = FE_DOWNWARD_PORTABLE;
+            break;
+        case FE_UPWARD:
+            flags = FE_UPWARD_PORTABLE;
+            break;
+        case FE_TOWARDZERO:
+            flags = FE_TOWARDZERO_PORTABLE;
+            break;
+    }
+
+    return flags;
+}
+
+int
+WRAP(fesetexceptflag)(const fexcept_t *flagp, int excepts)
+{
+    const fexcept_t flagp_ = x86_change_except(*flagp);
+    int excepts_ = x86_change_except(excepts);
+    return REAL(fesetexceptflag)(&flagp_, excepts_);
+}
+
+int
+WRAP(fegetexceptflag)(fexcept_t *flagp, int excepts)
+{
+    REAL(fegetexceptflag)(flagp, x86_change_except(excepts));
+    *flagp = x86_get_except(*flagp);
+    return 0;
+}
+
+int
+WRAP(feraiseexcept)(int excepts)
+{
+    return REAL(feraiseexcept)(x86_change_except(excepts));
+}
+
+int
+WRAP(feclearexcept)(int excepts)
+{
+    return REAL(feclearexcept)(x86_change_except(excepts));
+}
+
+int
+WRAP(fetestexcept)(int excepts)
+{
+    return REAL(fetestexcept)(x86_change_except(excepts));
+}
+
+int
+WRAP(fegetround)(void)
+{
+    int round = REAL(fegetround)();
+    return x86_get_rounding(round);
+}
+
+int
+WRAP(fesetround)(int round)
+{
+    return REAL(fesetround)(x86_change_rounding(round));
+}
+
+int
+WRAP(fegetexcept)(void)
+{
+    int flags = REAL(fegetexcept)();
+    return x86_get_except(flags);
+}
+
diff --git a/ndk/sources/android/libportable/arch-x86/ioctl.c b/ndk/sources/android/libportable/arch-x86/ioctl.c
index ea88c30..01ddbcd 100644
--- a/ndk/sources/android/libportable/arch-x86/ioctl.c
+++ b/ndk/sources/android/libportable/arch-x86/ioctl.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <stdarg.h>
 #include <sys/ioctl.h>
 #include <ioctls_portable.h>
@@ -31,7 +32,7 @@
 }
 
 extern int __ioctl(int, int, void *);
-int ioctl_portable(int fd, int request, ...)
+int WRAP(ioctl)(int fd, int request, ...)
 {
     va_list ap;
     void * arg;
diff --git a/ndk/sources/android/libportable/arch-x86/open.c b/ndk/sources/android/libportable/arch-x86/open.c
index a38f38c..dae578b 100644
--- a/ndk/sources/android/libportable/arch-x86/open.c
+++ b/ndk/sources/android/libportable/arch-x86/open.c
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdarg.h>
@@ -56,7 +57,7 @@
 }
 
 extern int  __open(const char*, int, int);
-int open_portable(const char *pathname, int flags, ...)
+int WRAP(open)(const char *pathname, int flags, ...)
 {
     mode_t  mode = 0;
     flags |= O_LARGEFILE;
diff --git a/ndk/sources/android/libportable/arch-x86/socket.c b/ndk/sources/android/libportable/arch-x86/socket.c
deleted file mode 100644
index 7e7ca9b..0000000
--- a/ndk/sources/android/libportable/arch-x86/socket.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/linux-syscalls.h>
-
-int socket_portable(int domain, int type, int protocol) {
-    return socket(domain, type, protocol);
-}
diff --git a/ndk/sources/android/libportable/arch-x86/sockopt.c b/ndk/sources/android/libportable/arch-x86/sockopt.c
deleted file mode 100644
index c86ded3..0000000
--- a/ndk/sources/android/libportable/arch-x86/sockopt.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2012, 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.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-extern int setsockopt(int, int, int, const void *, socklen_t);
-int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
-{
-    return setsockopt(s, level, optname, optval, optlen);
-}
-
-extern int getsockopt (int, int, int, void *, socklen_t *);
-int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
-{
-    return getsockopt(s, level, optname, optval, optlen);
-}
diff --git a/ndk/sources/android/libportable/arch-x86/stat.c b/ndk/sources/android/libportable/arch-x86/stat.c
index 6b368c8..1d17378 100644
--- a/ndk/sources/android/libportable/arch-x86/stat.c
+++ b/ndk/sources/android/libportable/arch-x86/stat.c
@@ -14,37 +14,38 @@
  * limitations under the License.
  */
 
+#include <portability.h>
 #include <stat_portable.h>
 
 /* Note: The Portable Header will define stat to stat_portable */
-int stat_portable(const char *path, struct stat_portable *s)
+int WRAP(stat)(const char *path, struct stat_portable *s)
 {
     struct stat x86_stat;
-    int ret = stat(path, &x86_stat);
+    int ret = REAL(stat)(path, &x86_stat);
     stat_ntop(&x86_stat, s);
     return ret;
 }
 
-int fstat_portable(int fd, struct stat_portable *s)
+int WRAP(fstat)(int fd, struct stat_portable *s)
 {
     struct stat x86_stat;
-    int ret = fstat(fd, &x86_stat);
+    int ret = REAL(fstat)(fd, &x86_stat);
     stat_ntop(&x86_stat, s);
     return ret;
 }   
 
-int lstat_portable(const char *path, struct stat_portable *s)
+int WRAP(lstat)(const char *path, struct stat_portable *s)
 {
     struct stat x86_stat;
-    int ret = lstat(path, &x86_stat);
+    int ret = REAL(lstat)(path, &x86_stat);
     stat_ntop(&x86_stat, s);
     return ret;
 }
 
-int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
+int WRAP(fstatat)(int dirfd, const char *path, struct stat_portable *s, int flags)
 {
     struct stat x86_stat;
-    int ret = fstatat(dirfd, path, &x86_stat, flags);
+    int ret = REAL(fstatat)(dirfd, path, &x86_stat, flags);
     stat_ntop(&x86_stat, s);
     return ret;
 }
diff --git a/ndk/sources/android/libportable/common/include/asm-generic/portability.h b/ndk/sources/android/libportable/common/include/asm-generic/portability.h
new file mode 100644
index 0000000..8d91854
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/asm-generic/portability.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2012, 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 _ASM_PORTABILITY_H_
+#define _ASM_PORTABILITY_H_
+
+#if !defined(__HOST__)
+#define WRAP(f)     f ## _portable
+#define REAL(f)     f
+#else
+/* On host app link with libpportable.a with -Wl,--wrap=symbol, which resolve symbol symbol to __wrap_symbol,
+ * and __real_symbol refer to the original symbol
+ */
+#define WRAP(f)     __wrap_ ## f
+#define REAL(f)     __real_ ## f
+#endif
+
+#endif /* _ASM_PORTABILITY_H_ */
diff --git a/ndk/sources/android/libportable/common/include/asm-generic/siginfo_portable.h b/ndk/sources/android/libportable/common/include/asm-generic/siginfo_portable.h
new file mode 100644
index 0000000..1f13ad8
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/asm-generic/siginfo_portable.h
@@ -0,0 +1,221 @@
+/****************************************************************************
+ Derived from platforms/android-14/arch-arm/usr/include/asm-generic/siginfo.h
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_PORTABLE_GENERIC_SIGINFO_H
+#define _ASM_PORTABLE_GENERIC_SIGINFO_H
+
+#include <linux/compiler.h>
+#include <linux/types.h>
+
+typedef union sigval_portable {
+    int sival_int;
+    void __user *sival_ptr;
+} sigval_portable_t;
+
+#ifndef __ARCH_SI_PREAMBLE_SIZE
+#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
+#endif
+
+#define SI_MAX_SIZE 128
+#ifndef SI_PAD_SIZE
+#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
+#endif
+
+#ifndef __ARCH_SI_UID_T
+#define __ARCH_SI_UID_T uid_t
+#endif
+
+#ifndef __ARCH_SI_BAND_T
+#define __ARCH_SI_BAND_T long
+#endif
+
+typedef struct siginfo_portable {
+    int si_signo;
+    int si_errno;
+    int si_code;
+
+    union {
+        int _pad[SI_PAD_SIZE];
+
+        struct {
+                pid_t _pid;
+                __ARCH_SI_UID_T _uid;
+        } _kill;
+
+        struct {
+            timer_t _tid;
+            int _overrun;
+            char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
+            sigval_portable_t _sigval;
+            int _sys_private;
+        } _timer;
+
+        struct {
+            pid_t _pid;
+            __ARCH_SI_UID_T _uid;
+            sigval_t _sigval;
+        } _rt;
+
+        struct {
+            pid_t _pid;
+            __ARCH_SI_UID_T _uid;
+            int _status;
+            clock_t _utime;
+            clock_t _stime;
+        } _sigchld;
+
+        struct {
+            void __user *_addr;
+#ifdef __ARCH_SI_TRAPNO
+            int _trapno;
+#endif
+        } _sigfault;
+
+        struct {
+            __ARCH_SI_BAND_T _band;
+            int _fd;
+        } _sigpoll;
+
+    } _sifields;
+} siginfo_portable_t;
+
+#ifndef si_pid
+#define si_pid _sifields._kill._pid
+#define si_uid _sifields._kill._uid
+#define si_tid _sifields._timer._tid
+#define si_overrun _sifields._timer._overrun
+#define si_sys_private _sifields._timer._sys_private
+#define si_status _sifields._sigchld._status
+#define si_utime _sifields._sigchld._utime
+#define si_stime _sifields._sigchld._stime
+#define si_value _sifields._rt._sigval
+#define si_int _sifields._rt._sigval.sival_int
+#define si_ptr _sifields._rt._sigval.sival_ptr
+#define si_addr _sifields._sigfault._addr
+#ifdef __ARCH_SI_TRAPNO
+#define si_trapno _sifields._sigfault._trapno
+#endif
+#define si_band _sifields._sigpoll._band
+#define si_fd _sifields._sigpoll._fd
+#endif
+
+#ifndef __SI_KILL
+#define __SI_KILL 0
+#define __SI_TIMER 0
+#define __SI_POLL 0
+#define __SI_FAULT 0
+#define __SI_CHLD 0
+#define __SI_RT 0
+#define __SI_MESGQ 0
+#define __SI_CODE(T,N) (N)
+#endif
+
+#ifndef SI_USER
+#define SI_USER 0
+#define SI_KERNEL 0x80
+#define SI_QUEUE -1
+#define SI_TIMER __SI_CODE(__SI_TIMER,-2)
+#define SI_MESGQ __SI_CODE(__SI_MESGQ,-3)
+#define SI_ASYNCIO -4
+#define SI_SIGIO -5
+#define SI_TKILL -6
+#define SI_DETHREAD -7
+
+#define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
+#define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
+#endif
+
+#ifndef ILL_ILLOPC
+#define ILL_ILLOPC (__SI_FAULT|1)
+#define ILL_ILLOPN (__SI_FAULT|2)
+#define ILL_ILLADR (__SI_FAULT|3)
+#define ILL_ILLTRP (__SI_FAULT|4)
+#define ILL_PRVOPC (__SI_FAULT|5)
+#define ILL_PRVREG (__SI_FAULT|6)
+#define ILL_COPROC (__SI_FAULT|7)
+#define ILL_BADSTK (__SI_FAULT|8)
+#define NSIGILL 8
+#endif
+
+#ifndef FPE_INTDIV
+#define FPE_INTDIV (__SI_FAULT|1)
+#define FPE_INTOVF (__SI_FAULT|2)
+#define FPE_FLTDIV (__SI_FAULT|3)
+#define FPE_FLTOVF (__SI_FAULT|4)
+#define FPE_FLTUND (__SI_FAULT|5)
+#define FPE_FLTRES (__SI_FAULT|6)
+#define FPE_FLTINV (__SI_FAULT|7)
+#define FPE_FLTSUB (__SI_FAULT|8)
+#define NSIGFPE 8
+
+#define SEGV_MAPERR (__SI_FAULT|1)
+#define SEGV_ACCERR (__SI_FAULT|2)
+#define NSIGSEGV 2
+
+#define BUS_ADRALN (__SI_FAULT|1)
+#define BUS_ADRERR (__SI_FAULT|2)
+#define BUS_OBJERR (__SI_FAULT|3)
+#define NSIGBUS 3
+
+#define TRAP_BRKPT (__SI_FAULT|1)
+#define TRAP_TRACE (__SI_FAULT|2)
+#define NSIGTRAP 2
+
+#define CLD_EXITED (__SI_CHLD|1)
+#define CLD_KILLED (__SI_CHLD|2)
+#define CLD_DUMPED (__SI_CHLD|3)
+#define CLD_TRAPPED (__SI_CHLD|4)
+#define CLD_STOPPED (__SI_CHLD|5)
+#define CLD_CONTINUED (__SI_CHLD|6)
+#define NSIGCHLD 6
+
+#define POLL_IN (__SI_POLL|1)
+#define POLL_OUT (__SI_POLL|2)
+#define POLL_MSG (__SI_POLL|3)
+#define POLL_ERR (__SI_POLL|4)
+#define POLL_PRI (__SI_POLL|5)
+#define POLL_HUP (__SI_POLL|6)
+#define NSIGPOLL 6
+
+#define SIGEV_SIGNAL 0
+#define SIGEV_NONE 1
+#define SIGEV_THREAD 2
+#define SIGEV_THREAD_ID 4
+#endif /* FPE_INTDIV */
+
+#ifndef __ARCH_SIGEV_PREAMBLE_SIZE
+#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_portable_t))
+#endif
+
+#define SIGEV_MAX_SIZE 64
+#define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE)   / sizeof(int))
+
+typedef struct sigevent_portable {
+    sigval_portable_t sigev_value;
+    int sigev_signo;
+    int sigev_notify;
+    union {
+        int _pad[SIGEV_PAD_SIZE];
+        int _tid;
+
+        struct {
+            void (*_function)(sigval_portable_t);
+            void *_attribute;
+        } _sigev_thread;
+     } _sigev_un;
+} sigevent_portable_t;
+
+#define sigev_notify_function _sigev_un._sigev_thread._function
+#define sigev_notify_attributes _sigev_un._sigev_thread._attribute
+#define sigev_notify_thread_id _sigev_un._tid
+
+#endif
diff --git a/ndk/sources/android/libportable/common/include/asm-generic/signal_portable.h b/ndk/sources/android/libportable/common/include/asm-generic/signal_portable.h
new file mode 100644
index 0000000..97b1b40
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/asm-generic/signal_portable.h
@@ -0,0 +1,21 @@
+/****************************************************************************
+ Derived from platforms/android-14/arch-arm/usr/include/asm-generic/signal.h
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_GENERIC_SIGNAL_PORTABLE_H
+#define __ASM_GENERIC_SIGNAL_PORTABLE_H
+
+#define SIG_BLOCK_PORTABLE   0
+#define SIG_UNBLOCK_PORTABLE 1
+#define SIG_SETMASK_PORTABLE 2
+
+#endif
+
diff --git a/ndk/sources/android/libportable/common/include/asm/sigcontext_portable.h b/ndk/sources/android/libportable/common/include/asm/sigcontext_portable.h
new file mode 100644
index 0000000..477b3e8
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/asm/sigcontext_portable.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+ Derived from gdk/platforms/android-14/arch-arm/usr/include/asm/sigcontext.h
+ ****************************************************************************
+ ***
+ ***   This header was ORIGINALLY automatically generated from a Linux kernel 
+ ***   header of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASMARM_SIGCONTEXT_PORTABLE_H
+#define _ASMARM_SIGCONTEXT_PORTABLE_H
+
+struct sigcontext_portable {
+ unsigned long trap_no;
+ unsigned long error_code;
+ unsigned long oldmask;
+ unsigned long arm_r0;
+ unsigned long arm_r1;
+ unsigned long arm_r2;
+ unsigned long arm_r3;
+ unsigned long arm_r4;
+ unsigned long arm_r5;
+ unsigned long arm_r6;
+ unsigned long arm_r7;
+ unsigned long arm_r8;
+ unsigned long arm_r9;
+ unsigned long arm_r10;
+ unsigned long arm_fp;
+ unsigned long arm_ip;
+ unsigned long arm_sp;
+ unsigned long arm_lr;
+ unsigned long arm_pc;
+ unsigned long arm_cpsr;
+ unsigned long fault_address;
+};
+
+#endif
diff --git a/ndk/sources/android/libportable/common/include/asm/siginfo_portable.h b/ndk/sources/android/libportable/common/include/asm/siginfo_portable.h
new file mode 100644
index 0000000..283f23e
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/asm/siginfo_portable.h
@@ -0,0 +1,17 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ ***   This header was automatically generated from a Linux kernel header
+ ***   of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_PORTABLE_SIGINFO_H
+#define _ASM_PORTABLE_SIGINFO_H
+
+#include <asm-generic/siginfo_portable.h>
+
+#endif
diff --git a/ndk/sources/android/libportable/common/include/asm/signal_portable.h b/ndk/sources/android/libportable/common/include/asm/signal_portable.h
new file mode 100644
index 0000000..a9608cc
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/asm/signal_portable.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+  Derived from gdk/platforms/android-14/arch-arm/usr/include/asm/signal.h
+ ****************************************************************************
+ ***
+ ***   This header was ORIGINALLY automatically generated from a Linux kernel
+ ***   header of the same name, to make information necessary for userspace to
+ ***   call into the kernel available to libc.  It contains only constants,
+ ***   structures, and macros generated from the original header, and thus,
+ ***   contains no copyrightable information.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASMARM_SIGNAL_PORTABLE_H
+#define _ASMARM_SIGNAL_PORTABLE_H
+
+struct siginfo;                         /* TODO: Change to siginfo_portable */
+
+#define NSIG_PORTABLE 64
+typedef unsigned long sigset_portable_t;
+
+#define SIGHUP_PORTABLE 1
+#define SIGINT_PORTABLE 2
+#define SIGQUIT_PORTABLE 3
+#define SIGILL_PORTABLE 4
+#define SIGTRAP_PORTABLE 5
+#define SIGABRT_PORTABLE 6
+#define SIGIOT_PORTABLE 6
+#define SIGBUS_PORTABLE 7
+#define SIGFPE_PORTABLE 8
+#define SIGKILL_PORTABLE 9
+#define SIGUSR1_PORTABLE 10
+#define SIGSEGV_PORTABLE 11
+#define SIGUSR2_PORTABLE 12
+#define SIGPIPE_PORTABLE 13
+#define SIGALRM_PORTABLE 14
+#define SIGTERM_PORTABLE 15
+#define SIGSTKFLT_PORTABLE 16
+#define SIGCHLD_PORTABLE 17
+#define SIGCONT_PORTABLE 18
+#define SIGSTOP_PORTABLE 19
+#define SIGTSTP_PORTABLE 20
+#define SIGTTIN_PORTABLE 21
+#define SIGTTOU_PORTABLE 22
+#define SIGURG_PORTABLE 23
+#define SIGXCPU_PORTABLE 24
+#define SIGXFSZ_PORTABLE 25
+#define SIGVTALRM_PORTABLE 26
+#define SIGPROF_PORTABLE 27
+#define SIGWINCH_PORTABLE 28
+#define SIGIO_PORTABLE 29
+#define SIGPOLL_PORTABLE SIGIO
+
+#define SIGPWR_PORTABLE 30
+#define SIGSYS_PORTABLE 31
+#define SIGUNUSED_PORTABLE 31
+
+#define SIGSWI_PORTABLE 32
+#define SIGRTMIN_PORTABLE 32
+
+#define SIGRT_1_PORTABLE (SIGRTMIN_PORTABLE + 1)
+#define SIGRT_2_PORTABLE (SIGRTMIN_PORTABLE + 2)
+#define SIGRT_3_PORTABLE (SIGRTMIN_PORTABLE + 3)
+#define SIGRT_4_PORTABLE (SIGRTMIN_PORTABLE + 4)
+#define SIGRT_5_PORTABLE (SIGRTMIN_PORTABLE + 5)
+#define SIGRT_5_PORTABLE (SIGRTMIN_PORTABLE + 5)
+#define SIGRT_6_PORTABLE (SIGRTMIN_PORTABLE + 6)
+#define SIGRT_7_PORTABLE (SIGRTMIN_PORTABLE + 7)
+#define SIGRT_8_PORTABLE (SIGRTMIN_PORTABLE + 8)
+#define SIGRT_9_PORTABLE (SIGRTMIN_PORTABLE + 9)
+#define SIGRT_10_PORTABLE (SIGRTMIN_PORTABLE + 10)
+#define SIGRT_11_PORTABLE (SIGRTMIN_PORTABLE + 11)
+#define SIGRT_12_PORTABLE (SIGRTMIN_PORTABLE + 12)
+#define SIGRT_13_PORTABLE (SIGRTMIN_PORTABLE + 13)
+#define SIGRT_14_PORTABLE (SIGRTMIN_PORTABLE + 14)
+#define SIGRT_15_PORTABLE (SIGRTMIN_PORTABLE + 15)
+#define SIGRT_15_PORTABLE (SIGRTMIN_PORTABLE + 15)
+#define SIGRT_16_PORTABLE (SIGRTMIN_PORTABLE + 16)
+#define SIGRT_17_PORTABLE (SIGRTMIN_PORTABLE + 17)
+#define SIGRT_18_PORTABLE (SIGRTMIN_PORTABLE + 18)
+#define SIGRT_19_PORTABLE (SIGRTMIN_PORTABLE + 19)
+#define SIGRT_20_PORTABLE (SIGRTMIN_PORTABLE + 20)
+#define SIGRT_20_PORTABLE (SIGRTMIN_PORTABLE + 20)
+#define SIGRT_21_PORTABLE (SIGRTMIN_PORTABLE + 21)
+#define SIGRT_22_PORTABLE (SIGRTMIN_PORTABLE + 22)
+#define SIGRT_23_PORTABLE (SIGRTMIN_PORTABLE + 23)
+#define SIGRT_24_PORTABLE (SIGRTMIN_PORTABLE + 24)
+#define SIGRT_25_PORTABLE (SIGRTMIN_PORTABLE + 25)
+#define SIGRT_25_PORTABLE (SIGRTMIN_PORTABLE + 25)
+#define SIGRT_26_PORTABLE (SIGRTMIN_PORTABLE + 26)
+#define SIGRT_27_PORTABLE (SIGRTMIN_PORTABLE + 27)
+#define SIGRT_28_PORTABLE (SIGRTMIN_PORTABLE + 28)
+#define SIGRT_29_PORTABLE (SIGRTMIN_PORTABLE + 29)
+#define SIGRT_30_PORTABLE (SIGRTMIN_PORTABLE + 30)
+#define SIGRT_31_PORTABLE (SIGRTMIN_PORTABLE + 31)
+#define SIGRT_32_PORTABLE (SIGRTMIN_PORTABLE + 32)
+
+#define SIGRTMAX_PORTABLE NSIG_PORTABLE
+
+/*
+ * Define MIPS/Native Real Time Signal Names for debugging.
+ * NOTE:
+ *    Currently only defining the 32 RT signals that the
+ *    lib-portable application can interact with. MIPS has
+ *    an additional 63 signals.
+ */
+#define SIGRT_1 (SIGRTMIN + 1)
+#define SIGRT_2 (SIGRTMIN + 2)
+#define SIGRT_3 (SIGRTMIN + 3)
+#define SIGRT_4 (SIGRTMIN + 4)
+#define SIGRT_5 (SIGRTMIN + 5)
+#define SIGRT_5 (SIGRTMIN + 5)
+#define SIGRT_6 (SIGRTMIN + 6)
+#define SIGRT_7 (SIGRTMIN + 7)
+#define SIGRT_8 (SIGRTMIN + 8)
+#define SIGRT_9 (SIGRTMIN + 9)
+#define SIGRT_10 (SIGRTMIN + 10)
+#define SIGRT_11 (SIGRTMIN + 11)
+#define SIGRT_12 (SIGRTMIN + 12)
+#define SIGRT_13 (SIGRTMIN + 13)
+#define SIGRT_14 (SIGRTMIN + 14)
+#define SIGRT_15 (SIGRTMIN + 15)
+#define SIGRT_15 (SIGRTMIN + 15)
+#define SIGRT_16 (SIGRTMIN + 16)
+#define SIGRT_17 (SIGRTMIN + 17)
+#define SIGRT_18 (SIGRTMIN + 18)
+#define SIGRT_19 (SIGRTMIN + 19)
+#define SIGRT_20 (SIGRTMIN + 20)
+#define SIGRT_20 (SIGRTMIN + 20)
+#define SIGRT_21 (SIGRTMIN + 21)
+#define SIGRT_22 (SIGRTMIN + 22)
+#define SIGRT_23 (SIGRTMIN + 23)
+#define SIGRT_24 (SIGRTMIN + 24)
+#define SIGRT_25 (SIGRTMIN + 25)
+#define SIGRT_25 (SIGRTMIN + 25)
+#define SIGRT_26 (SIGRTMIN + 26)
+#define SIGRT_27 (SIGRTMIN + 27)
+#define SIGRT_28 (SIGRTMIN + 28)
+#define SIGRT_29 (SIGRTMIN + 29)
+#define SIGRT_30 (SIGRTMIN + 30)
+#define SIGRT_31 (SIGRTMIN + 31)
+#define SIGRT_32 (SIGRTMIN + 32)
+/*
+ * NOTE: Native signals SIGRT_33 ... SIGRTMAX
+ * can't be used by a lib-portable application.
+ */
+
+#define SA_NOCLDSTOP_PORTABLE   0x00000001
+#define SA_NOCLDWAIT_PORTABLE   0x00000002
+#define SA_SIGINFO_PORTABLE     0x00000004
+#define SA_THIRTYTWO_PORTABLE   0x02000000
+#define SA_RESTORER_PORTABLE    0x04000000
+#define SA_ONSTACK_PORTABLE     0x08000000
+#define SA_RESTART_PORTABLE     0x10000000
+#define SA_NODEFER_PORTABLE     0x40000000
+#define SA_RESETHAND_PORTABLE   0x80000000
+
+#define SA_NOMASK_PORTSBLE      SA_NODEFER_PORTABLE
+#define SA_ONESHOT_PORTABLE     SA_RESETHAND_PORABLE
+
+
+#include <asm-generic/signal_portable.h>
+
+typedef __signalfn_t __user *__sighandler_portable_t;
+typedef void (*__sigaction_handler_portable_t)(int, struct siginfo *, void *);
+
+struct sigaction_portable {
+ union {
+   __sighandler_portable_t        _sa_handler;
+   __sigaction_handler_portable_t _sa_sigaction;
+ } _u;
+ sigset_portable_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+#define sa_handler_portable     _u._sa_handler
+#define sa_sigaction_portable   _u._sa_sigaction
+
+typedef struct sigaltstack_portable {
+ void __user *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+} portable_stack_t;
+
+#endif
diff --git a/ndk/sources/android/libportable/common/include/asm/unistd-portable.h b/ndk/sources/android/libportable/common/include/asm/unistd-portable.h
new file mode 100644
index 0000000..a542e92
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/asm/unistd-portable.h
@@ -0,0 +1,401 @@
+#ifndef __ASM_UNISTD_PORTABLE_H
+#define __ASM_UNISTD_PORTABLE_H
+
+/* Derived from android-14/arch-arm/usr/include/asm/unistd.h */
+
+#define __NR_SYSCALL_BASE_portable 0
+
+#define __NR_restart_syscall_portable (__NR_SYSCALL_BASE_portable+ 0)
+#define __NR_exit_portable (__NR_SYSCALL_BASE_portable+ 1)
+#define __NR_fork_portable (__NR_SYSCALL_BASE_portable+ 2)
+#define __NR_read_portable (__NR_SYSCALL_BASE_portable+ 3)
+#define __NR_write_portable (__NR_SYSCALL_BASE_portable+ 4)
+#define __NR_open_portable (__NR_SYSCALL_BASE_portable+ 5)
+#define __NR_close_portable (__NR_SYSCALL_BASE_portable+ 6)
+
+#define __NR_creat_portable (__NR_SYSCALL_BASE_portable+ 8)
+#define __NR_link_portable (__NR_SYSCALL_BASE_portable+ 9)
+#define __NR_unlink_portable (__NR_SYSCALL_BASE_portable+ 10)
+#define __NR_execve_portable (__NR_SYSCALL_BASE_portable+ 11)
+#define __NR_chdir_portable (__NR_SYSCALL_BASE_portable+ 12)
+#define __NR_time_portable (__NR_SYSCALL_BASE_portable+ 13)
+#define __NR_mknod_portable (__NR_SYSCALL_BASE_portable+ 14)
+#define __NR_chmod_portable (__NR_SYSCALL_BASE_portable+ 15)
+#define __NR_lchown_portable (__NR_SYSCALL_BASE_portable+ 16)
+
+#define __NR_lseek_portable (__NR_SYSCALL_BASE_portable+ 19)
+#define __NR_getpid_portable (__NR_SYSCALL_BASE_portable+ 20)
+#define __NR_mount_portable (__NR_SYSCALL_BASE_portable+ 21)
+#define __NR_umount_portable (__NR_SYSCALL_BASE_portable+ 22)
+#define __NR_setuid_portable (__NR_SYSCALL_BASE_portable+ 23)
+#define __NR_getuid_portable (__NR_SYSCALL_BASE_portable+ 24)
+#define __NR_stime_portable (__NR_SYSCALL_BASE_portable+ 25)
+#define __NR_ptrace_portable (__NR_SYSCALL_BASE_portable+ 26)
+#define __NR_alarm_portable (__NR_SYSCALL_BASE_portable+ 27)
+
+#define __NR_pause_portable (__NR_SYSCALL_BASE_portable+ 29)
+#define __NR_utime_portable (__NR_SYSCALL_BASE_portable+ 30)
+
+#define __NR_access_portable (__NR_SYSCALL_BASE_portable+ 33)
+#define __NR_nice_portable (__NR_SYSCALL_BASE_portable+ 34)
+
+#define __NR_sync_portable (__NR_SYSCALL_BASE_portable+ 36)
+#define __NR_kill_portable (__NR_SYSCALL_BASE_portable+ 37)
+#define __NR_rename_portable (__NR_SYSCALL_BASE_portable+ 38)
+#define __NR_mkdir_portable (__NR_SYSCALL_BASE_portable+ 39)
+#define __NR_rmdir_portable (__NR_SYSCALL_BASE_portable+ 40)
+#define __NR_dup_portable (__NR_SYSCALL_BASE_portable+ 41)
+#define __NR_pipe_portable (__NR_SYSCALL_BASE_portable+ 42)
+#define __NR_times_portable (__NR_SYSCALL_BASE_portable+ 43)
+
+#define __NR_brk_portable (__NR_SYSCALL_BASE_portable+ 45)
+#define __NR_setgid_portable (__NR_SYSCALL_BASE_portable+ 46)
+#define __NR_getgid_portable (__NR_SYSCALL_BASE_portable+ 47)
+
+#define __NR_geteuid_portable (__NR_SYSCALL_BASE_portable+ 49)
+#define __NR_getegid_portable (__NR_SYSCALL_BASE_portable+ 50)
+#define __NR_acct_portable (__NR_SYSCALL_BASE_portable+ 51)
+#define __NR_umount2_portable (__NR_SYSCALL_BASE_portable+ 52)
+
+#define __NR_ioctl_portable (__NR_SYSCALL_BASE_portable+ 54)
+#define __NR_fcntl_portable (__NR_SYSCALL_BASE_portable+ 55)
+
+#define __NR_setpgid_portable (__NR_SYSCALL_BASE_portable+ 57)
+
+#define __NR_umask_portable (__NR_SYSCALL_BASE_portable+ 60)
+#define __NR_chroot_portable (__NR_SYSCALL_BASE_portable+ 61)
+#define __NR_ustat_portable (__NR_SYSCALL_BASE_portable+ 62)
+#define __NR_dup2_portable (__NR_SYSCALL_BASE_portable+ 63)
+#define __NR_getppid_portable (__NR_SYSCALL_BASE_portable+ 64)
+#define __NR_getpgrp_portable (__NR_SYSCALL_BASE_portable+ 65)
+#define __NR_setsid_portable (__NR_SYSCALL_BASE_portable+ 66)
+#define __NR_sigaction_portable (__NR_SYSCALL_BASE_portable+ 67)
+
+#define __NR_setreuid_portable (__NR_SYSCALL_BASE_portable+ 70)
+#define __NR_setregid_portable (__NR_SYSCALL_BASE_portable+ 71)
+#define __NR_sigsuspend_portable (__NR_SYSCALL_BASE_portable+ 72)
+#define __NR_sigpending_portable (__NR_SYSCALL_BASE_portable+ 73)
+#define __NR_sethostname_portable (__NR_SYSCALL_BASE_portable+ 74)
+#define __NR_setrlimit_portable (__NR_SYSCALL_BASE_portable+ 75)
+#define __NR_getrlimit_portable (__NR_SYSCALL_BASE_portable+ 76)
+#define __NR_getrusage_portable (__NR_SYSCALL_BASE_portable+ 77)
+#define __NR_gettimeofday_portable (__NR_SYSCALL_BASE_portable+ 78)
+#define __NR_settimeofday_portable (__NR_SYSCALL_BASE_portable+ 79)
+#define __NR_getgroups_portable (__NR_SYSCALL_BASE_portable+ 80)
+#define __NR_setgroups_portable (__NR_SYSCALL_BASE_portable+ 81)
+#define __NR_select_portable (__NR_SYSCALL_BASE_portable+ 82)
+#define __NR_symlink_portable (__NR_SYSCALL_BASE_portable+ 83)
+
+#define __NR_readlink_portable (__NR_SYSCALL_BASE_portable+ 85)
+#define __NR_uselib_portable (__NR_SYSCALL_BASE_portable+ 86)
+#define __NR_swapon_portable (__NR_SYSCALL_BASE_portable+ 87)
+#define __NR_reboot_portable (__NR_SYSCALL_BASE_portable+ 88)
+#define __NR_readdir_portable (__NR_SYSCALL_BASE_portable+ 89)
+#define __NR_mmap_portable (__NR_SYSCALL_BASE_portable+ 90)
+#define __NR_munmap_portable (__NR_SYSCALL_BASE_portable+ 91)
+#define __NR_truncate_portable (__NR_SYSCALL_BASE_portable+ 92)
+#define __NR_ftruncate_portable (__NR_SYSCALL_BASE_portable+ 93)
+#define __NR_fchmod_portable (__NR_SYSCALL_BASE_portable+ 94)
+#define __NR_fchown_portable (__NR_SYSCALL_BASE_portable+ 95)
+#define __NR_getpriority_portable (__NR_SYSCALL_BASE_portable+ 96)
+#define __NR_setpriority_portable (__NR_SYSCALL_BASE_portable+ 97)
+
+#define __NR_statfs_portable (__NR_SYSCALL_BASE_portable+ 99)
+#define __NR_fstatfs_portable (__NR_SYSCALL_BASE_portable+100)
+
+#define __NR_socketcall_portable (__NR_SYSCALL_BASE_portable+102)
+#define __NR_syslog_portable (__NR_SYSCALL_BASE_portable+103)
+#define __NR_setitimer_portable (__NR_SYSCALL_BASE_portable+104)
+#define __NR_getitimer_portable (__NR_SYSCALL_BASE_portable+105)
+#define __NR_stat_portable (__NR_SYSCALL_BASE_portable+106)
+#define __NR_lstat_portable (__NR_SYSCALL_BASE_portable+107)
+#define __NR_fstat_portable (__NR_SYSCALL_BASE_portable+108)
+
+#define __NR_vhangup_portable (__NR_SYSCALL_BASE_portable+111)
+
+#define __NR_syscall_portable (__NR_SYSCALL_BASE_portable+113)
+#define __NR_wait4_portable (__NR_SYSCALL_BASE_portable+114)
+#define __NR_swapoff_portable (__NR_SYSCALL_BASE_portable+115)
+#define __NR_sysinfo_portable (__NR_SYSCALL_BASE_portable+116)
+#define __NR_ipc_portable (__NR_SYSCALL_BASE_portable+117)
+#define __NR_fsync_portable (__NR_SYSCALL_BASE_portable+118)
+#define __NR_sigreturn_portable (__NR_SYSCALL_BASE_portable+119)
+#define __NR_clone_portable (__NR_SYSCALL_BASE_portable+120)
+#define __NR_setdomainname_portable (__NR_SYSCALL_BASE_portable+121)
+#define __NR_uname_portable (__NR_SYSCALL_BASE_portable+122)
+
+#define __NR_adjtimex_portable (__NR_SYSCALL_BASE_portable+124)
+#define __NR_mprotect_portable (__NR_SYSCALL_BASE_portable+125)
+#define __NR_sigprocmask_portable (__NR_SYSCALL_BASE_portable+126)
+
+#define __NR_init_module_portable (__NR_SYSCALL_BASE_portable+128)
+#define __NR_delete_module_portable (__NR_SYSCALL_BASE_portable+129)
+
+#define __NR_quotactl_portable (__NR_SYSCALL_BASE_portable+131)
+#define __NR_getpgid_portable (__NR_SYSCALL_BASE_portable+132)
+#define __NR_fchdir_portable (__NR_SYSCALL_BASE_portable+133)
+#define __NR_bdflush_portable (__NR_SYSCALL_BASE_portable+134)
+#define __NR_sysfs_portable (__NR_SYSCALL_BASE_portable+135)
+#define __NR_personality_portable (__NR_SYSCALL_BASE_portable+136)
+
+#define __NR_setfsuid_portable (__NR_SYSCALL_BASE_portable+138)
+#define __NR_setfsgid_portable (__NR_SYSCALL_BASE_portable+139)
+#define __NR__llseek_portable (__NR_SYSCALL_BASE_portable+140)
+#define __NR_getdents_portable (__NR_SYSCALL_BASE_portable+141)
+#define __NR__newselect_portable (__NR_SYSCALL_BASE_portable+142)
+#define __NR_flock_portable (__NR_SYSCALL_BASE_portable+143)
+#define __NR_msync_portable (__NR_SYSCALL_BASE_portable+144)
+#define __NR_readv_portable (__NR_SYSCALL_BASE_portable+145)
+#define __NR_writev_portable (__NR_SYSCALL_BASE_portable+146)
+#define __NR_getsid_portable (__NR_SYSCALL_BASE_portable+147)
+#define __NR_fdatasync_portable (__NR_SYSCALL_BASE_portable+148)
+#define __NR__sysctl_portable (__NR_SYSCALL_BASE_portable+149)
+#define __NR_mlock_portable (__NR_SYSCALL_BASE_portable+150)
+#define __NR_munlock_portable (__NR_SYSCALL_BASE_portable+151)
+#define __NR_mlockall_portable (__NR_SYSCALL_BASE_portable+152)
+#define __NR_munlockall_portable (__NR_SYSCALL_BASE_portable+153)
+#define __NR_sched_setparam_portable (__NR_SYSCALL_BASE_portable+154)
+#define __NR_sched_getparam_portable (__NR_SYSCALL_BASE_portable+155)
+#define __NR_sched_setscheduler_portable (__NR_SYSCALL_BASE_portable+156)
+#define __NR_sched_getscheduler_portable (__NR_SYSCALL_BASE_portable+157)
+#define __NR_sched_yield_portable (__NR_SYSCALL_BASE_portable+158)
+#define __NR_sched_get_priority_max_portable (__NR_SYSCALL_BASE_portable+159)
+#define __NR_sched_get_priority_min_portable (__NR_SYSCALL_BASE_portable+160)
+#define __NR_sched_rr_get_interval_portable (__NR_SYSCALL_BASE_portable+161)
+#define __NR_nanosleep_portable (__NR_SYSCALL_BASE_portable+162)
+#define __NR_mremap_portable (__NR_SYSCALL_BASE_portable+163)
+#define __NR_setresuid_portable (__NR_SYSCALL_BASE_portable+164)
+#define __NR_getresuid_portable (__NR_SYSCALL_BASE_portable+165)
+
+#define __NR_poll_portable (__NR_SYSCALL_BASE_portable+168)
+#define __NR_nfsservctl_portable (__NR_SYSCALL_BASE_portable+169)
+#define __NR_setresgid_portable (__NR_SYSCALL_BASE_portable+170)
+#define __NR_getresgid_portable (__NR_SYSCALL_BASE_portable+171)
+#define __NR_prctl_portable (__NR_SYSCALL_BASE_portable+172)
+#define __NR_rt_sigreturn_portable (__NR_SYSCALL_BASE_portable+173)
+#define __NR_rt_sigaction_portable (__NR_SYSCALL_BASE_portable+174)
+#define __NR_rt_sigprocmask_portable (__NR_SYSCALL_BASE_portable+175)
+#define __NR_rt_sigpending_portable (__NR_SYSCALL_BASE_portable+176)
+#define __NR_rt_sigtimedwait_portable (__NR_SYSCALL_BASE_portable+177)
+#define __NR_rt_sigqueueinfo_portable (__NR_SYSCALL_BASE_portable+178)
+#define __NR_rt_sigsuspend_portable (__NR_SYSCALL_BASE_portable+179)
+#define __NR_pread64_portable (__NR_SYSCALL_BASE_portable+180)
+#define __NR_pwrite64_portable (__NR_SYSCALL_BASE_portable+181)
+#define __NR_chown_portable (__NR_SYSCALL_BASE_portable+182)
+#define __NR_getcwd_portable (__NR_SYSCALL_BASE_portable+183)
+#define __NR_capget_portable (__NR_SYSCALL_BASE_portable+184)
+#define __NR_capset_portable (__NR_SYSCALL_BASE_portable+185)
+#define __NR_sigaltstack_portable (__NR_SYSCALL_BASE_portable+186)
+#define __NR_sendfile_portable (__NR_SYSCALL_BASE_portable+187)
+
+#define __NR_vfork_portable (__NR_SYSCALL_BASE_portable+190)
+#define __NR_ugetrlimit_portable (__NR_SYSCALL_BASE_portable+191)
+#define __NR_mmap2_portable (__NR_SYSCALL_BASE_portable+192)
+#define __NR_truncate64_portable (__NR_SYSCALL_BASE_portable+193)
+#define __NR_ftruncate64_portable (__NR_SYSCALL_BASE_portable+194)
+#define __NR_stat64_portable (__NR_SYSCALL_BASE_portable+195)
+#define __NR_lstat64_portable (__NR_SYSCALL_BASE_portable+196)
+#define __NR_fstat64_portable (__NR_SYSCALL_BASE_portable+197)
+#define __NR_lchown32_portable (__NR_SYSCALL_BASE_portable+198)
+#define __NR_getuid32_portable (__NR_SYSCALL_BASE_portable+199)
+#define __NR_getgid32_portable (__NR_SYSCALL_BASE_portable+200)
+#define __NR_geteuid32_portable (__NR_SYSCALL_BASE_portable+201)
+#define __NR_getegid32_portable (__NR_SYSCALL_BASE_portable+202)
+#define __NR_setreuid32_portable (__NR_SYSCALL_BASE_portable+203)
+#define __NR_setregid32_portable (__NR_SYSCALL_BASE_portable+204)
+#define __NR_getgroups32_portable (__NR_SYSCALL_BASE_portable+205)
+#define __NR_setgroups32_portable (__NR_SYSCALL_BASE_portable+206)
+#define __NR_fchown32_portable (__NR_SYSCALL_BASE_portable+207)
+#define __NR_setresuid32_portable (__NR_SYSCALL_BASE_portable+208)
+#define __NR_getresuid32_portable (__NR_SYSCALL_BASE_portable+209)
+#define __NR_setresgid32_portable (__NR_SYSCALL_BASE_portable+210)
+#define __NR_getresgid32_portable (__NR_SYSCALL_BASE_portable+211)
+#define __NR_chown32_portable (__NR_SYSCALL_BASE_portable+212)
+#define __NR_setuid32_portable (__NR_SYSCALL_BASE_portable+213)
+#define __NR_setgid32_portable (__NR_SYSCALL_BASE_portable+214)
+#define __NR_setfsuid32_portable (__NR_SYSCALL_BASE_portable+215)
+#define __NR_setfsgid32_portable (__NR_SYSCALL_BASE_portable+216)
+#define __NR_getdents64_portable (__NR_SYSCALL_BASE_portable+217)
+#define __NR_pivot_root_portable (__NR_SYSCALL_BASE_portable+218)
+#define __NR_mincore_portable (__NR_SYSCALL_BASE_portable+219)
+#define __NR_madvise_portable (__NR_SYSCALL_BASE_portable+220)
+#define __NR_fcntl64_portable (__NR_SYSCALL_BASE_portable+221)
+
+#define __NR_gettid_portable (__NR_SYSCALL_BASE_portable+224)
+#define __NR_readahead_portable (__NR_SYSCALL_BASE_portable+225)
+#define __NR_setxattr_portable (__NR_SYSCALL_BASE_portable+226)
+#define __NR_lsetxattr_portable (__NR_SYSCALL_BASE_portable+227)
+#define __NR_fsetxattr_portable (__NR_SYSCALL_BASE_portable+228)
+#define __NR_getxattr_portable (__NR_SYSCALL_BASE_portable+229)
+#define __NR_lgetxattr_portable (__NR_SYSCALL_BASE_portable+230)
+#define __NR_fgetxattr_portable (__NR_SYSCALL_BASE_portable+231)
+#define __NR_listxattr_portable (__NR_SYSCALL_BASE_portable+232)
+#define __NR_llistxattr_portable (__NR_SYSCALL_BASE_portable+233)
+#define __NR_flistxattr_portable (__NR_SYSCALL_BASE_portable+234)
+#define __NR_removexattr_portable (__NR_SYSCALL_BASE_portable+235)
+#define __NR_lremovexattr_portable (__NR_SYSCALL_BASE_portable+236)
+#define __NR_fremovexattr_portable (__NR_SYSCALL_BASE_portable+237)
+#define __NR_tkill_portable (__NR_SYSCALL_BASE_portable+238)
+#define __NR_sendfile64_portable (__NR_SYSCALL_BASE_portable+239)
+#define __NR_futex_portable (__NR_SYSCALL_BASE_portable+240)
+#define __NR_sched_setaffinity_portable (__NR_SYSCALL_BASE_portable+241)
+#define __NR_sched_getaffinity_portable (__NR_SYSCALL_BASE_portable+242)
+#define __NR_io_setup_portable (__NR_SYSCALL_BASE_portable+243)
+#define __NR_io_destroy_portable (__NR_SYSCALL_BASE_portable+244)
+#define __NR_io_getevents_portable (__NR_SYSCALL_BASE_portable+245)
+#define __NR_io_submit_portable (__NR_SYSCALL_BASE_portable+246)
+#define __NR_io_cancel_portable (__NR_SYSCALL_BASE_portable+247)
+#define __NR_exit_group_portable (__NR_SYSCALL_BASE_portable+248)
+#define __NR_lookup_dcookie_portable (__NR_SYSCALL_BASE_portable+249)
+#define __NR_epoll_create_portable (__NR_SYSCALL_BASE_portable+250)
+#define __NR_epoll_ctl_portable (__NR_SYSCALL_BASE_portable+251)
+#define __NR_epoll_wait_portable (__NR_SYSCALL_BASE_portable+252)
+#define __NR_remap_file_pages_portable (__NR_SYSCALL_BASE_portable+253)
+
+#define __NR_set_tid_address_portable (__NR_SYSCALL_BASE_portable+256)
+#define __NR_timer_create_portable (__NR_SYSCALL_BASE_portable+257)
+#define __NR_timer_settime_portable (__NR_SYSCALL_BASE_portable+258)
+#define __NR_timer_gettime_portable (__NR_SYSCALL_BASE_portable+259)
+#define __NR_timer_getoverrun_portable (__NR_SYSCALL_BASE_portable+260)
+#define __NR_timer_delete_portable (__NR_SYSCALL_BASE_portable+261)
+#define __NR_clock_settime_portable (__NR_SYSCALL_BASE_portable+262)
+#define __NR_clock_gettime_portable (__NR_SYSCALL_BASE_portable+263)
+#define __NR_clock_getres_portable (__NR_SYSCALL_BASE_portable+264)
+#define __NR_clock_nanosleep_portable (__NR_SYSCALL_BASE_portable+265)
+#define __NR_statfs64_portable (__NR_SYSCALL_BASE_portable+266)
+#define __NR_fstatfs64_portable (__NR_SYSCALL_BASE_portable+267)
+#define __NR_tgkill_portable (__NR_SYSCALL_BASE_portable+268)
+#define __NR_utimes_portable (__NR_SYSCALL_BASE_portable+269)
+#define __NR_arm_fadvise64_64_portable (__NR_SYSCALL_BASE_portable+270)
+#define __NR_pciconfig_iobase_portable (__NR_SYSCALL_BASE_portable+271)
+#define __NR_pciconfig_read_portable (__NR_SYSCALL_BASE_portable+272)
+#define __NR_pciconfig_write_portable (__NR_SYSCALL_BASE_portable+273)
+#define __NR_mq_open_portable (__NR_SYSCALL_BASE_portable+274)
+#define __NR_mq_unlink_portable (__NR_SYSCALL_BASE_portable+275)
+#define __NR_mq_timedsend_portable (__NR_SYSCALL_BASE_portable+276)
+#define __NR_mq_timedreceive_portable (__NR_SYSCALL_BASE_portable+277)
+#define __NR_mq_notify_portable (__NR_SYSCALL_BASE_portable+278)
+#define __NR_mq_getsetattr_portable (__NR_SYSCALL_BASE_portable+279)
+#define __NR_waitid_portable (__NR_SYSCALL_BASE_portable+280)
+#define __NR_socket_portable (__NR_SYSCALL_BASE_portable+281)
+#define __NR_bind_portable (__NR_SYSCALL_BASE_portable+282)
+#define __NR_connect_portable (__NR_SYSCALL_BASE_portable+283)
+#define __NR_listen_portable (__NR_SYSCALL_BASE_portable+284)
+#define __NR_accept_portable (__NR_SYSCALL_BASE_portable+285)
+#define __NR_getsockname_portable (__NR_SYSCALL_BASE_portable+286)
+#define __NR_getpeername_portable (__NR_SYSCALL_BASE_portable+287)
+#define __NR_socketpair_portable (__NR_SYSCALL_BASE_portable+288)
+#define __NR_send_portable (__NR_SYSCALL_BASE_portable+289)
+#define __NR_sendto_portable (__NR_SYSCALL_BASE_portable+290)
+#define __NR_recv_portable (__NR_SYSCALL_BASE_portable+291)
+#define __NR_recvfrom_portable (__NR_SYSCALL_BASE_portable+292)
+#define __NR_shutdown_portable (__NR_SYSCALL_BASE_portable+293)
+#define __NR_setsockopt_portable (__NR_SYSCALL_BASE_portable+294)
+#define __NR_getsockopt_portable (__NR_SYSCALL_BASE_portable+295)
+#define __NR_sendmsg_portable (__NR_SYSCALL_BASE_portable+296)
+#define __NR_recvmsg_portable (__NR_SYSCALL_BASE_portable+297)
+#define __NR_semop_portable (__NR_SYSCALL_BASE_portable+298)
+#define __NR_semget_portable (__NR_SYSCALL_BASE_portable+299)
+#define __NR_semctl_portable (__NR_SYSCALL_BASE_portable+300)
+#define __NR_msgsnd_portable (__NR_SYSCALL_BASE_portable+301)
+#define __NR_msgrcv_portable (__NR_SYSCALL_BASE_portable+302)
+#define __NR_msgget_portable (__NR_SYSCALL_BASE_portable+303)
+#define __NR_msgctl_portable (__NR_SYSCALL_BASE_portable+304)
+#define __NR_shmat_portable (__NR_SYSCALL_BASE_portable+305)
+#define __NR_shmdt_portable (__NR_SYSCALL_BASE_portable+306)
+#define __NR_shmget_portable (__NR_SYSCALL_BASE_portable+307)
+#define __NR_shmctl_portable (__NR_SYSCALL_BASE_portable+308)
+#define __NR_add_key_portable (__NR_SYSCALL_BASE_portable+309)
+#define __NR_request_key_portable (__NR_SYSCALL_BASE_portable+310)
+#define __NR_keyctl_portable (__NR_SYSCALL_BASE_portable+311)
+#define __NR_semtimedop_portable (__NR_SYSCALL_BASE_portable+312)
+#define __NR_vserver_portable (__NR_SYSCALL_BASE_portable+313)
+#define __NR_ioprio_set_portable (__NR_SYSCALL_BASE_portable+314)
+#define __NR_ioprio_get_portable (__NR_SYSCALL_BASE_portable+315)
+#define __NR_inotify_init_portable (__NR_SYSCALL_BASE_portable+316)
+#define __NR_inotify_add_watch_portable (__NR_SYSCALL_BASE_portable+317)
+#define __NR_inotify_rm_watch_portable (__NR_SYSCALL_BASE_portable+318)
+#define __NR_mbind_portable (__NR_SYSCALL_BASE_portable+319)
+#define __NR_get_mempolicy_portable (__NR_SYSCALL_BASE_portable+320)
+#define __NR_set_mempolicy_portable (__NR_SYSCALL_BASE_portable+321)
+
+#define  __NR_openat_portable (__NR_SYSCALL_BASE_portable+322)
+#define  __NR_mkdirat_portable (__NR_SYSCALL_BASE_portable+323)
+#define  __NR_mknodat_portable (__NR_SYSCALL_BASE_portable+324)
+#define  __NR_fchownat_portable (__NR_SYSCALL_BASE_portable+325)
+#define  __NR_futimesat_portable (__NR_SYSCALL_BASE_portable+326)
+#define  __NR_fstatat64_portable (__NR_SYSCALL_BASE_portable+327)
+#define  __NR_unlinkat_portable (__NR_SYSCALL_BASE_portable+328)
+#define  __NR_renameat_portable (__NR_SYSCALL_BASE_portable+329)
+#define  __NR_linkat_portable (__NR_SYSCALL_BASE_portable+330)
+#define  __NR_symlinkat_portable (__NR_SYSCALL_BASE_portable+331)
+#define  __NR_readlinkat_portable (__NR_SYSCALL_BASE_portable+332)
+#define  __NR_fchmodat_portable (__NR_SYSCALL_BASE_portable+333)
+#define  __NR_faccessat_portable (__NR_SYSCALL_BASE_portable+334)
+#define  __NR_pselect6_portable (__NR_SYSCALL_BASE_portable+335)
+#define  __NR_ppoll_portable (__NR_SYSCALL_BASE_portable+336)
+#define  __NR_unshare_portable (__NR_SYSCALL_BASE_portable+337)
+#define  __NR_set_robust_list_portable (__NR_SYSCALL_BASE_portable+338)
+#define  __NR_get_robust_list_portable (__NR_SYSCALL_BASE_portable+339)
+#define  __NR_splice_portable (__NR_SYSCALL_BASE_portable+340)
+#define  __NR_arm_sync_file_range_portable (__NR_SYSCALL_BASE_portable+341)
+#define  __NR_tee_portable (__NR_SYSCALL_BASE_portable+342)
+#define  __NR_vmsplice_portable (__NR_SYSCALL_BASE_portable+343)
+#define  __NR_move_pages_portable (__NR_SYSCALL_BASE_portable+344)
+#define  __NR_getcpu_portable (__NR_SYSCALL_BASE_portable+345)
+#define  __NR_epoll_pwait_portable (__NR_SYSCALL_BASE_portable+346)
+#define  __NR_kexec_load_portable (__NR_SYSCALL_BASE_portable+347)
+#define  __NR_utimensat_portable (__NR_SYSCALL_BASE_portable+348)
+#define  __NR_signalfd_portable (__NR_SYSCALL_BASE_portable+349)
+#define  __NR_timerfd_create_portable (__NR_SYSCALL_BASE_portable+350)
+#define  __NR_eventfd_portable (__NR_SYSCALL_BASE_portable+351)
+#define  __NR_fallocate_portable (__NR_SYSCALL_BASE_portable+352)
+#define  __NR_timerfd_settime_portable (__NR_SYSCALL_BASE_portable+353)
+#define  __NR_timerfd_gettime_portable (__NR_SYSCALL_BASE_portable+354)
+#define  __NR_signalfd4_portable (__NR_SYSCALL_BASE_portable+355)
+#define  __NR_eventfd2_portable (__NR_SYSCALL_BASE_portable+356)
+#define  __NR_epoll_create1_portable (__NR_SYSCALL_BASE_portable+357)
+#define  __NR_dup3_portable (__NR_SYSCALL_BASE_portable+358)
+#define  __NR_pipe2_portable (__NR_SYSCALL_BASE_portable+359)
+#define  __NR_inotify_init1_portable (__NR_SYSCALL_BASE_portable+360)
+#define  __NR_preadv_portable (__NR_SYSCALL_BASE_portable+361)
+#define  __NR_pwritev_portable (__NR_SYSCALL_BASE_portable+362)
+#define  __NR_rt_tgsigqueueinfo_portable (__NR_SYSCALL_BASE_portable+363)
+#define  __NR_perf_event_open_portable (__NR_SYSCALL_BASE_portable+364)
+#define  __NR_recvmmsg_portable (__NR_SYSCALL_BASE_portable+365)
+#define  __NR_accept4_portable (__NR_SYSCALL_BASE_portable+366)
+#define  __NR_fanotify_init_portable (__NR_SYSCALL_BASE_portable+367)
+#define  __NR_fanotify_mark_portable (__NR_SYSCALL_BASE_portable+368)
+#define  __NR_prlimit64_portable (__NR_SYSCALL_BASE_portable+369)
+#define  __NR_name_to_handle_at_portable (__NR_SYSCALL_BASE_portable+370)
+#define  __NR_open_by_handle_at_portable (__NR_SYSCALL_BASE_portable+371)
+#define  __NR_clock_adjtime_portable (__NR_SYSCALL_BASE_portable+372)
+#define  __NR_syncfs_portable (__NR_SYSCALL_BASE_portable+373)
+#define  __NR_sendmmsg_portable (__NR_SYSCALL_BASE_portable+374)
+#define  __NR_setns_portable (__NR_SYSCALL_BASE_portable+375)
+#define  __NR_process_vm_readv_portable (__NR_SYSCALL_BASE_portable+376)
+#define  __NR_process_vm_writev_portable (__NR_SYSCALL_BASE_portable+377)
+
+
+#define __ARM_NR_BASE_portable (__NR_SYSCALL_BASE_portable+0x0f0000)
+#define __ARM_NR_breakpoint_portable (__ARM_NR_BASE_portable+1)
+#define __ARM_NR_cacheflush_portable (__ARM_NR_BASE_portable+2)
+#define __ARM_NR_usr26_portable (__ARM_NR_BASE_portable+3)
+#define __ARM_NR_usr32_portable (__ARM_NR_BASE_portable+4)
+#define __ARM_NR_set_tls_portable (__ARM_NR_BASE_portable+5)
+
+/* Apparently these are not callable using syscall on ARM... */
+#undef __NR_time_portable
+#undef __NR_umount_portable
+#undef __NR_stime_portable
+#undef __NR_alarm_portable
+#undef __NR_utime_portable
+#undef __NR_getrlimit_portable
+#undef __NR_select_portable
+#undef __NR_readdir_portable
+#undef __NR_mmap_portable
+#undef __NR_socketcall_portable
+#undef __NR_syscall_portable
+#undef __NR_ipc_portable
+
+#endif
diff --git a/ndk/sources/android/libportable/common/include/errno_portable.h b/ndk/sources/android/libportable/common/include/errno_portable.h
index c2f6523..61888c6 100644
--- a/ndk/sources/android/libportable/common/include/errno_portable.h
+++ b/ndk/sources/android/libportable/common/include/errno_portable.h
@@ -17,7 +17,14 @@
 #ifndef _ERRNO_PORTABLE_H_
 #define _ERRNO_PORTABLE_H_
 
-/* Derived from development/ndk/platforms/android-3/include/asm-generic/errno.h */
+#include <portability.h>
+
+/*
+ * Derived from development/ndk/platforms/android-3/include/asm-generic/errno.h
+ * NOTE:
+ *   Base errno #defines from 1...35 are ARCH independent and not defined;
+ *   they are defined in ./asm-generic/errno-base.h
+ */
 #define EDEADLK_PORTABLE 35
 #define ENAMETOOLONG_PORTABLE 36
 #define ENOLCK_PORTABLE 37
@@ -120,4 +127,9 @@
 #define EOWNERDEAD_PORTABLE 130
 #define ENOTRECOVERABLE_PORTABLE 131
 
+extern __hidden int errno_ntop(int native_errno);
+extern __hidden int errno_pton(int native_errno);
+
+extern volatile int*   REAL(__errno)(void);
+
 #endif /* _ERRNO_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/eventfd_portable.h b/ndk/sources/android/libportable/common/include/eventfd_portable.h
new file mode 100644
index 0000000..d72ca8d
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/eventfd_portable.h
@@ -0,0 +1,63 @@
+/*
+ * Derived from bionic/libc/include/sys/eventfd.h
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _SYS_EVENTFD_PORTABLE_H
+#define _SYS_EVENTFD_PORTABLE_H
+
+#include <portability.h>
+#include <sys/cdefs.h>
+#include <fcntl_portable.h>
+
+__BEGIN_DECLS
+
+/*
+ * EFD_SEMAPHORE is defined in recent linux kernels;
+ * but isn't mentioned elsewhere. See linux 3.4
+ * include/linux/eventfd.h for example.
+ */
+#define EFD_SEMAPHORE           (1 << 0)
+
+#define EFD_SEMAPHORE_PORTABLE  EFD_SEMAPHORE
+#define EFD_CLOEXEC_PORTABLE    O_CLOEXEC_PORTABLE
+#define EFD_NONBLOCK_PORTABLE   O_NONBLOCK_PORTABLE
+
+/* type of event counter */
+typedef uint64_t  eventfd_portable_t;
+
+extern int WRAP(eventfd)(unsigned int initval, int flags);
+
+#if 0
+/* Compatibility with GLibc; libportable versions don't appear to be necessary */
+extern int eventfd_read(int fd, eventfd_t *counter);
+extern int eventfd_write(int fd, const eventfd_t counter);
+#endif
+
+__END_DECLS
+
+#endif /* _SYS_EVENTFD_H */
diff --git a/ndk/sources/android/libportable/common/include/fcntl_portable.h b/ndk/sources/android/libportable/common/include/fcntl_portable.h
index 7240ad3..6e99c8b 100644
--- a/ndk/sources/android/libportable/common/include/fcntl_portable.h
+++ b/ndk/sources/android/libportable/common/include/fcntl_portable.h
@@ -18,7 +18,7 @@
 #define _FCNTL_PORTABLE_H_
 
 /* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/fcntl.h */
-/* NB x86 does not have these and only uses the generic definitions */
+/* NB x86 does not have these and only uses the generic definitions. */
 #define O_DIRECTORY_PORTABLE    040000
 #define O_NOFOLLOW_PORTABLE     0100000
 #define O_DIRECT_PORTABLE       0200000
@@ -72,6 +72,30 @@
 #define O_NDELAY_PORTABLE   O_NONBLOCK_PORTABLE
 #endif
 
+/* From Bionic libc/kernel/common/asm-generic/fcntl.h */
+#ifndef O_CLOEXEC_PORTABLE
+#define O_CLOEXEC_PORTABLE 02000000
+#endif
+
+#ifndef __ARCH_FLOCK64_PAD
+#define __ARCH_FLOCK64_PAD
+#endif
+
+/*
+ * For use with F_GETLK and F_SETLK
+ */
+struct flock_portable {
+   short l_type;
+   short l_whence;
+   off_t l_start;
+   off_t l_len;
+   pid_t l_pid;
+   __ARCH_FLOCK64_PAD
+};
+
+/*
+ * For use with F_GETLK64 and F_SETLK64
+ */
 struct flock64_portable {
    short l_type;
    short l_whence;
@@ -82,9 +106,10 @@
    __ARCH_FLOCK64_PAD
 };
 
+#if 0
 /*
-The X86 Version is
-
+ * The X86 Version is
+ */
 struct flock64 {
    short l_type;
    short l_whence;
@@ -93,22 +118,48 @@
    pid_t l_pid;
    __ARCH_FLOCK64_PAD
 };
-*/
+#endif /* 0 */
+
+
+#ifndef F_DUPFD_PORTABLE
+#define F_DUPFD_PORTABLE 0
+#define F_GETFD_PORTABLE 1
+#define F_SETFD_PORTABLE 2
+#define F_GETFL_PORTABLE 3
+#define F_SETFL_PORTABLE 4
+#endif
 
 #ifndef F_GETLK_PORTABLE
 #define F_GETLK_PORTABLE 5
 #define F_SETLK_PORTABLE 6
 #define F_SETLKW_PORTABLE 7
 #endif
+
 #ifndef F_SETOWN_PORTABLE
 #define F_SETOWN_PORTABLE 8
 #define F_GETOWN_PORTABLE 9
 #endif
 
+#ifndef F_SETSIG_PORTABLE
+#define F_SETSIG_PORTABLE 10
+#define F_GETSIG_PORTABLE 11
+#endif
+
 #ifndef F_GETLK64_PORTABLE
 #define F_GETLK64_PORTABLE 12
 #define F_SETLK64_PORTABLE 13
 #define F_SETLKW64_PORTABLE 14
 #endif
 
+/* This constant seems to be the same for all ARCH's */
+#define F_LINUX_SPECIFIC_BASE_PORTABLE 1024
+
+#define F_SETLEASE_PORTABLE             (F_LINUX_SPECIFIC_BASE+0)       /* 1024 */
+#define F_GETLEASE_PORTABLE             (F_LINUX_SPECIFIC_BASE+1)       /* 1025 */
+#define F_NOTIFY_PORTABLE               (F_LINUX_SPECIFIC_BASE+2)       /* 1026 */
+
+/* Currently these are only supported by X86_64 */
+#define F_CANCELLK_PORTABLE             (F_LINUX_SPECIFIC_BASE+5)       /* 1029 */
+#define F_DUPFD_CLOEXEC_PORTABLE        (F_LINUX_SPECIFIC_BASE+6)       /* 1030 */
+
 #endif /* _FCNTL_PORTABLE_H */
diff --git a/ndk/sources/android/libportable/common/include/fenv_portable.h b/ndk/sources/android/libportable/common/include/fenv_portable.h
new file mode 100644
index 0000000..902c141
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/fenv_portable.h
@@ -0,0 +1,37 @@
+/*
+ * 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 _FENV_PORTABLE_H_
+#define _FENV_PORTABLE_H_
+
+#include <sys/types.h>
+
+/* Exception flags. */
+#define FE_INVALID_PORTABLE    0x01
+#define FE_DIVBYZERO_PORTABLE  0x02
+#define FE_OVERFLOW_PORTABLE   0x04
+#define FE_UNDERFLOW_PORTABLE  0x08
+#define FE_INEXACT_PORTABLE    0x10
+#define FE_ALL_EXCEPT_PORTABLE (FE_DIVBYZERO_PORTABLE | FE_INEXACT_PORTABLE | FE_INVALID_PORTABLE |\
+                                FE_OVERFLOW_PORTABLE | FE_UNDERFLOW_PORTABLE)
+
+/* Rounding modes. */
+#define FE_TONEAREST_PORTABLE  0x0
+#define FE_UPWARD_PORTABLE     0x1
+#define FE_DOWNWARD_PORTABLE   0x2
+#define FE_TOWARDZERO_PORTABLE 0x3
+
+#endif /* _FENV_PORTABLE_H_ */
diff --git a/ndk/sources/android/libportable/common/include/filefd_portable.h b/ndk/sources/android/libportable/common/include/filefd_portable.h
new file mode 100644
index 0000000..76cd4b8
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/filefd_portable.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012, 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 _FILEFD_PORTABLE_H_
+#define _FILEFD_PORTABLE_H_
+
+/*
+ * Maintaining a list of special file descriptors in lib-portable
+ * which are maintained across a execve() via environment variables.
+ * See portable/arch-mips/filefd.c for details.
+ */
+enum filefd_type {
+    UNUSED_FD_TYPE = 0,
+    EVENT_FD_TYPE,
+    INOTIFY_FD_TYPE,
+    SIGNAL_FD_TYPE,
+    TIMER_FD_TYPE,
+    MAX_FD_TYPE
+};
+
+extern __hidden void filefd_opened(int fd, enum filefd_type fd_type);
+extern __hidden void filefd_closed(int fd);
+extern __hidden void filefd_CLOEXEC_enabled(int fd);
+extern __hidden void filefd_CLOEXEC_disabled(int fd);
+extern __hidden void filefd_disable_mapping(void);
+
+extern int WRAP(close)(int fd);
+extern int WRAP(read)(int fd, void *buf, size_t count);
+extern int WRAP(pipe2)(int pipefd[2], int portable_flags);
+
+#endif /* _FILEFD_PORTABLE_H_ */
diff --git a/ndk/sources/android/libportable/common/include/inotify_portable.h b/ndk/sources/android/libportable/common/include/inotify_portable.h
new file mode 100644
index 0000000..09d4d64
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/inotify_portable.h
@@ -0,0 +1,51 @@
+/*
+ * Derived from bionic/libc/include/sys/eventfd.h
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_INOTIFY_PORTABLE_H
+#define _SYS_INOTIFY_PORTABLE_H
+
+#include <portability.h>
+#include <sys/cdefs.h>
+#include <fcntl.h>
+#include <fcntl_portable.h>
+
+__BEGIN_DECLS
+
+#define  IN_CLOEXEC   O_CLOEXEC
+#define  IN_NONBLOCK  O_NONBLOCK
+
+#define  IN_CLOEXEC_PORTABLE   O_CLOEXEC_PORTABLE
+#define  IN_NONBLOCK_PORTABLE  O_NONBLOCK_PORTABLE
+
+extern int WRAP(inotify_init1)(int flags);
+
+__END_DECLS
+
+#endif /* _SYS_INOTIFY_H */
diff --git a/ndk/sources/android/libportable/common/include/ioctls_portable.h b/ndk/sources/android/libportable/common/include/ioctls_portable.h
index e9e977c..9c03f25 100644
--- a/ndk/sources/android/libportable/common/include/ioctls_portable.h
+++ b/ndk/sources/android/libportable/common/include/ioctls_portable.h
@@ -17,8 +17,9 @@
 #ifndef _IOCTLS_PORTABLE_H_
 #define _IOCTLS_PORTABLE_H_
 
-/* Derived from development/ndk/platforms/android-3/include/asm-generic/ioctl.h */
-
+/*
+ * Derived from development/ndk/platforms/android-3/include/asm-generic/ioctl.h
+ */
 #define _IOC_NRBITS_PORTABLE 8
 #define _IOC_TYPEBITS_PORTABLE 8
 #define _IOC_SIZEBITS_PORTABLE 14
@@ -38,18 +39,37 @@
 #define _IOC_WRITE_PORTABLE 1U
 #define _IOC_READ_PORTABLE 2U
 
-#define _IOC_PORTABLE(dir,type,nr,size)   (((dir) << _IOC_DIRSHIFT_PORTABLE) |   ((type) << _IOC_TYPESHIFT_PORTABLE) |   ((nr) << _IOC_NRSHIFT_PORTABLE) |   ((size) << _IOC_SIZESHIFT_PORTABLE))
+#define _IOC_PORTABLE(dir, type, nr, size) (                                            \
+    ((dir) << _IOC_DIRSHIFT_PORTABLE)    |                                              \
+    ((type) << _IOC_TYPESHIFT_PORTABLE)  |                                              \
+    ((nr) << _IOC_NRSHIFT_PORTABLE)      |                                              \
+    ((size) << _IOC_SIZESHIFT_PORTABLE)                                                 \
+)
 
 extern unsigned int __invalid_size_argument_for_IOC;
-#define _IOC_TYPECHECK_PORTABLE(t)   ((sizeof(t) == sizeof(t[1]) &&   sizeof(t) < (1 << _IOC_SIZEBITS_PORTABLE)) ?   sizeof(t) : __invalid_size_argument_for_IOC)
 
-#define _IO_PORTABLE(type,nr) _IOC_PORTABLE(_IOC_NONE_PORTABLE,(type),(nr),0)
-#define _IOR_PORTABLE(type,nr,size) _IOC_PORTABLE(_IOC_READ_PORTABLE,(type),(nr),(_IOC_TYPECHECK_PORTABLE(size)))
-#define _IOW_PORTABLE(type,nr,size) _IOC_PORTABLE(_IOC_WRITE_PORTABLE,(type),(nr),(_IOC_TYPECHECK_PORTABLE(size)))
-#define _IOWR_PORTABLE(type,nr,size) _IOC_PORTABLE(_IOC_READ_PORTABLE|_IOC_WRITE_PORTABLE,(type),(nr),(_IOC_TYPECHECK_PORTABLE(size)))
+#define _IOC_TYPECHECK_PORTABLE(t) (                                                    \
+    (sizeof(t) == sizeof(t[1]) && sizeof(t) < (1 << _IOC_SIZEBITS_PORTABLE)) ?          \
+    sizeof(t) :                                                                         \
+    __invalid_size_argument_for_IOC                                                     \
+)
 
-/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/ioctls.h */
+#define _IO_PORTABLE(type, nr) _IOC_PORTABLE(_IOC_NONE_PORTABLE, (type), (nr), 0)
 
+#define _IOR_PORTABLE(type, nr, size)                                                    \
+    _IOC_PORTABLE(_IOC_READ_PORTABLE, (type), (nr), (_IOC_TYPECHECK_PORTABLE(size)))
+
+#define _IOW_PORTABLE(type, nr, size)                                                    \
+    _IOC_PORTABLE(_IOC_WRITE_PORTABLE, (type), (nr), (_IOC_TYPECHECK_PORTABLE(size)))
+
+#define _IOWR_PORTABLE(type, nr, size)                                                   \
+    IOC_PORTABLE(_IOC_READ_PORTABLE |                                                    \
+                 _IOC_WRITE_PORTABLE, (type), (nr), (IOC_TYPECHECK_PORTABLE(size)) )
+
+
+/*
+ * Derived from development/ndk/platforms/android-3/arch-arm/include/asm/ioctls.h
+ */
 #define TCGETS_PORTABLE     0x5401
 #define TCSETS_PORTABLE     0x5402
 #define TCSETSW_PORTABLE    0x5403
@@ -121,8 +141,9 @@
 
 #define TIOCSER_TEMT_PORTABLE   0x01
 
-/* Derived from development/ndk/platforms/android-3/include/sys/ioctl_compat.h */
-
+/*
+ * Derived from development/ndk/platforms/android-3/include/sys/ioctl_compat.h
+ */
 struct tchars_portable {
         char    t_intrc;        /* interrupt */
         char    t_quitc;        /* quit */
@@ -142,11 +163,11 @@
 };
 
 struct sgttyb_portable {
-        char    sg_ispeed;              /* input speed */
-        char    sg_ospeed;              /* output speed */
-        char    sg_erase;               /* erase character */
-        char    sg_kill;                /* kill character */
-        short   sg_flags;               /* mode flags */
+        char    sg_ispeed;      /* input speed */
+        char    sg_ospeed;      /* output speed */
+        char    sg_erase;       /* erase character */
+        char    sg_kill;        /* kill character */
+        short   sg_flags;       /* mode flags */
 };
 
 #ifdef USE_OLD_TTY
@@ -156,23 +177,49 @@
 # define OTIOCGETD_PORTABLE  _IOR_PORTABLE('t', 0, int)       /* get line discipline */
 # define OTIOCSETD_PORTABLE  _IOW_PORTABLE('t', 1, int)       /* set line discipline */
 #endif
-#define TIOCHPCL_PORTABLE    _IO_PORTABLE('t', 2)             /* hang up on last close */
-#define TIOCGETP_PORTABLE    _IOR_PORTABLE('t', 8,struct sgttyb_portable)/* get parameters -- gtty */
-#define TIOCSETP_PORTABLE    _IOW_PORTABLE('t', 9,struct sgttyb_portable)/* set parameters -- stty */
-#define TIOCSETN_PORTABLE    _IOW_PORTABLE('t',10,struct sgttyb_portable)/* as above, but no flushtty*/
-#define TIOCSETC_PORTABLE    _IOW_PORTABLE('t',17,struct tchars_portable)/* set special characters */
-#define TIOCGETC_PORTABLE    _IOR_PORTABLE('t',18,struct tchars_portable)/* get special characters */
 
-#define TIOCLBIS_PORTABLE    _IOW_PORTABLE('t', 127, int)     /* bis local mode bits */
-#define TIOCLBIC_PORTABLE    _IOW_PORTABLE('t', 126, int)     /* bic local mode bits */
-#define TIOCLSET_PORTABLE    _IOW_PORTABLE('t', 125, int)     /* set entire local mode word */
-#define TIOCLGET_PORTABLE    _IOR_PORTABLE('t', 124, int)     /* get local modes */
-#define TIOCSLTC_PORTABLE    _IOW_PORTABLE('t',117,struct ltchars_portable)/* set local special chars*/
-#define TIOCGLTC_PORTABLE    _IOR_PORTABLE('t',116,struct ltchars_portable)/* get local special chars*/
-#define OTIOCCONS_PORTABLE   _IO_PORTABLE('t', 98)    /* for hp300 -- sans int arg */
+/* hang up on last close */
+#define TIOCHPCL_PORTABLE    _IO_PORTABLE('t', 2)
 
-/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/sockios.h */
+/* get parameters -- gtty */
+#define TIOCGETP_PORTABLE    _IOR_PORTABLE('t', 8,struct sgttyb_portable)
 
+/* set parameters -- stty */
+#define TIOCSETP_PORTABLE    _IOW_PORTABLE('t', 9,struct sgttyb_portable)
+
+/* as above, but no flushtty*/
+#define TIOCSETN_PORTABLE    _IOW_PORTABLE('t',10,struct sgttyb_portable)
+
+/* set special characters */
+#define TIOCSETC_PORTABLE    _IOW_PORTABLE('t',17,struct tchars_portable)
+
+/* get special characters */
+#define TIOCGETC_PORTABLE    _IOR_PORTABLE('t',18,struct tchars_portable)
+
+/* bis local mode bits */
+#define TIOCLBIS_PORTABLE    _IOW_PORTABLE('t', 127, int)
+
+/* bic local mode bits */
+#define TIOCLBIC_PORTABLE    _IOW_PORTABLE('t', 126, int)
+
+/* set entire local mode word */
+#define TIOCLSET_PORTABLE    _IOW_PORTABLE('t', 125, int)
+
+/* get local modes */
+#define TIOCLGET_PORTABLE    _IOR_PORTABLE('t', 124, int)
+
+/* set local special chars*/
+#define TIOCSLTC_PORTABLE    _IOW_PORTABLE('t',117,struct ltchars_portable)
+
+/* get local special chars*/
+#define TIOCGLTC_PORTABLE    _IOR_PORTABLE('t',116,struct ltchars_portable)
+
+ /* for hp300 -- sans int arg */
+#define OTIOCCONS_PORTABLE   _IO_PORTABLE('t', 98)
+
+/*
+ * Derived from development/ndk/platforms/android-3/arch-arm/include/asm/sockios.h
+ */
 #define FIOSETOWN_PORTABLE 0x8901
 #define SIOCSPGRP_PORTABLE 0x8902
 #define FIOGETOWN_PORTABLE 0x8903
diff --git a/ndk/sources/android/libportable/common/include/log_portable.h b/ndk/sources/android/libportable/common/include/log_portable.h
new file mode 100644
index 0000000..1a4fd43
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/log_portable.h
@@ -0,0 +1,101 @@
+/*
+ * ALOG Levels: F - Fatal, E - Error, W - Warning, I - Info, D - Debug, V - Verbose
+ *
+ * Using them to work within the Android logcat logging mechanism:
+ *
+ *    % logcat '*:v'                    [To display Verbose Logging]
+ *    % logcat 'fcntl_portable:v'       [To display just this fcntl logging]
+ *
+ * NOTE: This assumes you only use the 'PORTABLE_TAG'; which is the default.
+ *       For debugging LTP it's been helpful to include the LTP program being tested;
+ *       which is enabled below with #define EXTENDED_LOGGING.
+ *
+ * Logging routines also support ALOG*_IF() and ASSERT(); For details See:
+ *
+ *       ${ANDROID_TOP}/system/core/include/cutils/log.h
+ * and
+ *        http://developer.android.com/tools/debugging/debugging-log.html
+ *
+ * ALOGV is turned off by release builds: Use the #define below with LOG_NDEBUG=0 to enable.
+ *
+ * Strace works fine with ALOG out if a large max string size is used via the -s option;
+ * Example:
+ *
+ *   strace -s 132 ./sigaction01
+ *
+ *   writev(3, [{"\2", 1},
+ *      {"./sigaction01`signal_portable\0", 30},
+ *      {"sigaction_portable(portable_signum:10:'SIGUSR1_PORTABLE:10', ...
+ *      {"map_portable_sigset_to_mips(portable_sigset:0x7fe47a0c, ...
+ *      ...
+ */
+
+ /*
+  * Enable LOG_NDEBUG to have debug code visible in logcat output by default.
+  * Also possible via the Lib-Portable Android.mk  file. Example:
+  *
+  *     # Have logging permanently enable during development.
+  *     LOCAL_CFLAGS += -DLOG_NDEBUG=0
+  */
+// # define LOG_NDEBUG 0
+
+
+// #define EXTENDED_LOGGING        /* Include the current program name in the LOG_TAG */
+#ifdef EXTENDED_LOGGING
+/*
+ * Inline function to put the current program name
+ * and this library into the logcat prefix. Example:
+ *
+ *    V/./sigaction01`signal_portable(605): sigaction_portable(... ) {
+ *      -----------------------------
+ *
+ * Disabled by default in AOSP, enable by removing the // above.
+ * Useful when debugging more than one program; For example LTP has thousands.
+ */
+#define MAX_TAG_LEN 128
+static char my_portable_tag[MAX_TAG_LEN + 1];
+
+static inline char *portable_tag() {
+    extern char *__progname;
+
+    if (my_portable_tag[0] == '\000') {
+        strncat(&my_portable_tag[0], __progname, MAX_TAG_LEN);
+        strncat(&my_portable_tag[0], ".", MAX_TAG_LEN - strlen(my_portable_tag));
+        strncat(&my_portable_tag[0], PORTABLE_TAG, MAX_TAG_LEN - strlen(my_portable_tag));
+    }
+    return my_portable_tag;
+}
+#define LOG_TAG  portable_tag()
+#else /* !EXTENDED_LOGGING */
+#define LOG_TAG PORTABLE_TAG
+#endif
+
+/*
+ * Override LOG_PRI() defined in ${AOSP}/system/core/include/cutils/log.h
+ * to preserve the value of errno while logging.
+ */
+#define LOG_PRI(priority, tag, ...) ({                      \
+    int _errno = *REAL(__errno)();                          \
+    int _rv = android_printLog(priority, tag, __VA_ARGS__); \
+    *REAL(__errno)() = _errno;                              \
+    _rv;                   /* Returned to caller */         \
+})
+
+#if !defined(__HOST__)
+#include <cutils/log.h>
+
+# define PERROR(str)  {                                                                  \
+    ALOGE("%s: PERROR('%s'): errno:%d:'%s'", __func__, str, *REAL(__errno)(), strerror(errno)); \
+}
+
+# define ASSERT(cond) ALOG_ASSERT(cond, "assertion failed:(%s), file: %s, line: %d:%s",  \
+                                 #cond, __FILE__, __LINE__, __func__);
+#else
+#include <assert.h>
+# define PERROR(str) fprintf(stderr, "%s: PERROR('%s'): errno:%d:'%s'", __func__, str, *REAL(__errno)(), strerror(*REAL(__errno)()))
+# define ASSERT(cond) assert(cond)
+# define ALOGV(a,...)
+# define ALOGW(a,...)
+# define ALOGE(a,...)
+
+#endif
\ No newline at end of file
diff --git a/ndk/sources/android/libportable/common/include/netdb_portable.h b/ndk/sources/android/libportable/common/include/netdb_portable.h
new file mode 100644
index 0000000..b3e6528
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/netdb_portable.h
@@ -0,0 +1,281 @@
+/*
+ * Derived from android-14/arch-arm/usr/include/netdb.h
+ *-
+ * Copyright (c) 1980, 1983, 1988, 1993
+ *      The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*
+ *      @(#)netdb.h     8.1 (Berkeley) 6/2/93
+ *      From: Id: netdb.h,v 8.9 1996/11/19 08:39:29 vixie Exp $
+ * $FreeBSD: /repoman/r/ncvs/src/include/netdb.h,v 1.41 2006/04/15 16:20:26 ume Exp $
+ */
+
+#ifndef _NETDB_PORTABLE_H_
+#define _NETDB_PORTABLE_H_
+
+#if 0
+/*
+ * Most of the declararitions are not needed for addrinfo mapping.
+ * Diff of mips and arm code running through cpp show only the
+ * values of ai_socktype being different.
+ */
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#ifndef  _PATH_HEQUIV
+# define _PATH_HEQUIV    "/system/etc/hosts.equiv"
+#endif
+
+#define _PATH_HOSTS     "/system/etc/hosts"
+#define _PATH_NETWORKS  "/system/etc/networks"
+#define _PATH_PROTOCOLS "/system/etc/protocols"
+#define _PATH_SERVICES  "/system/etc/services"
+
+#define  MAXHOSTNAMELEN  256
+
+
+/*
+ * Structures returned by network data base library.  All addresses are
+ * supplied in host order, and returned in network order (suitable for
+ * use in system calls).
+ */
+struct hostent {
+        char    *h_name;        /* official name of host */
+        char    **h_aliases;    /* alias list */
+        int     h_addrtype;     /* host address type */
+        int     h_length;       /* length of address */
+        char    **h_addr_list;  /* list of addresses from name server */
+#define h_addr  h_addr_list[0]  /* address, for backward compatibility */
+};
+
+struct netent {
+        char     *n_name;        /* official name of net */
+        char     **n_aliases;    /* alias list */
+        int      n_addrtype;     /* net address type */
+        uint32_t n_net;          /* network # */
+};
+
+struct servent {
+        char    *s_name;        /* official service name */
+        char    **s_aliases;    /* alias list */
+        int     s_port;         /* port # */
+        char    *s_proto;       /* protocol to use */
+};
+
+struct protoent {
+        char    *p_name;        /* official protocol name */
+        char    **p_aliases;    /* alias list */
+        int     p_proto;        /* protocol # */
+};
+#endif
+
+/*
+ * For mapping MIPS and ARM these structures differ only in the
+ * ai_socktype values.
+ */
+struct addrinfo_portable {
+        int     ai_flags;           /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
+        int     ai_family;          /* PF_xxx */
+        int     ai_socktype;        /* SOCK_xxx */
+        int     ai_protocol;        /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+        socklen_t ai_addrlen;       /* length of ai_addr */
+        char    *ai_canonname;      /* canonical name for hostname */
+        struct  sockaddr *ai_addr;  /* binary address */
+        struct  addrinfo *ai_next;  /* next structure in linked list */
+};
+
+#if 0
+/*
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ * (left in h_errno).
+ */
+
+#define NETDB_INTERNAL  -1      /* see errno */
+#define NETDB_SUCCESS   0       /* no problem */
+#define HOST_NOT_FOUND  1       /* Authoritative Answer Host not found */
+#define TRY_AGAIN       2       /* Non-Authoritative Host not found, or SERVERFAIL */
+#define NO_RECOVERY     3       /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+#define NO_DATA         4       /* Valid name, no data record of requested type */
+#define NO_ADDRESS      NO_DATA /* no address, look for MX record */
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#define EAI_ADDRFAMILY   1      /* address family for hostname not supported */
+#define EAI_AGAIN        2      /* temporary failure in name resolution */
+#define EAI_BADFLAGS     3      /* invalid value for ai_flags */
+#define EAI_FAIL         4      /* non-recoverable failure in name resolution */
+#define EAI_FAMILY       5      /* ai_family not supported */
+#define EAI_MEMORY       6      /* memory allocation failure */
+#define EAI_NODATA       7      /* no address associated with hostname */
+#define EAI_NONAME       8      /* hostname nor servname provided, or not known */
+#define EAI_SERVICE      9      /* servname not supported for ai_socktype */
+#define EAI_SOCKTYPE    10      /* ai_socktype not supported */
+#define EAI_SYSTEM      11      /* system error returned in errno */
+#define EAI_BADHINTS    12      /* invalid value for hints */
+#define EAI_PROTOCOL    13      /* resolved protocol is unknown */
+#define EAI_OVERFLOW    14      /* argument buffer overflow */
+#define EAI_MAX         15
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#define AI_PASSIVE      0x00000001 /* get address to use bind() */
+#define AI_CANONNAME    0x00000002 /* fill ai_canonname */
+#define AI_NUMERICHOST  0x00000004 /* prevent host name resolution */
+#define AI_NUMERICSERV  0x00000008 /* prevent service name resolution */
+/* valid flags for addrinfo (not a standard def, apps should not use it) */
+#define AI_MASK \
+    (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \
+    AI_ADDRCONFIG)
+
+#define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
+#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
+#define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
+#define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */
+/* special recommended flags for getipnodebyname */
+#define AI_DEFAULT      (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+
+/*
+ * Constants for getnameinfo()
+ */
+#define NI_MAXHOST      1025
+#define NI_MAXSERV      32
+
+/*
+ * Flag values for getnameinfo()
+ */
+#define NI_NOFQDN       0x00000001
+#define NI_NUMERICHOST  0x00000002
+#define NI_NAMEREQD     0x00000004
+#define NI_NUMERICSERV  0x00000008
+#define NI_DGRAM        0x00000010
+#if 0 /* obsolete */
+#define NI_WITHSCOPEID  0x00000020
+#endif
+
+/*
+ * Scope delimit character
+ */
+#define SCOPE_DELIMITER '%'
+
+__BEGIN_DECLS
+/* BIONIC-BEGIN */
+#define  h_errno   (*__get_h_errno())
+int*  __get_h_errno(void);
+/* BIONIC-END */
+void endservent(void);
+struct hostent  *gethostbyaddr(const char *, int, int);
+struct hostent  *gethostbyname(const char *);
+int gethostbyname_r(const char *, struct hostent *, char *, size_t, struct hostent **, int *);
+struct hostent  *gethostbyname2(const char *, int);
+struct hostent  *gethostent(void);
+struct netent   *getnetbyaddr(uint32_t, int);
+struct netent   *getnetbyname(const char *);
+struct protoent *getprotobyname(const char *);
+struct protoent *getprotobynumber(int);
+struct servent  *getservbyname(const char *, const char *);
+struct servent  *getservbyport(int, const char *);
+struct servent  *getservent(void);
+void herror(const char *);
+const char      *hstrerror(int);
+#endif
+
+int WRAP(getaddrinfo)(const char *, const char *, struct addrinfo_portable *,
+                         struct addrinfo_portable **);
+
+void WRAP(freeaddrinfo)(struct addrinfo_portable *);
+
+#if 0 /* Not needed for addrinfo mapping */
+int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int);
+const char      *gai_strerror(int);
+void setservent(int);
+
+#if 0 /* MISSING FROM BIONIC */
+void endhostent(void);
+void endnetent(void);
+void endnetgrent(void);
+void endprotoent(void);
+void freehostent(struct hostent *);
+
+int gethostbyaddr_r(const char *, int, int, struct hostent *, char *, size_t,
+                    struct hostent **, int *);
+
+int gethostbyname2_r(const char *, int, struct hostent *, char *, size_t,
+                     struct hostent **, int *);
+
+int gethostent_r(struct hostent *, char *, size_t, struct hostent **, int *);
+struct hostent   *getipnodebyaddr(const void *, size_t, int, int *);
+struct hostent   *getipnodebyname(const char *, int, int, int *);
+int getnetbyaddr_r(uint32_t, int, struct netent *, char *, size_t, struct netent**, int *);
+int getnetbyname_r(const char *, struct netent *, char *, size_t, struct netent **, int *);
+int getnetent_r(struct netent *, char *, size_t, struct netent **, int *);
+int getnetgrent(char **, char **, char **);
+int getprotobyname_r(const char *, struct protoent *, char *, size_t, struct protoent **);
+int getprotobynumber_r(int, struct protoent *, char *, size_t, struct protoent **);
+struct protoent  *getprotoent(void);
+int getprotoent_r(struct protoent *, char *, size_t, struct protoent **);
+int innetgr(const char *, const char *, const char *, const char *);
+void sethostent(int);
+void setnetent(int);
+void setprotoent(int);
+struct netent   *getnetent(void);
+void setnetgrent(const char *);
+#endif /* MISSING FROM BIONIC */
+#endif /* Not needed for addrinfo mapping */
+
+
+__END_DECLS
+
+#endif /* !_NETDB_H_ */
diff --git a/ndk/sources/android/libportable/common/include/portability.h b/ndk/sources/android/libportable/common/include/portability.h
new file mode 100644
index 0000000..54f1406
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/portability.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012, 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 _PORTABILITY_H_
+#define _PORTABILITY_H_
+
+#include "asm-generic/portability.h"
+/*
+ * Common portability helper routines
+ */
+
+/*
+ * Check a portable pointer before we access it
+ * Well behaved programs should not be passing bad pointers
+ * to the kernel but this routine can be used to check a pointer
+ * if we need to use it before calling the kernel
+ *
+ * It does not catch every possible case but it is sufficient for LTP
+ */
+inline static int invalid_pointer(void *p)
+{
+    return p == 0
+        || p == (void *)-1
+#ifdef __mips__
+        || (int)p < 0
+#endif
+        ;
+}
+
+/*
+ * Hidden functions are exposed while linking the libportable shared object
+ * but are not exposed thereafter.
+ */
+#define __hidden __attribute__((visibility("hidden")))
+
+#endif /* _PORTABILITY_H_ */
diff --git a/ndk/sources/android/libportable/common/include/signal_portable.h b/ndk/sources/android/libportable/common/include/signal_portable.h
new file mode 100644
index 0000000..3ea8de1
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/signal_portable.h
@@ -0,0 +1,198 @@
+/*
+ * Derived from gdk/platforms/android-14/arch-arm/usr/include/signal.h
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _SIGNAL_PORTABLE_H_
+#define _SIGNAL_PORTABLE_H_
+
+#include <portability.h>
+#include <sys/cdefs.h>
+#include <limits.h>             /* For LONG_BIT */
+#include <string.h>             /* For memset() */
+#include <signal.h>
+#include <time.h>
+#include <sys/types.h>
+#include <asm/signal_portable.h>
+#include <asm/sigcontext_portable.h>
+
+#define __ARCH_SI_UID_T __kernel_uid32_t
+#include <asm/siginfo_portable.h>
+#undef __ARCH_SI_UID_T
+
+__BEGIN_DECLS
+
+typedef int sig_atomic_t;
+
+#if 0
+/* _NSIG is used by the SIGRTMAX definition under <asm/signal.h>, however
+ * its definition is part of a #if __KERNEL__ .. #endif block in the original
+ * kernel headers and is thus not part of our cleaned-up versions.
+ *
+ * Looking at the current kernel sources, it is defined as 64 for all
+ * architectures except for the 'mips' one which set it to 128.
+ */
+#ifndef _NSIG_PORTABLE
+#  define _NSIG_PORTABLE  64
+#endif
+#endif
+
+extern const char * const sys_siglist[];
+extern const char * const sys_signame[];
+
+static __inline__ int WRAP(sigismember)(sigset_portable_t *set, int signum)
+{
+    unsigned long *local_set = (unsigned long *)set;
+    signum--;
+    return (int)((local_set[signum/LONG_BIT] >> (signum%LONG_BIT)) & 1);
+}
+
+
+static __inline__ int WRAP(sigaddset)(sigset_portable_t *set, int signum)
+{
+    unsigned long *local_set = (unsigned long *)set;
+    signum--;
+    local_set[signum/LONG_BIT] |= 1UL << (signum%LONG_BIT);
+    return 0;
+}
+
+
+static __inline__ int WRAP(sigdelset)(sigset_portable_t *set, int signum)
+{
+    unsigned long *local_set = (unsigned long *)set;
+    signum--;
+    local_set[signum/LONG_BIT] &= ~(1UL << (signum%LONG_BIT));
+    return 0;
+}
+
+
+static __inline__ int WRAP(sigemptyset)(sigset_portable_t *set)
+{
+    memset(set, 0, sizeof *set);
+    return 0;
+}
+
+static __inline__ int WRAP(sigfillset)(sigset_portable_t *set)
+{
+    memset(set, ~0, sizeof *set);
+    return 0;
+}
+
+/* compatibility types */
+typedef void            (*sig_portable_t)(int);
+typedef sig_portable_t   sighandler_portable_t;
+
+/* Extended compatibility types, for processing a siginfo_t argument */
+typedef void            (*sig3_portable_t)(int, siginfo_portable_t *, void *);
+typedef sig3_portable_t   sig3handler_portable_t;
+
+/* differentiater between sysv and bsd behaviour 8*/
+extern __sighandler_t sysv_signal(int, __sighandler_portable_t);
+extern __sighandler_t bsd_signal(int, __sighandler_portable_t);
+
+#if 0
+/* the default is bsd */
+static __inline__ __sighandler_portable_t WRAP(signal)(int s, sighandler_portable_t f)
+{
+    return bsd_signal(s,f);
+}
+#endif
+
+/* the portable mapped syscall itself */
+extern __sighandler_portable_t WRAP(__signal)(int, __sighandler_portable_t);
+
+extern int WRAP(sigprocmask)(int, const sigset_portable_t *, sigset_portable_t *);
+
+extern int WRAP(sigaction)(int, const struct sigaction_portable *,
+                              struct sigaction_portable *);
+
+extern int WRAP(sigpending)(sigset_portable_t *);
+extern int WRAP(sigsuspend)(const sigset_portable_t *);
+extern int WRAP(sigwait)(const sigset_portable_t *set, int *sig);
+extern int WRAP(siginterrupt)(int  sig, int  flag);
+
+extern int WRAP(raise)(int);
+extern int WRAP(kill)(pid_t, int);
+extern int WRAP(killpg)(int pgrp, int sig);
+extern int WRAP(tkill)(int tid, int portable_signum);
+extern int WRAP(sigaltstack)(const portable_stack_t *ss, portable_stack_t *oss);
+extern int WRAP(timer_create)(clockid_t, struct sigevent *, timer_t *);
+
+#if 0
+extern int WRAP(signalfd)(int fd, const sigset_portable_t *portable_sigmask, int flags);
+#endif
+
+extern __hidden int do_signalfd4_portable(int fd, const sigset_portable_t *portable_sigmask,
+                                          int portable_sigsetsize, int flags);
+
+extern __hidden int read_signalfd_mapper(int fd, void *buf, size_t count);
+extern __hidden char *map_portable_signum_to_name(int portable_signum);
+extern __hidden char *map_mips_signum_to_name(int mips_signum);
+extern __hidden int signum_pton(int portable_signum);
+extern __hidden int signum_ntop(int mips_signum);
+
+typedef int (*sigmask_fn)(int, const sigset_t *, sigset_t *);
+typedef int (*rt_sigmask_fn)(int, const sigset_t *, sigset_t *, size_t);
+typedef int (*sigaction_fn)(int, const struct sigaction *, struct sigaction *);
+typedef int (*rt_sigaction_fn)(int, const struct sigaction *, struct sigaction *, size_t);
+
+
+extern __hidden int do_sigmask(int portable_how, const sigset_portable_t *portable_sigset,
+                               sigset_portable_t *portable_oldset, sigmask_fn fn,
+                               rt_sigmask_fn rt_fn);
+
+
+/* These functions are called from syscall.c and experimental Bionic linker. */
+extern int WRAP(__rt_sigaction)(int portable_signum,
+                                const struct sigaction_portable *act,
+                                struct sigaction_portable *oldact,
+                                size_t sigsetsize);
+
+extern int WRAP(__rt_sigprocmask)(int portable_how,
+                                  const sigset_portable_t *portable_sigset,
+                                  sigset_portable_t *portable_oldset,
+                                  size_t sigsetsize);
+
+extern int WRAP(__rt_sigtimedwait)(const sigset_portable_t *portable_sigset,
+                                   siginfo_portable_t *portable_siginfo,
+                                   const struct timespec *timeout,
+                                   size_t portable_sigsetsize);
+
+
+/* These functions are only called from syscall.c; not experimental Bionic linker. */
+extern __hidden int WRAP(rt_sigqueueinfo)(pid_t pid, int sig, siginfo_portable_t *uinfo);
+
+extern __hidden int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int sig,
+                                               siginfo_portable_t *uinfo);
+
+
+/* Called by clone when memory and signal handlers aren't compatable. */
+extern __hidden void signal_disable_mapping(void);
+
+__END_DECLS
+
+#endif /* _SIGNAL_PORTABLE_H_ */
diff --git a/ndk/sources/android/libportable/common/include/signalfd_portable.h b/ndk/sources/android/libportable/common/include/signalfd_portable.h
new file mode 100644
index 0000000..54ff470
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/signalfd_portable.h
@@ -0,0 +1,60 @@
+/*
+ *  Derived from Goldfish include/linux/signalfd.h
+ *
+ *  Copyright (C) 2007  Davide Libenzi <davidel@xmailserver.org>
+ *
+ */
+
+#ifndef _LINUX_SIGNALFD_PORTABLE_H
+#define _LINUX_SIGNALFD_PORTABLE_H
+
+#include <linux/types.h>
+#include <fcntl.h>
+
+/* Flags for signalfd4.  */
+#define SFD_CLOEXEC             O_CLOEXEC
+#define SFD_NONBLOCK            O_NONBLOCK
+
+/* For O_CLOEXEC_PORTABLE and O_NONBLOCK_PORTABLE */
+#include "fcntl_portable.h"
+
+#define SFD_CLOEXEC_PORTABLE    O_CLOEXEC_PORTABLE
+#define SFD_NONBLOCK_PORTABLE   O_NONBLOCK_PORTABLE
+
+/*
+ * This structure is the same for Native and Portable.
+ * However for MIPS ssi_signo and ssi_errno differ in their
+ * values and need to be mapped.
+ */
+struct signalfd_siginfo {
+        __u32 ssi_signo;
+        __s32 ssi_errno;
+        __s32 ssi_code;
+        __u32 ssi_pid;
+        __u32 ssi_uid;
+        __s32 ssi_fd;
+        __u32 ssi_tid;
+        __u32 ssi_band;
+        __u32 ssi_overrun;
+        __u32 ssi_trapno;
+        __s32 ssi_status;
+        __s32 ssi_int;
+        __u64 ssi_ptr;
+        __u64 ssi_utime;
+        __u64 ssi_stime;
+        __u64 ssi_addr;
+
+        /*
+         * Pad structure to 128 bytes. Remember to update the
+         * pad size when you add new members. We use a fixed
+         * size structure to avoid compatibility problems with
+         * future versions, and we leave extra space for additional
+         * members. We use fixed size members because this structure
+         * comes out of a read(2) and we really don't want to have
+         * a compat (sp?) on read(2).
+         */
+        __u8 __pad[48];
+};
+
+#endif /* _LINUX_SIGNALFD_PORTABLE_H */
+
diff --git a/ndk/sources/android/libportable/common/include/timerfd_portable.h b/ndk/sources/android/libportable/common/include/timerfd_portable.h
new file mode 100644
index 0000000..d6c294c
--- /dev/null
+++ b/ndk/sources/android/libportable/common/include/timerfd_portable.h
@@ -0,0 +1,51 @@
+/*
+ * Derived from bionic/libc/include/sys/eventfd.h
+ *
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _SYS_TIMERFD_PORTABLE_H
+#define _SYS_TIMERFD_PORTABLE_H
+
+#include <portability.h>
+#include <sys/cdefs.h>
+#include <fcntl.h>
+#include <fcntl_portable.h>
+
+__BEGIN_DECLS
+
+#define  TFD_CLOEXEC   O_CLOEXEC
+#define  TFD_NONBLOCK  O_NONBLOCK
+
+#define  TFD_CLOEXEC_PORTABLE   O_CLOEXEC_PORTABLE
+#define  TFD_NONBLOCK_PORTABLE  O_NONBLOCK_PORTABLE
+
+extern int WRAP(timerfd_create)(int clockid, int flags);
+
+__END_DECLS
+
+#endif /* _SYS_TIMERFD_H */
diff --git a/ndk/sources/android/native_app_glue/android_native_app_glue.c b/ndk/sources/android/native_app_glue/android_native_app_glue.c
index 82fc030..0c526fa 100644
--- a/ndk/sources/android/native_app_glue/android_native_app_glue.c
+++ b/ndk/sources/android/native_app_glue/android_native_app_glue.c
@@ -186,15 +186,18 @@
 
 static void process_input(struct android_app* app, struct android_poll_source* source) {
     AInputEvent* event = NULL;
-    if (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
+    int processed = 0;
+    while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
         LOGV("New input event: type=%d\n", AInputEvent_getType(event));
         if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {
-            return;
+            continue;
         }
         int32_t handled = 0;
         if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);
         AInputQueue_finishEvent(app->inputQueue, event, handled);
-    } else {
+        processed = 1;
+    }
+    if (processed == 0) {
         LOGE("Failure reading next input event: %s\n", strerror(errno));
     }
 }
diff --git a/samples/ApiDemos/res/layout/textclock.xml b/samples/ApiDemos/res/layout/textclock.xml
index f86f616..827c3d3 100644
--- a/samples/ApiDemos/res/layout/textclock.xml
+++ b/samples/ApiDemos/res/layout/textclock.xml
@@ -47,8 +47,8 @@
 
         <!-- Shows seconds -->
         <TextClock
-            android:format12Hour="hh:mm:ss aa"
-            android:format24Hour="kk:mm:ss"
+            android:format12Hour="hh:mm:ss a"
+            android:format24Hour="HH:mm:ss"
 
             android:textSize="20sp"
             android:shadowColor="#7fffffff"
@@ -59,8 +59,8 @@
 
         <!-- Use a fixed time zone -->
         <TextClock
-            android:format12Hour="'Time in Paris:' MMM dd, yyyy h:mmaa"
-            android:format24Hour="'Time in Paris:' MMM dd, yyyy k:mm"
+            android:format12Hour="'Time in Paris:' MMM dd, yyyy h:mma"
+            android:format24Hour="'Time in Paris:' MMM dd, yyyy HH:mm"
             android:timeZone="Europe/Paris"
 
             android:layout_width="wrap_content"
diff --git a/samples/LunarLander/res/layout/lunar_layout.xml b/samples/LunarLander/res/layout/lunar_layout.xml
index f1a8990..bac8188 100644
--- a/samples/LunarLander/res/layout/lunar_layout.xml
+++ b/samples/LunarLander/res/layout/lunar_layout.xml
@@ -15,21 +15,21 @@
 -->
 
 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent">
     
     <com.example.android.lunarlander.LunarView
       android:id="@+id/lunar"
-      android:layout_width="match_parent"
-      android:layout_height="match_parent"/>
+      android:layout_width="fill_parent"
+      android:layout_height="fill_parent"/>
     
     <RelativeLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent" >
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent" >
         <TextView
           android:id="@+id/text"
-		  android:text="@string/lunar_layout_text_text"
-		  android:visibility="visible"
+          android:text="@string/lunar_layout_text_text"
+          android:visibility="visible"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:layout_centerInParent="true"
diff --git a/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java b/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java
index 15c5923..03faee9 100644
--- a/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java
+++ b/samples/LunarLander/src/com/example/android/lunarlander/LunarLander.java
@@ -149,8 +149,8 @@
      */
     @Override
     protected void onPause() {
-        super.onPause();
         mLunarView.getThread().pause(); // pause game when Activity pauses
+        super.onPause();
     }
 
     /**
diff --git a/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java b/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java
index 2a46147..81e0470 100644
--- a/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java
+++ b/samples/LunarLander/src/com/example/android/lunarlander/LunarView.java
@@ -196,6 +196,8 @@
         /** Indicate whether the surface has been created & is ready to draw */
         private boolean mRun = false;
 
+        private final Object mRunLock = new Object();
+
         /** Scratch rect object. */
         private RectF mScratchRect;
 
@@ -356,7 +358,13 @@
                     c = mSurfaceHolder.lockCanvas(null);
                     synchronized (mSurfaceHolder) {
                         if (mMode == STATE_RUNNING) updatePhysics();
-                        doDraw(c);
+                        // Critical section. Do not allow mRun to be set false until
+                        // we are sure all canvas draw operations are complete.
+                        //
+                        // If mRun has been toggled false, inhibit canvas operations.
+                        synchronized (mRunLock) {
+                            if (mRun) doDraw(c);
+                        }
                     }
                 } finally {
                     // do this in a finally so that if an exception is thrown
@@ -427,7 +435,11 @@
          * @param b true to run, false to shut down
          */
         public void setRunning(boolean b) {
-            mRun = b;
+            // Do not allow mRun to be modified while any canvas operations
+            // are potentially in-flight. See doDraw().
+            synchronized (mRunLock) {
+                mRun = b;
+            }
         }
 
         /**
diff --git a/tools/elftree/Android.mk b/tools/elftree/Android.mk
index c2199aa..6327273 100644
--- a/tools/elftree/Android.mk
+++ b/tools/elftree/Android.mk
@@ -29,7 +29,6 @@
 #LOCAL_SHARED_LIBRARIES := $(shared_libraries)
 #LOCAL_STATIC_LIBRARIES := $(static_libraries)
 #LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-#LOCAL_MODULE_TAGS := debug
 #LOCAL_LDLIBS +=
 #include $(BUILD_EXECUTABLE)
 
diff --git a/tools/emulator/opengl/common.mk b/tools/emulator/opengl/common.mk
index 8f31e17..6dd503e 100644
--- a/tools/emulator/opengl/common.mk
+++ b/tools/emulator/opengl/common.mk
@@ -31,7 +31,6 @@
 emugl-begin-module = \
     $(eval include $(CLEAR_VARS)) \
     $(eval LOCAL_MODULE := $1) \
-    $(eval LOCAL_MODULE_TAGS := debug) \
     $(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \
     $(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\
     $(eval LOCAL_C_INCLUDES := $(EMUGL_COMMON_INCLUDES)) \
@@ -239,4 +238,3 @@
     $(eval LOCAL_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$1)\
     $(eval _emugl.$(LOCAL_MODULE).moved := true)\
     $(call emugl-export-outer,ADDITIONAL_DEPENDENCIES,$(LOCAL_MODULE_PATH)/$(LOCAL_MODULE)$(TARGET_SHLIB_SUFFIX))
-
diff --git a/tools/emulator/opengl/system/egl/Android.mk b/tools/emulator/opengl/system/egl/Android.mk
index cf55b48..a979089 100644
--- a/tools/emulator/opengl/system/egl/Android.mk
+++ b/tools/emulator/opengl/system/egl/Android.mk
@@ -33,7 +33,6 @@
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
 
 LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/egl
-LOCAL_MODULE_TAGS := debug
 LOCAL_MODULE_CLASS := ETC
 
 include $(BUILD_PREBUILT)
diff --git a/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk b/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
index f5254b7..d97212d 100644
--- a/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
+++ b/tools/emulator/opengl/tests/gles_android_wrapper/Android.mk
@@ -56,7 +56,6 @@
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
 
 LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/egl
-LOCAL_MODULE_TAGS := debug
 LOCAL_MODULE_CLASS := ETC
 
 include $(BUILD_PREBUILT)
@@ -70,11 +69,6 @@
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
 
 LOCAL_MODULE_PATH := $(TARGET_OUT)/etc
-LOCAL_MODULE_TAGS := debug
 LOCAL_MODULE_CLASS := ETC
 
 include $(BUILD_PREBUILT)
-
-
-
-
diff --git a/tools/emulator/system/camera/Android.mk b/tools/emulator/system/camera/Android.mk
index 3843c1d..83dcefe 100755
--- a/tools/emulator/system/camera/Android.mk
+++ b/tools/emulator/system/camera/Android.mk
@@ -12,8 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-ifndef BUILD_EMULATOR_CAMERA_HAL
-BUILD_EMULATOR_CAMERA_HAL := true
 
 LOCAL_PATH := $(call my-dir)
 
@@ -71,7 +69,4 @@
 LOCAL_MODULE := camera.goldfish
 endif
 
-LOCAL_MODULE_TAGS := debug
 include $(BUILD_SHARED_LIBRARY)
-
-endif # BUILD_EMULATOR_CAMERA_HAL
diff --git a/tools/emulator/system/gps/Android.mk b/tools/emulator/system/gps/Android.mk
index 9daf4d6..6840f84 100644
--- a/tools/emulator/system/gps/Android.mk
+++ b/tools/emulator/system/gps/Android.mk
@@ -17,8 +17,6 @@
 # development.git/tools/emulator/. The following test is to ensure
 # smooth builds even if the tree contains both versions.
 #
-ifndef BUILD_EMULATOR_GPS_MODULE
-BUILD_EMULATOR_GPS_MODULE := true
 
 LOCAL_PATH := $(call my-dir)
 
@@ -35,7 +33,4 @@
 else
 LOCAL_MODULE := gps.goldfish
 endif
-LOCAL_MODULE_TAGS := debug
 include $(BUILD_SHARED_LIBRARY)
-
-endif # BUILD_EMULATOR_GPS_MODULE
diff --git a/tools/emulator/system/libqemu/tests.mk b/tools/emulator/system/libqemu/tests.mk
index 3e89b23..886973f 100644
--- a/tools/emulator/system/libqemu/tests.mk
+++ b/tools/emulator/system/libqemu/tests.mk
@@ -6,25 +6,25 @@
 include $(CLEAR_VARS)
 LOCAL_MODULE := test-libqemu-1
 LOCAL_SRC_FILES := test_host_1.c
-LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_TAGS := tests
 include $(BUILD_HOST_EXECUTABLE)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := test-libqemu-2
 LOCAL_SRC_FILES := test_host_2.c
-LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_TAGS := tests
 include $(BUILD_HOST_EXECUTABLE)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := test-libqemu-1
 LOCAL_SRC_FILES := test_guest_1.c test_util.c
-LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_TAGS := tests
 LOCAL_STATIC_LIBRARIES := libcutils
 include $(BUILD_EXECUTABLE)
 
 include $(CLEAR_VARS)
 LOCAL_MODULE := test-libqemu-2
 LOCAL_SRC_FILES := test_guest_2.c test_util.c
-LOCAL_MODULE_TAGS := debug
+LOCAL_MODULE_TAGS := tests
 LOCAL_STATIC_LIBRARIES := libcutils
 include $(BUILD_EXECUTABLE)
diff --git a/tools/emulator/system/lights/Android.mk b/tools/emulator/system/lights/Android.mk
index f0f76dc..3fa04ed 100644
--- a/tools/emulator/system/lights/Android.mk
+++ b/tools/emulator/system/lights/Android.mk
@@ -22,6 +22,5 @@
 LOCAL_SHARED_LIBRARIES := liblog libcutils
 LOCAL_SRC_FILES := lights_qemu.c
 LOCAL_MODULE := lights.goldfish
-LOCAL_MODULE_TAGS := debug
 LOCAL_CFLAGS += -DLIGHT_BACKLIGHT
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tools/emulator/system/qemu-props/Android.mk b/tools/emulator/system/qemu-props/Android.mk
index 1b2932f..885e5b7 100644
--- a/tools/emulator/system/qemu-props/Android.mk
+++ b/tools/emulator/system/qemu-props/Android.mk
@@ -16,13 +16,6 @@
 # that should only run in the emulator.
 #
 
-# We're moving the emulator-specific platform libs to
-# development.git/tools/emulator/. The following test is to ensure
-# smooth builds even if the tree contains both versions.
-#
-ifndef BUILD_EMULATOR_QEMU_PROPS
-BUILD_EMULATOR_QEMU_PROPS := true
-
 LOCAL_PATH := $(call my-dir)
 
 # The 'qemu-props' program is run from /system/etc/init.goldfish.rc
@@ -32,9 +25,4 @@
 LOCAL_MODULE    := qemu-props
 LOCAL_SRC_FILES := qemu-props.c
 LOCAL_SHARED_LIBRARIES := libcutils
-# we don't want this in 'user' builds which don't have
-# emulator-specific binaries.
-LOCAL_MODULE_TAGS := debug
 include $(BUILD_EXECUTABLE)
-
-endif # BUILD_EMULATOR_QEMU_PROPS
diff --git a/tools/emulator/system/qemud/Android.mk b/tools/emulator/system/qemud/Android.mk
index 5666a74..237572c 100644
--- a/tools/emulator/system/qemud/Android.mk
+++ b/tools/emulator/system/qemud/Android.mk
@@ -4,8 +4,6 @@
 # development.git/tools/emulator/. The following test is to ensure
 # smooth builds even if the tree contains both versions.
 #
-ifndef BUILD_EMULATOR_QEMUD
-BUILD_EMULATOR_QEMUD := true
 
 LOCAL_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
@@ -18,8 +16,5 @@
 	libcutils \
 
 LOCAL_MODULE:= qemud
-LOCAL_MODULE_TAGS := debug
 
 include $(BUILD_EXECUTABLE)
-
-endif # BUILD_EMULATOR_QEMUD
\ No newline at end of file
diff --git a/tools/emulator/system/sensors/Android.mk b/tools/emulator/system/sensors/Android.mk
index 4ae048b..a1b8967 100644
--- a/tools/emulator/system/sensors/Android.mk
+++ b/tools/emulator/system/sensors/Android.mk
@@ -13,16 +13,8 @@
 # limitations under the License.
 
 
-# We're moving the emulator-specific platform libs to
-# development.git/tools/emulator/. The following test is to ensure
-# smooth builds even if the tree contains both versions.
-#
-ifndef BUILD_EMULATOR_SENSORS_MODULE
-BUILD_EMULATOR_SENSORS_MODULE := true
-
 LOCAL_PATH := $(call my-dir)
 
-ifneq ($(TARGET_PRODUCT),sim)
 # HAL module implemenation stored in
 # hw/<SENSORS_HARDWARE_MODULE_ID>.<ro.hardware>.so
 include $(CLEAR_VARS)
@@ -35,8 +27,4 @@
 else
 LOCAL_MODULE := sensors.goldfish
 endif
-LOCAL_MODULE_TAGS := debug
 include $(BUILD_SHARED_LIBRARY)
-endif
-
-endif # BUILD_EMULATOR_SENSORS_MODULE