libc headers: make <complex.h> work, add struct ipv6_mreq (#1100)

1. `libc/isystem/complex.h` (included when you do `#include <complex.h>`)
   defines `_COMPLEX_H`, and then proceeds to include `libc/complex.h`,
   which contains the actual complex-related declarations. However, they
   are *also* guarded by `_COMPLEX_H` and hence effectively ignored.
   Fix this by changing `_COMPLEX_H` to `COSMOPOLITAN_LIBC_COMPLEX_H_`,
   which is consistent with what the other headers (such as `math.h`) do.
2. Cosmopolitan could only support IPv4 multicast requests for sockets,
   since a declaration for `struct ipv6_mreq` was missing. Add support
   for IPv6, too, by adding the missing declaration.
This commit is contained in:
Ivan Komarov 2024-02-05 23:22:56 +01:00 committed by GitHub
parent c72904b2f6
commit d5225a693b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 3 deletions

View file

@ -1,5 +1,5 @@
#ifndef _COMPLEX_H
#define _COMPLEX_H
#ifndef COSMOPOLITAN_LIBC_COMPLEX_H_
#define COSMOPOLITAN_LIBC_COMPLEX_H_
COSMOPOLITAN_C_START_
#if __STDC_VERSION__ + 0 >= 201112 && !defined(__STDC_NO_COMPLEX__)
@ -116,4 +116,4 @@ complex long double cpowl(complex long double, complex long double) libcesque;
#endif /* C11 */
COSMOPOLITAN_C_END_
#endif /* _COMPLEX_H */
#endif /* COSMOPOLITAN_LIBC_COMPLEX_H_ */

View file

@ -5,6 +5,7 @@
#include "libc/sock/struct/in6_pktinfo.h"
#include "libc/sock/struct/in_pktinfo.h"
#include "libc/sock/struct/ip_mreq.h"
#include "libc/sock/struct/ipv6_mreq.h"
#include "libc/sock/struct/sockaddr.h"
#include "libc/sock/struct/sockaddr6.h"
#include "libc/sysv/consts/in.h"

View file

@ -6,6 +6,7 @@
#include "libc/sock/struct/in6_pktinfo.h"
#include "libc/sock/struct/in_pktinfo.h"
#include "libc/sock/struct/ip_mreq.h"
#include "libc/sock/struct/ipv6_mreq.h"
#include "libc/sock/struct/sockaddr.h"
#include "libc/sock/struct/sockaddr6.h"
#include "libc/sysv/consts/in.h"

View file

@ -0,0 +1,12 @@
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IPV6_MREQ_H_
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IPV6_MREQ_H_
#include "libc/sock/struct/sockaddr6.h"
COSMOPOLITAN_C_START_
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address of group */
unsigned ipv6mr_interface; /* local interface */
};
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_IPV6_MREQ_H_ */