diff --git a/src/pal/pal_bsd.h b/src/pal/pal_bsd.h index a07b7c5..4689b43 100644 --- a/src/pal/pal_bsd.h +++ b/src/pal/pal_bsd.h @@ -10,8 +10,8 @@ namespace snmalloc * Generic *BSD PAL mixin. This provides features that are common to the BSD * family. */ - template - class PALBSD : public PALPOSIX + template + class PALBSD : public PALPOSIX { public: /** diff --git a/src/pal/pal_bsd_aligned.h b/src/pal/pal_bsd_aligned.h index c770a52..4c88287 100644 --- a/src/pal/pal_bsd_aligned.h +++ b/src/pal/pal_bsd_aligned.h @@ -10,8 +10,8 @@ namespace snmalloc * This adds aligned allocation using `MAP_ALIGNED` to the generic BSD * implementation. This flag is supported by NetBSD and FreeBSD. */ - template - class PALBSD_Aligned : public PALBSD + template + class PALBSD_Aligned : public PALBSD { public: /** diff --git a/src/pal/pal_freebsd.h b/src/pal/pal_freebsd.h index 916fc70..d24f4b7 100644 --- a/src/pal/pal_freebsd.h +++ b/src/pal/pal_freebsd.h @@ -13,6 +13,15 @@ # endif # endif +/** + * Direct system-call wrappers so that we can skip libthr interception, which + * won't work if malloc is broken. + * @{ + */ +extern "C" ssize_t __sys_writev(int fd, const struct iovec* iov, int iovcnt); +extern "C" int __sys_fsync(int fd); +/// @} + namespace snmalloc { /** @@ -21,7 +30,8 @@ namespace snmalloc * This adds FreeBSD-specific aligned allocation to the generic BSD * implementation. */ - class PALFreeBSD : public PALBSD_Aligned + class PALFreeBSD + : public PALBSD_Aligned { public: /** diff --git a/src/pal/pal_posix.h b/src/pal/pal_posix.h index 16c5ef7..add7712 100644 --- a/src/pal/pal_posix.h +++ b/src/pal/pal_posix.h @@ -34,11 +34,13 @@ namespace snmalloc * efficient implementation. Subclasses should provide more efficient * implementations using platform-specific functionality. * - * The template parameter for this is the subclass and is used for explicit - * up casts to allow this class to call non-virtual methods on the templated - * version. + * The first template parameter for this is the subclass and is used for + * explicit up casts to allow this class to call non-virtual methods on the + * templated version. The next two allow subclasses to provide `writev` and + * `fsync` implementations that bypass any libc machinery that might not be + * working when an early-malloc error appears. */ - template + template class PALPOSIX : public PalTimerDefaultImpl> { /**