📄 async.h
字号:
/*0001*//*
/*0002./ * Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
/*0003./ *
/*0004./ * This software is the confidential and proprietary information of Sun
/*0005./ * Microsystems, Inc. ("Confidential Information"). You shall not
/*0006./ * disclose such Confidential Information and shall use it only in
/*0007./ * accordance with the terms of the license agreement you entered into
/*0008./ * with Sun.
/*0009./ *
/*0010./ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
/*0011./ * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/*0012./ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
/*0013./ * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
/*0014./ * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
/*0015./ * THIS SOFTWARE OR ITS DERIVATIVES.
/*0016./ *
/*0017./ */
/*0018*/
/*0019*//*=========================================================================
/*0020./ * SYSTEM: KVM
/*0021./ * SUBSYSTEM: KVM
/*0022./ * FILE: async.h
/*0023./ * OVERVIEW: Definitions to support (and not support) asynchronous I/O
/*0024./ * AUTHOR: Nik Shaylor, Sun C&E
/*0025./ *=======================================================================*/
/*0026*/
/*0027*/#ifndef KVM_ASYNC_H
/*0028*/#define KVM_ASYNC_H
/*0029*/
/*0030*//*
/*0031./ * Data structure used in all cases
/*0032./ */
/*0033*/typedef struct asynciocb {
/*0034*/ struct asynciocb *nextFree;
/*0035*/ THREAD thread;
/*0036*/ INSTANCE instance;
/*0037*/ BYTEARRAY array;
/*0038*/ char *exception;
/*0039*/} ASYNCIOCB;
/*0040*/
/*0041*/#if !ASYNCHRONOUS_NATIVE_FUNCTIONS
/*0042*/
/*0043*//*
/*0044./ * NO ASYNCHRONOUS_NATIVE_FUNCTIONS
/*0045./ */
/*0046*/
/*0047*/#define ASYNC_FUNCTION(x) \
/*0048*/void x(void) { \
/*0049*/ static void internal ## x (ASYNCIOCB *); \
/*0050*/ ASYNCIOCB anaiocb; \
/*0051*/ ASYNCIOCB *aiocb = &anaiocb; \
/*0052*/ aiocb->thread = CurrentThread; \
/*0053*/ aiocb->instance = 0; \
/*0054*/ aiocb->array = 0; \
/*0055*/ aiocb->exception = 0; \
/*0056*/ internal ## x (aiocb); \
/*0057*/} \
/*0058*/static void internal ## x (ASYNCIOCB *aiocb)
/*0059*/
/*0060*/#define ASYNC_popStack popStack
/*0061*/#define ASYNC_pushStack pushStack
/*0062*/#define ASYNC_popStackAsType popStackAsType
/*0063*/#define ASYNC_pushStackAsType pushStackAsType
/*0064*/#define ASYNC_popLong popLong
/*0065*/#define ASYNC_pushLong pushLong
/*0066*/#define ASYNC_raiseException(x) (aiocb->exception = (x))
/*0067*/#define ASYNC_oneLess oneLess;
/*0068*/#define ASYNC_resumeThread() if(aiocb->exception != 0) raiseException(aiocb->exception)
/*0069*/
/*0070*/#define ASYNC_enableGarbageCollection() /**/
/*0071*/#define ASYNC_disableGarbageCollection() /**/
/*0072*/
/*0073*/#else
/*0074*/
/*0075*//*
/*0076./ * ASYNCHRONOUS_NATIVE_FUNCTIONS
/*0077./ */
/*0078*/
/*0079*/ASYNCIOCB *AcquireAsyncIOCB(void);
/*0080*/void ReleaseAsyncIOCB(ASYNCIOCB *);
/*0081*/void AbortAsyncIOCB(ASYNCIOCB *);
/*0082*/
/*0083*//*
/*0084./ * The number if I/O control blocks in the system
/*0085./ */
/*0086*/#ifndef ASYNC_IOCB_COUNT
/*0087*/#define ASYNC_IOCB_COUNT 5
/*0088*/#endif
/*0089*/
/*0090*//*
/*0091./ * The transfer buffer size. By default it is large enough
/*0092./ * to hold one standard ethernet datagram. Note that this
/*0093./ * buffer is allocated on the stack of the I/O threads.
/*0094./ */
/*0095*/#ifndef ASYNC_BUFFER_SIZE
/*0096*/#define ASYNC_BUFFER_SIZE 1500
/*0097*/#endif
/*0098*/
/*0099*/#define ASYNC_FUNCTION(x) \
/*0100*/void x(void) { \
/*0101*/ static void internal ## x (ASYNCIOCB *); \
/*0102*/ ASYNCIOCB *aiocb = AcquireAsyncIOCB(); \
/*0103*/ CallAsyncNativeFunction_md(aiocb, internal ## x); \
/*0104*/} \
/*0105*/static void internal ## x (ASYNCIOCB *aiocb)
/*0106*/
/*0107*/#define ASYNC_popStack() popStackForThread(aiocb->thread)
/*0108*/#define ASYNC_pushStack(x) pushStackForThread(aiocb->thread,x)
/*0109*/#define ASYNC_popStackAsType(_type_) popStackAsTypeForThread(aiocb->thread, _type_)
/*0110*/#define ASYNC_pushStackAsType(_type_, x) pushStackAsTypeForThread(aiocb->thread,_type_,x)
/*0111*/#define ASYNC_popLong(x) popLongForThread(aiocb->thread,x)
/*0112*/#define ASYNC_pushLong(x) pushLongForThread(aiocb->thread,x)
/*0113*/#define ASYNC_raiseException(x) (aiocb->thread->pendingException = (x))
/*0114*/#define ASYNC_oneLess oneLessForThread(aiocb->thread)
/*0115*/#define ASYNC_resumeThread() ReleaseAsyncIOCB(aiocb)
/*0116*/
/*0117*/extern void decrementAsyncCount();
/*0118*/extern void incrementAsyncCount();
/*0119*/
/*0120*/#if EXCESSIVE_GARBAGE_COLLECTION
/*0121*/
/*0122*/extern void RequestGarbageCollection();
/*0123*/
/*0124*/#define ASYNC_enableGarbageCollection() { \
/*0125*/ extern int VersionOfTheWorld; \
/*0126*/ int _verson_ = VersionOfTheWorld; \
/*0127*/ decrementAsyncCount(); \
/*0128*/ RequestGarbageCollection(); /* only when testing */ \
/*0129*/
/*0130*/
/*0131*/#define ASYNC_disableGarbageCollection() \
/*0132*/ if (_verson_ != VersionOfTheWorld) { \
/*0133*/ /* This is not the same system that we started with so \
/*0134./ just release the IOCB and exit from the native method */ \
/*0135*/ AbortAsyncIOCB(aiocb); \
/*0136*/ return; \
/*0137*/ } \
/*0138*/ incrementAsyncCount(); \
/*0139*/ RequestGarbageCollection(); /* only when testing */ \
/*0140*/}
/*0141*/
/*0142*/#else
/*0143*/
/*0144*/#define ASYNC_enableGarbageCollection() { \
/*0145*/ extern int VersionOfTheWorld; \
/*0146*/ int _verson_ = VersionOfTheWorld; \
/*0147*/ decrementAsyncCount(); \
/*0148*/
/*0149*/
/*0150*/#define ASYNC_disableGarbageCollection() \
/*0151*/ if (_verson_ != VersionOfTheWorld) { \
/*0152*/ /* This is not the same system that we started with so \
/*0153./ just release the IOCB and exit from the native method */ \
/*0154*/ AbortAsyncIOCB(aiocb); \
/*0155*/ return; \
/*0156*/ } \
/*0157*/ incrementAsyncCount(); \
/*0158*/}
/*0159*/
/*0160*/#endif /* EXCESSIVE_GARBAGE_COLLECTION */
/*0161*/
/*0162*/#endif /* !ASYNCHRONOUS_NATIVE_FUNCTIONS */
/*0163*/
/*0164*/#define ASYNC_FUNCTION_START(x) ASYNC_FUNCTION(x) {
/*0165*/#define ASYNC_FUNCTION_END ASYNC_resumeThread(); }
/*0166*/
/*0167*/#endif /* KVM_ASYNC_H */
/*0168*/
/*0169*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -