Add trivial no-op <nl_types.h>.

Needed to build OpenMP.

Bug: http://b/27617302
Change-Id: Iac15c84ead6f5d5274cfdb2d6d4a4ec0072244bb
diff --git a/libc/Android.bp b/libc/Android.bp
index 5568760..3ec5e96 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1317,6 +1317,7 @@
         "bionic/NetdClientDispatch.cpp",
         "bionic/net_if.cpp",
         "bionic/netinet_in.cpp",
+        "bionic/nl_types.cpp",
         "bionic/open.cpp",
         "bionic/pathconf.cpp",
         "bionic/pause.cpp",
diff --git a/libc/Android.mk b/libc/Android.mk
index c74c237..fa392d1 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -145,6 +145,7 @@
     bionic/NetdClientDispatch.cpp \
     bionic/net_if.cpp \
     bionic/netinet_in.cpp \
+    bionic/nl_types.cpp \
     bionic/open.cpp \
     bionic/pathconf.cpp \
     bionic/pause.cpp \
diff --git a/libc/bionic/nl_types.cpp b/libc/bionic/nl_types.cpp
new file mode 100644
index 0000000..2cde591
--- /dev/null
+++ b/libc/bionic/nl_types.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include <nl_types.h>
+
+#include <errno.h>
+
+nl_catd catopen(const char*, int) {
+  return reinterpret_cast<nl_catd>(-1);
+}
+
+char* catgets(nl_catd, int, int, const char* message) {
+  return const_cast<char*>(message);
+}
+
+int catclose(nl_catd) {
+  // Since we didn't hand out a valid nl_catd, you can't be returning one to us.
+  errno = EBADF;
+  return -1;
+}
diff --git a/libc/include/nl_types.h b/libc/include/nl_types.h
new file mode 100644
index 0000000..84227bd
--- /dev/null
+++ b/libc/include/nl_types.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 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 _NL_TYPES_H_
+#define _NL_TYPES_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+#define NL_CAT_LOCALE 1
+#define NL_SETD 1
+
+typedef void* nl_catd;
+typedef int nl_item;
+
+nl_catd catopen(const char*, int);
+char* catgets(nl_catd, int, int, const char*);
+int catclose(nl_catd);
+
+__END_DECLS
+
+#endif
diff --git a/libc/libc.arm.brillo.map b/libc/libc.arm.brillo.map
index 666d752..651fea4 100644
--- a/libc/libc.arm.brillo.map
+++ b/libc/libc.arm.brillo.map
@@ -1273,6 +1273,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.arm.map b/libc/libc.arm.map
index fa83528..1c7a0ba 100644
--- a/libc/libc.arm.map
+++ b/libc/libc.arm.map
@@ -1273,6 +1273,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map
index c9f5213..7daa557 100644
--- a/libc/libc.arm64.map
+++ b/libc/libc.arm64.map
@@ -1195,6 +1195,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 49572a0..ed20efc 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -1299,6 +1299,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.mips.brillo.map b/libc/libc.mips.brillo.map
index 83a6f74..d96de34 100644
--- a/libc/libc.mips.brillo.map
+++ b/libc/libc.mips.brillo.map
@@ -1257,6 +1257,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.mips.map b/libc/libc.mips.map
index 1a3e56b..5fe3a51 100644
--- a/libc/libc.mips.map
+++ b/libc/libc.mips.map
@@ -1257,6 +1257,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map
index c9f5213..7daa557 100644
--- a/libc/libc.mips64.map
+++ b/libc/libc.mips64.map
@@ -1195,6 +1195,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.x86.brillo.map b/libc/libc.x86.brillo.map
index cee82c2..f167183 100644
--- a/libc/libc.x86.brillo.map
+++ b/libc/libc.x86.brillo.map
@@ -1256,6 +1256,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.x86.map b/libc/libc.x86.map
index 9b65cbf..d37d28a 100644
--- a/libc/libc.x86.map
+++ b/libc/libc.x86.map
@@ -1256,6 +1256,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map
index c9f5213..7daa557 100644
--- a/libc/libc.x86_64.map
+++ b/libc/libc.x86_64.map
@@ -1195,6 +1195,9 @@
 
 LIBC_O {
   global:
+    catclose;
+    catgets;
+    catopen;
     getdomainname;
     getsubopt;
     hasmntopt;
diff --git a/tests/Android.mk b/tests/Android.mk
index c7356b8..7292d9d 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -74,6 +74,7 @@
     net_if_test.cpp \
     netinet_in_test.cpp \
     netinet_udp_test.cpp \
+    nl_types_test.cpp \
     pthread_test.cpp \
     pty_test.cpp \
     regex_test.cpp \
diff --git a/tests/nl_types_test.cpp b/tests/nl_types_test.cpp
new file mode 100644
index 0000000..2e3995b
--- /dev/null
+++ b/tests/nl_types_test.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 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 <nl_types.h>
+
+#include <errno.h>
+#include <gtest/gtest.h>
+
+TEST(nl_types, smoke) {
+  nl_catd cat = catopen("/does/not/exist", NL_CAT_LOCALE);
+  ASSERT_EQ(reinterpret_cast<nl_catd>(-1), cat);
+
+  ASSERT_STREQ("hello, world!", catgets(cat, NL_SETD, 0, "hello, world!"));
+
+  errno = 0;
+  ASSERT_EQ(-1, catclose(cat));
+  ASSERT_EQ(EBADF, errno);
+}