libk  Artifact [676bf37092]

Artifact 676bf370924920efc78d003b3f03847854613475852fb144c2236619a7e80a4e:


/* arch/posix.h - posix constants
 *  ? this file defines posix magic numbers
 *    needed in syscalls, both cross-platform
 *    ones and os-dependent ones. note that
 *    the values may change depending on the
 *    OS specified! */

#ifndef KIplatform_posix
#define KIplatform_posix
#include <k/def.h>
#include <k/type.h>

#if (!defined(KFplatform_define_constants)) && \
    (!defined(KFplatform_define_types)) && \
    (!defined(KFplatform_define_funcs))
#define KFplatform_define_constants
#define KFplatform_define_types
#define KFplatform_define_funcs
#endif

#ifdef KFplatform_define_constants

enum posix_prot {
	posix_prot_none  = 0,
	posix_prot_read  = 1 << 0,
	posix_prot_write = 1 << 1,
	posix_prot_exec  = 1 << 2
};

enum posix_map {
	posix_map_shared  = 1,
	posix_map_private = 2
};

enum posix_flag {
	posix_flag_fixed     = 0x10,
#if KVos == KA_os_lin
	posix_flag_anonymous = 0x20,
#elif KVos == KA_os_fbsd
	posix_flag_anonymous = 0x1000,
#endif

	/* platform flags */
	posix_flag_linux_hugetlb = 0x40000
};

#endif
#ifdef KFplatform_define_types

/* platform types */

typedef s64 k_platform_syscall_return;
typedef u64 k_platform_syscall_error;

#if KVos == KA_os_lin
	typedef long k_platform_syscall_arg;
#elif KVos == KA_os_fbsd
	typedef u64  k_platform_syscall_arg;
#else
	/* we're going to just pick a sane
	 * fallback that's reasonably likely
	 * to work with most systems one way
	 * or another */
	typedef unsigned long long k_platform_syscall_arg;
#endif

struct k_platform_syscall_answer {
	k_platform_syscall_return ret;
	k_platform_syscall_error error;
};

#endif

#if defined(KFplatform_define_constants) ||\
    defined(KFplatform_define_funcs)
#		include <system_calls.h>
#endif

#ifdef KFplatform_define_funcs

extern struct k_platform_syscall_answer
k_platform_syscall(enum k_platform_syscall call, u8 valency, 
		k_platform_syscall_arg args[]);

#endif

#endif