Skip to content

Commit 0ceaf5f

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.
1 parent c992dac commit 0ceaf5f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/shims/hw_config.h

Lines changed: 5 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

0 commit comments

Comments
 (0)