SunOS: support swap & opengl detection

This commit is contained in:
Carter Li
2024-06-17 16:43:52 +08:00
parent 72d332772d
commit 1d6a48e49a
4 changed files with 44 additions and 7 deletions
+5 -1
View File
@@ -259,7 +259,11 @@ static const char* glxPrint(FFOpenGLResult* result)
#endif //FF_HAVE_GLX
#ifdef FF_HAVE_OSMESA
#include <GL/osmesa.h>
#if __has_include(<GL/osmesa.h>)
#include <GL/osmesa.h>
#else
#include <mesa/osmesa.h> // for sunos
#endif
typedef struct OSMesaData
{
+33
View File
@@ -0,0 +1,33 @@
#include "swap.h"
#include <sys/stat.h>
#include <sys/swap.h>
#include <limits.h>
enum { FFMaxNSwap = 8 };
const char* ffDetectSwap(FFSwapResult* swap)
{
char strings[FFMaxNSwap][PATH_MAX];
uint8_t buffer[sizeof(swaptbl_t) + sizeof(swapent_t) * (FFMaxNSwap - 1)] = {};
swaptbl_t* table = (swaptbl_t*) buffer;
table->swt_n = FFMaxNSwap;
for (int i = 0; i < FFMaxNSwap; ++i)
table->swt_ent[i].ste_path = strings[i];
int size = swapctl(SC_LIST, table);
if (size < 0)
return "swapctl() failed";
swap->bytesTotal = swap->bytesUsed = 0;
for (int i = 0; i < size; ++i)
{
swap->bytesTotal += (uint64_t) table->swt_ent[i].ste_pages;
swap->bytesUsed += (uint64_t) table->swt_ent[i].ste_free;
}
swap->bytesUsed = swap->bytesTotal - swap->bytesUsed;
swap->bytesTotal *= instance.state.platform.pageSize;
swap->bytesUsed *= instance.state.platform.pageSize;
return NULL;
}
+2 -2
View File
@@ -4,7 +4,7 @@
#include "common/option.h"
#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
typedef enum FFOpenGLLibrary
{
FF_OPENGL_LIBRARY_AUTO,
@@ -19,7 +19,7 @@ typedef struct FFOpenGLOptions
FFModuleBaseInfo moduleInfo;
FFModuleArgs moduleArgs;
#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__sun)
FFOpenGLLibrary library;
#endif
} FFOpenGLOptions;