Skip to content

Commit

Permalink
Remove musl ctype code.
Browse files Browse the repository at this point in the history
All we need from this is iswblank, for which we can trivially provide
our own definition.

Test: ./run_tests.py
Bug: android/ndk#300
Change-Id: I47ff80c27e0d475b7275c2c791a7ce1841b1a1ed
  • Loading branch information
DanAlbert committed Jun 30, 2017
1 parent a6c33d1 commit 39a94a9
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 670 deletions.
75 changes: 31 additions & 44 deletions sources/android/support/Android.mk
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
LOCAL_PATH := $(call my-dir)

android_support_c_includes := $(LOCAL_PATH)/include
android_support_export_c_includes := $(LOCAL_PATH)/include

ifneq ($(filter $(NDK_KNOWN_DEVICE_ABI64S),$(TARGET_ARCH_ABI)),)
is_lp64 := true
else
is_lp64 :=
endif

ifneq ($(LIBCXX_FORCE_REBUILD),true) # Using prebuilt

LIBCXX_LIBS := ../../cxx-stl/llvm-libc++/libs/$(TARGET_ARCH_ABI)

include $(CLEAR_VARS)
LOCAL_MODULE := android_support
LOCAL_SRC_FILES := $(LIBCXX_LIBS)/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
LOCAL_EXPORT_C_INCLUDES := $(android_support_export_c_includes)
include $(PREBUILT_STATIC_LIBRARY)

else # Building

android_support_c_includes := $(android_support_export_c_includes)

ifeq ($(is_lp64),true)
# 64-bit ABIs
android_support_sources := \
Expand All @@ -16,8 +30,23 @@ android_support_sources := \
else
# 32-bit ABIs

BIONIC_PATH := ../../../../bionic

android_support_c_includes += $(BIONIC_PATH)/libc

android_support_sources := \
$(BIONIC_PATH)/libc/bionic/c32rtomb.cpp \
$(BIONIC_PATH)/libc/bionic/mbrtoc32.cpp \
$(BIONIC_PATH)/libc/bionic/mbstate.cpp \
$(BIONIC_PATH)/libc/bionic/wchar.cpp \
$(BIONIC_PATH)/libc/upstream-openbsd/lib/libc/locale/mbtowc.c \
src/_Exit.cpp \
src/iswblank.cpp \
src/posix_memalign.cpp \
src/swprintf.cpp \

# These are old sources that should be purged/rewritten/taken from bionic.
android_support_sources += \
src/locale/duplocale.c \
src/locale/freelocale.c \
src/locale/localeconv.c \
Expand All @@ -28,27 +57,10 @@ android_support_sources := \
src/msun/e_log2.c \
src/msun/e_log2f.c \
src/msun/s_nan.c \
src/musl-ctype/iswalnum.c \
src/musl-ctype/iswalpha.c \
src/musl-ctype/iswblank.c \
src/musl-ctype/iswcntrl.c \
src/musl-ctype/iswctype.c \
src/musl-ctype/iswdigit.c \
src/musl-ctype/iswgraph.c \
src/musl-ctype/iswlower.c \
src/musl-ctype/iswprint.c \
src/musl-ctype/iswpunct.c \
src/musl-ctype/iswspace.c \
src/musl-ctype/iswupper.c \
src/musl-ctype/iswxdigit.c \
src/musl-ctype/wcswidth.c \
src/musl-ctype/wcwidth.c \
src/musl-math/frexp.c \
src/musl-math/frexpf.c \
src/musl-math/frexpl.c \
src/posix_memalign.cpp \
src/stdlib_support.c \
src/swprintf.cpp \
src/wchar_support.c \
src/wcstox/floatscan.c \
src/wcstox/intscan.c \
Expand All @@ -68,20 +80,6 @@ endif

endif # 64-/32-bit ABIs

ifneq ($(LIBCXX_FORCE_REBUILD),true) # Using prebuilt

LIBCXX_LIBS := ../../cxx-stl/llvm-libc++/libs/$(TARGET_ARCH_ABI)

include $(CLEAR_VARS)
LOCAL_MODULE := android_support
LOCAL_SRC_FILES := $(LIBCXX_LIBS)/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
LOCAL_EXPORT_C_INCLUDES := $(android_support_c_includes)
include $(PREBUILT_STATIC_LIBRARY)

else # Building

BIONIC_PATH := ../../../../bionic

# This is only available as a static library for now.
include $(CLEAR_VARS)
LOCAL_MODULE := android_support
Expand Down Expand Up @@ -110,18 +108,7 @@ LOCAL_CFLAGS += \
-Wno-shift-negative-value
endif

LOCAL_EXPORT_C_INCLUDES := $(android_support_c_includes)

ifneq ($(is_lp64),true)
LOCAL_SRC_FILES += \
$(BIONIC_PATH)/libc/bionic/c32rtomb.cpp \
$(BIONIC_PATH)/libc/bionic/mbstate.cpp \
$(BIONIC_PATH)/libc/bionic/mbrtoc32.cpp \
$(BIONIC_PATH)/libc/bionic/wchar.cpp \
$(BIONIC_PATH)/libc/upstream-openbsd/lib/libc/locale/mbtowc.c \

LOCAL_C_INCLUDES += $(BIONIC_PATH)/libc
endif
LOCAL_EXPORT_C_INCLUDES := $(android_support_export_c_includes)

include $(BUILD_STATIC_LIBRARY)

Expand Down
65 changes: 6 additions & 59 deletions sources/android/support/include/wctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,69 +25,16 @@
#ifndef NDK_ANDROID_SUPPORT_WCTYPE_H
#define NDK_ANDROID_SUPPORT_WCTYPE_H

/* Please read note in wchar.h to see why the C library version of this
* file is not included through #include_next here.
*/
#if defined(__LP64__)

# include_next <wctype.h>

#else

# include <xlocale.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef __WINT_TYPE__ wint_t;
typedef const void* wctrans_t;
typedef long wctype_t;

#define WEOF ((wint_t)(-1))

int iswalnum(wint_t);
int iswalpha(wint_t);
int iswblank(wint_t);
int iswcntrl(wint_t);
int iswdigit(wint_t);
int iswgraph(wint_t);
int iswlower(wint_t);
int iswprint(wint_t);
int iswpunct(wint_t);
int iswspace(wint_t);
int iswupper(wint_t);
int iswxdigit(wint_t);
int iswctype(wint_t, wctype_t);
wint_t towctrans(wint_t, wctrans_t);
wint_t towlower(wint_t);
wint_t towupper(wint_t);
wctrans_t wctrans(const char *);
wctype_t wctype(const char *);
#include_next <wctype.h>

int iswalnum_l(wint_t, locale_t);
int iswgraph_l(wint_t, locale_t);
int iswctype_l(wint_t, wctype_t, locale_t);
__BEGIN_DECLS

wint_t towctrans_l(wint_t, wctrans_t, locale_t);
wctrans_t wctrans_l(const char *, locale_t);
wctype_t wctype_l(const char *, locale_t);
#if __ANDROID_API__ < __ANDROID_API_L__

int iswalpha_l(wint_t, locale_t);
int iswblank_l(wint_t, locale_t);
int iswcntrl_l(wint_t, locale_t);
int iswdigit_l(wint_t, locale_t);
int iswlower_l(wint_t, locale_t);
int iswprint_l(wint_t, locale_t);
int iswpunct_l(wint_t, locale_t);
int iswspace_l(wint_t, locale_t);
int iswupper_l(wint_t, locale_t);
int iswxdigit_l(wint_t, locale_t);
int iswblank(wint_t);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // !__LP64__
__END_DECLS

#endif // NDK_ANDROID_SUPPORT_WCTYPE_H
#endif /* NDK_ANDROID_SUPPORT_WCTYPE_H */
33 changes: 33 additions & 0 deletions sources/android/support/src/iswblank.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2017 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 <ctype.h>
#include <wctype.h>

int iswblank(wint_t ch) {
return isblank(ch);
}
125 changes: 0 additions & 125 deletions sources/android/support/src/musl-ctype/alpha.h

This file was deleted.

7 changes: 0 additions & 7 deletions sources/android/support/src/musl-ctype/iswalnum.c

This file was deleted.

14 changes: 0 additions & 14 deletions sources/android/support/src/musl-ctype/iswalpha.c

This file was deleted.

8 changes: 0 additions & 8 deletions sources/android/support/src/musl-ctype/iswblank.c

This file was deleted.

Loading

0 comments on commit 39a94a9

Please sign in to comment.