From 4291a0564fcec8e5162657b4b2802aa6d6a8f258 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Tue, 30 Sep 2008 14:09:00 +0000 Subject: [PATCH] - The memory allocated by malloc() and friends is now of type MEMF_PRIVATE under OS4 and beyond. The AmigaOS 2.x/3.x compatible code will still use MEMF_ANY in the same situation, though. Other uses of MEMF_ANY have been replaced as well where MEMF_PRIVATE would have made better sense. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15201 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/amiga_argarrayinit.c | 12 ++++++++++-- library/changes | 5 +++++ library/stdlib_main.c | 14 ++++++++++++-- library/stdlib_malloc.c | 18 +++++++++++++++--- library/stdlib_program_name.c | 12 ++++++++++-- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/library/amiga_argarrayinit.c b/library/amiga_argarrayinit.c index 1b3bae3..55bd5ee 100644 --- a/library/amiga_argarrayinit.c +++ b/library/amiga_argarrayinit.c @@ -1,5 +1,5 @@ /* - * $Id: amiga_argarrayinit.c,v 1.6 2006-09-22 09:02:51 obarthel Exp $ + * $Id: amiga_argarrayinit.c,v 1.7 2008-09-30 14:09:00 obarthel Exp $ * * :ts=4 * @@ -52,6 +52,14 @@ /****************************************************************************/ +#ifdef __amigaos4__ +#define MEMORY_TYPE MEMF_PRIVATE +#else +#define MEMORY_TYPE MEMF_ANY +#endif /* __amigaos4__ */ + +/****************************************************************************/ + const unsigned char ** CXLIB_argarray; struct DiskObject * CXLIB_disko; @@ -70,7 +78,7 @@ ArgArrayInit(LONG argc, CONST_STRPTR * argv) if(argc == 1) goto out; /* skip command name */ - CXLIB_argarray = (const unsigned char **)AllocVec(sizeof(char *) * argc,MEMF_ANY|MEMF_CLEAR); + CXLIB_argarray = (const unsigned char **)AllocVec(sizeof(char *) * argc,MEMORY_TYPE|MEMF_CLEAR); if(CXLIB_argarray == NULL) goto out; diff --git a/library/changes b/library/changes index 9037cd4..361f996 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,8 @@ +- The memory allocated by malloc() and friends is now of type MEMF_PRIVATE + under OS4 and beyond. The AmigaOS 2.x/3.x compatible code will still + use MEMF_ANY in the same situation, though. Other uses of MEMF_ANY have + been replaced as well where MEMF_PRIVATE would have made better sense. + - I/O buffers allocated are now aligned according to the CPU cache line size, if the operating system can supply that detailed information. diff --git a/library/stdlib_main.c b/library/stdlib_main.c index 692ba7b..b61ff48 100644 --- a/library/stdlib_main.c +++ b/library/stdlib_main.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_main.c,v 1.33 2006-09-25 14:51:15 obarthel Exp $ + * $Id: stdlib_main.c,v 1.34 2008-09-30 14:09:00 obarthel Exp $ * * :ts=4 * @@ -61,6 +61,16 @@ /****************************************************************************/ +/* On OS4 memory of type MEMF_ANY may not be paged out. Where this is desirable + MEMF_PRIVATE should be used instead. */ +#ifdef __amigaos4__ +#define MEMORY_TYPE MEMF_PRIVATE +#else +#define MEMORY_TYPE MEMF_ANY +#endif /* __amigaos4__ */ + +/****************************************************************************/ + extern int main(int arg_c,char ** arg_v); /****************************************************************************/ @@ -107,7 +117,7 @@ call_main(void) struct Process * this_process = (struct Process *)FindTask(NULL); UBYTE * arg_str = GetArgStr(); size_t arg_str_len = strlen(arg_str); - UBYTE * arg_str_copy = AllocVec(arg_str_len+1,MEMF_ANY); + UBYTE * arg_str_copy = AllocVec(arg_str_len+1,MEMF_PRIVATE); UBYTE current_dir_name[256]; if(arg_str_copy != NULL && NameFromLock(this_process->pr_CurrentDir,current_dir_name,sizeof(current_dir_name))) diff --git a/library/stdlib_malloc.c b/library/stdlib_malloc.c index 3ea2ee4..5ff9b9b 100644 --- a/library/stdlib_malloc.c +++ b/library/stdlib_malloc.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_malloc.c,v 1.19 2006-01-08 12:04:25 obarthel Exp $ + * $Id: stdlib_malloc.c,v 1.20 2008-09-30 14:09:00 obarthel Exp $ * * :ts=4 * @@ -143,9 +143,21 @@ __allocate_memory(size_t size,BOOL never_free,const char * UNUSED unused_file,in #endif /* __MEM_DEBUG */ if(__memory_pool != NULL) + { mn = AllocPooled(__memory_pool,allocation_size); + } else - mn = AllocMem(allocation_size,MEMF_ANY); + { + #if defined(__amigaos4__) + { + mn = AllocMem(allocation_size,MEMF_PRIVATE); + } + #else + { + mn = AllocMem(allocation_size,MEMF_ANY); + } + #endif /* __amigaos4__ */ + } if(mn == NULL) { @@ -401,7 +413,7 @@ STDLIB_CONSTRUCTOR(stdlib_memory_init) #if defined(__amigaos4__) { - __memory_pool = CreatePool(MEMF_ANY,(ULONG)__default_pool_size,(ULONG)__default_puddle_size); + __memory_pool = CreatePool(MEMF_PRIVATE,(ULONG)__default_pool_size,(ULONG)__default_puddle_size); } #else { diff --git a/library/stdlib_program_name.c b/library/stdlib_program_name.c index c69eba6..58afd68 100755 --- a/library/stdlib_program_name.c +++ b/library/stdlib_program_name.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_program_name.c,v 1.2 2006-01-08 12:04:26 obarthel Exp $ + * $Id: stdlib_program_name.c,v 1.3 2008-09-30 14:09:00 obarthel Exp $ * * :ts=4 * @@ -49,6 +49,14 @@ /****************************************************************************/ +#ifdef __amigaos4__ +#define MEMORY_TYPE MEMF_PRIVATE +#else +#define MEMORY_TYPE MEMF_ANY +#endif /* __amigaos4__ */ + +/****************************************************************************/ + static BOOL free_program_name; /****************************************************************************/ @@ -83,7 +91,7 @@ STDLIB_CONSTRUCTOR(stdlib_program_name_init) const size_t program_name_size = 256; /* Make a copy of the current command name string. */ - __program_name = AllocVec((ULONG)program_name_size,MEMF_ANY); + __program_name = AllocVec((ULONG)program_name_size,MEMORY_TYPE); if(__program_name == NULL) goto out;