mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			106 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			106 lines
		
	
	
	
		
			2.4 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 | |
| From: Brian Gianforcaro <b.gianfo@gmail.com>
 | |
| Date: Tue, 21 Dec 2021 23:47:36 -0800
 | |
| Subject: [PATCH] Add SerenityOS platform support
 | |
| 
 | |
| `fio` abstracts individual operating system support out into to an
 | |
| `os/os-<name>.h` header where you can select which platform features
 | |
| are available and implement missing function stubs for our operating
 | |
| system.
 | |
| 
 | |
| This patch implements basic OS support for Serenity just to get fio up
 | |
| and running.
 | |
| ---
 | |
|  os/os-serenity.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++
 | |
|  os/os.h          |  3 +++
 | |
|  2 files changed, 64 insertions(+)
 | |
|  create mode 100644 os/os-serenity.h
 | |
| 
 | |
| diff --git a/os/os-serenity.h b/os/os-serenity.h
 | |
| new file mode 100644
 | |
| index 0000000..387727a
 | |
| --- /dev/null
 | |
| +++ b/os/os-serenity.h
 | |
| @@ -0,0 +1,61 @@
 | |
| +#ifndef FIO_OS_SERENITY_H
 | |
| +#define FIO_OS_SERENITY_H
 | |
| +
 | |
| +#define	FIO_OS	os_serenity
 | |
| +
 | |
| +#include <sys/param.h>
 | |
| +#include <sys/statvfs.h>
 | |
| +#include <sys/utsname.h>
 | |
| +#include <sys/mman.h>
 | |
| +#include <sys/select.h>
 | |
| +#include <netinet/in.h>
 | |
| +
 | |
| +#include "../file.h"
 | |
| +
 | |
| +#define FIO_NO_HAVE_SHM_H
 | |
| +#define FIO_USE_GENERIC_INIT_RANDOM_STATE
 | |
| +#define FIO_HAVE_FS_STAT
 | |
| +#define FIO_HAVE_GETTID
 | |
| +
 | |
| +#define OS_MAP_ANON		MAP_ANON
 | |
| +
 | |
| +static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
 | |
| +{
 | |
| +	// TODO: Implement
 | |
| +	return ENOTSUP;
 | |
| +}
 | |
| +
 | |
| +static inline int blockdev_invalidate_cache(struct fio_file *f)
 | |
| +{
 | |
| +	// TODO: Implement
 | |
| +	return ENOTSUP;
 | |
| +}
 | |
| +
 | |
| +static inline unsigned long long os_phys_mem(void)
 | |
| +{
 | |
| +	// TODO: Implement
 | |
| +	return 0; 
 | |
| +}
 | |
| +
 | |
| +static inline unsigned long long get_fs_free_size(const char *path)
 | |
| +{
 | |
| +	unsigned long long ret;
 | |
| +	struct statvfs s;
 | |
| +
 | |
| +	if (statvfs(path, &s) < 0)
 | |
| +		return -1ULL;
 | |
| +
 | |
| +	ret = s.f_frsize;
 | |
| +	ret *= (unsigned long long) s.f_bfree;
 | |
| +	return ret;
 | |
| +}
 | |
| +
 | |
| +static inline in_addr_t inet_network(const char *cp)
 | |
| +{
 | |
| +	in_addr_t hbo;
 | |
| +	in_addr_t nbo = inet_addr(cp);
 | |
| +	hbo = ((nbo & 0xFF) << 24) + ((nbo & 0xFF00) << 8) + ((nbo & 0xFF0000) >> 8) + ((nbo & 0xFF000000) >> 24);
 | |
| +	return hbo;
 | |
| +}
 | |
| +
 | |
| +#endif
 | |
| diff --git a/os/os.h b/os/os.h
 | |
| index 5965d7b..46604f7 100644
 | |
| --- a/os/os.h
 | |
| +++ b/os/os.h
 | |
| @@ -24,6 +24,7 @@ enum {
 | |
|  	os_windows,
 | |
|  	os_android,
 | |
|  	os_dragonfly,
 | |
| +	os_serenity,
 | |
|  
 | |
|  	os_nr,
 | |
|  };
 | |
| @@ -55,6 +56,8 @@ typedef enum {
 | |
|  #include "os-windows.h"
 | |
|  #elif defined (__DragonFly__)
 | |
|  #include "os-dragonfly.h"
 | |
| +#elif defined (__serenity__)
 | |
| +#include "os-serenity.h"
 | |
|  #else
 | |
|  #error "unsupported os"
 | |
|  #endif
 | 
