Merge "Add trivial no-op <nl_types.h>."
This commit is contained in:
commit
322d6cfb33
16 changed files with 157 additions and 0 deletions
|
@ -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",
|
||||
|
|
|
@ -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 \
|
||||
|
|
45
libc/bionic/nl_types.cpp
Normal file
45
libc/bionic/nl_types.cpp
Normal file
|
@ -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;
|
||||
}
|
48
libc/include/nl_types.h
Normal file
48
libc/include/nl_types.h
Normal file
|
@ -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
|
|
@ -1273,6 +1273,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1273,6 +1273,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1195,6 +1195,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1299,6 +1299,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1257,6 +1257,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1257,6 +1257,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1195,6 +1195,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1256,6 +1256,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1256,6 +1256,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -1195,6 +1195,9 @@ LIBC_N {
|
|||
|
||||
LIBC_O {
|
||||
global:
|
||||
catclose;
|
||||
catgets;
|
||||
catopen;
|
||||
getdomainname;
|
||||
getsubopt;
|
||||
hasmntopt;
|
||||
|
|
|
@ -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 \
|
||||
|
|
31
tests/nl_types_test.cpp
Normal file
31
tests/nl_types_test.cpp
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue