Skip to content

Commit

Permalink
Don't use __Userspace_OS_* defines anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
tuexen committed Jun 13, 2020
1 parent 5be0c25 commit eb61157
Show file tree
Hide file tree
Showing 45 changed files with 345 additions and 357 deletions.
16 changes: 8 additions & 8 deletions Manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ \subsection{Discard Server}\label{server}
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
Expand Down Expand Up @@ -1098,7 +1098,7 @@ \subsection{Discard Server}\label{server}
}
while (1) {
if (use_cb) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1*1000);
#else
sleep(1);
Expand Down Expand Up @@ -1133,7 +1133,7 @@ \subsection{Discard Server}\label{server}
}
usrsctp_close(sock);
while (usrsctp_finish() != 0) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1000);
#else
sleep(1);
Expand Down Expand Up @@ -1183,11 +1183,11 @@ \subsection{Client}\label{client}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <unistd.h>
#endif
#include <sys/types.h>
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
Expand Down Expand Up @@ -1242,7 +1242,7 @@ \subsection{Client}\label{client}
}
memset((void *)&addr4, 0, sizeof(struct sockaddr_in));
memset((void *)&addr6, 0, sizeof(struct sockaddr_in6));
#if !defined(__Userspace_os_Linux) && !defined(__Userspace_os_Windows)
#if !defined(__linux__) && !defined(_WIN32)
addr4.sin_len = sizeof(struct sockaddr_in);
addr6.sin6_len = sizeof(struct sockaddr_in6);
#endif
Expand Down Expand Up @@ -1271,14 +1271,14 @@ \subsection{Client}\label{client}
usrsctp_shutdown(sock, SHUT_WR);
}
while (!done) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1*1000);
#else
sleep(1);
#endif
}
while (usrsctp_finish() != 0) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(1000);
#else
sleep(1);
Expand Down
6 changes: 0 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,25 @@ APPCFLAGS=""
case $host_os in
darwin*)
CFLAGS="$CFLAGS -std=c99 -Wno-deprecated-declarations -D__APPLE_USE_RFC_2292"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Darwin"
;;
dragonfly*)
CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_DragonFly"
;;
freebsd*)
CFLAGS="$CFLAGS -std=c99 -pthread"
if $CC --version | grep -q clang; then
CFLAGS="$CFLAGS -Wno-unknown-warning-option"
LDFLAGS="$LDFLAGS -Qunused-arguments"
fi
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_FreeBSD"
;;
linux*)
CFLAGS="$CFLAGS -std=c99 -pthread -D_GNU_SOURCE -Wno-address-of-packed-member"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_Linux"
;;
netbsd*)
CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_NetBSD"
;;
openbsd*)
CFLAGS="$CFLAGS -std=c99 -pthread"
LIBCFLAGS="$LIBCFLAGS -D__Userspace_os_OpenBSD"
;;
solaris*)
CFLAGS="$CFLAGS -D_XPG4_2"
Expand Down
21 changes: 6 additions & 15 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,28 @@ add_project_arguments([
system = host_machine.system()
if system in ['linux', 'android']
add_project_arguments([
'-D__Userspace_os_Linux',
'-D_GNU_SOURCE',
], language: 'c')
elif system == 'freebsd'
add_project_arguments([
'-D__Userspace_os_FreeBSD',
] + compiler.get_supported_arguments([
add_project_arguments(
compiler.get_supported_arguments([
'-Wno-address-of-packed-member',
]), language: 'c')
elif system in ['darwin', 'ios']
add_project_arguments([
'-D__Userspace_os_Darwin',
'-D__APPLE_USE_RFC_2292',
] + compiler.get_supported_arguments([
'-Wno-address-of-packed-member',
'-Wno-deprecated-declarations',
]), language: 'c')
elif system == 'dragonfly'
add_project_arguments([
'-D__Userspace_os_DragonFly',
], language: 'c')
add_project_arguments([], language: 'c')
elif system == 'netbsd'
add_project_arguments([
'-D__Userspace_os_NetBSD',
], language: 'c')
add_project_arguments([], language: 'c')
elif system == 'openbsd'
add_project_arguments([
'-D__Userspace_os_OpenBSD',
], language: 'c')
add_project_arguments([], language: 'c')
elif system == 'windows'
add_project_arguments('-D__Userspace_os_Windows', language: 'c')
add_project_arguments([]], language: 'c')
dependencies += compiler.find_library('ws2_32', required: true)
dependencies += compiler.find_library('iphlpapi', required: true)
if compiler.get_id() == 'gcc'
Expand Down
1 change: 0 additions & 1 deletion usrsctplib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ set(CMAKE_MACOSX_RPATH 1)
include(CheckCCompilerFlag)

add_definitions(-D__Userspace__)
add_definitions(-D__Userspace_os_${CMAKE_SYSTEM_NAME})
add_definitions(-DSCTP_SIMPLE_ALLOCATOR)
add_definitions(-DSCTP_PROCESS_LEVEL_LOCKS)

Expand Down
2 changes: 1 addition & 1 deletion usrsctplib/Makefile.nmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
CFLAGS=/I. /W3 /WX

CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS
CVARSDLL=$(CVARSDLL) -D__Userspace__ -D__Userspace_os_Windows
CVARSDLL=$(CVARSDLL) -D__Userspace__
CVARSDLL=$(CVARSDLL) -DINET -DINET6
CVARSDLL=$(CVARSDLL) -D_LIB

Expand Down
8 changes: 4 additions & 4 deletions usrsctplib/netinet/sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp.h 356357 2020-01-04 20:33:12Z tuexen $
#ifndef _NETINET_SCTP_H_
#define _NETINET_SCTP_H_

#if defined(__APPLE__) || defined(__Userspace_os_Linux)
#if defined(__APPLE__) || defined(__linux__)
#include <stdint.h>
#endif

#include <sys/types.h>


#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#define SCTP_PACKED __attribute__((packed))
#else
#pragma pack (push, 1)
Expand Down Expand Up @@ -290,7 +290,7 @@ struct sctp_paramhdr {
/* temporary workaround for Apple listen() issue, no args used */
#define SCTP_LISTEN_FIX 0x0000800c
#endif
#if defined(__Windows__)
#if defined(_WIN32) && !defined(__Userspace__)
/* workaround for Cygwin on Windows: returns the SOCKET handle */
#define SCTP_GET_HANDLE 0x0000800d
#endif
Expand Down Expand Up @@ -613,7 +613,7 @@ struct sctp_error_auth_invalid_hmac {
/* Largest PMTU allowed when disabling PMTU discovery */
#define SCTP_LARGEST_PMTU 65536

#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
#pragma pack(pop)
#endif
#undef SCTP_PACKED
Expand Down
6 changes: 3 additions & 3 deletions usrsctplib/netinet/sctp_bsd_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void
sctp_wakeup_iterator(void)
{
#if defined(SCTP_PROCESS_LEVEL_LOCKS)
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup);
#else
pthread_cond_broadcast(&sctp_it_ctl.iterator_wakeup);
Expand Down Expand Up @@ -143,7 +143,7 @@ sctp_iterator_thread(void *v SCTP_UNUSED)
#endif
0, "waiting_for_work", 0);
#else
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
SleepConditionVariableCS(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx, INFINITE);
#else
pthread_cond_wait(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx);
Expand Down Expand Up @@ -303,7 +303,7 @@ sctp_is_vmware_interface(struct ifnet *ifn)
}
#endif

#if defined(__Userspace_os_Windows)
#if defined(_WIN32) && defined(__Userspace__)
#ifdef MALLOC
#undef MALLOC
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
Expand Down
6 changes: 3 additions & 3 deletions usrsctplib/netinet/sctp_callout.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@

#if defined(__Userspace__)
#include <sys/types.h>
#if !defined (__Userspace_os_Windows)
#if !defined(_WIN32)
#include <sys/wait.h>
#include <unistd.h>
#include <pthread.h>
#endif
#if defined(__Userspace_os_NaCl)
#if defined(__native_client__)
#include <sys/select.h>
#endif
#include <stdlib.h>
Expand Down Expand Up @@ -197,7 +197,7 @@ user_sctp_timer_iterate(void *arg)
{
sctp_userspace_set_threadname("SCTP timer");
for (;;) {
#if defined (__Userspace_os_Windows)
#if defined(_WIN32)
Sleep(TIMEOUT_INTERVAL);
#else
struct timespec amount, remaining;
Expand Down
2 changes: 1 addition & 1 deletion usrsctplib/netinet/sctp_callout.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
#define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */

#if defined(__Userspace__)
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
#define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx))
#define SCTP_TIMERQ_UNLOCK() LeaveCriticalSection(&SCTP_BASE_VAR(timer_mtx))
#define SCTP_TIMERQ_LOCK_INIT() InitializeCriticalSection(&SCTP_BASE_VAR(timer_mtx))
Expand Down
8 changes: 4 additions & 4 deletions usrsctplib/netinet/sctp_cc_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,7 @@ sctp_htcp_cwnd_update_after_ecn_echo(struct sctp_tcb *stcb,

const struct sctp_cc_functions sctp_cc_functions[] = {
{
#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
#if defined(_WIN32) && !defined(__MINGW32__)
sctp_set_initial_cc_param,
sctp_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
Expand All @@ -2431,7 +2431,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
#if defined(_WIN32) && !defined(__MINGW32__)
sctp_set_initial_cc_param,
sctp_hs_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
Expand All @@ -2452,7 +2452,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
#if defined(_WIN32) && !defined(__MINGW32__)
sctp_htcp_set_initial_cc_param,
sctp_htcp_cwnd_update_after_sack,
sctp_cwnd_update_exit_pf_common,
Expand All @@ -2473,7 +2473,7 @@ const struct sctp_cc_functions sctp_cc_functions[] = {
#endif
},
{
#if defined(__Windows__) || (defined(__Userspace_os_Windows) && !defined(__MINGW32__))
#if defined(_WIN32) && !defined(__MINGW32__)
sctp_set_rtcc_initial_cc_param,
sctp_cwnd_update_rtcc_after_sack,
sctp_cwnd_update_exit_pf_common,
Expand Down
8 changes: 4 additions & 4 deletions usrsctplib/netinet/sctp_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_constants.h 362107 2020-06-12 16:40:10
#ifndef _NETINET_SCTP_CONSTANTS_H_
#define _NETINET_SCTP_CONSTANTS_H_

#if defined(__Userspace_os_Windows)
#if defined(_Win32) && defined(__Userspace__)
extern void getwintimeofday(struct timeval *tv);
#endif

Expand Down Expand Up @@ -995,7 +995,7 @@ extern void getwintimeofday(struct timeval *tv);
#define SCTP_SOCKET_OPTION_LIMIT (64 * 1024)

#if defined(__Userspace__)
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
#define SCTP_GETTIME_TIMEVAL(x) getwintimeofday(x)
#define SCTP_GETPTIME_TIMEVAL(x) getwintimeofday(x) /* this doesn't seem to ever be used.. */
#else
Expand All @@ -1019,7 +1019,7 @@ do { \
} \
} while (0)

#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
#define sctp_sowwakeup_locked(inp, so) \
do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
Expand Down Expand Up @@ -1050,7 +1050,7 @@ do { \
} \
} while (0)

#if defined(__FreeBSD__) || defined(__Windows__) || defined(__Userspace__)
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
#define sctp_sorwakeup_locked(inp, so) \
do { \
if (inp->sctp_flags & SCTP_PCB_FLAGS_DONT_WAKE) { \
Expand Down
10 changes: 5 additions & 5 deletions usrsctplib/netinet/sctp_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 309682 2016-12-07 19:30:59Z t
#ifndef _NETINET_SCTP_HEADER_H_
#define _NETINET_SCTP_HEADER_H_

#if defined(__Windows__) && !defined(__Userspace_os_Windows)
#if defined(_WIN32) && !defined(__Userspace__)
#include <packon.h>
#endif
#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#include <sys/time.h>
#endif
#include <netinet/sctp.h>
#include <netinet/sctp_constants.h>

#if !defined(__Userspace_os_Windows)
#if !defined(_WIN32)
#define SCTP_PACKED __attribute__((packed))
#else
#pragma pack (push, 1)
Expand Down Expand Up @@ -601,10 +601,10 @@ struct sctp_auth_chunk {
#define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
sizeof(struct sctphdr))

#if defined(__Windows__)
#if defined(_WIN32) && !defined(__Userspace__)
#include <packoff.h>
#endif
#if defined(__Userspace_os_Windows)
#if defined(_WIN32) && defined(__Userspace__)
#pragma pack(pop)
#endif
#undef SCTP_PACKED
Expand Down
8 changes: 4 additions & 4 deletions usrsctplib/netinet/sctp_indata.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo)
struct sctp_sndrcvinfo *outinfo;
struct sctp_rcvinfo *rcvinfo;
struct sctp_nxtinfo *nxtinfo;
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
WSACMSGHDR *cmh;
#else
struct cmsghdr *cmh;
Expand Down Expand Up @@ -232,7 +232,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo)
SCTP_BUF_LEN(ret) = 0;

/* We need a CMSG header followed by the struct */
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
cmh = mtod(ret, WSACMSGHDR *);
#else
cmh = mtod(ret, struct cmsghdr *);
Expand All @@ -255,7 +255,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo)
rcvinfo->rcv_cumtsn = sinfo->sinfo_cumtsn;
rcvinfo->rcv_context = sinfo->sinfo_context;
rcvinfo->rcv_assoc_id = sinfo->sinfo_assoc_id;
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
cmh = (WSACMSGHDR *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_rcvinfo)));
#else
cmh = (struct cmsghdr *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_rcvinfo)));
Expand All @@ -281,7 +281,7 @@ sctp_build_ctl_nchunk(struct sctp_inpcb *inp, struct sctp_sndrcvinfo *sinfo)
nxtinfo->nxt_ppid = seinfo->serinfo_next_ppid;
nxtinfo->nxt_length = seinfo->serinfo_next_length;
nxtinfo->nxt_assoc_id = seinfo->serinfo_next_aid;
#if defined(__Userspace_os_Windows)
#if defined(_WIN32)
cmh = (WSACMSGHDR *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_nxtinfo)));
#else
cmh = (struct cmsghdr *)((caddr_t)cmh + CMSG_SPACE(sizeof(struct sctp_nxtinfo)));
Expand Down
Loading

0 comments on commit eb61157

Please sign in to comment.