vmemory.h
上传用户:dgyhgb
上传日期:2007-01-07
资源大小:676k
文件大小:5k
源码类别:

SQL Server

开发平台:

Unix_Linux

  1. /*
  2.  *  vmemory.h  - support tree library for SQL precompiler
  3.  *               Virtual memory manager interface
  4.  *
  5.  *  This file is a part of GNU SQL Server
  6.  *
  7.  *  Copyright (c) 1996, 1997, Free Software Foundation, Inc
  8.  *  Developed at the Institute of System Programming, Russia
  9.  *  This file is written by Michael Kimelman
  10.  *
  11.  *  This program is free software; you can redistribute it and/or modify
  12.  *  it under the terms of the GNU General Public License as published by
  13.  *  the Free Software Foundation; either version 2 of the License, or
  14.  *  (at your option) any later version.
  15.  *
  16.  *  This program is distributed in the hope that it will be useful,
  17.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  *  GNU General Public License for more details.
  20.  *
  21.  *  You should have received a copy of the GNU General Public License
  22.  *  along with this program; if not, write to the Free Software
  23.  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  24.  *
  25.  *  Contact:  gss@ispras.ru
  26.  *
  27.  */
  28. /* $Id: vmemory.h,v 1.246 1997/03/31 11:03:59 kml Exp $ */
  29. /*=====================================================================
  30.   
  31.             Simulated virtual memory (user interface)
  32.         Simululated virtual memory  looks from the  user point of
  33. view as a   set  of VM  segments, each  of  them assotiated  with
  34. independently compiled or  used piece  of  interpretator code  or
  35. compiler tree (just like object modules in ordinary OS). User can
  36. create, link, unlink  and  store out segments during  the program
  37. execution.  Virtual space  is shared by  all  linked segments and
  38. each   of  them  assotiated   with  it's   own   range of virtual
  39. addresses. To allow intersegment references each segment contains
  40. table  of  relocable virtual  addresses  and table of names which
  41. segment exports. Relocation  table used by  VM manager to correct
  42. listed addresses when the segment linked.
  43.         VM  manager support    special  conception of   "current"
  44. segment, allowing local inside  segments references.  The segment
  45. marked as a  current by 'create', 'link' or 'set_current_segment'
  46. calls.  
  47. =====================================================================*/
  48. #ifndef __VMEMORY_H__
  49. #define __VMEMORY_H__
  50. #include "setup_os.h"
  51. typedef i4_t VADR;
  52. #define VNULL (VADR)0l
  53. VADR create_segment __P((void));
  54. /* Function returns   relocable   virtual  address   NULL of */
  55. /* created segment.  Actually  it's just  segment identifier */
  56. /* but  in form of virtual address.                          */
  57. VADR link_segment __P((void *buffer,i4_t size));
  58. /* buffer contains loaded from outside packed segment, which */
  59. /* has to  be  linked to   others (set segment's  interpages */
  60. /* references to physical address as well as correct virtual */
  61. /* relocation addresses).                                    */
  62. void *export_segment __P((VADR s_id,i4_t *buf_size, i4_t unlink_seg));
  63. /* create buffer and    put packed  segment  in it.   Before  */
  64. /* packing routine changed relocation adresses and interpage  */
  65. /* references  to   base   them   on   the    beginning   of  */
  66. /* buffer. Returns  buf_size  and  address of  buffer.  s_id  */
  67. /* should point inside   segment (You can  use VADR received  */
  68. /* from create_segment or load_segment as  well as any other  */
  69. /* relocable addresses pointed into the segment.)             */
  70. int  unlink_segment __P((VADR s_id,i4_t enforce_free));
  71. VADR switch_to_segment __P((VADR segment_id));
  72. VADR get_vm_segment_id __P((VADR ptr_in_segment));
  73. #define GET_CURRENT_SEGMENT_ID  get_vm_segment_id(0)
  74. VADR vmalloc __P((i4_t size));
  75. #define vmalloc(size) vm_ob_alloc(size,0)
  76. VADR vm_ob_alloc __P((i4_t size,i4_t align));
  77. VADR vmrealloc __P((VADR old_ptr,i4_t new_size));
  78. /*      vmrealloc(NULL,new_size) => vmalloc(new_size));        */
  79. void vmfree __P((VADR ptr));
  80. void *vpointer __P((VADR ptr));
  81. VADR ptr2vadr __P((void *p));
  82. void register_relocation_address __P((VADR ptr));
  83. /* add  new entry to relocation  table  of the segment where  */
  84. /* this  address is. "ptr"  points to address data which has  */
  85. /* to be relocable.                                           */
  86. void register_export_name __P((VADR object_ptr,VADR name_ptr));
  87. /* add  new entry to export  list  and register reference to */
  88. /* object as relocation  address. (both  address have to  be */
  89. /* placed on the same segment) */
  90. void register_export_address __P((VADR registered_adr,char *name));
  91. VADR resolve_reference __P((char *name));
  92. VADR resolve_local_reference __P((char *name));
  93. VADR resolve_import_name __P((VADR name_ptr));
  94. #define resolve_import_name(n) resolve_reference((char*)vpointer(n))
  95. VADR external_reference __P((char *name));
  96. /* make  pointer (!local) to object which  is required to be */
  97. /* imported.    When   vpointer   read    such  pointer,  it */
  98. /* automatically  try   to  find  required  name and resolve */
  99. /* reference, returning the   phisical address of  desirable */
  100. /* data. */
  101. #endif