2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Tell how much memory is available.
9 #include <exec/alerts.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <aros/macros.h>
13 #include <exec/memory.h>
14 #include <exec/memheaderext.h>
15 #include <proto/exec.h>
17 #include "exec_intern.h"
18 #include "exec_util.h"
22 /*****************************************************************************
26 AROS_LH1(IPTR
, AvailMem
,
29 AROS_LHA(ULONG
, attributes
, D1
),
32 struct ExecBase
*, SysBase
, 36, Exec
)
35 Return either the total available memory or the largest available
36 chunk of a given type of memory.
39 attributes - The same attributes you would give to AllocMem().
42 Either the total of the available memory or the largest chunk if
43 MEMF_LARGEST is set in the attributes.
46 Due to the nature of multitasking the returned value may already
47 be obsolete when this function returns.
50 Print the total available memory.
52 printf("Free memory: %lu bytes\n", AvailMem(0));
54 Print the size of the largest chunk of chip memory.
56 printf("Largest chipmem chunk: %lu bytes\n",
57 AvailMem(MEMF_CHIP | MEMF_LARGEST));
65 ******************************************************************************/
70 struct TraceLocation tp
= CURRENT_LOCATION("AvailMem");
72 ret
= nommu_AvailMem(attributes
, SysBase
);
74 if (attributes
& MEMF_CLEAR
)
75 MungWall_Scan(NULL
, &tp
, SysBase
);