home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / exec / typeofmem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  1.8 KB  |  89 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: typeofmem.c,v 1.5 1996/10/24 15:50:58 aros Exp $
  4.     $Log: typeofmem.c,v $
  5.     Revision 1.5  1996/10/24 15:50:58  aros
  6.     Use the official AROS macros over the __AROS versions.
  7.  
  8.     Revision 1.4  1996/08/13 13:56:09  digulla
  9.     Replaced AROS_LA by AROS_LHA
  10.     Replaced some AROS_LH*I by AROS_LH*
  11.     Sorted and added includes
  12.  
  13.     Revision 1.3  1996/08/01 17:41:21  digulla
  14.     Added standard header for all files
  15.  
  16.     Desc:
  17.     Lang: english
  18. */
  19. #include <exec/memory.h>
  20. #include <exec/execbase.h>
  21. #include <aros/libcall.h>
  22.  
  23. /*****************************************************************************
  24.  
  25.     NAME */
  26.     #include <clib/exec_protos.h>
  27.  
  28.     AROS_LH1(ULONG, TypeOfMem,
  29.  
  30. /*  SYNOPSIS */
  31.     AROS_LHA(APTR, address, A1),
  32.  
  33. /*  LOCATION */
  34.     struct ExecBase *, SysBase, 89, Exec)
  35.  
  36. /*  FUNCTION
  37.     Return type of memory at a given address or 0 if there is no memory
  38.     there.
  39.  
  40.     INPUTS
  41.     address - Address to test
  42.  
  43.     RESULT
  44.     The memory flags you would give to AllocMem().
  45.  
  46.     NOTES
  47.  
  48.     EXAMPLE
  49.  
  50.     BUGS
  51.  
  52.     SEE ALSO
  53.  
  54.     INTERNALS
  55.  
  56.     HISTORY
  57.     18-10-95    Created by M. Fleischer
  58.  
  59. ******************************************************************************/
  60. {
  61.     AROS_LIBFUNC_INIT
  62.  
  63.     ULONG ret=0;
  64.     struct MemHeader *mh;
  65.  
  66.     /* Nobody should change the memory list now. */
  67.     Forbid();
  68.  
  69.     /* Follow the list of MemHeaders */
  70.     mh=(struct MemHeader *)SysBase->MemList.lh_Head;
  71.     while(mh->mh_Node.ln_Succ!=NULL)
  72.     {
  73.     /* Check if this MemHeader fits */
  74.     if(address>=mh->mh_Lower&&address<mh->mh_Upper)
  75.     {
  76.         /* Yes. Prepare returncode */
  77.         ret=mh->mh_Attributes;
  78.         break;
  79.     }
  80.     /* Go to next MemHeader */
  81.     mh=(struct MemHeader *)mh->mh_Node.ln_Succ;
  82.     }
  83.     /* Allow Taskswitches and return */
  84.     Permit();
  85.     return ret;
  86.     AROS_LIBFUNC_EXIT
  87. } /* TypeOfMem */
  88.  
  89.