From 6cfb84b97eb5a60c0cea06145677fec6ae754b49 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 6 Apr 2016 17:14:45 -0700 Subject: [PATCH] Add trivial no-op . Needed to build OpenMP. Bug: http://b/27617302 Change-Id: Iac15c84ead6f5d5274cfdb2d6d4a4ec0072244bb --- libc/Android.bp | 1 + libc/Android.mk | 1 + libc/bionic/nl_types.cpp | 45 ++++++++++++++++++++++++++++++++++++ libc/include/nl_types.h | 48 +++++++++++++++++++++++++++++++++++++++ libc/libc.arm.brillo.map | 3 +++ libc/libc.arm.map | 3 +++ libc/libc.arm64.map | 3 +++ libc/libc.map.txt | 3 +++ libc/libc.mips.brillo.map | 3 +++ libc/libc.mips.map | 3 +++ libc/libc.mips64.map | 3 +++ libc/libc.x86.brillo.map | 3 +++ libc/libc.x86.map | 3 +++ libc/libc.x86_64.map | 3 +++ tests/Android.mk | 1 + tests/nl_types_test.cpp | 31 +++++++++++++++++++++++++ 16 files changed, 157 insertions(+) create mode 100644 libc/bionic/nl_types.cpp create mode 100644 libc/include/nl_types.h create mode 100644 tests/nl_types_test.cpp diff --git a/libc/Android.bp b/libc/Android.bp index 55687600b..3ec5e96aa 100644 --- a/libc/Android.bp +++ b/libc/Android.bp @@ -1317,6 +1317,7 @@ cc_library_static { "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 c74c23750..fa392d1b0 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -145,6 +145,7 @@ libc_bionic_ndk_src_files := \ 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 000000000..2cde59188 --- /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 + +#include + +nl_catd catopen(const char*, int) { + return reinterpret_cast(-1); +} + +char* catgets(nl_catd, int, int, const char* message) { + return const_cast(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 000000000..84227bdb7 --- /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 + +__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 666d752f9..651fea488 100644 --- a/libc/libc.arm.brillo.map +++ b/libc/libc.arm.brillo.map @@ -1273,6 +1273,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.arm.map b/libc/libc.arm.map index fa83528e2..1c7a0ba11 100644 --- a/libc/libc.arm.map +++ b/libc/libc.arm.map @@ -1273,6 +1273,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.arm64.map b/libc/libc.arm64.map index c9f521393..7daa5574c 100644 --- a/libc/libc.arm64.map +++ b/libc/libc.arm64.map @@ -1195,6 +1195,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.map.txt b/libc/libc.map.txt index 49572a054..ed20efc5a 100644 --- a/libc/libc.map.txt +++ b/libc/libc.map.txt @@ -1299,6 +1299,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.mips.brillo.map b/libc/libc.mips.brillo.map index 83a6f745b..d96de3431 100644 --- a/libc/libc.mips.brillo.map +++ b/libc/libc.mips.brillo.map @@ -1257,6 +1257,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.mips.map b/libc/libc.mips.map index 1a3e56b01..5fe3a5194 100644 --- a/libc/libc.mips.map +++ b/libc/libc.mips.map @@ -1257,6 +1257,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.mips64.map b/libc/libc.mips64.map index c9f521393..7daa5574c 100644 --- a/libc/libc.mips64.map +++ b/libc/libc.mips64.map @@ -1195,6 +1195,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.x86.brillo.map b/libc/libc.x86.brillo.map index cee82c2d7..f16718325 100644 --- a/libc/libc.x86.brillo.map +++ b/libc/libc.x86.brillo.map @@ -1256,6 +1256,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.x86.map b/libc/libc.x86.map index 9b65cbf74..d37d28ace 100644 --- a/libc/libc.x86.map +++ b/libc/libc.x86.map @@ -1256,6 +1256,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/libc/libc.x86_64.map b/libc/libc.x86_64.map index c9f521393..7daa5574c 100644 --- a/libc/libc.x86_64.map +++ b/libc/libc.x86_64.map @@ -1195,6 +1195,9 @@ LIBC_N { LIBC_O { global: + catclose; + catgets; + catopen; getdomainname; getsubopt; hasmntopt; diff --git a/tests/Android.mk b/tests/Android.mk index c7356b89b..7292d9d12 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -74,6 +74,7 @@ libBionicStandardTests_src_files := \ 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 000000000..2e3995b99 --- /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 + +#include +#include + +TEST(nl_types, smoke) { + nl_catd cat = catopen("/does/not/exist", NL_CAT_LOCALE); + ASSERT_EQ(reinterpret_cast(-1), cat); + + ASSERT_STREQ("hello, world!", catgets(cat, NL_SETD, 0, "hello, world!")); + + errno = 0; + ASSERT_EQ(-1, catclose(cat)); + ASSERT_EQ(EBADF, errno); +}