Bug 948777 - Build netwerk/sctp/src in unified mode r=ng

Apply bundled patches and pull the trigger for UNIFIED_SOURCE
compatibility.

Depends on D170918

Differential Revision: https://phabricator.services.mozilla.com/D171743
This commit is contained in:
serge-sans-paille 2023-03-06 19:48:17 +00:00
parent d5dc8e74aa
commit 2ba86b92ec
4 changed files with 23 additions and 13 deletions

View File

@ -8,7 +8,7 @@ EXPORTS.mozilla.net += [
'usrsctp.h',
]
SOURCES += [
UNIFIED_SOURCES += [
'netinet/sctp_asconf.c',
'netinet/sctp_auth.c',
'netinet/sctp_bsd_addr.c',

View File

@ -32,6 +32,14 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(_WIN32)
// Needed for unified build so that rand_s is available to all unified
// sources.
#if !defined(_CRT_RAND_S) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
#define _CRT_RAND_S
#endif
#endif
#if defined(__FreeBSD__) && !defined(__Userspace__)
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

View File

@ -304,14 +304,7 @@ sctp_is_vmware_interface(struct ifnet *ifn)
#endif
#if defined(_WIN32) && defined(__Userspace__)
#ifdef MALLOC
#undef MALLOC
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#endif
#ifdef FREE
#undef FREE
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
#endif
#define SCTP_BSD_FREE(x) HeapFree(GetProcessHeap(), 0, (x))
static void
sctp_init_ifns_for_vrf(int vrfid)
{
@ -341,7 +334,7 @@ sctp_init_ifns_for_vrf(int vrfid)
/* Get actual adapter information */
if ((Err = GetAdaptersAddresses(AF_INET, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
SCTP_PRINTF("GetAdaptersV4Addresses() failed with error code %d\n", Err);
FREE(pAdapterAddrs);
SCTP_BSD_FREE(pAdapterAddrs);
return;
}
/* Enumerate through each returned adapter and save its information */
@ -366,7 +359,7 @@ sctp_init_ifns_for_vrf(int vrfid)
}
}
}
FREE(pAdapterAddrs);
SCTP_BSD_FREE(pAdapterAddrs);
#endif
#ifdef INET6
AdapterAddrsSize = 0;
@ -386,7 +379,7 @@ sctp_init_ifns_for_vrf(int vrfid)
/* Get actual adapter information */
if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
SCTP_PRINTF("GetAdaptersV6Addresses() failed with error code %d\n", Err);
FREE(pAdapterAddrs);
SCTP_BSD_FREE(pAdapterAddrs);
return;
}
/* Enumerate through each returned adapter and save its information */
@ -408,7 +401,7 @@ sctp_init_ifns_for_vrf(int vrfid)
}
}
}
FREE(pAdapterAddrs);
SCTP_BSD_FREE(pAdapterAddrs);
#endif
}
#elif defined(__Userspace__)

View File

@ -30,6 +30,15 @@
#ifndef _USER_ENVIRONMENT_H_
#define _USER_ENVIRONMENT_H_
#if defined(_WIN32)
// Needed for unified build so that rand_s is available to all unified
// sources.
#if !defined(_CRT_RAND_S) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
#define _CRT_RAND_S
#endif
#endif
/* __Userspace__ */
#include <sys/types.h>