Removed ACE_HAS_BSTRING, not used
[ACE_TAO.git] / ACE / ace / Sbrk_Memory_Pool.cpp
blob45dd167ac6bba0c4d1eab5518d0ec589b92d621b
1 #include "ace/OS_NS_unistd.h"
2 #include "ace/Sbrk_Memory_Pool.h"
3 #include "ace/Log_Category.h"
4 #include "ace/Malloc_Base.h"
7 #if !defined (ACE_LACKS_SBRK)
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 ACE_ALLOC_HOOK_DEFINE(ACE_Sbrk_Memory_Pool)
13 // Ask system for more local memory via sbrk(2).
15 void *
16 ACE_Sbrk_Memory_Pool::acquire (size_t nbytes,
17 size_t &rounded_bytes)
19 ACE_TRACE ("ACE_Sbrk_Memory_Pool::acquire");
20 rounded_bytes = this->round_up (nbytes);
21 // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquiring more chunks, nbytes = %d, rounded_bytes = %d\n"), nbytes, rounded_bytes));
22 void *cp = ACE_OS::sbrk (rounded_bytes);
24 if (cp == MAP_FAILED)
25 ACELIB_ERROR_RETURN ((LM_ERROR,
26 "(%P|%t) cp = %u\n",
27 cp),
28 0);
29 else
30 // ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) acquired more chunks, nbytes = %d, rounded_bytes = %d, new break = %u\n"), nbytes, rounded_bytes, cp));
31 return cp;
34 /* No-op for now... */
36 int
37 ACE_Sbrk_Memory_Pool::release (int)
39 ACE_TRACE ("ACE_Sbrk_Memory_Pool::release");
40 return 0;
43 int
44 ACE_Sbrk_Memory_Pool::sync (ssize_t, int)
46 ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
47 return 0;
50 int
51 ACE_Sbrk_Memory_Pool::sync (void *, size_t, int)
53 ACE_TRACE ("ACE_Sbrk_Memory_Pool::sync");
54 return 0;
57 int
58 ACE_Sbrk_Memory_Pool::protect (ssize_t, int)
60 ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
61 return 0;
64 int
65 ACE_Sbrk_Memory_Pool::protect (void *, size_t, int)
67 ACE_TRACE ("ACE_Sbrk_Memory_Pool::protect");
68 return 0;
71 // Ask system for initial chunk of local memory.
73 void *
74 ACE_Sbrk_Memory_Pool::init_acquire (size_t nbytes,
75 size_t &rounded_bytes,
76 int &first_time)
78 ACE_TRACE ("ACE_Sbrk_Memory_Pool::init_acquire");
79 // Note that we assume that when ACE_Sbrk_Memory_Pool is used,
80 // ACE_Malloc's constructor will only get called once. If this
81 // assumption doesn't hold, we are in deep trouble!
83 first_time = 1;
84 return this->acquire (nbytes, rounded_bytes);
87 void
88 ACE_Sbrk_Memory_Pool::dump (void) const
90 #if defined (ACE_HAS_DUMP)
91 ACE_TRACE ("ACE_Sbrk_Memory_Pool::dump");
92 #endif /* ACE_HAS_DUMP */
95 ACE_Sbrk_Memory_Pool::ACE_Sbrk_Memory_Pool (const ACE_TCHAR *,
96 const OPTIONS *)
98 ACE_TRACE ("ACE_Sbrk_Memory_Pool::ACE_Sbrk_Memory_Pool");
101 ACE_Sbrk_Memory_Pool::~ACE_Sbrk_Memory_Pool (void)
105 void *
106 ACE_Sbrk_Memory_Pool::base_addr (void) const
108 return 0;
111 // Round up the request to a multiple of the page size.
113 size_t
114 ACE_Sbrk_Memory_Pool::round_up (size_t nbytes)
116 ACE_TRACE ("ACE_Sbrk_Memory_Pool::round_up");
117 return ACE::round_to_pagesize (nbytes);
120 ACE_END_VERSIONED_NAMESPACE_DECL
122 #endif /* !ACE_LACKS_SBRK */