libc icon indicating copy to clipboard operation
libc copied to clipboard

Fix ESP-IDF constants and structs

Open SergioGasquez opened this issue 5 months ago • 2 comments

This PR fixes some constants and structs which were wrong for ESP-IDF targets. I created an app that compares all the constants in src/unix/newlib and src/unix/newlib/espidf modules with the ones in ESP-IDF source code (accessed via esp_idf_svc::sys). Here is the app https://github.com/SergioGasquez/libc-checks, using [email protected] yields the following errors:

E (622) libc_checks: Mismatch detected for constant `SIGABRT`: `esp-idf` 6 | `libc` 1
E (632) libc_checks: Mismatch detected for constant `SIGFPE`: `esp-idf` 8 | `libc` 1
E (642) libc_checks: Mismatch detected for constant `SIGILL`: `esp-idf` 4 | `libc` 1
E (652) libc_checks: Mismatch detected for constant `SIGINT`: `esp-idf` 2 | `libc` 1
E (662) libc_checks: Mismatch detected for constant `SIGSEGV`: `esp-idf` 11 | `libc` 1
E (672) libc_checks: Mismatch detected for constant `SIGTERM`: `esp-idf` 15 | `libc` 1
E (672) libc_checks: Mismatch detected for constant `SIGQUIT`: `esp-idf` 3 | `libc` 1
E (682) libc_checks: Mismatch detected for constant `NSIG`: `esp-idf` 32 | `libc` 2
E (692) libc_checks: Mismatch detected for type `tcflag_t` size: `esp-idf` 2 | `libc` 4
E (702) libc_checks: Mismatch detected for type `tcflag_t` alignment: `esp-idf` 2 | `libc` 4
E (712) libc_checks: Mismatch detected for type `sigaction` size: `esp-idf` 12 | `libc` 72
E (722) libc_checks: Mismatch detected for type `termios` size: `esp-idf` 28 | `libc` 52
E (732) libc_checks: Mismatch detected for type `pthread_attr_t` alignment: `esp-idf` 4 | `libc` 1
E (742) libc_checks: Mismatch detected for constant `NCCS`: `esp-idf` 11 | `libc` 32
E (752) libc_checks: Mismatch detected for constant `O_CLOEXEC`: `esp-idf` 262144 | `libc` 524288
E (762) libc_checks: Mismatch detected for constant `PF_INET6`: `esp-idf` 10 | `libc` 23
E (762) libc_checks: Mismatch detected for constant `SOCK_CLOEXEC`: `esp-idf` 262144 | `libc` 524288
E (772) libc_checks: Mismatch detected for constant `TCP_NODELAY`: `esp-idf` 1 | `libc` 8193
E (782) libc_checks: Mismatch detected for constant `TCP_KEEPIDLE`: `esp-idf` 3 | `libc` 256
E (792) libc_checks: Mismatch detected for constant `TCP_KEEPINTVL`: `esp-idf` 4 | `libc` 512
E (802) libc_checks: Mismatch detected for constant `TCP_KEEPCNT`: `esp-idf` 5 | `libc` 1024
E (812) libc_checks: Mismatch detected for constant `IP_TOS`: `esp-idf` 1 | `libc` 3
E (822) libc_checks: Mismatch detected for constant `IP_TTL`: `esp-idf` 2 | `libc` 8
E (832) libc_checks: Mismatch detected for constant `IP_MULTICAST_IF`: `esp-idf` 6 | `libc` 9
E (842) libc_checks: Mismatch detected for constant `IP_MULTICAST_TTL`: `esp-idf` 5 | `libc` 10
E (842) libc_checks: Mismatch detected for constant `IP_MULTICAST_LOOP`: `esp-idf` 7 | `libc` 11
E (852) libc_checks: Mismatch detected for constant `IP_ADD_MEMBERSHIP`: `esp-idf` 3 | `libc` 11
E (862) libc_checks: Mismatch detected for constant `IP_DROP_MEMBERSHIP`: `esp-idf` 4 | `libc` 12
E (872) libc_checks: Mismatch detected for constant `IPV6_MULTICAST_IF`: `esp-idf` 768 | `libc` 9
E (882) libc_checks: Mismatch detected for constant `IPV6_MULTICAST_HOPS`: `esp-idf` 769 | `libc` 10
E (892) libc_checks: Mismatch detected for constant `IPV6_MULTICAST_LOOP`: `esp-idf` 770 | `libc` 11
E (902) libc_checks: Mismatch detected for constant `HOST_NOT_FOUND`: `esp-idf` 210 | `libc` 1
E (912) libc_checks: Mismatch detected for constant `NO_DATA`: `esp-idf` 211 | `libc` 2
E (922) libc_checks: Mismatch detected for constant `NO_RECOVERY`: `esp-idf` 212 | `libc` 3
E (932) libc_checks: Mismatch detected for constant `TRY_AGAIN`: `esp-idf` 213 | `libc` 4
E (942) libc_checks: Mismatch detected for constant `AI_NUMERICSERV`: `esp-idf` 8 | `libc` 0
E (952) libc_checks: Mismatch detected for constant `AI_ADDRCONFIG`: `esp-idf` 64 | `libc` 0
E (962) libc_checks: Mismatch detected for constant `NI_NUMERICSERV`: `esp-idf` 8 | `libc` 0
E (972) libc_checks: Mismatch detected for constant `NI_DGRAM`: `esp-idf` 16 | `libc` 0
E (972) libc_checks: Mismatch detected for constant `EAI_FAMILY`: `esp-idf` 204 | `libc` -303
E (982) libc_checks: Mismatch detected for constant `EAI_MEMORY`: `esp-idf` 203 | `libc` -304
E (992) libc_checks: Mismatch detected for constant `EAI_NONAME`: `esp-idf` 200 | `libc` -305
E (1002) libc_checks: Mismatch detected for constant `EAI_SOCKTYPE`: `esp-idf` 10 | `libc` -307

All those errors are fixed in this PR, if I point the app to use the branch of this PR, no errors appear.

cc and thanks to @ivmarkov!

closes https://github.com/rust-lang/libc/issues/3774

SergioGasquez avatar Sep 13 '24 12:09 SergioGasquez