Files
mars-nwe/include/core/library/inlines.h

342 lines
8.9 KiB
C

/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program 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, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: vandana $
| $Date: 2007-04-18 23:26:20 +0530 (Wed, 18 Apr 2007) $
|
| $RCSfile$
| $Revision: 1954 $
|
|---------------------------------------------------------------------------
| This module is used to:
| Assembly inline routines for the PSS libraries
|
|******** DO NOT INCLUDE THIS UNLESS YOU ARE A LIBRARY ROUTINE *******
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
| This header file should ONLY be used for NSS internal development.
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
| Any other use may cause conflicts which NSS will NOT fix.
+-------------------------------------------------------------------------*/
#ifndef _INLINES_H_
#define _INLINES_H_
#include <library/xUnicode.h>
#ifndef _ZOMNI_H_
# include <public/zOmni.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WATCOMC_
/**
* This is a little Watcom specific routine that reads the
* QUAD cycle count that Pentiums have.
*/
QUAD LB_CycleCount();
#pragma aux LB_CycleCount = \
0x0f 0x31 \
modify exact [EAX EDX];
/*---------------------------------------------------------------------------
* inline find a long in a list of longs
*---------------------------------------------------------------------------*/
extern LONG FindLongInList(
LONG value,
void *address,
LONG numberOfBytes);
//#pragma aux FindLongInList parm [EAX] [EDI] [ECX];
#pragma aux FindLongInList = \
"test ecx, ecx", \
"jz *+0x0d", \
"mov edx, ecx", \
"repne scasd", \
"jnz *+7", \
"lea eax, [edx - 1]", \
"sub eax, ecx", \
"jmp *+5", \
"mov eax, -1" \
parm [EAX] [EDI] [ECX] \
modify exact [EAX ECX EDX EDI];
/*---------------------------------------------------------------------------
* inline ZERO array function
*---------------------------------------------------------------------------*/
extern void inline_bzero(
void *dst,
size_t numberOfBytes);
//#pragma aux inline_bzero parm [EDI] [ECX];
#pragma aux inline_bzero = \
"mov edx,ecx", \
"xor eax,eax", \
"shr ecx,2", \
"rep stosd", \
"mov ecx,edx", \
"and ecx,3", \
"je *+2", \
"rep stosb" \
parm [edi] [ecx] \
modify exact [eax edx edi ecx];
/*---------------------------------------------------------------------------
* Inline MOVE function
*---------------------------------------------------------------------------*/
extern void inline_movefwd(
void *dst,
const void *src,
size_t len);
#pragma aux inline_movefwd = \
"mov eax,ecx", \
"shr ecx,2", \
"rep movsd", \
"mov ecx,eax", \
"and ecx,3", \
"je *+2", \
"rep movsb" \
parm [edi] [esi] [ecx] \
modify exact [eax edi esi ecx];
/*---------------------------------------------------------------------------
* Inline MOVE function
*---------------------------------------------------------------------------*/
extern void inline_movebwd(
void *dst,
const void *src,
size_t len);
#pragma aux inline_movebwd = \
"sub esi,4", \
"sub edi,4", \
"mov eax,ecx", \
"std", \
"shr ecx,2", \
"rep movsd", \
"mov ecx,eax", \
"and ecx,3", \
"je *+8", \
"add esi,3", \
"add edi,3", \
"rep movsb", \
"cld" \
parm [edi] [esi] [ecx] \
modify exact [eax edi esi ecx];
/*---------------------------------------------------------------------------
*
*---------------------------------------------------------------------------*/
extern void inline_movebwd_bytesOnly(
void *dst,
const void *src,
size_t len);
#pragma aux inline_movebwd_bytesOnly = \
"dec esi", \
"dec edi", \
"std", \
"rep movsb", \
"cld" \
parm [edi] [esi] [ecx] \
modify exact [edi esi ecx];
/*---------------------------------------------------------------------------
* INLINE strlen routine
*---------------------------------------------------------------------------*/
#ifdef i386 /*PJT*/
extern size_t inline_strlen(
const char *str);
#pragma aux inline_strlen = \
"sub ecx,ecx", \
"dec ecx", \
"xor eax,eax", \
"repne scasb", \
"not ecx", \
"dec ecx", \
"mov eax,ecx" \
parm [edi] \
modify exact [eax edi ecx];
#endif /*PJT*/
/*---------------------------------------------------------------------------
* INLINE unilen routine
*---------------------------------------------------------------------------*/
extern size_t inline_unilen(
const unicode_t *str);
#pragma aux inline_unilen = \
"sub ecx,ecx", \
"dec ecx", \
"xor eax,eax", \
"repne scasw", \
"not ecx", \
"dec ecx", \
"mov eax,ecx" \
parm [edi] \
modify exact [eax edi ecx];
/*---------------------------------------------------------------------------
* Rotates a NINT value LEFT by the numBits count
*---------------------------------------------------------------------------*/
NINT inline_RotateLeft(NINT value, NINT numBits);
#pragma aux inline_RotateLeft = \
"rol eax,cl" \
parm [eax] [ecx] \
modify exact [eax];
/*---------------------------------------------------------------------------
* Rotates a NINT value RIGHT by the numBits count
*---------------------------------------------------------------------------*/
NINT inline_RotateRight(NINT value, NINT numBits);
#pragma aux inline_RotateRight = \
"ror eax,cl" \
parm [EAX] [ECX] \
modify exact [EAX];
/*---------------------------------------------------------------------------
* Disable interrupts
*---------------------------------------------------------------------------*/
#if MPK_REAL IS_ENABLED
# define Disable()
#else
void Disable(void);
#pragma aux Disable = \
"cli" \
modify exact [];
#endif
/*---------------------------------------------------------------------------
* Enable interrupts
*---------------------------------------------------------------------------*/
#if MPK_REAL IS_ENABLED
#define Enable()
#else
void Enable(void);
#pragma aux Enable = \
"sti" \
modify exact [];
#endif
//#if NSS_DEBUG IS_ENABLED
// #define DEBUG_ENABLE_INTERRUPTS() (Enable())
//#else
// #define DEBUG_ENABLE_INTERRUPTS()
//#endif
/*---------------------------------------------------------------------------
* Set FLAGS register
*---------------------------------------------------------------------------*/
#if MPK_REAL IS_ENABLED
# define SetFlags(_flags) ((void)0)
#else
void SetFlags(NINT flag);
#pragma aux SetFlags = \
"push eax", \
"popfd" \
parm [eax] \
modify exact [];
#endif
/*---------------------------------------------------------------------------
* Disable interrupts and RETURN flags register
*---------------------------------------------------------------------------*/
#if MPK_REAL IS_ENABLED
# define DisableAndRetFlags() 0
#else
NINT DisableAndRetFlags(void);
#pragma aux DisableAndRetFlags = \
"pushfd", \
"pop eax", \
"cli" \
modify exact [eax];
#endif
/*-------------------------------------------------------------------------
* Enable interrupts and RETURN flags register
*-------------------------------------------------------------------------*/
#if MPK_REAL IS_ENABLED
# define EnableAndRetFlags() 0
#else
NINT EnableAndRetFlags(void);
#pragma aux EnableAndRetFlags = \
"pushfd", \
"pop eax", \
"sti" \
modify exact [eax];
#endif
/*---------------------------------------------------------------------------
* Returns TRUE if interrupts are enabled, else false
*---------------------------------------------------------------------------*/
BOOL IntsEnabled(void);
#pragma aux IntsEnabled = \
"pushfd", \
"pop eax", \
"and eax,200h" \
modify exact [eax];
#endif /*_WATCOMC_*/
#ifdef __linux__
#if MPK_REAL IS_ENABLED
# define Disable()
# define DisableAndRetFlags() 0
# define Enable()
# define SetFlags(_flags) ((void)0)
#else
// FixFixFix(linux) - Added by Greg - need to add actual function. Look at callers to see if we really need.
# define Disable()
# define DisableAndRetFlags() 0
# define Enable()
# define SetFlags(_flags) ((void)0)
// # error Need to define Disable(), DisableAndRetFlags(), Enable() and SetFlags().
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif