130 lines
5.6 KiB
C
130 lines
5.6 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_RUNTIME_H_
|
|
#define _CM_RUNTIME_H_
|
|
|
|
struct CMActivity_s;
|
|
|
|
void CM_activityPoolChange();
|
|
void CM_threadsChange();
|
|
|
|
STATUS CM_runtimeInit();
|
|
void CM_runtimeUninit(Volume_s *volume, BOOL abortOngoingActivities, BOOL wait);
|
|
BOOL CM_startActivity(struct CMActivity_s *activity);
|
|
void CM_startThreads();
|
|
void CM_threadExit(struct CMActivity_s *activity);
|
|
|
|
STATUS CM_awaitEvent(ADDR event);
|
|
SNINT CM_signalEvent(ADDR event, STATUS retCode);
|
|
STATUS CM_activityAlloc(
|
|
NINT activityOp,
|
|
struct CMActivity_s **activity, /* out */
|
|
BOOL wait);
|
|
void CM_activityFree(struct CMActivity_s *activity);
|
|
|
|
BOOL CM_removeBeastCompressRequest(RootBeast_s *beast);
|
|
|
|
extern DQhead_t CM_activities;
|
|
|
|
/*
|
|
* This iterator can be safely used to browse thru a queue while removing the
|
|
* current cursor element inside the body of the loop.
|
|
* You still have to ensure that nobody modifies the queue while the iteration
|
|
* is in progress.
|
|
* Adapted from DQ_FOREACH() macro in que.h
|
|
*/
|
|
#define DQ_FOREACH_SAFE(head, item, _tmp, type, linkField) \
|
|
for (_tmp = (type *)(((ADDR)((head)->next)) - offsetof(type, linkField)); \
|
|
(_tmp == (type *)(((ADDR)head) - offsetof(type, linkField))) \
|
|
? 0 \
|
|
: ((item = _tmp), \
|
|
(_tmp = ONEXT(_tmp, type, linkField)), \
|
|
1); \
|
|
)
|
|
|
|
#define DQ_INSERT_AFTER(__item, __newItem, linkField) \
|
|
DQ_PUSH((DQhead_t *)(&(__item)->linkField), __newItem, linkField)
|
|
|
|
#define DQ_INSERT_BEFORE(__item, __newItem, linkField) \
|
|
DQ_ENQ((DQhead_t *)(&(__item)->linkField), __newItem, linkField)
|
|
|
|
typedef struct DataWaiter_s
|
|
{
|
|
DQlink_t waitqLink;
|
|
ADDR threadID;
|
|
QUAD offset;
|
|
} DataWaiter_s;
|
|
|
|
#define ADD_UNCOMP_DATA_WAITER(_waitqHead, _offset) \
|
|
do \
|
|
{ \
|
|
DataWaiter_s *waiter = (DataWaiter_s *)malloc(sizeof(DataWaiter_s)); \
|
|
\
|
|
if (waiter) \
|
|
{ \
|
|
waiter->offset = (_offset); \
|
|
waiter->threadID = ThreadId(); \
|
|
NULLIFY(&waiter->waitqLink); \
|
|
DQ_ENQ((_waitqHead), waiter, waitqLink); \
|
|
\
|
|
awaitEvent(waiter); \
|
|
} \
|
|
else \
|
|
{ \
|
|
zASSERT("Couldn't malloc DataWaiter_s!\n" == 0); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define UNCOMP_DATA_AVAILABLE(_waitqHead, _offset, _size) \
|
|
do \
|
|
{ \
|
|
DataWaiter_s *waiter, *tmp; \
|
|
\
|
|
DQ_FOREACH_SAFE(_waitqHead, waiter, tmp, DataWaiter_s, waitqLink) \
|
|
{ \
|
|
if ((waiter->offset >= (_offset)) && \
|
|
(waiter->offset <= ((_offset) + (_size)))) \
|
|
{ \
|
|
DQ_RMV(waiter, waitqLink); \
|
|
Continue(waiter->threadID); \
|
|
free(waiter); \
|
|
} \
|
|
} \
|
|
} while (0)
|
|
|
|
#endif /* _CM_RUNTIME_H_ */
|