aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ng <dave@codeaurora.org>2016-03-05 07:20:25 -0800
committerLinux Build Service Account <lnxbuild@localhost>2016-08-24 08:17:48 -0600
commitd1e3615cc2b92497dc4bbaf860ee1a6f4b222dd5 (patch)
treeda3c0775726d401163ef67d449e963738e6ce92e
parent7cdb481dfe626524c93e4b6a1aae4621b1beedbc (diff)
downloadandroid_bionic-d1e3615cc2b92497dc4bbaf860ee1a6f4b222dd5.tar.gz
android_bionic-d1e3615cc2b92497dc4bbaf860ee1a6f4b222dd5.tar.bz2
android_bionic-d1e3615cc2b92497dc4bbaf860ee1a6f4b222dd5.zip
Revert "<netinet/udp.h> should include <linux/udp.h>."
This reverts commit f8a2243ebeb3ce60e412cd7b71b31c7b31313d58. Revert combined union of Linux and BSD-style as this causes incompatibility with numerous modules that also defines udphdr (but differently). Change-Id: Ide8e36cb02d9145aaebaf90c101100dc578a44ec
-rw-r--r--libc/include/netinet/udp.h36
-rw-r--r--libc/kernel/tools/defaults.py2
-rw-r--r--libc/kernel/uapi/linux/udp.h2
-rw-r--r--tests/Android.mk1
-rw-r--r--tests/netinet_udp_test.cpp46
5 files changed, 20 insertions, 67 deletions
diff --git a/libc/include/netinet/udp.h b/libc/include/netinet/udp.h
index d4eb36806..25e0dfca9 100644
--- a/libc/include/netinet/udp.h
+++ b/libc/include/netinet/udp.h
@@ -25,29 +25,31 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
#ifndef _NETINET_UDP_H
#define _NETINET_UDP_H
-#include <sys/types.h>
+/*
+ * We would include linux/udp.h, but it brings in too much other stuff
+ */
+
+#ifdef __FAVOR_BSD
-#include <linux/udp.h>
+struct udphdr {
+ u_int16_t uh_sport; /* source port */
+ u_int16_t uh_dport; /* destination port */
+ u_int16_t uh_ulen; /* udp length */
+ u_int16_t uh_sum; /* udp checksum */
+};
+
+#else
struct udphdr {
- __extension__ union {
- struct /* BSD names */ {
- u_int16_t uh_sport;
- u_int16_t uh_dport;
- u_int16_t uh_ulen;
- u_int16_t uh_sum;
- };
- struct /* Linux names */ {
- u_int16_t source;
- u_int16_t dest;
- u_int16_t len;
- u_int16_t check;
- };
- };
+ __u16 source;
+ __u16 dest;
+ __u16 len;
+ __u16 check;
};
+#endif /* __FAVOR_BSD */
+
#endif /* _NETINET_UDP_H */
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index 773d22f00..1b6853e51 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -64,8 +64,6 @@ kernel_token_replacements = {
# The kernel's SIGRTMIN/SIGRTMAX are absolute limits; userspace steals a few.
"SIGRTMIN": "__SIGRTMIN",
"SIGRTMAX": "__SIGRTMAX",
- # We want to support both BSD and Linux member names in struct udphdr.
- "udphdr": "__kernel_udphdr",
}
# this is the set of known static inline functions that we want to keep
diff --git a/libc/kernel/uapi/linux/udp.h b/libc/kernel/uapi/linux/udp.h
index a3e9e9711..e1d546cb7 100644
--- a/libc/kernel/uapi/linux/udp.h
+++ b/libc/kernel/uapi/linux/udp.h
@@ -19,7 +19,7 @@
#ifndef _UAPI_LINUX_UDP_H
#define _UAPI_LINUX_UDP_H
#include <linux/types.h>
-struct __kernel_udphdr {
+struct udphdr {
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
__be16 source;
__be16 dest;
diff --git a/tests/Android.mk b/tests/Android.mk
index 956b76fcc..06bbb262c 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -68,7 +68,6 @@ libBionicStandardTests_src_files := \
netdb_test.cpp \
net_if_test.cpp \
netinet_in_test.cpp \
- netinet_udp_test.cpp \
pthread_test.cpp \
pty_test.cpp \
regex_test.cpp \
diff --git a/tests/netinet_udp_test.cpp b/tests/netinet_udp_test.cpp
deleted file mode 100644
index 661458ed1..000000000
--- a/tests/netinet_udp_test.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2015 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 <netinet/udp.h>
-
-#include <gtest/gtest.h>
-
-#if defined(__BIONIC__)
- #define UDPHDR_USES_ANON_UNION
-#elif defined(__GLIBC_PREREQ)
- #if __GLIBC_PREREQ(2, 18)
- #define UDPHDR_USES_ANON_UNION
- #endif
-#endif
-
-TEST(netinet_udp, compat) {
-#if defined(UDPHDR_USES_ANON_UNION)
- static_assert(offsetof(udphdr, uh_sport) == offsetof(udphdr, source), "udphdr::source");
- static_assert(offsetof(udphdr, uh_dport) == offsetof(udphdr, dest), "udphdr::dest");
- static_assert(offsetof(udphdr, uh_ulen) == offsetof(udphdr, len), "udphdr::len");
- static_assert(offsetof(udphdr, uh_sum) == offsetof(udphdr, check), "udphdr::check");
-
- udphdr u;
- u.uh_sport = 0x1111;
- u.uh_dport = 0x2222;
- u.uh_ulen = 0x3333;
- u.uh_sum = 0x4444;
- ASSERT_EQ(0x1111, u.source);
- ASSERT_EQ(0x2222, u.dest);
- ASSERT_EQ(0x3333, u.len);
- ASSERT_EQ(0x4444, u.check);
-#endif
-}