Skip to content

Commit 35e8017

Browse files
committed
Make some preliminary porting changes.
These changes include: * hw_config.h: prevent referring to sysctlbyname on OpenBSD, as this is not available on all platforms. * transform.c: these stanzas referring to FreeBSD or Linux also apply to OpenBSD. * tests/dispatch_apply.c: stanza applying to Linux applies to OpenBSD and also tweak style for consistency. * tests/dispatch_io_net.c, tests/dispatch_test.h: stanzas applying to FreeBSD also apply to OpenBSD.
1 parent c992dac commit 35e8017

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

src/shims/hw_config.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,16 @@ _dispatch_hw_get_config(_dispatch_hw_config_t c)
187187
name = "hw.activecpu"; break;
188188
}
189189
#elif defined(__FreeBSD__)
190-
(void)c; name = "kern.smp.cpus";
190+
(void)c; name = "kern.smp.cpus";
191+
#elif defined(__OpenBSD__)
192+
(void)c;
191193
#endif
192194
if (name) {
193195
size_t valsz = sizeof(val);
196+
#if !defined(__OpenBSD__)
194197
r = sysctlbyname(name, &val, &valsz, NULL, 0);
195198
(void)dispatch_assume_zero(r);
199+
#endif
196200
dispatch_assert(valsz == sizeof(uint32_t));
197201
} else {
198202
#if HAVE_SYSCONF && defined(_SC_NPROCESSORS_ONLN)

src/transform.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <endian.h>
2727
#define OSLittleEndian __LITTLE_ENDIAN
2828
#define OSBigEndian __BIG_ENDIAN
29-
#elif defined(__FreeBSD__)
29+
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
3030
#include <sys/endian.h>
3131
#define OSLittleEndian _LITTLE_ENDIAN
3232
#define OSBigEndian _BIG_ENDIAN
@@ -35,7 +35,7 @@
3535
#define OSBigEndian 4321
3636
#endif
3737

38-
#if defined(__linux__) || defined(__FreeBSD__)
38+
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
3939
#define OSSwapLittleToHostInt16 le16toh
4040
#define OSSwapBigToHostInt16 be16toh
4141
#define OSSwapHostToLittleInt16 htole16

tests/dispatch_apply.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void busythread(void *ignored)
8080
static void test_apply_contended(dispatch_queue_t dq)
8181
{
8282
uint32_t activecpu;
83-
#ifdef __linux__
83+
#if defined(__linux__) || defined(__OpenBSD__)
8484
activecpu = (uint32_t)sysconf(_SC_NPROCESSORS_ONLN);
8585
#elif defined(_WIN32)
8686
SYSTEM_INFO si;

tests/dispatch_io_net.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ extern char **environ;
5555
#endif
5656
#endif
5757

58-
#if defined(__linux__) || defined(__FreeBSD__) || defined(_WIN32)
58+
#if defined(__linux__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__OpenBSD__)
5959
#define _NSGetExecutablePath(ef,bs) (*(bs)=(size_t)snprintf(ef,*(bs),"%s",argv[0]),0)
6060
#endif
6161

tests/dispatch_test.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <stdbool.h>
2222
#include <dispatch/dispatch.h>
2323

24-
#if defined(__linux__) || defined(__FreeBSD__)
24+
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
2525
#include <generic_unix_port.h>
2626
#elif defined(_WIN32)
2727
#include <generic_win_port.h>

0 commit comments

Comments
 (0)