#ifndef	ARCH_GENERIC_H
#define	ARCH_GENERIC_H

#ifndef	ARCH_H
#error	Master header is $(libv_root)/arch/arch.h; #include _it_ first !
#endif	/* ARCH_H */

/*
 * Enable/disable some features
 */
#include "./platform.h"

/*
 * UNIX - specific defines and structures
 */
#define	ARCH_INVALID_FILE		-1
typedef int						arch_file_t;
typedef	unsigned				arch_file_off_t;

struct arch_dir_s
{
	/*
	 * POSIX - specific part
	 */
	DIR				*dir;
	struct dirent	*ent;
	char			dir_start[_MAX_PATH];
	u32_t			dir_start_len;
	/*
	 * Common part
	 */
	char			name[_MAX_PATH];	/* entry name */

	/* FIXME: need only one of this ! */

	vboolean		is_dir;	/* == true if 'name' is a directory name */
	file_type_t		ftype;	/* meaningful only if 'name' is a file name */
};

#ifdef	ARCH_MAPPED_IO_SUPPORTED

struct arch_filemap_s
{
	void_p	base_addr;
	void_p	real_addr;
	arch_file_off_t	len;
};

#endif	/* ARCH_MAPPED_IO_SUPPORTED */

#ifdef	ARCH_IPC_SUPPORTED

#define	IPC_MSG_LEN			512

typedef struct arch_pipe_s
{
	vboolean inbound;
	char	pipe_name[_MAX_PATH];
	char	full_name[_MAX_PATH];
	int		fd;
}	arch_pipe_t, *arch_pipe_p;

#endif	/* ARCH_IPC_SUPPORTED */

#ifdef	ARCH_THREADING_SUPPORTED

#include "./amutex.h"

#endif	/* ARCH_THREADING_SUPPORTED */

/*
 * Debug output
 */

#ifdef	ARCH_VERBOSE

#define	SYSCALL_FAILED(syscall_name) \
		conlPrintf(LOG_ERROR,"%s(): %s() failed (%s).\n", \
			arch_caller_name,syscall_name,strerror(errno));

#define	SYSCALL_FAILED_1STR(syscall_name,str_arg1) \
		conlPrintf(LOG_ERROR,"%s(): %s(%s) failed (%s).\n", \
			arch_caller_name,syscall_name,str_arg1,strerror(errno));

#else	/* !ARCH_VERBOSE */

#define	SYSCALL_FAILED(syscall_name)
#define	SYSCALL_FAILED_1STR(syscall_name,str_arg1)

#endif	/* !ARCH_VERBOSE */

#endif /* ARCH_GENERIC_H */
