Skip to content

Commit

Permalink
Support building with emscripten. (sctplab#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylor-b authored Nov 18, 2020
1 parent 3906e03 commit c5c0584
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions usrsctplib/netinet/sctp_os_userspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ typedef char* caddr_t;

#else /* !defined(Userspace_os_Windows) */
#include <sys/socket.h>
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__native_client__) || defined(__Fuchsia__)
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__native_client__) || defined(__Fuchsia__) || defined(__EMSCRIPTEN_PTHREADS__)
#include <pthread.h>
#endif
typedef pthread_mutex_t userland_mutex_t;
Expand Down Expand Up @@ -509,7 +509,7 @@ struct sx {int dummy;};
#if !defined(_WIN32)
#include <netinet/ip6.h>
#endif
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(_WIN32)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(_WIN32) || defined(__EMSCRIPTEN__)
#include "user_ip6_var.h"
#else
#include <netinet6/ip6_var.h>
Expand Down Expand Up @@ -1132,7 +1132,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a

#define SCTP_IS_LISTENING(inp) ((inp->sctp_flags & SCTP_PCB_FLAGS_ACCEPTING) != 0)

#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__)
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
int
timingsafe_bcmp(const void *, const void *, size_t);
#endif
Expand Down
2 changes: 1 addition & 1 deletion usrsctplib/netinet/sctp_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
}
#endif

#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__)
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
int
timingsafe_bcmp(const void *b1, const void *b2, size_t n)
{
Expand Down
2 changes: 1 addition & 1 deletion usrsctplib/netinet/sctp_usrreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -7863,7 +7863,7 @@ sctp_connect(struct socket *so, struct mbuf *nam, struct proc *p)
#if defined(__Userspace__)
/* TODO __Userspace__ falls into this code for IPv6 stuff at the moment... */
#endif
#if !defined(_WIN32) && !defined(__linux__)
#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__)
switch (addr->sa_family) {
#ifdef INET6
case AF_INET6:
Expand Down
6 changes: 2 additions & 4 deletions usrsctplib/user_environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ finish_random(void)
{
return;
}
#elif defined(__ANDROID__)
#if (__ANDROID_API__ < 28)
#elif (defined(__ANDROID__) && (__ANDROID_API__ < 28)) || defined(__EMSCRIPTEN__)
#include <fcntl.h>

static int fd = -1;
Expand Down Expand Up @@ -174,7 +173,7 @@ finish_random(void)
close(fd);
return;
}
#else
#elif defined(__ANDROID__) && (__ANDROID_API__ >= 28)
#include <sys/random.h>

void
Expand Down Expand Up @@ -204,7 +203,6 @@ finish_random(void)
{
return;
}
#endif
#elif defined(__linux__)
#include <unistd.h>
#include <sys/syscall.h>
Expand Down
4 changes: 1 addition & 3 deletions usrsctplib/user_ip6_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ struct ip6_hdr {
#if defined(_WIN32)
#define s6_addr16 u.Word
#endif
#if !defined(_WIN32)
#if !defined(__linux__)
#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__)
#define s6_addr8 __u6_addr.__u6_addr8
#define s6_addr16 __u6_addr.__u6_addr16
#define s6_addr32 __u6_addr.__u6_addr32
#endif
#endif

#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
struct route_in6 {
Expand Down

0 comments on commit c5c0584

Please sign in to comment.