home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / j2sdk / files / linux / j2sdklin.bin / jdk1.3.1 / include-old / util.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-05-06  |  3.6 KB  |  130 lines

  1. /*
  2.  * @(#)util.h    1.6 00/02/02
  3.  *
  4.  * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the proprietary information of Sun Microsystems, Inc.  
  7.  * Use is subject to license terms.
  8.  * 
  9.  */
  10.  
  11. #ifndef _JAVASOFT__JAVASOFT_UTIL_h__
  12. #define _JAVASOFT__JAVASOFT_UTIL_h__
  13.  
  14. #include <stdio.h>
  15. #include <stdarg.h> 
  16. #include "miscdefs_md.h"
  17. #include "bool.h" 
  18.  
  19. struct execenv;
  20. struct Hjava_lang_Object;
  21. struct Hjava_lang_Class;
  22.  
  23.  
  24. void lock_utf8_hash(struct execenv *ee);
  25. void unlock_utf8_hash(struct execenv *ee);
  26.  
  27. /* global UTF-8 pool */
  28. extern char *utf8_literal_obj_init_name;  /* "<init>" */
  29. extern char *utf8_literal_cls_init_name;  /* "<clinit>" */
  30. extern char *utf8_literal_null_init_sig;  /* "()V" */
  31. extern char *utf8_literal_java_lang_ref_Reference;
  32. extern char *utf8_literal_finalizer_name;
  33. extern char *utf8_literal_finalizer_sig;
  34. extern char *utf8_literal_java_lang_Class;
  35. extern char *utf8_literal_java_lang_Object;
  36. extern char *utf8_literal_LineNumberTable;
  37. extern char *utf8_literal_CoverageTable;
  38. extern char *utf8_literal_LocalVariableTable;
  39. extern char *utf8_literal_ConstantValue;
  40. extern char *utf8_literal_Code;
  41. extern char *utf8_literal_Exceptions;
  42. extern char *utf8_literal_SourceFile;
  43. extern char *utf8_literal_InnerClasses;
  44. extern char *utf8_literal_AbsoluteSourcePath;
  45. extern char *utf8_literal_TimeStamp;
  46.  
  47. typedef struct {
  48.     char *name;
  49.     char *signature;
  50. } HashedNameAndType;
  51.  
  52. void HashNameAndType(struct execenv * ee,
  53.              const char *name, 
  54.              const char *signature,
  55.              HashedNameAndType *hashed);
  56.  
  57. #define NAMETYPE_MATCH(hashed, fb) \
  58.     (((hashed)->name == (fb)->name) && \
  59.      ((hashed)->signature == (fb)->signature))
  60.  
  61. char *AddUTF8(struct execenv * ee, const char *str);
  62. void ReleaseUTF8(struct execenv * ee, const char *str);
  63. char *HashUTF8(struct execenv * ee, const char *str);
  64.  
  65. struct Hjava_lang_Class * getClass(struct Hjava_lang_Object *p);
  66.  
  67. #ifdef HPROF
  68.  
  69. bool_t jvmpi_utf8_marked(const char *str);
  70. bool_t jvmpi_utf8_mark(const char *str);
  71.  
  72. #endif /* HPROF */
  73.  
  74. /* allows you to override panic & oom "functionality" */
  75. typedef void (*PanicHook)(const char* panicString);
  76. typedef void (*OutOfMemoryHook) (void);
  77.  
  78. extern PanicHook panic_hook;
  79. extern OutOfMemoryHook out_of_memory_hook;
  80.  
  81. /*
  82.  * The __attribute__ statements allow gcc to typecheck the arguments
  83.  * to jio_* function with the format string.  The warnings it might
  84.  * generate aren't guaranteed to be correct because I'm not sure that
  85.  * jio_vsnprintf is exactly the same as sprintf and friends.
  86.  */
  87.  
  88.  
  89. void out_of_memory(void);
  90. int jio_snprintf(char *str, size_t count, const char *fmt, ...)
  91. #ifdef __GNUC__
  92. __attribute ((format (printf, 3, 4)))
  93. #endif
  94. ;
  95. int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
  96.  
  97. int jio_printf(const char *fmt, ...)
  98. #ifdef __GNUC__
  99. __attribute ((format (printf, 1, 2)))
  100. #endif
  101. ;
  102. int jio_fprintf(FILE *, const char *fmt, ...)
  103. #ifdef __GNUC__
  104. __attribute ((format (printf, 2, 3)))
  105. #endif
  106. ;
  107. int jio_vfprintf(FILE *, const char *fmt, va_list args);
  108.  
  109. /*
  110.  * To override these byte alignment macros, define platform
  111.  * specific versions in miscdefs_md.h on your platform.
  112.  */
  113. #ifndef ALIGN_UP
  114. #define ALIGN_UP(n,align_grain) (((n) + ((align_grain) - 1)) & ~((align_grain)-1))
  115. #endif /* ALIGN_UP */
  116.  
  117. #ifndef ALIGN_DOWN
  118. #define ALIGN_DOWN(value, align_grain) ((value) & ~((align_grain) - 1))
  119. #endif /* ALIGN_DOWN */
  120.  
  121. #ifndef IS_ALIGNED
  122. #define IS_ALIGNED(value, align_grain) (((value) & ((align_grain) - 1)) == 0)
  123. #endif /* IS_ALIGNED */
  124.  
  125. #ifndef ALIGN_NATURAL
  126. #define ALIGN_NATURAL(p) ALIGN_UP(p, sizeof(double))
  127. #endif /* ALIGN_NATURAL */
  128.  
  129. #endif /* !_JAVASOFT__JAVASOFT_UTIL_h__ */
  130.