471471 __pgrp: :: pid_t,
472472 __sd: :: sigset_t,
473473 __ss: :: sigset_t,
474- #[ cfg( target_env = "musl" ) ]
474+ #[ cfg( any ( target_env = "musl" , target_env = "ohos" ) ) ]
475475 __prio: :: c_int,
476- #[ cfg( not( target_env = "musl" ) ) ]
476+ #[ cfg( not( any ( target_env = "musl" , target_env = "ohos" ) ) ) ]
477477 __sp: :: sched_param,
478478 __policy: :: c_int,
479479 __pad: [ :: c_int; 16 ] ,
@@ -1225,7 +1225,7 @@ cfg_if! {
12251225}
12261226
12271227cfg_if ! {
1228- if #[ cfg( any( target_env = "gnu" , target_env = "musl" ) ) ] {
1228+ if #[ cfg( any( target_env = "gnu" , target_env = "musl" , target_env = "ohos" ) ) ] {
12291229 pub const ABDAY_1 : :: nl_item = 0x20000 ;
12301230 pub const ABDAY_2 : :: nl_item = 0x20001 ;
12311231 pub const ABDAY_3 : :: nl_item = 0x20002 ;
@@ -3970,7 +3970,7 @@ safe_f! {
39703970}
39713971
39723972cfg_if ! {
3973- if #[ cfg( not( target_env = "uclibc" ) ) ] {
3973+ if #[ cfg( all ( not( target_env = "uclibc" ) , not ( target_env = "ohos" ) ) ) ] {
39743974 extern "C" {
39753975 pub fn aio_read( aiocbp: * mut aiocb) -> :: c_int;
39763976 pub fn aio_write( aiocbp: * mut aiocb) -> :: c_int;
@@ -3989,6 +3989,13 @@ cfg_if! {
39893989 nitems: :: c_int,
39903990 sevp: * mut :: sigevent,
39913991 ) -> :: c_int;
3992+ }
3993+ }
3994+ }
3995+
3996+ cfg_if ! {
3997+ if #[ cfg( not( target_env = "uclibc" ) ) ] {
3998+ extern "C" {
39923999 pub fn pwritev(
39934000 fd: :: c_int,
39944001 iov: * const :: iovec,
@@ -4038,8 +4045,79 @@ cfg_if! {
40384045 }
40394046}
40404047
4048+ // These functions are not available on OpenHarmony
4049+ cfg_if ! {
4050+ if #[ cfg( not( target_env = "ohos" ) ) ] {
4051+ extern "C" {
4052+ // Only `getspnam_r` is implemented for musl, out of all of the reenterant
4053+ // functions from `shadow.h`.
4054+ // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
4055+ pub fn getspnam_r(
4056+ name: * const :: c_char,
4057+ spbuf: * mut spwd,
4058+ buf: * mut :: c_char,
4059+ buflen: :: size_t,
4060+ spbufp: * mut * mut spwd,
4061+ ) -> :: c_int;
4062+
4063+ pub fn shm_open( name: * const c_char, oflag: :: c_int, mode: mode_t) -> :: c_int;
4064+ pub fn shm_unlink( name: * const :: c_char) -> :: c_int;
4065+
4066+ pub fn mq_open( name: * const :: c_char, oflag: :: c_int, ...) -> :: mqd_t;
4067+ pub fn mq_close( mqd: :: mqd_t) -> :: c_int;
4068+ pub fn mq_unlink( name: * const :: c_char) -> :: c_int;
4069+ pub fn mq_receive(
4070+ mqd: :: mqd_t,
4071+ msg_ptr: * mut :: c_char,
4072+ msg_len: :: size_t,
4073+ msg_prio: * mut :: c_uint,
4074+ ) -> :: ssize_t;
4075+ pub fn mq_timedreceive(
4076+ mqd: :: mqd_t,
4077+ msg_ptr: * mut :: c_char,
4078+ msg_len: :: size_t,
4079+ msg_prio: * mut :: c_uint,
4080+ abs_timeout: * const :: timespec,
4081+ ) -> :: ssize_t;
4082+ pub fn mq_send(
4083+ mqd: :: mqd_t,
4084+ msg_ptr: * const :: c_char,
4085+ msg_len: :: size_t,
4086+ msg_prio: :: c_uint,
4087+ ) -> :: c_int;
4088+ pub fn mq_timedsend(
4089+ mqd: :: mqd_t,
4090+ msg_ptr: * const :: c_char,
4091+ msg_len: :: size_t,
4092+ msg_prio: :: c_uint,
4093+ abs_timeout: * const :: timespec,
4094+ ) -> :: c_int;
4095+ pub fn mq_getattr( mqd: :: mqd_t, attr: * mut :: mq_attr) -> :: c_int;
4096+ pub fn mq_setattr(
4097+ mqd: :: mqd_t,
4098+ newattr: * const :: mq_attr,
4099+ oldattr: * mut :: mq_attr
4100+ ) -> :: c_int;
4101+
4102+ pub fn pthread_mutex_consistent( mutex: * mut pthread_mutex_t) -> :: c_int;
4103+ pub fn pthread_cancel( thread: :: pthread_t) -> :: c_int;
4104+ pub fn pthread_mutexattr_getrobust(
4105+ attr: * const pthread_mutexattr_t,
4106+ robustness: * mut :: c_int,
4107+ ) -> :: c_int;
4108+ pub fn pthread_mutexattr_setrobust(
4109+ attr: * mut pthread_mutexattr_t,
4110+ robustness: :: c_int,
4111+ ) -> :: c_int;
4112+ }
4113+ }
4114+ }
4115+
40414116extern "C" {
4042- #[ cfg_attr( not( target_env = "musl" ) , link_name = "__xpg_strerror_r" ) ]
4117+ #[ cfg_attr(
4118+ not( any( target_env = "musl" , target_env = "ohos" ) ) ,
4119+ link_name = "__xpg_strerror_r"
4120+ ) ]
40434121 pub fn strerror_r ( errnum : :: c_int , buf : * mut c_char , buflen : :: size_t ) -> :: c_int ;
40444122
40454123 pub fn abs ( i : :: c_int ) -> :: c_int ;
@@ -4070,18 +4148,6 @@ extern "C" {
40704148 pub fn getspent ( ) -> * mut spwd ;
40714149
40724150 pub fn getspnam ( name : * const :: c_char ) -> * mut spwd ;
4073- // Only `getspnam_r` is implemented for musl, out of all of the reenterant
4074- // functions from `shadow.h`.
4075- // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
4076- pub fn getspnam_r (
4077- name : * const :: c_char ,
4078- spbuf : * mut spwd ,
4079- buf : * mut :: c_char ,
4080- buflen : :: size_t ,
4081- spbufp : * mut * mut spwd ,
4082- ) -> :: c_int ;
4083-
4084- pub fn shm_open ( name : * const c_char , oflag : :: c_int , mode : mode_t ) -> :: c_int ;
40854151
40864152 // System V IPC
40874153 pub fn shmget ( key : :: key_t , size : :: size_t , shmflg : :: c_int ) -> :: c_int ;
@@ -4187,37 +4253,6 @@ extern "C" {
41874253 id : :: c_int ,
41884254 data : * mut :: c_char ,
41894255 ) -> :: c_int ;
4190- pub fn mq_open ( name : * const :: c_char , oflag : :: c_int , ...) -> :: mqd_t ;
4191- pub fn mq_close ( mqd : :: mqd_t ) -> :: c_int ;
4192- pub fn mq_unlink ( name : * const :: c_char ) -> :: c_int ;
4193- pub fn mq_receive (
4194- mqd : :: mqd_t ,
4195- msg_ptr : * mut :: c_char ,
4196- msg_len : :: size_t ,
4197- msg_prio : * mut :: c_uint ,
4198- ) -> :: ssize_t ;
4199- pub fn mq_timedreceive (
4200- mqd : :: mqd_t ,
4201- msg_ptr : * mut :: c_char ,
4202- msg_len : :: size_t ,
4203- msg_prio : * mut :: c_uint ,
4204- abs_timeout : * const :: timespec ,
4205- ) -> :: ssize_t ;
4206- pub fn mq_send (
4207- mqd : :: mqd_t ,
4208- msg_ptr : * const :: c_char ,
4209- msg_len : :: size_t ,
4210- msg_prio : :: c_uint ,
4211- ) -> :: c_int ;
4212- pub fn mq_timedsend (
4213- mqd : :: mqd_t ,
4214- msg_ptr : * const :: c_char ,
4215- msg_len : :: size_t ,
4216- msg_prio : :: c_uint ,
4217- abs_timeout : * const :: timespec ,
4218- ) -> :: c_int ;
4219- pub fn mq_getattr ( mqd : :: mqd_t , attr : * mut :: mq_attr ) -> :: c_int ;
4220- pub fn mq_setattr ( mqd : :: mqd_t , newattr : * const :: mq_attr , oldattr : * mut :: mq_attr ) -> :: c_int ;
42214256 pub fn epoll_pwait (
42224257 epfd : :: c_int ,
42234258 events : * mut :: epoll_event ,
@@ -4284,8 +4319,6 @@ extern "C" {
42844319
42854320 pub fn posix_madvise ( addr : * mut :: c_void , len : :: size_t , advice : :: c_int ) -> :: c_int ;
42864321
4287- pub fn shm_unlink ( name : * const :: c_char ) -> :: c_int ;
4288-
42894322 pub fn seekdir ( dirp : * mut :: DIR , loc : :: c_long ) ;
42904323
42914324 pub fn telldir ( dirp : * mut :: DIR ) -> :: c_long ;
@@ -4389,7 +4422,7 @@ extern "C" {
43894422 attr : * mut pthread_mutexattr_t ,
43904423 protocol : :: c_int ,
43914424 ) -> :: c_int ;
4392- pub fn pthread_mutex_consistent ( mutex : * mut pthread_mutex_t ) -> :: c_int ;
4425+
43934426 pub fn pthread_mutex_timedlock (
43944427 lock : * mut pthread_mutex_t ,
43954428 abstime : * const :: timespec ,
@@ -4487,7 +4520,6 @@ extern "C" {
44874520 pub fn pthread_sigmask ( how : :: c_int , set : * const sigset_t , oldset : * mut sigset_t ) -> :: c_int ;
44884521 pub fn sem_open ( name : * const :: c_char , oflag : :: c_int , ...) -> * mut sem_t ;
44894522 pub fn getgrnam ( name : * const :: c_char ) -> * mut :: group ;
4490- pub fn pthread_cancel ( thread : :: pthread_t ) -> :: c_int ;
44914523 pub fn pthread_kill ( thread : :: pthread_t , sig : :: c_int ) -> :: c_int ;
44924524 pub fn sem_unlink ( name : * const :: c_char ) -> :: c_int ;
44934525 pub fn daemon ( nochdir : :: c_int , noclose : :: c_int ) -> :: c_int ;
@@ -4522,14 +4554,6 @@ extern "C" {
45224554 attr : * const pthread_mutexattr_t ,
45234555 pshared : * mut :: c_int ,
45244556 ) -> :: c_int ;
4525- pub fn pthread_mutexattr_getrobust (
4526- attr : * const pthread_mutexattr_t ,
4527- robustness : * mut :: c_int ,
4528- ) -> :: c_int ;
4529- pub fn pthread_mutexattr_setrobust (
4530- attr : * mut pthread_mutexattr_t ,
4531- robustness : :: c_int ,
4532- ) -> :: c_int ;
45334557 pub fn popen ( command : * const c_char , mode : * const c_char ) -> * mut :: FILE ;
45344558 pub fn faccessat (
45354559 dirfd : :: c_int ,
@@ -4729,7 +4753,7 @@ cfg_if! {
47294753 if #[ cfg( target_env = "uclibc" ) ] {
47304754 mod uclibc;
47314755 pub use self :: uclibc:: * ;
4732- } else if #[ cfg( target_env = "musl" ) ] {
4756+ } else if #[ cfg( any ( target_env = "musl" , target_env = "ohos" ) ) ] {
47334757 mod musl;
47344758 pub use self :: musl:: * ;
47354759 } else if #[ cfg( target_env = "gnu" ) ] {
0 commit comments