From 5b10cde59f5b364c57ec1e9b387b98b9865c6671 Mon Sep 17 00:00:00 2001 From: Verdgil Date: Tue, 10 Feb 2026 12:32:20 +0300 Subject: [PATCH] Global: Add support for Oracle Solaris (#2176) * Fix Oracle Solaris zpool build * Add memrchr fallback * Change to include fron extern * add new line * remove ; in zpool.c * Change wrapper to macro Also change README.md * Tweaks --------- Co-authored-by: Carter Li --- CMakeLists.txt | 1 + README.md | 2 +- src/common/solaris/memrchr.c | 15 +++++++++++++++ src/common/solaris/memrchr.h | 6 ++++++ src/detection/gpu/gpu_pci.c | 4 ++++ src/detection/zpool/zpool.c | 5 +++++ 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 src/common/solaris/memrchr.c create mode 100644 src/common/solaris/memrchr.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 28778aacb..58fc2a11d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1115,6 +1115,7 @@ elseif(SunOS) src/detection/displayserver/linux/xcb.c src/detection/displayserver/linux/xlib.c src/detection/font/font_linux.c + src/common/solaris/memrchr.c src/detection/gpu/gpu_sunos.c src/detection/gpu/gpu_pci.c src/detection/gtk_qt/gtk.c diff --git a/README.md b/README.md index 4630b13ee..7fc0a1705 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/fastfetch-cli/fastfetch) [![中文README](https://img.shields.io/badge/%E4%B8%AD%E6%96%87-README-red)](README-cn.md) -Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying it in a visually appealing way. It is written mainly in C, with a focus on performance and customizability. Currently, it supports Linux, macOS, Windows 7+, Android, FreeBSD, OpenBSD, NetBSD, DragonFly, Haiku, and illumos (SunOS). +Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for fetching system information and displaying it in a visually appealing way. It is written mainly in C, with a focus on performance and customizability. Currently, it supports Linux, macOS, Windows 7+, Android, FreeBSD, OpenBSD, NetBSD, DragonFly, Haiku, illumos (SunOS), and Solaris. diff --git a/src/common/solaris/memrchr.c b/src/common/solaris/memrchr.c new file mode 100644 index 000000000..0e0c03d99 --- /dev/null +++ b/src/common/solaris/memrchr.c @@ -0,0 +1,15 @@ +#if defined(__sun) && ! defined(__illumos__) +#include "memrchr.h" + +void *memrchr(const void *s, int c, size_t n) +{ + if(n == 0) return NULL; + const unsigned char *p = (const unsigned char *)s + n; + while (n--) { + if (*(--p) == (unsigned char) c) + return (void*) p; + } + + return NULL; +} +#endif diff --git a/src/common/solaris/memrchr.h b/src/common/solaris/memrchr.h new file mode 100644 index 000000000..6e6453d82 --- /dev/null +++ b/src/common/solaris/memrchr.h @@ -0,0 +1,6 @@ +#pragma once +#include + +#if defined(__sun) && !defined(__illumos__) +void *memrchr(const void *s, int c, size_t n); +#endif diff --git a/src/detection/gpu/gpu_pci.c b/src/detection/gpu/gpu_pci.c index 02923a286..8d66bd977 100644 --- a/src/detection/gpu/gpu_pci.c +++ b/src/detection/gpu/gpu_pci.c @@ -24,6 +24,10 @@ #define FF_STR_INDIR(x) #x #define FF_STR(x) FF_STR_INDIR(x) +#if defined(__sun) && ! defined(__illumos__) +#include "common/solaris/memrchr.h" +#endif + static const FFstrbuf* loadPciIds() { static FFstrbuf pciids; diff --git a/src/detection/zpool/zpool.c b/src/detection/zpool/zpool.c index ca2c31a28..2f4a4a83f 100644 --- a/src/detection/zpool/zpool.c +++ b/src/detection/zpool/zpool.c @@ -6,6 +6,11 @@ #ifdef __sun #include + #ifndef __illumos__ + // On Solaris 11, zpool_get_prop has only 5 arguments. #2173 + #define ffzpool_get_prop(zhp, prop, buf, len, srctype, literal) \ + ffzpool_get_prop(zhp, prop, buf, len, srctype) + #endif #else #include "libzfs_simplified.h" #endif