You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/21 13:09:45 UTC

[GitHub] [incubator-nuttx] Donny9 opened a new pull request, #6662: sys/sysmacros.h: support sysmacros header

Donny9 opened a new pull request, #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662

   
   
   ## Summary
   Add sys/sysmacros.h 
   
   Refer to:
   https://fossies.org/linux/glibc/misc/sys/sysmacros.h
   https://github.com/bminor/musl/blob/master/include/sys/sysmacros.h
   
   
   Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
   ## Impact
   N/A
   ## Testing
   Vela CI
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] fjpanag commented on pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
fjpanag commented on PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#issuecomment-1192356205

   This PR breaks NuttX...
   
   I am using sim, with `CONFIG_HOST_FS` enabled.  
   I am trying to get the size of a file in the host FS using `stat()`.
   
   When `dev_t` is `uint32_t` the stat struct contains garbage.  
   When I revert it back to `uint16_t` it works correctly. 


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] fjpanag commented on pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
fjpanag commented on PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#issuecomment-1192394508

   > @fjpanag could you try where #6686 can fix your issue?
   
   Yes, indeed it solves the issue.  
   Thank you!


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] Donny9 commented on pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
Donny9 commented on PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#issuecomment-1192361969

   > This PR breaks NuttX...
   > 
   > I am using sim, with `CONFIG_HOST_FS` enabled. I am trying to get the size of a file in the host FS using `stat()`.
   > 
   > When `dev_t` is `uint32_t` the stat struct contains garbage. When I revert it back to `uint16_t` it works correctly.
   
   Okay, i'l see it right away


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#discussion_r927019854


##########
include/sys/sysmacros.h:
##########
@@ -0,0 +1,32 @@
+/****************************************************************************
+ * include/sys/sysmacros.h
+ *
+ * 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_SYS_SYSMACROS_H
+#define __INCLUDE_SYS_SYSMACROS_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define major(x)          ((int)(0x00ff & ((x) >> 8)))
+#define minor(x)          ((int)(0xffff00ff & (x)))

Review Comment:
   Yes, could be. I think nobody consider/require NuttX kernel need be binary compatibility.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#issuecomment-1192364811

   @fjpanag could you try where https://github.com/apache/incubator-nuttx/pull/6686 can fix your issue?


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#discussion_r926935011


##########
include/sys/sysmacros.h:
##########
@@ -0,0 +1,32 @@
+/****************************************************************************
+ * include/sys/sysmacros.h
+ *
+ * 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_SYS_SYSMACROS_H
+#define __INCLUDE_SYS_SYSMACROS_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define major(x)          ((int)(0x00ff & ((x) >> 8)))
+#define minor(x)          ((int)(0xffff00ff & (x)))

Review Comment:
   Is this "strange" mask for minor related to version is a 2 uint16_t in big-endian? I mean, that usually from my experience the value of minor is incremental, so no jumps from 255 to 16K+1. What is the general approach for dev versioning?



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] Donny9 commented on a diff in pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
Donny9 commented on code in PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#discussion_r926696107


##########
include/sys/sysmacros.h:
##########
@@ -0,0 +1,40 @@
+/****************************************************************************
+ * include/sys/sysmacros.h
+ *
+ * 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_SYS_SYSMACROS_H
+#define __INCLUDE_SYS_SYSMACROS_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define major(x) \
+        ((unsigned)((((x) >> 31 >> 1) & 0xfffff000) | \
+                    (((x) >> 8) & 0x00000fff)))
+#define minor(x) \
+        ((unsigned)((((x) >> 12) & 0xffffff00) | ((x) & 0x000000ff)))
+
+#define makedev(x,y) ( \
+        (((x) & 0xfffff000ull) << 32) | \

Review Comment:
   ULL to big, refer to :https://github.com/freebsd/freebsd-src/blob/833a452e9f082a7982a31c21f0da437dbbe0a39d/contrib/libarchive/libarchive/archive_pack_dev.c#L90 to change to uint32.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#discussion_r927004812


##########
include/sys/sysmacros.h:
##########
@@ -0,0 +1,32 @@
+/****************************************************************************
+ * include/sys/sysmacros.h
+ *
+ * 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_SYS_SYSMACROS_H
+#define __INCLUDE_SYS_SYSMACROS_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define major(x)          ((int)(0x00ff & ((x) >> 8)))
+#define minor(x)          ((int)(0xffff00ff & (x)))

Review Comment:
   my guess is that the initial dev_t is 16bits(high 8bits for major and low 8bit for minor) and later extend to 32bits to support more devices in the same class, but the more minor bits have to put to high 16bits to keep the binary combability.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#discussion_r927006273


##########
include/sys/sysmacros.h:
##########
@@ -0,0 +1,32 @@
+/****************************************************************************
+ * include/sys/sysmacros.h
+ *
+ * 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_SYS_SYSMACROS_H
+#define __INCLUDE_SYS_SYSMACROS_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define major(x)          ((int)(0x00ff & ((x) >> 8)))
+#define minor(x)          ((int)(0xffff00ff & (x)))

Review Comment:
   Maybe concatenating 16 + 8 bits into continuous value can be a solution?



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#discussion_r926667380


##########
include/sys/sysmacros.h:
##########
@@ -0,0 +1,40 @@
+/****************************************************************************
+ * include/sys/sysmacros.h
+ *
+ * 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_SYS_SYSMACROS_H
+#define __INCLUDE_SYS_SYSMACROS_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define major(x) \
+        ((unsigned)((((x) >> 31 >> 1) & 0xfffff000) | \
+                    (((x) >> 8) & 0x00000fff)))
+#define minor(x) \
+        ((unsigned)((((x) >> 12) & 0xffffff00) | ((x) & 0x000000ff)))
+
+#define makedev(x,y) ( \
+        (((x) & 0xfffff000ull) << 32) | \

Review Comment:
   Definitely depends on `HAVE_LONG_LONG`



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6662: sys/sysmacros.h: support sysmacros header

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #6662:
URL: https://github.com/apache/incubator-nuttx/pull/6662#discussion_r927040193


##########
include/sys/sysmacros.h:
##########
@@ -0,0 +1,32 @@
+/****************************************************************************
+ * include/sys/sysmacros.h
+ *
+ * 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_SYS_SYSMACROS_H
+#define __INCLUDE_SYS_SYSMACROS_H
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define major(x)          ((int)(0x00ff & ((x) >> 8)))
+#define minor(x)          ((int)(0xffff00ff & (x)))

Review Comment:
   As this is a direct copy from FreeBSD then let's use it as is.



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org