What are the most important POSIX functions not available in Android?

后端 未结 4 630
星月不相逢
星月不相逢 2021-01-02 01:20

I\'m about to port a large C++ project (some sort of Library Project, it contains absolutely no GUI) to Android. It\'s actually a Visual C++ project, but it will be ported t

相关标签:
4条回答
  • 2021-01-02 01:57

    Bionic a recode by Google. It is small but optimized for Android.

    The only big thing I know of that it lacks is indeed the pthread_cancel() function.

    My experience is that if you port it successfully to GNU/Linux, without pthread_cancel() calls, then you should be mostly ok.

    BTW, what kind of library are you trying to build? What does it uses? Network, threads...

    PS: Even Linux is not fully POSIX.

    0 讨论(0)
  • 2021-01-02 02:13

    shared memory is also something you might find differently implemented in android. was hit hard while trying to work with shm_open and shm_unlink on android kernel. Android implements asynchronous shared memory (ashmem).

    0 讨论(0)
  • 2021-01-02 02:14

    Bionic Wikipedia page

    https://en.wikipedia.org/wiki/Bionic_(software)#Differences_from_POSIX

    Also has some interesting info:

    Although bionic aims to implement all of C11 and POSIX, there are still (as of Oreo) about 70 POSIX functions missing[8] from libc. There are also POSIX functions such as the endpwent/getpwent/setpwent family that are inapplicable to Android because it lacks a passwd database. As of Oreo, libm is complete.

    Some functions deliberately do not conform to the POSIX or C standards for security reasons, such as printf which does not support the %n format string.[9]

    Official Bionic in tree documentation quote

    https://android.googlesource.com/platform/bionic/+/37ad9597839c70a7ec79578e5072df9c189fc830/docs/status.md

    Run ./libc/tools/check-symbols-glibc.py in bionic/ for the current list of POSIX functions implemented by glibc but not by bionic. Currently (2017-10):

    aio_cancel
    aio_error
    aio_fsync
    aio_read
    aio_return
    aio_suspend
    aio_write
    lio_listio
    pthread_cancel
    pthread_mutex_consistent
    pthread_mutex_getprioceiling
    pthread_mutex_setprioceiling
    pthread_mutexattr_getprioceiling
    pthread_mutexattr_getprotocol
    pthread_mutexattr_getrobust
    pthread_mutexattr_setprioceiling
    pthread_mutexattr_setprotocol
    pthread_mutexattr_setrobust
    pthread_setcancelstate
    pthread_setcanceltype
    pthread_testcancel
    wordexp
    wordfree
    libm
    

    Current libm symbols: https://android.googlesource.com/platform/bionic/+/master/libm/libm.map.txt

    0 remaining missing POSIX libm functions.

    0 讨论(0)
  • 2021-01-02 02:16

    The most obvious feature missing is pthread_cancel().

    This blog has some additional details: http://codingrelic.geekhold.com/2008/11/six-million-dollar-libc.html

    Good overview of Bionic: https://android-platform.googlegroups.com/attach/0f8eba5ecb95c6f4/OVERVIEW.TXT?gda=HWJaO0UAAAB1RXoVyyH5sRXFfLYnAq48KOFqr-45JqvtfiaR6gxIj4Qe8cBqW3BaWdSUPWi_jHqO3f1cykW9hbJ1ju6H3kglGu1iLHeqhw4ZZRj3RjJ_-A&view=1&part=4

    0 讨论(0)
提交回复
热议问题