230 lines
6.5 KiB
C
230 lines
6.5 KiB
C
/****************************************************************************
|
|
|
|
|
| (C) Copyright 2001 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
|
|
|
|
|
|***************************************************************************
|
|
|
|
|
| Novell Storage Services (NSS) / Distributed File Services (DFS)
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
|
|
|
| $Author: stoner $
|
|
| $Date: 2005-04-13 22:08:08 +0530 (Wed, 13 Apr 2005) $
|
|
|
|
|
| $RCSfile$
|
|
| $Revision: 927 $
|
|
|
|
|
|---------------------------------------------------------------------------
|
|
| This module is used to:
|
|
| Provide a means for an NSS NLM that is internally MPK safe to operate
|
|
| without holding the NSS MPK Spin Lock except where required for
|
|
| specific NSS function calls as defined by the macros below.
|
|
+-------------------------------------------------------------------------*/
|
|
|
|
#ifndef _WITHMPKSPINLOCK_H_
|
|
#define _WITHMPKSPINLOCK_H_
|
|
|
|
|
|
/* If we are compiling six pack code for Cobra */
|
|
#ifdef NSS_ON_NW56_MODE
|
|
|
|
/* Include the MPK headers */
|
|
#include <mpkapis.h>
|
|
#include <mpkerror.h>
|
|
|
|
/* Function style macros */
|
|
#define ASSERT_MPKNSS_LOCK() /* Fake the assert on the NSS MPK lock for the pre-MP version of NSS */
|
|
#define MPKNSS_LOCK() /* Fake the NSS MPK lock for the pre-MP version of NSS */
|
|
#define MPKNSS_UNLOCK() /* Fake the NSS MPK unlock for the pre-MPK version of NSS */
|
|
|
|
#define microSecondTimer() ((QUAD)GetHighResClock() * (QUAD)100)
|
|
|
|
#endif
|
|
|
|
|
|
#ifdef TOTALALLOCS
|
|
/*
|
|
These need to be defined in the source for the NLM being compiled with the TOTALALLOCS macro enabled
|
|
*/
|
|
extern LONG AllocBytes;
|
|
extern LONG AllocPages;
|
|
#endif
|
|
|
|
|
|
/*
|
|
Manifest constants
|
|
*/
|
|
|
|
|
|
/* New types */
|
|
|
|
|
|
/* Function style macros */
|
|
#define NOZOS_UnRegisterEventNotification(_p1) \
|
|
UnRegisterEventNotification(_p1);
|
|
|
|
#define WithMPKLock_ByteToUnicode(_ret, _arg1, _arg2, _arg3, _arg4, _arg5) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
_ret = LB_ByteToUnicode(_arg1, _arg2, _arg3, _arg4, _arg5); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#define WithMPKLock_COMN_NameToUnicode(_ret, _arg1, _arg2, _arg3, _arg4, _arg5) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
_ret = COMN_NameToUnicode(_arg1, _arg2, _arg3, _arg4, _arg5); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
|
|
#define WithMPKLock_exitMyselfAndReturn(_arg1, _arg2) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
LB_exitMyselfAndReturn(_arg1, _arg2); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
|
|
#if zNETWARE
|
|
#ifndef TOTALALLOCS
|
|
#define WithMPKLock_free(_arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
free(_arg1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#else
|
|
#define WithMPKLock_free(_arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
atomic_sub(&AllocBytes, *(((LONG *)_arg1)-1)); \
|
|
free(((LONG *)_arg1)-1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#endif
|
|
#else
|
|
#define WithMPKLock_free(_arg1) free(_arg1);
|
|
#endif
|
|
|
|
#ifndef TOTALALLOCS
|
|
#define WithMPKLock_freePage(_arg1, _arg2) { \
|
|
MPKNSS_LOCK(); \
|
|
freePage(_arg1, _arg2); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#else
|
|
#define WithMPKLock_freePage(_arg1, _arg2) { \
|
|
MPKNSS_LOCK(); \
|
|
freePage(_arg1, _arg2); \
|
|
atomic_sub(&AllocPages, _arg2); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#endif
|
|
|
|
#define WithMPKLock_LB_GUIDGenerate(_arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
LB_GUIDGenerate(_arg1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
|
|
#define WithMPKLock_LB_GUIDToString(_ret, _arg1, _arg2, _arg3) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
_ret = LB_GUIDToString(_arg1, _arg2, _arg3); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
|
|
#if zNETWARE
|
|
#ifndef TOTALALLOCS
|
|
#define WithMPKLock_malloc(_ret, _arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
_ret = malloc(_arg1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#else
|
|
#define WithMPKLock_malloc(_ret, _arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
_ret = malloc((_arg1) + 4); \
|
|
*(LONG *)_ret = _arg1; \
|
|
_ret = (void *)(&((LONG *)_ret)[1]); \
|
|
atomic_add(&AllocBytes, _arg1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#endif
|
|
#else
|
|
#define WithMPKLock_malloc(_ret, _arg1) _ret = malloc(_arg1);
|
|
#endif
|
|
|
|
#ifndef TOTALALLOCS
|
|
#define WithMPKLock_mallocPage(_ret, _arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
_ret = mallocPage(_arg1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#else
|
|
#define WithMPKLock_mallocPage(_ret, _arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
_ret = mallocPage(_arg1); \
|
|
atomic_add(&AllocPages, _arg1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#endif
|
|
|
|
#ifndef TOTALALLOCS
|
|
#define WithMPKLock_realloc(_ret, _arg1, _arg2) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
_ret = realloc(_arg1, _arg2); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#else
|
|
#define WithMPKLock_realloc(_ret, _arg1, _arg2) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
atomic_sub(&AllocBytes, *(((LONG *)_arg1)-1); \
|
|
_ret = realloc(((LONG *)_arg1)-1, _arg2 + 4); \
|
|
*(LONG *)_ret = arg2; \
|
|
_ret = (void *)(&((LONG *)_ret)[1]); \
|
|
atomic_add(&AllocBytes, arg2); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
#endif
|
|
|
|
#define WithMPKLock_UnicodeToByte(_ret, _arg1, _arg2, _arg3, _arg4, _arg5) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
_ret = LB_UnicodeToByte(_arg1, _arg2, _arg3, _arg4, _arg5); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
|
|
#define WithMPKLock_uniupr(_ret, _arg1) { \
|
|
MPKNSS_LOCK(); \
|
|
_ret = uniupr(_arg1); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
|
|
#define WithMPKLock_UTCTime2Str(_ret, _arg1, _arg2) \
|
|
{ \
|
|
MPKNSS_LOCK(); \
|
|
_ret = UTCTime2Str(_arg1, _arg2); \
|
|
MPKNSS_UNLOCK(); \
|
|
}
|
|
|
|
/* Function prototypes */
|
|
|
|
|
|
|
|
#endif
|