summaryrefslogtreecommitdiffstats
path: root/luni/src
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2014-06-13 12:03:43 +0100
committerNarayan Kamath <narayan@google.com>2014-06-13 12:45:39 +0100
commit857e3a0f4f1f0d381a06d69c8facac5d59d6461e (patch)
treea3aa87c5860f87f5cd8ef3969836676b74a2b72b /luni/src
parentf577d7594f3acc1d97e119c508e8e4edfeb1f20b (diff)
downloadlibcore-857e3a0f4f1f0d381a06d69c8facac5d59d6461e.zip
libcore-857e3a0f4f1f0d381a06d69c8facac5d59d6461e.tar.gz
libcore-857e3a0f4f1f0d381a06d69c8facac5d59d6461e.tar.bz2
Fix bogus define checks and a typo.
RT_* constants are enum members in the UAPI so we can't use #define checks for them. Also fix a typo in the define check for an IFA_ constant. More generally, we should get rid of all these conditional checks for target builds because we know what version of the UAPI we have in bionic. We should move these conditional checks under #if HOST_BUILD or something similar. bug: 15602893 Change-Id: I3affc10773ade4dac68c176f79962ca8ad312579
Diffstat (limited to 'luni/src')
-rw-r--r--luni/src/main/native/android_system_OsConstants.cpp16
-rw-r--r--luni/src/test/java/libcore/android/system/OsConstantsTest.java31
2 files changed, 37 insertions, 10 deletions
diff --git a/luni/src/main/native/android_system_OsConstants.cpp b/luni/src/main/native/android_system_OsConstants.cpp
index 13a0b1c..87ebc21 100644
--- a/luni/src/main/native/android_system_OsConstants.cpp
+++ b/luni/src/main/native/android_system_OsConstants.cpp
@@ -254,7 +254,7 @@ static void OsConstants_initConstants(JNIEnv* env, jclass c) {
#if defined(IFA_F_TEMPORARY)
initConstant(env, c, "IFA_F_TEMPORARY", IFA_F_TEMPORARY);
#endif
-#if defined(IDA_F_TENTATIVE)
+#if defined(IFA_F_TENTATIVE)
initConstant(env, c, "IFA_F_TENTATIVE", IFA_F_TENTATIVE);
#endif
initConstant(env, c, "IFF_ALLMULTI", IFF_ALLMULTI);
@@ -390,19 +390,15 @@ static void OsConstants_initConstants(JNIEnv* env, jclass c) {
initConstant(env, c, "PROT_READ", PROT_READ);
initConstant(env, c, "PROT_WRITE", PROT_WRITE);
initConstant(env, c, "R_OK", R_OK);
-#if defined(RT_SCOPE_HOST)
+// NOTE: The RT_* constants are not preprocessor defines, they're enum
+// members. The best we can do (barring UAPI / kernel version checks) is
+// to hope they exist on all host linuxes we're building on. These
+// constants have been around since 2.6.35 at least, so we should be ok.
+#if !defined(__APPLE__)
initConstant(env, c, "RT_SCOPE_HOST", RT_SCOPE_HOST);
-#endif
-#if defined(RT_SCOPE_LINK)
initConstant(env, c, "RT_SCOPE_LINK", RT_SCOPE_LINK);
-#endif
-#if defined(RT_SCOPE_NOWHERE)
initConstant(env, c, "RT_SCOPE_NOWHERE", RT_SCOPE_NOWHERE);
-#endif
-#if defined(RT_SCOPE_SITE)
initConstant(env, c, "RT_SCOPE_SITE", RT_SCOPE_SITE);
-#endif
-#if defined(RT_SCOPE_UNIVERSE)
initConstant(env, c, "RT_SCOPE_UNIVERSE", RT_SCOPE_UNIVERSE);
#endif
initConstant(env, c, "SEEK_CUR", SEEK_CUR);
diff --git a/luni/src/test/java/libcore/android/system/OsConstantsTest.java b/luni/src/test/java/libcore/android/system/OsConstantsTest.java
new file mode 100644
index 0000000..681d68c
--- /dev/null
+++ b/luni/src/test/java/libcore/android/system/OsConstantsTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package android.system;
+
+import junit.framework.TestCase;
+
+public class OsConstantsTest extends TestCase {
+
+ // http://b/15602893
+ public void testBug15602893() {
+ assertTrue(OsConstants.RT_SCOPE_HOST > 0);
+ assertTrue(OsConstants.RT_SCOPE_LINK > 0);
+ assertTrue(OsConstants.RT_SCOPE_SITE > 0);
+
+ assertTrue(OsConstants.IFA_F_TENTATIVE > 0);
+ }
+}