xiaoxiang781216 commented on code in PR #21491:
URL: https://github.com/apache/nuttx/pull/21491#discussion_r4594341279


##########
include/nuttx/lib/math32.h:
##########
@@ -447,6 +447,29 @@ invdiv_udiv128_soft(uint64_t hi, uint64_t lo, uint64_t d, 
int s)
 #if defined(CONFIG_ARCH_ARM)
 uint64_t arm_umulh64(uint64_t a, uint64_t b);
 #  define up_umulh64(a, b) arm_umulh64(a, b)
+#elif defined(CONFIG_ARCH_RISCV)
+#  if UINTPTR_MAX == UINT64_MAX
+
+/* rv64 has UMULH as the single mulhu instruction. */
+
+static inline_function uint64_t riscv_umulh64(uint64_t a, uint64_t b)

Review Comment:
   why not keep up_umulh64 name



##########
arch/risc-v/src/common/riscv_umulh64.c:
##########
@@ -0,0 +1,58 @@
+/****************************************************************************
+ * arch/risc-v/src/common/riscv_umulh64.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+#include <stdint.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/* UMULH: high 64 bits of the 128-bit product a * b, the rv32 form of
+ * the up_umulh64() arch hook; rv64 reduces the hook to one mulhu and
+ * is inlined in include/nuttx/lib/math32.h.
+ */
+
+#if UINTPTR_MAX == UINT32_MAX
+
+uint64_t riscv_umulh64(uint64_t a, uint64_t b)

Review Comment:
   move to libc/machine, need be callable in kernel/protected build



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to