Files
mars-nwe/include/nwnss/internal/cmDefs.h

196 lines
9.3 KiB
C

/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996-1999 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
|
|***************************************************************************
|
| NSS Compression Management module
|
|---------------------------------------------------------------------------
|
| $Author: taysom $
| $Date: 2004-12-31 01:10:58 +0530 (Fri, 31 Dec 2004) $
|
| $RCSfile$
| $Revision: 465 $
|
|---------------------------------------------------------------------------
| Module Description:
|
+-------------------------------------------------------------------------*/
#ifndef _CM_DEFS_H_
#define _CM_DEFS_H_
/*
* This file contains common internal definitions/declarations
* for Compression Manager's internal use only.
*/
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <utc.h>
#define INSIDE_CM 1
#ifdef MARS_NWE_NWNSS_USERSPACE
#include <schedule.h>
#else
#include "mpkapis.h"
#endif
#include "comnPublics.h"
#include "xError.h"
#include "que.h"
#define TRUNC(_value, _size) (((_value) / (_size)) * (_size))
#define SLATCH_BEAST(_beast) S_LATCH(&(_beast)->ROOTbeastLatch)
#define XLATCH_BEAST(_beast) X_LATCH(&(_beast)->ROOTbeastLatch)
#define UPLATCH_BEAST(_beast) UP_LATCH(&(_beast)->ROOTbeastLatch)
#define DOWNLATCH_BEAST(_beast) DOWN_LATCH(&(_beast)->ROOTbeastLatch)
#define UNSLATCH_BEAST(_beast) UNS_LATCH(&(_beast)->ROOTbeastLatch)
#define UNXLATCH_BEAST(_beast) UNX_LATCH(&(_beast)->ROOTbeastLatch)
#define UNLATCH_BEAST(_beast) UN_LATCH(&(_beast)->ROOTbeastLatch)
#define ASSERT_NOLATCH_BEAST(_beast) ASSERT_NOLATCH(&beast->ROOTbeastLatch)
#define LATCH_FREE_BEAST(_beast) LATCH_FREE(&beast->ROOTbeastLatch)
#define awaitEvent(_event) Wait()
#define BEAST_CM_INFO(_rootBeast) \
((_rootBeast)->ROOTvariableData \
? ((CompressInfo_s *)(*(_rootBeast)->ROOTvariableData)[RVD_COMP_META_DATA]) \
: 0)
#define SET_BEAST_CM_INFO(_rootBeast, _value) \
((*(_rootBeast)->ROOTvariableData)[RVD_COMP_META_DATA] = (void *)(_value))
#define TRUNCATE_BEAST(_genMsg, _beast, _offset) \
BST_truncate(_genMsg, _beast, \
((_offset) + (1 << (_beast)->blkSizeShift) - 1) >> (_beast)->blkSizeShift, -1, 0)
#if 0
#define CREATE_HOLE_IN_BEAST(_genMsg, _beast, _startBlknum, _blkcnt) \
BST_truncate(_genMsg, _beast, _startBlknum, _blkcnt, 0)
#else
#define CREATE_HOLE_IN_BEAST(_genMsg, _beast, _startBlknum, _blkcnt) zOK
#endif
#define GET_DATASTREAM_SIZE(_beast) ((_beast)->ROOTeof)
#define SET_DATASTREAM_SIZE(_genMsg, _beast, _newsize) \
do \
{ \
(_beast)->ROOTeof = (_newsize); \
TRUNCATE_BEAST(_genMsg, _beast, _newsize); \
} while (0)
//#define USE_BG_THREAD_FOR_COMPRESSION 1
#define CHANGE_VOLUME_COMPRESSED_FILES(_volume, _xaction, _delta) \
do { \
VolInfoLog_s volLog; \
\
zASSERT(_xaction); \
volLog.delta = (_delta); \
volLog.action = VOLINFO_CHANGE_NUM_COMPRESSED_FILES; \
/* done in VOL_writeVolumeLoggedData \
* (_volume)->VOLnumCompressedFiles += (_delta); */ \
(_volume)->VOLcomnVolOps.VOL_writeVolumeLoggedData(_volume, _xaction, \
&volLog); \
} while (0)
#define INC_VOLUME_COMPRESSED_FILES(_volume, _xaction) \
CHANGE_VOLUME_COMPRESSED_FILES(_volume, _xaction, 1)
#define DEC_VOLUME_COMPRESSED_FILES(_volume, _xaction) \
CHANGE_VOLUME_COMPRESSED_FILES(_volume, _xaction, -1)
#define CHANGE_VOLUME_COMP_DELETED_FILES(_volume, _xaction, _delta) \
do { \
VolInfoLog_s volLog; \
\
zASSERT(_xaction); \
volLog.delta = (_delta); \
volLog.action = VOLINFO_CHANGE_NUM_COMP_DELETED_FILES; \
/* done in VOL_writeVolumeLoggedData \
* (_volume)->VOLnumCompDelFiles += (_delta); */ \
(_volume)->VOLcomnVolOps.VOL_writeVolumeLoggedData(_volume, _xaction, \
&volLog); \
} while (0)
#define INC_VOLUME_COMP_DELETED_FILES(_volume, _xaction) \
CHANGE_VOLUME_COMP_DELETED_FILES(_volume, _xaction, 1)
#define DEC_VOLUME_COMP_DELETED_FILES(_volume, _xaction) \
CHANGE_VOLUME_COMP_DELETED_FILES(_volume, _xaction, -1)
#define CHANGE_VOLUME_UNCOMPRESSIBLE_FILES(_namedBeast, _xaction, _delta) \
do { \
VolInfoLog_s volLog; \
Xaction_s *_localXaction = \
(_xaction) ? (_xaction) : COMN_BeginXLocal(_namedBeast); \
\
zASSERT(_localXaction); \
volLog.delta = (_delta); \
volLog.action = VOLINFO_CHANGE_NUM_UNCOMPRESSIBLE_FILES; \
/* done in VOL_writeVolumeLoggedData \
* (_namedBeast)->NAMEDvolume->VOLnumUncompressibleFiles += (_delta);*/ \
(_namedBeast)->NAMEDvolume->VOLcomnVolOps.VOL_writeVolumeLoggedData( \
(_namedBeast)->NAMEDvolume, _localXaction, &volLog); \
if (! (_xaction)) \
COMN_EndXLocal(_namedBeast, &_localXaction); \
} while (0)
#define INC_VOLUME_UNCOMPRESSIBLE_FILES(_namedBeast, _xaction) \
CHANGE_VOLUME_UNCOMPRESSIBLE_FILES(_namedBeast, _xaction, 1)
#define DEC_VOLUME_UNCOMPRESSIBLE_FILES(_namedBeast, _xaction) \
CHANGE_VOLUME_UNCOMPRESSIBLE_FILES(_namedBeast, _xaction, -1)
#define CHANGE_VOLUME_COMPRESSED_FILE_BLOCKS(_beast, _xaction, _delta) \
do { \
VolInfoLog_s volLog; \
Xaction_s *_localXaction = \
(_xaction) ? (_xaction) : COMN_BeginXLocal(_beast); \
RootBeast_s *_rootBeast = (RootBeast_s *)(_beast); \
\
zASSERT(_localXaction); \
volLog.delta = (_delta); \
volLog.action = VOLINFO_CHANGE_NUM_COMPRESSED_FILE_BLOCKS; \
/* done in VOL_writeVolumeLoggedData \
* (_namedBeast)->NAMEDvolume->VOLnumUncompressibleFiles += (_delta);*/ \
(_rootBeast)->ROOTvolume->VOLcomnVolOps.VOL_writeVolumeLoggedData( \
(_rootBeast)->ROOTvolume, _localXaction, &volLog); \
if (! (_xaction)) \
COMN_EndXLocal(_beast, &_localXaction); \
} while (0)
#define CHANGE_VOLUME_PRECOMPRESSED_FILE_BLOCKS(_beast, _xaction, _delta) \
do { \
VolInfoLog_s volLog; \
Xaction_s *_localXaction = \
(_xaction) ? (_xaction) : COMN_BeginXLocal(_beast); \
RootBeast_s *_rootBeast = (RootBeast_s *)(_beast); \
\
zASSERT(_localXaction); \
volLog.delta = (_delta); \
volLog.action = VOLINFO_CHANGE_NUM_PRECOMPRESSED_FILE_BLOCKS; \
/* done in VOL_writeVolumeLoggedData \
* (_namedBeast)->NAMEDvolume->VOLnumUncompressibleFiles += (_delta);*/ \
(_rootBeast)->ROOTvolume->VOLcomnVolOps.VOL_writeVolumeLoggedData( \
(_rootBeast)->ROOTvolume, _localXaction, &volLog); \
if (! (_xaction)) \
COMN_EndXLocal(_beast, &_localXaction); \
} while (0)
#endif /* _CM_DEFS_H_ */