From b739b135949dfcefb5bebe1834569e353f436c3c Mon Sep 17 00:00:00 2001 From: Yandong Lin Date: Wed, 31 Jul 2024 16:56:36 +0800 Subject: [PATCH] fix[mpp_common]: fix compile err on F_DUPFD_CLOEXEC not defined Change-Id: I5e258a13be331af7a4d11d6ab2e4a8afb12418dd Signed-off-by: Yandong Lin --- osal/inc/mpp_common.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/osal/inc/mpp_common.h b/osal/inc/mpp_common.h index fec223db..48a7884d 100644 --- a/osal/inc/mpp_common.h +++ b/osal/inc/mpp_common.h @@ -216,7 +216,20 @@ static __inline RK_U32 mpp_is_32bit() static __inline RK_S32 mpp_dup(RK_S32 fd) { /* avoid stdin / stdout / stderr so start from 3 */ +#ifdef F_DUPFD_CLOEXEC return fcntl(fd, F_DUPFD_CLOEXEC, 3); +#else + RK_S32 new_fd = -1; + + new_fd = fcntl(fd, F_DUPFD, 3); + if (new_fd == -1) + return -1; + + if (fcntl(new_fd, F_SETFD, FD_CLOEXEC) == -1) + return -1; + + return new_fd; +#endif } RK_S32 axb_div_c(RK_S32 a, RK_S32 b, RK_S32 c);