casaroli opened a new pull request, #20747:
URL: https://github.com/apache/nuttx/pull/20747

   ## Summary
   
   NuttX public headers define names that are not in any standard: `OK`, 
`ERROR`, `set_errno`, `get_errno`, `zalloc`, `O_TEXT`, and `weak_alias`, 
`visibility_hidden`, `visibility_default` and `unused_data` from 
`nuttx/compiler.h`. A ported program that defines one of these names itself 
does not compile.
   
   This PR adds `NUTTX_NO_EXTENSIONS`, in the same form as the existing 
`NUTTX_NO_GETOPT_MACROS`. When a program defines it before its first include, 
the public headers do not define these names.
   
   - The first two commits stop the public headers from using `OK` and `ERROR` 
themselves: `PTHREAD_CANCELED`, `thrd_success` and `thrd_error`, and the inline 
functions of `nuttx/mutex.h` and `nuttx/signal.h`, now use the plain values. 
The values do not change.
   - The third commit adds the macro.
   - The last commit adds a section to `Documentation/os/libs/libc/index.rst` 
that describes `NUTTX_NO_GETOPT_MACROS` (not documented before) and 
`NUTTX_NO_EXTENSIONS`.
   
   `CODE`, `builtin_function` and `object_size` stay visible, because public 
prototypes and inline functions use them.
   
   ## Impact
   
   Nothing changes when the macro is not defined.
   
   ## Testing
   
   A test program defines `NUTTX_NO_EXTENSIONS` and then its own `OK`/`ERROR` 
enum, a static `zalloc()`, `set_errno()`/`get_errno()` functions and the other 
names. On master it gives 15 compile errors; with this PR it compiles with 
`-Werror` and passes on `qemu-armv8a:knsh`. Without the macro, a program that 
uses the NuttX names compiles with `-Werror` on master and with this PR.
   
   Each public header compiles alone, with and without the macro, on 
`lm3s6965-ek:qemu-flat` and `qemu-armv8a:knsh`, with the same results as 
master. All `include/cxx` headers compile with g++ with and without the macro.
   
   `ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: 
Exiting with status 0`. `tools/checkpatch.sh -c -u -m -g` passes.
   


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