diff --git a/libc/Android.mk b/libc/Android.mk index 47c0d90b7..9eacb542f 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -142,6 +142,7 @@ libc_bionic_src_files := \ bionic/mkfifo.cpp \ bionic/mknod.cpp \ bionic/mntent.cpp \ + bionic/NetdClientDispatch.cpp \ bionic/open.cpp \ bionic/pause.cpp \ bionic/pipe.cpp \ @@ -847,7 +848,6 @@ LOCAL_SRC_FILES := \ bionic/dlmalloc.c \ bionic/malloc_debug_common.cpp \ bionic/libc_init_static.cpp \ - bionic/NetdClient.cpp \ LOCAL_CFLAGS := $(libc_common_cflags) \ -DLIBC_STATIC diff --git a/libc/bionic/NetdClient.cpp b/libc/bionic/NetdClient.cpp index 56d82445b..6826ee8ee 100644 --- a/libc/bionic/NetdClient.cpp +++ b/libc/bionic/NetdClient.cpp @@ -14,24 +14,14 @@ * limitations under the License. */ +#ifdef LIBC_STATIC +#error NetdClient.cpp should NOT be included in static libc builds. +#endif + #include #include #include -#ifdef __i386__ -#define __socketcall __attribute__((__cdecl__)) -#else -#define __socketcall -#endif - -extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t); - -NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = { - __connect -}; - -#ifndef LIBC_STATIC - #include template @@ -56,13 +46,9 @@ static void netdClientInitImpl() { static pthread_once_t netdClientInitOnce = PTHREAD_ONCE_INIT; -#endif // LIBC_STATIC - extern "C" __LIBC_HIDDEN__ void netdClientInit() { -#ifndef LIBC_STATIC if (pthread_once(&netdClientInitOnce, netdClientInitImpl)) { __libc_format_log(ANDROID_LOG_ERROR, "netdClient", "Unable to initialize netd_client component."); } -#endif // LIBC_STATIC } diff --git a/libc/bionic/NetdClientDispatch.cpp b/libc/bionic/NetdClientDispatch.cpp new file mode 100644 index 000000000..31728d2fe --- /dev/null +++ b/libc/bionic/NetdClientDispatch.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2014 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 + +#ifdef __i386__ +#define __socketcall __attribute__((__cdecl__)) +#else +#define __socketcall +#endif + +extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t); + +NetdClientDispatch __netdClientDispatch __attribute__((aligned(32))) = { + __connect +};