📄 hashtable.h
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* hashtable.h
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
*
*
* Author:
* -------
*
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
/*
* Copyright (c) 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
* Use is subject to license terms.
*/
/*=========================================================================
* KVM
*=========================================================================
* SYSTEM: KVM
* SUBSYSTEM: Internal hashtables
* FILE: hashtable.h
* OVERVIEW: This file defines the structures for maintaining
* hashtables inside the KVM. Hashtable data structures
* are used internally by the KVM for maintaining:
* 1) classes (ClassTable)
* 2) strings (InternStringTable)
* 3) UTF8 strings (UTFStringTable)
* AUTHOR: Frank Yellin
*=======================================================================*/
/*=========================================================================
* Include files
*=======================================================================*/
#if NOT_SUPPORTED_STDDEF_H
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
#else
#include <stddef.h>
#endif /* end of #if NOT_SUPPORTED_STDDEF_H */
/*=========================================================================
* Definitions and declarations
*=======================================================================*/
/* The sizes of the various hash tables */
#define UTF_TABLE_SIZE 256
#define CLASS_TABLE_SIZE 32
#define INTERN_TABLE_SIZE 32
/* The declaration of a hashtable. We make the buckets fairly
* generic.
*/
typedef struct HashTable {
long bucketCount; /* Number of buckets */
long count; /* Number of total items in the table */
cell *bucket[1]; /* Array of entries */
} *HASHTABLE;
/* The declaration of one bucket that holds unique instances of UTF strings
*/
typedef struct UTF_Hash_Entry {
struct UTF_Hash_Entry *next; /* The next bucket */
unsigned short length;
unsigned short key;
char string[1]; /* The characters of the string */
} *UTF_HASH_ENTRY, *UString;
/*=========================================================================
* Size macros
*=======================================================================*/
/* A hashtable with n buckets */
#define SIZEOF_HASHTABLE(n) (StructSizeInCells(HashTable) + (n - 1))
/* A UTF_HASH_ENTRY that can hold a string of length n. Note that
* this >>does<< include the NULL character, since we've already saved
* space for one character */
#define SIZEOF_UTF_HASH_ENTRY(n) \
ByteSizeToCellSize(offsetof(struct UTF_Hash_Entry, string) + n + 1)
/*=========================================================================
* Global variables
*=======================================================================*/
/* Hashtable containing all the Java strings in the system */
extern HASHTABLE InternStringTable;
/* Hashtable containing all the utf C strings in the system */
extern HASHTABLE UTFStringTable;
/* Hashtable containing all the classes in the system */
extern HASHTABLE ClassTable;
/*=========================================================================
* Hashtable creation and deletion
*=======================================================================*/
/* Create a new hash table */
void createHashTable(HASHTABLE *tablePtr, int bucketCount);
/* Called at startup to initialize the hashtables */
void InitializeHashtables(void);
void FinalizeHashtables(void);
#if ROMIZING
void finalizeROMHashTable(HASHTABLE, int offset);
#endif
/*=========================================================================
* Functions
*=======================================================================*/
/* Convert a const char* to a UString, or a UString to a const char */
UString getUString(const char *string);
UString getUStringX(CONST_CHAR_HANDLE nameH, int offset, int length);
#define UStringInfo(str) str->string
/* Get a unique String for a given char array */
INTERNED_STRING_INSTANCE internString(const char *string, int length);
/* Convert utf8 to unicode */
short utf2unicode(const char **utf);
#if ENABLE_JAVA_DEBUGGER
char *unicode2utf(unsigned short *, int, char *, int);
int unicode2utfstrlen(unsigned short *, int);
#endif /* ENABLE_JAVA_DEBUGGER */
/* Determine the actual number of characters in a utf8 string */
unsigned int utfStringLength(const char *utfstring, int length);
/* Conversion between keys and names */
NameKey change_Name_to_Key(CONST_CHAR_HANDLE, int offset, int length);
char *change_Key_to_Name(NameKey, int *length);
/* Conversion between classes and names */
CLASS change_Name_to_CLASS(UString package, UString base);
CLASS change_Key_to_CLASS(FieldTypeKey);
/*=========================================================================
* Printing and debugging operations
*=======================================================================*/
#if INCLUDEDEBUGCODE
void printUTFStringTable();
#else
# define printUTFStringTable()
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -