/*
	KON - Kanji ON Linux Console -
	Copyright (C) 1992, 1993 Takashi MANABE (manabe@tut.ac.jp)

	KON is free software; you can redistribute it and/or modify it
	under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	KON is distributed in the hope that it will be useful, but
	WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
	See the GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include	"big5con.h"

u_char	PortInb(unsigned short port)
{
	u_char	_rval;

	__asm__	volatile ("inb %1,%0"
		:"=a" (_rval)
		:"d" ((u_short) port));

	return(_rval);
}

#if 0
void	wzero(void *head, int n)
{
	__asm__	("cld\n\t"
		"rep\n\t"
		"stosw"
		::"a" (0),
		"c" (n>>1),
		"D" ((long)head)
		:"cx","di");
}

void	wmove(void *dst, void *src, int n)
{
	__asm__	("cld\n\t"
		"rep\n\t"
		"movsw\n\t"
		::"c" (n>>1),
		"D" ((long)dst),
		"S" ((long)src)
		:"cx","di","si");
}

void	lmove(void *dst, void *src, int n)
{
	__asm__	("cld\n\t"
		"rep\n\t"
		"movsl\n\t"
		::"c" (n>>2),
		"D" ((long)dst),
		"S" ((long)src)
		:"cx","di","si");
}
#endif

void	SafeFree(void **p)
{
	if (*p) {
		free(*p);
		*p = NULL;
	}
}
