arjav1528 commented on code in PR #18347:
URL: https://github.com/apache/nuttx/pull/18347#discussion_r2763832789


##########
include/nuttx/lib/stdbit.h:
##########
@@ -0,0 +1,189 @@
+/****************************************************************************
+ * include/nuttx/lib/stdbit.h
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_LIB_STDBIT_H
+#define __INCLUDE_NUTTX_LIB_STDBIT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/* If CONFIG_ARCH_STDBIT_H is defined, then the top-level Makefile will copy
+ * this header file to include/stdbit.h.  In that case the architecture may
+ * provide arch/<architecture>/include/stdbit.h which will be included below.
+ * If CONFIG_LIBC_STDBIT_GENERIC is defined (or arch does not provide the
+ * header), the generic C23 implementation is used.
+ */
+
+#if defined(CONFIG_ARCH_STDBIT_H) && defined(CONFIG_ARCH_HAVE_STDBIT_H)
+#  include <arch/stdbit.h>
+#else
+
+/****************************************************************************
+ * Preprocessor Definitions
+ ****************************************************************************/
+
+/* C23 endianness.  Prefer compiler definitions if present. */
+
+#ifndef __STDC_ENDIAN_NATIVE__
+#  if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+#    define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_LITTLE__
+#    define __STDC_ENDIAN_LITTLE__ 1
+#    define __STDC_ENDIAN_BIG__    2
+#  elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#    define __STDC_ENDIAN_NATIVE__ __STDC_ENDIAN_BIG__
+#    define __STDC_ENDIAN_LITTLE__ 1
+#    define __STDC_ENDIAN_BIG__    2
+#  else
+#    define __STDC_ENDIAN_LITTLE__ 1
+#    define __STDC_ENDIAN_BIG__    2
+#    define __STDC_ENDIAN_NATIVE__ 0
+#  endif
+#endif
+
+/****************************************************************************
+ * Generic C23 stdbit implementation (type-specific macros)
+ ****************************************************************************/
+
+#include <stdint.h>
+
+#define _STDBIT_WIDTH_UC   (sizeof(unsigned char) * 8)
+#define _STDBIT_WIDTH_US  (sizeof(unsigned short) * 8)
+#define _STDBIT_WIDTH_UI  (sizeof(unsigned int) * 8)
+#define _STDBIT_WIDTH_UL  (sizeof(unsigned long) * 8)
+#define _STDBIT_WIDTH_ULL (sizeof(unsigned long long) * 8)
+
+/* Leading zeros: result is width when x == 0 (C23). */
+
+#define stdc_leading_zeros_uc(x)  ((x) ? (unsigned 
int)(__builtin_clz((unsigned int)(x)) - (_STDBIT_WIDTH_UI - _STDBIT_WIDTH_UC)) 
: _STDBIT_WIDTH_UC)

Review Comment:
   sure, I have applied the changes, could you please review the changes



-- 
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