allow building bcm2708 support files into their own package
[AROS.git] / rom / exec / allocentry.c
blobe94694d5a5f5fd96e0290ba49fbf750a76fd6bd0
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Allocate memory.
6 Lang: english
7 */
8 #include <aros/config.h>
9 #include "exec_intern.h"
10 #include <aros/libcall.h>
11 #include <exec/memory.h>
12 #include <proto/exec.h>
14 #include "exec_debug.h"
15 #ifndef DEBUG_AllocEntry
16 # define DEBUG_AllocEntry 0
17 #endif
18 #undef DEBUG
19 #if DEBUG_AllocEntry
20 # define DEBUG 1
21 #endif
22 #include <aros/debug.h>
23 #undef kprintf
25 /*****************************************************************************
27 NAME */
29 AROS_LH1(struct MemList *, AllocEntry,
31 /* SYNOPSIS */
32 AROS_LHA(struct MemList *, entry, A0),
34 /* LOCATION */
35 struct ExecBase *, SysBase, 37, Exec)
37 /* FUNCTION
38 Allocate a number of memory blocks through a MemList structure.
40 INPUTS
41 entry - The MemList with one MemEntry for each block you want to get
43 RESULT
44 The allocation was successful if the most significant bit of the
45 result is 0. The result then contains a pointer to a copy of
46 the MemList structure with the me_Addr fields filled.
47 If the most significant bit is set the result contains the type of
48 memory that couldn't be allocated.
50 NOTES
52 EXAMPLE
54 BUGS
56 SEE ALSO
57 FreeEntry()
59 INTERNALS
61 ******************************************************************************/
63 AROS_LIBFUNC_INIT
65 struct MemList *ret;
66 ULONG ret_flags;
68 ret = NewAllocEntry(entry, &ret_flags);
69 if (ret)
71 /* Check nasty case where the returncode is misleading :-(
72 Like when memory was allocated at address 0x8???????. And
73 0x80000000 flag is at the same time used to indicate allocentry
74 failure! */
76 if(!AROS_CHECK_ALLOCENTRY(ret))
78 FreeEntry(ret);
79 ret = AROS_ALLOCENTRY_FAILED(MEMF_PUBLIC);
82 else
84 ret = AROS_ALLOCENTRY_FAILED(ret_flags);
87 return ret;
89 AROS_LIBFUNC_EXIT
90 } /* AllocEntry */