"Fossies" - the Fresh Open Source Software Archive

Member "erltools/pub/library/memges.h" (26 Mar 2005, 3935 Bytes) of package /linux/misc/old/erltools-4.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "memges.h" see the Fossies "Dox" file reference documentation.

    1 /**************************************************************
    2      
    3      
    4                     QMemGes : Malloc without a cache in files
    5      
    6                     Developped by Eric Lavillonniere on Tandon
    7      
    8    ***************************************************************/
    9 /* This file is part of metagen                                             
   10    
   11    Metagen is a syntaxic analyser generator with backtrack.
   12    
   13    It runs on dos and unix. It generates c code. */
   14 /* Copyright(C) 1989 Eric Lavillonniere */
   15 /*
   16    This program is free software; you can redistribute it and/or modify
   17    it under the terms of the GNU General Public License as published by
   18    the Free Software Foundation; either version 1, or (at your option)
   19    any later version.
   20    
   21    This program is distributed in the hope that it will be useful,
   22    but WITHOUT ANY WARRANTY; without even the implied warranty of
   23    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   24    GNU General Public License for more details.
   25    
   26    You should have received a copy of the GNU General Public License
   27    along with this program; see the file COPYING. If not, write to 
   28    the Free Software
   29    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   30    
   31    */
   32 #ifndef MEMGES_FILE
   33 #define MEMGES_FILE 1
   34 #include <stdio.h>
   35 
   36 /**************************************************************
   37        CacheRead : read a value with a cache
   38    ***************************************************************/
   39 inline int CacheRead ( void *position )
   40 {
   41     return *((int *)position);
   42 }
   43 
   44 /**************************************************************
   45        CacheAddrRead : read an address of a value in a cache
   46    ***************************************************************/
   47 inline char *CacheAddrRead ( void *position )
   48 {
   49     return (char *)position ;
   50 }
   51 
   52 inline char *CacheAddrReadM ( void *position )
   53 {
   54     return (char *)position ;
   55 }
   56 
   57 /**************************************************************
   58        CacheWrite : write a value with a cache
   59    ***************************************************************/
   60 inline void CacheWrite ( void *position, int value )
   61 {
   62     register int    *addr = (int *)position ;
   63     
   64     *addr = value ;
   65 }
   66 
   67 /**************************************************************
   68        LCacheRead : read a long value with a cache
   69    ***************************************************************/
   70 inline void *LCacheRead ( void *position )
   71 {
   72     return *((void **)position);
   73 }
   74 
   75 /**************************************************************
   76        LCacheWrite : write a value with a cache
   77    ***************************************************************/
   78 inline void LCacheWrite ( void **position, void *value )
   79 {
   80     *position = value ;
   81 }
   82 
   83 /**************************************************************
   84        CacheInit : init the cache manager
   85    ***************************************************************/
   86 inline void CacheInit () {}
   87 
   88 /**************************************************************
   89        CacheEnd : end the cache manager
   90    ***************************************************************/
   91 inline void CacheEnd () {}
   92 
   93 /**************************************************************
   94        CacheMalloc : malloc of a data with cache manager
   95    ***************************************************************/
   96 extern void MetaExit (int, const char *) ;
   97 
   98 inline long CacheMalloc ( int size )
   99 {
  100     long    ret ;
  101     
  102     if ( ret = (long)malloc(size) ) 
  103         return ret ;
  104     else {
  105         MetaExit(3, "Allocation Error\n");
  106     }
  107     return 0 ;
  108 }
  109 
  110 /**************************************************************
  111        CacheFree : free of a data with cache manager
  112    ***************************************************************/
  113 inline void CacheFree ( void *position )
  114 {
  115     free((char *)position);
  116 }
  117 
  118 inline int CacheLockFree ()
  119 {
  120     return 0 ;
  121 }
  122 
  123 inline void CacheUnLockFree () {}
  124 #endif