1 /***************************************************************************
3 TheBar.mcc - Next Generation Toolbar MUI Custom Class
4 Copyright (C) 2003-2005 Alfonso Ranieri
5 Copyright (C) 2005-2013 by TheBar.mcc Open Source Team
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 TheBar class Support Site: http://www.sf.net/projects/thebar
21 ***************************************************************************/
25 /***********************************************************************/
28 // Calls parent NEW method within a subclass
29 #if !defined(__MORPHOS__)
31 Object
* VARARGS68K
DoSuperNew(struct IClass
*cl
, Object
*obj
, Tag tag1
, ...)
33 AROS_SLOWSTACKTAGS_PRE_AS(tag1
, Object
*)
34 retval
= (Object
*)DoSuperMethod(cl
, obj
, OM_NEW
, AROS_SLOWSTACKTAGS_ARG(tag1
), NULL
);
35 AROS_SLOWSTACKTAGS_POST
38 Object
* VARARGS68K
DoSuperNew(struct IClass
*cl
, Object
*obj
, ...)
44 rc
= (Object
*)DoSuperMethod(cl
, obj
, OM_NEW
, VA_ARG(args
, ULONG
), NULL
);
52 /***********************************************************************/
53 static APTR sharedPool
;
54 #if !defined(__amigaos4__) && !defined(__MORPHOS__)
55 static struct SignalSemaphore sharedPoolSema
;
58 BOOL
CreateSharedPool(void)
64 #if defined(__amigaos4__)
65 sharedPool
= AllocSysObjectTags(ASOT_MEMPOOL
, ASOPOOL_MFlags
, MEMF_SHARED
,
67 ASOPOOL_Threshold
, 1024,
69 ASOPOOL_Name
, "TheBarVirt.mcc shared pool",
71 ASOPOOL_Name
, "TheBar.mcc shared pool",
73 ASOPOOL_Protected
, TRUE
,
74 ASOPOOL_LockMem
, FALSE
,
76 #elif defined(__MORPHOS__)
77 sharedPool
= CreatePool(MEMF_SEM_PROTECTED
, 2048, 1024);
79 sharedPool
= CreatePool(MEMF_ANY
, 2048, 1024);
80 memset(&sharedPoolSema
, 0, sizeof(sharedPoolSema
));
81 InitSemaphore(&sharedPoolSema
);
84 if(sharedPool
!= NULL
)
91 void DeleteSharedPool(void)
95 if(sharedPool
!= NULL
)
97 #if defined(__amigaos4__)
98 FreeSysObject(ASOT_MEMPOOL
, sharedPool
);
100 DeletePool(sharedPool
);
107 APTR
SharedAlloc(ULONG size
)
113 #if defined(__amigaos4__) || defined(__MORPHOS__)
114 mem
= AllocVecPooled(sharedPool
, size
);
115 #else // __amigaos4__ || __MORPHOS__
116 size
+= sizeof(ULONG
);
118 ObtainSemaphore(&sharedPoolSema
);
120 if((mem
= AllocPooled(sharedPool
, size
)) != NULL
)
123 ReleaseSemaphore(&sharedPoolSema
);
124 #endif // __amigaos4__ || __MORPHOS__
130 /****************************************************************************/
132 void SharedFree(APTR mem
)
138 #if defined(__amigaos4__) || defined(__MORPHOS__)
139 FreeVecPooled(sharedPool
, mem
);
140 #else // __amigaos4__ || __MORPHOS__
141 ULONG
*_mem
= (ULONG
*)mem
;
143 ObtainSemaphore(&sharedPoolSema
);
145 FreePooled(sharedPool
, &_mem
[-1], _mem
[-1]);
147 ReleaseSemaphore(&sharedPoolSema
);
148 #endif // __amigaos4__ || __MORPHOS__
154 /****************************************************************************/