Merge "Fixed int fast types for LP64"
authorCalin Juravle <calin@google.com>
Fri, 21 Feb 2014 17:09:13 +0000 (17:09 +0000)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Fri, 21 Feb 2014 17:09:13 +0000 (17:09 +0000)
libc/include/stdint.h
tests/Android.mk
tests/stdint_test.cpp [new file with mode: 0644]

index 0d65ff8aa26ecfe4077687fd8d7d67fec8859691..1f3d003d14f98cb25a21006a26c3b2ada20806fd 100644 (file)
@@ -69,29 +69,35 @@ typedef __intptr_t    intptr_t;
 typedef __uintptr_t   uintptr_t;
 
 typedef int8_t        int_least8_t;
-typedef int8_t        int_fast8_t;
-
 typedef uint8_t       uint_least8_t;
-typedef uint8_t       uint_fast8_t;
 
 typedef int16_t       int_least16_t;
-typedef int32_t       int_fast16_t;
-
 typedef uint16_t      uint_least16_t;
-typedef uint32_t      uint_fast16_t;
 
 typedef int32_t       int_least32_t;
-typedef int32_t       int_fast32_t;
-
 typedef uint32_t      uint_least32_t;
-typedef uint32_t      uint_fast32_t;
 
 typedef int64_t       int_least64_t;
-typedef int64_t       int_fast64_t;
-
 typedef uint64_t      uint_least64_t;
+
+typedef int8_t        int_fast8_t;
+typedef uint8_t       uint_fast8_t;
+
+typedef int64_t       int_fast64_t;
 typedef uint64_t      uint_fast64_t;
 
+#ifdef __LP64__
+typedef int64_t       int_fast16_t;
+typedef uint64_t      uint_fast16_t;
+typedef int64_t       int_fast32_t;
+typedef uint64_t      uint_fast32_t;
+#else
+typedef int32_t       int_fast16_t;
+typedef uint32_t      uint_fast16_t;
+typedef int32_t       int_fast32_t;
+typedef uint32_t      uint_fast32_t;
+#endif
+
 typedef uint64_t      uintmax_t;
 typedef int64_t       intmax_t;
 
index 5ee2596dd48a9424a8e1b0bde765511006b7096a..4879e523b8a9006a907ba7aea499fbbea62d7064 100644 (file)
@@ -59,6 +59,7 @@ libBionicStandardTests_src_files := \
     stack_protector_test.cpp \
     stack_unwinding_test.cpp \
     stack_unwinding_test_impl.c \
+    stdint_test.cpp \
     stdio_test.cpp \
     stdlib_test.cpp \
     string_test.cpp \
diff --git a/tests/stdint_test.cpp b/tests/stdint_test.cpp
new file mode 100644 (file)
index 0000000..5dafee3
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 <gtest/gtest.h>
+
+#include <stdint.h>
+
+TEST(stdint_types, type_sizes) {
+  ASSERT_EQ(1U, sizeof(int_fast8_t));
+  ASSERT_EQ(8U, sizeof(int_fast64_t));
+  ASSERT_EQ(1U, sizeof(uint_fast8_t));
+  ASSERT_EQ(8U, sizeof(uint_fast64_t));
+#if defined(__LP64__)
+  ASSERT_EQ(8U, sizeof(int_fast16_t));
+  ASSERT_EQ(8U, sizeof(int_fast32_t));
+  ASSERT_EQ(8U, sizeof(uint_fast16_t));
+  ASSERT_EQ(8U, sizeof(uint_fast32_t));
+#else
+  ASSERT_EQ(4U, sizeof(int_fast16_t));
+  ASSERT_EQ(4U, sizeof(int_fast32_t));
+  ASSERT_EQ(4U, sizeof(uint_fast16_t));
+  ASSERT_EQ(4U, sizeof(uint_fast32_t));
+#endif
+}