Compare commits

..

8 Commits

Author SHA1 Message Date
openharmony_ci
16dae422eb !1051 Fix : 修复gettimeofday对RTC钩子依赖的问题
Merge pull request !1051 from yinjiaming/fix
2023-06-06 00:59:38 +00:00
yinjiaming
96c16b0cbf fix: 修复gettimeofday接口获取时间方式依赖RTC钩子
gettimeofday 接口获取时间的方式依赖于RTC钩子,造成了精度的差异,
现去掉其依赖

BREAKING CHANGE:
修复gettimeofday接口获取时间方式依赖RTC钩子对外变更描述:
修改API:
int gettimeofday(struct timeval *tv, void *ptz);

Close #I6WV3V

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I87f46661a2b6edf9fd179e8c6e2cfe72da0c0c61
2023-05-29 17:27:55 +08:00
openharmony_ci
748e0a4447 !1036 fix: 修改一些拼写错误
Merge pull request !1036 from 程子丘/master
2023-05-24 04:03:47 +00:00
openharmony_ci
a1989614f4 !1068 GN绝对路径修改
Merge pull request !1068 from zhushengle/GN
2023-05-23 12:33:40 +00:00
zhushengle
3241a67dc6 feat: GN绝对路径修改
Close #I77PSG
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I095e5d0aac99eda1a8c238701e560655477b04d2
2023-05-23 20:08:02 +08:00
openharmony_ci
14868aebdc !1064 feat:内核time模块RTC与settimeofday接口逻辑修复
Merge pull request !1064 from zhangdengyu/RTC0515
2023-05-18 06:28:49 +00:00
zhangdengyu
b4873b06e8 feat: 修复time中TIMEZONE优先使用RTC模块的问题
方案描述:
1、time中timezone全局变量修改为优先从RTC获取
2、settimeofday接口,linux和posix标准有差异,m核中对齐posix标准,具体如下:
int settimeofday(const struct timeval *tv, const struct timezone *tz)
2.1、linux中:
        tz参数已弃用,一般设置为NULL;
        tv参数,为NULL时返回0,不设置错误码,表示不修改当前时间;
2.2、posix中:
        tv或tz全部为NULL时,返回-1,设置错误码EFAULT;
        tv或tz有一个不为NULL时,不设置相应的参数,返回0;不设置错误码;
3、新增settimeofday接口设置timezone相关测试用例

BREAKING CHANGE:
修复time中TIMEZONE优先使用RTC模块的问题对外变更描述:
修改int settimeofday(const struct timeval *tv, const struct timezone *tz)接口
settimeofday接口对入参的判断逻辑修改:
1、tv或tz全部为NULL时,返回-1,设置错误码EFAULT;
2、tv或tz有一个不为NULL时,不设置相应的参数,返回0;不设置错误码;

Close: #I73G40

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: Id536fc27d8bf0697765ac1543776e8105e6f62f4
2023-05-18 11:50:38 +08:00
Cheng Ziqiu
8b11135135 fix: 修改注释中的一些拼写错误
Signed-off-by: Cheng Ziqiu <chengziqiu@hust.edu.cn>
Change-Id: Icc152031144f9756f4da018e24d338c0d28a8fa9
2023-03-15 22:01:50 +08:00
22 changed files with 129 additions and 70 deletions

View File

@@ -137,8 +137,8 @@ config("public") {
]
if (BOARD_SOC_FEATURE) {
configs += [ "//device/board/$device_company:public" ]
configs += [ "//device/soc/$LOSCFG_SOC_COMPANY:public" ]
configs += [ "$DEVICE_BOARD_DIR/$device_company:public" ]
configs += [ "$DEVICE_SOC_DIR/$LOSCFG_SOC_COMPANY:public" ]
} else {
if (HAVE_DEVICE_SDK) {
configs += [ "$device_path:public" ]
@@ -158,8 +158,8 @@ group("modules") {
]
if (BOARD_SOC_FEATURE) {
deps += [ "//device/board/$device_company" ]
deps += [ "//device/soc/$LOSCFG_SOC_COMPANY" ]
deps += [ "$DEVICE_BOARD_DIR/$device_company" ]
deps += [ "$DEVICE_SOC_DIR/$LOSCFG_SOC_COMPANY" ]
} else {
if (HAVE_DEVICE_SDK) {
deps += [ device_path ]

View File

@@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/FatFs/FatFs.gni")
import("$THIRDPARTY_FATFS_DIR/FatFs.gni")
module_switch = defined(LOSCFG_FS_FAT)
module_name = get_path_info(rebase_path("."), "name")

View File

@@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/littlefs/littlefs.gni")
import("$THIRDPARTY_LITTLEFS_DIR/littlefs.gni")
module_switch = defined(LOSCFG_FS_LITTLEFS)
module_name = get_path_info(rebase_path("."), "name")

View File

@@ -78,7 +78,7 @@ struct File {
off_t fOffset;
INT32 fOwner;
struct MountPoint *fMp;
void *fData; /* file system opreations handle, fatfs FIL, etc. */
void *fData; /* file system operations handle, fatfs FIL, etc. */
const char *fullPath;
};

View File

@@ -184,7 +184,7 @@ STATIC struct MountPoint *VfsMountPointInit(const char *source, const char *targ
return NULL;
}
/* Find fsMap coresponding to the fsType */
/* Find fsMap corresponding to the fsType */
mFs = VfsFsMapGet(fsType);
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
errno = ENODEV;

View File

@@ -27,14 +27,14 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("$LITEOSTHIRDPARTY/lwip/lwip.gni")
import("$LITEOSTOPDIR/components/net/lwip-2.1/lwip_porting.gni")
import("$THIRDPARTY_LWIP_DIR/lwip.gni")
module_switch = defined(LOSCFG_NET_LWIP_SACK)
module_name = "lwip"
kernel_module(module_name) {
sources = LWIP_PORTING_FILES + LWIPNOAPPSFILES - [ "$LWIPDIR/api/sockets.c" ]
include_dirs = [ "//commonlibrary/utils_lite/include" ]
include_dirs = [ "$COMMONLIBRARY_UTILS_LITE_DIR/include" ]
}
config("public") {

View File

@@ -33,5 +33,5 @@ module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = []
deps = [ "//third_party/musl/porting/liteos_m/user" ]
deps = [ "$THIRDPARTY_MUSL_DIR/porting/liteos_m/user" ]
}

View File

@@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/cmsis/cmsis.gni")
import("$THIRDPARTY_CMSIS_DIR/cmsis.gni")
module_switch = defined(LOSCFG_KAL_CMSIS)
module_name = get_path_info(rebase_path("."), "name")

View File

@@ -27,14 +27,14 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/musl/porting/liteos_m_iccarm/kernel/iccarm.gni")
import("$THIRDPARTY_MUSL_DIR/porting/liteos_m_iccarm/kernel/iccarm.gni")
module_switch = defined(LOSCFG_LIBC_ICCARM)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
configs += [ "$LITEOSTOPDIR:warn_config" ]
deps = [ "//third_party/musl/porting/liteos_m_iccarm/kernel" ]
deps = [ "$THIRDPARTY_MUSL_DIR/porting/liteos_m_iccarm/kernel" ]
}
config("public") {

View File

@@ -28,14 +28,14 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/musl/porting/liteos_m/kernel/musl.gni")
import("$THIRDPARTY_MUSL_DIR/porting/liteos_m/kernel/musl.gni")
module_switch = defined(LOSCFG_LIBC_MUSL)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
configs += [ "$LITEOSTOPDIR:warn_config" ]
deps = [ "//third_party/musl/porting/liteos_m/kernel" ]
deps = [ "$THIRDPARTY_MUSL_DIR/porting/liteos_m/kernel" ]
}
config("public") {

View File

@@ -43,7 +43,7 @@ kernel_module(module_name) {
if (defined(LOSCFG_FS_VFS)) {
sources +=
[ "//third_party/musl/porting/liteos_m/kernel/src/misc/realpath.c" ]
[ "$THIRDPARTY_MUSL_DIR/porting/liteos_m/kernel/src/misc/realpath.c" ]
}
}

View File

@@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/bounds_checking_function/libsec_src.gni")
import("$THIRDPARTY_BOUNDS_CHECKING_FUNCTION_DIR/libsec_src.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {

View File

@@ -613,11 +613,22 @@ struct tm *gmtime(const time_t *timer)
struct tm *localtime_r(const time_t *timep, struct tm *result)
{
INT32 ret;
if ((timep == NULL) || (result == NULL)) {
errno = EFAULT;
return NULL;
}
if (!ConvertSecs2Utc(*timep, -TIMEZONE, result)) {
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
ret = ConvertSecs2Utc(*timep, -tempTimezone, result);
} else {
ret = ConvertSecs2Utc(*timep, -TIMEZONE, result);
}
if (!ret) {
errno = EINVAL;
return NULL;
}
@@ -660,7 +671,14 @@ static time_t ConvertUtc2Secs(struct tm *tm)
seconds += (tm->tm_mday - 1) * SECS_PER_DAY;
seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec;
seconds += TIMEZONE;
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
seconds += tempTimezone;
} else {
seconds += TIMEZONE;
}
return seconds;
}
@@ -686,7 +704,14 @@ time_t mktime(struct tm *tmptr)
}
timeInSeconds = ConvertUtc2Secs(tmptr);
/* normalize tm_wday and tm_yday */
ConvertSecs2Utc(timeInSeconds, -TIMEZONE, tmptr);
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
ConvertSecs2Utc(timeInSeconds, -tempTimezone, tmptr);
} else {
ConvertSecs2Utc(timeInSeconds, -TIMEZONE, tmptr);
}
return timeInSeconds;
}
@@ -695,20 +720,11 @@ int gettimeofday(struct timeval *tv, void *ptz)
struct timezone *tz = (struct timezone *)ptz;
if (tv != NULL) {
INT32 rtcRet;
UINT64 usec = 0;
UINT64 currentTime;
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
if (rtcRet != 0) {
currentTime = GetCurrentTime();
tv->tv_sec = currentTime / OS_SYS_MS_PER_SECOND;
tv->tv_usec = (currentTime % OS_SYS_MS_PER_SECOND) * OS_SYS_MS_PER_SECOND;
} else {
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
}
if ((g_rtcTimeFunc.RtcGetTimeHook != NULL) && (g_rtcTimeFunc.RtcGetTimeHook(&usec) == 0)) {
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
} else {
struct timespec ts;
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
@@ -718,7 +734,7 @@ int gettimeofday(struct timeval *tv, void *ptz)
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
}
}
if (tz != NULL) {
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
@@ -740,12 +756,12 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
{
struct timespec ts;
if (tv == NULL) {
if ((tv == NULL) && (tz == NULL)) {
errno = EFAULT;
return -1;
}
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
if ((tv != NULL) && (tv->tv_usec >= OS_SYS_US_PER_SECOND)) {
errno = EINVAL;
return -1;
}
@@ -764,18 +780,20 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
}
}
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
UINT64 usec;
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
if (-1 == g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec)) {
return -1;
}
} else {
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
if (-1 == clock_settime(CLOCK_REALTIME, &ts)) {
return -1;
if (tv != NULL) {
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
UINT64 usec;
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
if (g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec) < 0) {
return -1;
}
} else {
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
if (clock_settime(CLOCK_REALTIME, &ts) < 0) {
return -1;
}
}
}

View File

@@ -51,8 +51,19 @@ exec_script("//build/lite/run_shell_cmd.py",
import("$root_out_dir/config.gni")
LITEOSTOPDIR = "//kernel/liteos_m"
LITEOSTHIRDPARTY = "//third_party"
HDFTOPDIR = "//drivers/hdf_core/adapter/khdf/liteos_m"
THIRDPARTY_BOUNDS_CHECKING_FUNCTION_DIR =
"//third_party/bounds_checking_function"
LITEOSTHIRDPARTY = "//third_party"
THIRDPARTY_FATFS_DIR = "//third_party/FatFs"
THIRDPARTY_MUSL_DIR = "//third_party/musl"
THIRDPARTY_LITTLEFS_DIR = "//third_party/littlefs"
THIRDPARTY_CMSIS_DIR = "//third_party/cmsis"
THIRDPARTY_LWIP_DIR = "//third_party/lwip"
DEVICE_BOARD_DIR = "//device/board"
DEVICE_SOC_DIR = "//device/soc"
COMMONLIBRARY_UTILS_LITE_DIR = "//commonlibrary/utils_lite"
TEST_XTS_TOOLS_DIR = "//test/xts/tools"
ARCH = ""
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
@@ -163,8 +174,8 @@ set_defaults("kernel_module") {
"$LITEOSTOPDIR:los_config",
]
visibility = [
"$LITEOSTOPDIR:*",
":*",
"$LITEOSTOPDIR:*",
"..:*",
"../..:*",
]

View File

@@ -27,6 +27,8 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
static_library("test_dynlink") {
sources = [
"It_los_dynlink.c",
@@ -52,14 +54,5 @@ static_library("test_dynlink") {
"It_los_dynlink_020.c",
]
include_dirs = [
"../../../../kernel/include",
"../../../../kernel/arch/include",
"../../../include",
"../../../../utils",
"../../../../components/dynlink",
".",
"../../../../components/cpup",
"//third_party/bounds_checking_function/include",
]
configs += [ "$LITEOSTOPDIR/testsuites:include" ]
}

View File

@@ -51,6 +51,7 @@ VOID ItLosDynlink007(VOID);
VOID ItLosDynlink008(VOID);
VOID ItLosDynlink009(VOID);
VOID ItLosDynlink010(VOID);
VOID ItLosDynlink011(VOID);
VOID ItLosDynlink012(VOID);
VOID ItLosDynlink013(VOID);
VOID ItLosDynlink014(VOID);

View File

@@ -33,8 +33,8 @@
/* Test invalid params */
STATIC UINT32 TestCase(VOID)
{
VOID *handle = NULL;
VOID *invalHandle = NULL;
CHAR *handle = NULL;
CHAR *invalHandle = NULL;
INT32 (*func)(INT32, INT32) = NULL;
CHAR *symbolName = "test_api";
CHAR *dsoName = DSO_FULL_PATH("Align4_dynamic_align4.so");

View File

@@ -34,7 +34,7 @@
STATIC UINT32 TestCase(VOID)
{
VOID *handle = NULL;
INT32 (*func)() = NULL;
INT32 (*func)(VOID) = NULL;
INT32 *pValue = NULL;
CHAR *symbolName1 = "dyn_bss_func";
CHAR *symbolName2 = "test_array";
@@ -44,7 +44,7 @@ STATIC UINT32 TestCase(VOID)
handle = (VOID *)LOS_SoLoad(dsoName, NULL);
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = (INT32 (*)())LOS_FindSym(handle, symbolName1);
func = (INT32 (*)(VOID))LOS_FindSym(handle, symbolName1);
ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ret = func();
ICUNIT_GOTO_EQUAL(ret, 2117, ret, EXIT);

View File

@@ -34,7 +34,7 @@
STATIC UINT32 TestCase(VOID)
{
VOID *handle = NULL;
INT32 (*func)() = NULL;
INT32 (*func)(VOID) = NULL;
INT32 *pValueAddr = NULL;
INT32 **ppValueAddr = NULL;
CHAR *symbolName1 = "get_value100";
@@ -49,12 +49,12 @@ STATIC UINT32 TestCase(VOID)
handle = (VOID *)LOS_SoLoad(dsoName, NULL);
ICUNIT_ASSERT_NOT_EQUAL(handle, NULL, handle);
func = (INT32 (*)())LOS_FindSym(handle, symbolName1);
func = (INT32 (*)(VOID))LOS_FindSym(handle, symbolName1);
ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ret = func();
ICUNIT_GOTO_EQUAL(ret, 100, ret, EXIT);
func = (INT32 (*)())LOS_FindSym(handle, symbolName2);
func = (INT32 (*)(VOID))LOS_FindSym(handle, symbolName2);
ICUNIT_GOTO_NOT_EQUAL(func, NULL, func, EXIT);
ret = func();
ICUNIT_GOTO_EQUAL(ret, 200, ret, EXIT);

View File

@@ -34,7 +34,6 @@
STATIC UINT32 TestCase(VOID)
{
VOID *handle = NULL;
VOID (*func)(INT32, INT32) = NULL;
CHAR *dsoName = DSO_FULL_PATH("Align4_dynamic_stdlib.so");
handle = (VOID *)LOS_SoLoad(dsoName, NULL);

View File

@@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//test/xts/tools/lite/build/suite_lite.gni")
import("$TEST_XTS_TOOLS_DIR/lite/build/suite_lite.gni")
static_library("posix_test") {
sources = [
@@ -65,7 +65,7 @@ static_library("posix_test") {
}
include_dirs = [
"//test/xts/tools/hctest/include",
"$TEST_XTS_TOOLS_DIR/hctest/include",
"src",
]

View File

@@ -293,6 +293,42 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime002, Function | MediumTe
return 0;
}
/* *
* @tc.number SUB_KERNEL_TIME_LOCALTIME_003
* @tc.name test settimeofday api
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime003, Function | MediumTest | Level1)
{
char cTime[32]; /* 32, no special meaning */
time_t tStart;
time_t tEnd;
struct timezone tz;
struct timeval timeSet = {
.tv_sec = 86399, /* 86399, no special meaning */
.tv_usec = 0
};
int ret = gettimeofday(NULL, &tz);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = settimeofday(&timeSet, &tz);
time(&tStart);
sleep(2); /* 2, sleep time */
time(&tEnd);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
struct tm *tmStart = localtime(&tStart);
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmStart);
ICUNIT_ASSERT_STRING_EQUAL(cTime, "07:59:59", 0);
LOG("\n time_t=%lld, first time:%s", tStart, cTime);
struct tm *tmEnd = localtime(&tEnd);
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmEnd);
ICUNIT_ASSERT_STRING_EQUAL(cTime, "08:00:01", 0);
LOG("\n time_t=%lld, first time:%s", tEnd, cTime);
return 0;
}
/* *
* @tc.number SUB_KERNEL_TIME_LOCALTIMER_001
* @tc.name localtime_r api base test
@@ -593,6 +629,7 @@ void PosixTimeFuncTest(void)
#if (LOSCFG_LIBC_MUSL == 1)
RUN_ONE_TESTCASE(testTimeLocaltime001);
RUN_ONE_TESTCASE(testTimeLocaltime002);
RUN_ONE_TESTCASE(testTimeLocaltime003);
RUN_ONE_TESTCASE(testTimeLocaltimer001);
RUN_ONE_TESTCASE(testTimeLocaltimer002);
#endif