📄 global.h
字号:
/*0181*/#include <native.h>
/*0182*/#include <cache.h>
/*0183*/
/*0184*/#include <runtime.h>
/*0185*/#include <profiling.h>
/*0186*/#include <verifier.h>
/*0187*/#include <log.h>
/*0188*/#include <property.h>
/*0189*/
/*0190*//* The network protocol implementations. These */
/*0191*//* are not part of the CLDC Specification. */
/*0192*/#include <commProtocol.h>
/*0193*/#include <datagramProtocol.h>
/*0194*/#include <socketProtocol.h>
/*0195*/
/*0196*//*=========================================================================
/*0197./ * Miscellaneous global variables
/*0198./ *=======================================================================*/
/*0199*/
/*0200*//* Shared string buffer that is used internally by the VM */
/*0201*/extern char str_buffer[];
/*0202*/
/*0203*//* Requested heap size when starting the VM from command line */
/*0204*/extern long RequestedHeapSize;
/*0205*/
/*0206*//*=========================================================================
/*0207./ * Global execution modes
/*0208./ *=======================================================================*/
/*0209*/
/*0210*//* Flags for toggling certain global modes on and off */
/*0211*/extern bool_t JamEnabled;
/*0212*/extern bool_t JamRepeat;
/*0213*/
/*0214*//*=========================================================================
/*0215./ * Macros for controlling global execution tracing modes
/*0216./ *=======================================================================*/
/*0217*/
/*0278*//* Declare each of the trace flags to be external. Note that we define
/*0279./ * a two-variable macro, then use that macro as an argument to
/*0280./ * FOR_EACH_TRACE_FLAG
/*0281./ */
/*0282*/
/*0283*/#define DECLARE_TRACE_VAR_EXTERNAL(varName, userName) \
/*0284*/ extern int varName;
/*0286*/
/*0287*//*=========================================================================
/*0288./ * Most frequently called functions are "inlined" here
/*0289./ *=======================================================================*/
/*0290*/
/*0291*//*=========================================================================
/*0292./ * Quick operations for stack manipulation (for manipulating stack
/*0293./ * frames and operands).
/*0294./ *=======================================================================*/
/*0295*/
/*0296*/#define topStack (*getSP())
/*0297*/#define secondStack (*(getSP()-1))
/*0298*/#define thirdStack (*(getSP()-2))
/*0299*/#define fourthStack (*(getSP()-3))
/*0300*/
/*0301*/#define topStackAsType(_type_) (*(_type_ *)(getSP()))
/*0302*/#define secondStackAsType(_type_) (*(_type_ *)(getSP() - 1))
/*0303*/#define thirdStackAsType(_type_) (*(_type_ *)(getSP() - 2))
/*0304*/#define fourthStackAsType(_type_) (*(_type_ *)(getSP() - 3))
/*0305*/
/*0306*/#define oneMore getSP()++
/*0307*/#define oneLess getSP()--
/*0308*/#define moreStack(n) getSP() += (n)
/*0309*/#define lessStack(n) getSP() -= (n)
/*0310*/
/*0311*/#define popStack() (*getSP()--)
/*0312*/#define popStackAsType(_type_) (*(_type_ *)(getSP()--))
/*0313*/
/*0314*/#define pushStack(data) *++getSP() = (data)
/*0315*/#define pushStackAsType(_type_, data) *(_type_ *)(++getSP()) = (data)
/*0316*/
/*0317*//*=========================================================================
/*0318./ * The equivalent macros to the above for use when the stack being
/*0319./ * manipulated is not for the currently executing thread. In all cases
/*0320./ * the additional parameter is the THREAD pointer.
/*0321./ *=======================================================================*/
/*0322*/
/*0323*/#define topStackForThread(t) (*((t)->spStore))
/*0324*/#define secondStackForThread(t) (*((t)->spStore - 1))
/*0325*/#define thirdStackForThread(t) (*((t)->spStore - 2))
/*0326*/#define fourthStackForThread(t) (*((t)->spStore - 3))
/*0327*/
/*0328*/#define popStackForThread(t) (*((t)->spStore--))
/*0329*/#define pushStackForThread(t, data) (*(++(t)->spStore) = (data))
/*0330*/#define popStackAsTypeForThread(t, _type_) \
/*0331*/ (*(_type_*)((t)->spStore--))
/*0332*/#define pushStackAsTypeForThread(t, _type_, data) \
/*0333*/ (*(_type_ *)(++(t)->spStore) = (data))
/*0334*/#define moreStackForThread(t, n) ((t)->spStore += (n))
/*0335*/#define lessStackForThread(t, n) ((t)->spStore -= (n))
/*0336*/#define oneMoreForThread(t) ((t)->spStore++)
/*0337*/#define oneLessForThread(t) ((t)->spStore--)
/*0338*/
/*0339*/#define spForThread(t) ((t)->spStore)
/*0340*/
/*0341*//*=========================================================================
/*0342./ * Error handling definitions
/*0343./ *=======================================================================*/
/*0344*/
/*0345*/#ifndef ERROR_TRY
/*0346*/# include <setjmp.h>
/*0347*/# define ERROR_TRY \
/*0348*/ { jmp_buf *__prev__ = topJumpBuffer; \
/*0349*/ int *__prev__value = topJumpBuffer_value; \
/*0350*/ jmp_buf __jmp_buf__; \
/*0351*/ int __value__; \
/*0352*/ int __state__; \
/*0353*/ topJumpBuffer = &__jmp_buf__; \
/*0354*/ topJumpBuffer_value = &__value__; \
/*0355*/ if ((__state__ = setjmp(__jmp_buf__)) == 0) {
/*0356*/
/*0357*/# define ERROR_CATCH(var) \
/*0358*/ } \
/*0359*/ topJumpBuffer = __prev__; \
/*0360*/ topJumpBuffer_value = __prev__value; \
/*0361*/ if (__state__ != 0) { \
/*0362*/ long var = __value__;
/*0363*/
/*0364*/# define ERROR_END_CATCH } }
/*0365*/
/*0366*/# define ERROR_THROW(i) \
/*0367*/ *topJumpBuffer_value = i; \
/*0368*/ longjmp(*topJumpBuffer, i)
/*0369*/
/*0370*/extern jmp_buf *topJumpBuffer;
/*0371*/extern int *topJumpBuffer_value;
/*0372*/
/*0373*/#define NEED_GLOBAL_JUMPBUFFER 1
/*0374*/#endif /* ERROR_TRY */
/*0375*/
/*0376*/#ifndef FATAL_ERROR_EXIT_CODE
/*0377*/#define FATAL_ERROR_EXIT_CODE 127
/*0378*/#endif
/*0379*/
/*0380*//*=========================================================================
/*0381./ * Operations for handling memory fetches and stores
/*0382./ *=======================================================================*/
/*0383*/
/*0384*//*=========================================================================
/*0385./ * These macros define Java-specific memory read/write operations
/*0386./ * for reading high-endian numbers.
/*0387./ *=======================================================================*/
/*0388*/
/*0389*//* Get a 32-bit value from the given memory location */
/*0390*/#define getCell(addr) \
/*0391*/ ((((long)(((unsigned char *)(addr))[0])) << 24) | \
/*0392*/ (((long)(((unsigned char *)(addr))[1])) << 16) | \
/*0393*/ (((long)(((unsigned char *)(addr))[2])) << 8) | \
/*0394*/ (((long)(((unsigned char *)(addr))[3])) << 0))
/*0395*/
/*0396*/#if BIG_ENDIAN
/*0397*/#define getAlignedCell(addr) (*(long *)(addr))
/*0398*/#else
/*0399*/#define getAlignedCell(addr) getCell(addr)
/*0400*/#endif
/*0401*/
/*0402*//* Get an unsigned 16-bit value from the given memory location */
/*0403*/#define getUShort(addr) \
/*0404*/ ((((unsigned short)(((unsigned char *)(addr))[0])) << 8) | \
/*0405*/ (((unsigned short)(((unsigned char *)(addr))[1])) << 0))
/*0406*/
/*0407*//* Get a 16-bit value from the given memory location */
/*0408*/#define getShort(addr) ((short)(getUShort(addr)))
/*0409*/
/*0410*//* Store a 16-bit value in the given memory location */
/*0411*/#define putShort(addr, value) \
/*0412*/ ((unsigned char *)(addr))[0] = (unsigned char)((value) >> 8); \
/*0413*/ ((unsigned char *)(addr))[1] = (unsigned char)((value) & 0xFF)
/*0414*/
/*0415*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -