diff --git a/arch/Kconfig b/arch/Kconfig index 188a9ff278..e569655683 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -139,6 +139,13 @@ config ARCH_TOOLCHAIN_GNU bool default n +config ARCH_GNU_NO_WEAKFUNCTIONS + bool + depends on ARCH_TOOLCHAIN_GNU + default n + ---help--- + Disable support for weak functions. + comment "Architecture Options" config ARCH_NOINTC @@ -222,6 +229,10 @@ config ARCH_HAVE_RTC_SUBSECONDS bool default n +config ARCH_HAVE_GARBAGE + bool + default n + config ARCH_GLOBAL_IRQDISABLE bool default n diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 0fe9e6516c..bf8ba19f2d 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/arch.h * - * Copyright (C) 2007-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -732,7 +732,26 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages); #endif /**************************************************************************** - * Name: up_setpicbase, up_getpicbase + * Name: up_sched_have_garbage and up_sched_garbage_collection + * + * Description: + * Some architectures may soft unique memory allocators. If + * CONFIG_ARCH_HAVE_GARBAGE is defined, those architectures must provide + * both up_sched_have_garbage and up_sched_garbage_collection. These will + * be tied into the NuttX memory garbage collection logic. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_HAVE_GARBAGE +bool up_sched_have_garbage(void); +void up_sched_garbage_collection(void); +#else +# define up_sched_have_garbage() false +# define up_sched_garbage_collection() +#endif + +/**************************************************************************** + * Name: up_setpicbase and up_getpicbase * * Description: * It NXFLAT external modules (or any other binary format that requires) diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index fba7aeb5f6..7cb9054f51 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -93,7 +93,7 @@ * unnecessary "weak" functions can be excluded from the link. */ -# ifndef __CYGWIN__ +# if !defined(__CYGWIN__) && !defined(CONFIG_ARCH_GNU_NO_WEAKFUNCTIONS) # define CONFIG_HAVE_WEAKFUNCTIONS 1 # define weak_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); diff --git a/include/nuttx/kmalloc.h b/include/nuttx/kmalloc.h index 4809b849ab..31cdecbcb7 100644 --- a/include/nuttx/kmalloc.h +++ b/include/nuttx/kmalloc.h @@ -1,7 +1,8 @@ /**************************************************************************** * include/nuttx/kmalloc.h * - * Copyright (C) 2007-2008, 2011, 2013, 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2008, 2011, 2013, 2016, 2018 Gregory Nutt. All + * rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -203,6 +204,10 @@ void sched_kfree(FAR void *address); # define sched_kfree(a) sched_ufree(a) #endif +/* Signal the worker thread that is has some clean up to do */ + +void sched_signal_free(void); + /* Functions defined in sched/sched_garbage *********************************/ /* Must be called periodically to clean up deallocations delayed by diff --git a/sched/sched/sched_free.c b/sched/sched/sched_free.c index bc02ff89b8..22934a2355 100644 --- a/sched/sched/sched_free.c +++ b/sched/sched/sched_free.c @@ -1,7 +1,8 @@ /**************************************************************************** * sched/sched/sched_free.c * - * Copyright (C) 2007, 2009, 2012-2013, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2012-2013, 2015-2016, 2018 Gregory Nutt. All + * rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -105,9 +106,7 @@ void sched_ufree(FAR void *address) /* Signal the worker thread that is has some clean up to do */ -#ifdef CONFIG_SCHED_WORKQUEUE - work_signal(LPWORK); -#endif + sched_signal_free(); leave_critical_section(flags); } else @@ -146,9 +145,7 @@ void sched_kfree(FAR void *address) /* Signal the worker thread that is has some clean up to do */ -#ifdef CONFIG_SCHED_WORKQUEUE - work_signal(LPWORK); -#endif + sched_signal_free(); leave_critical_section(flags); } else @@ -160,3 +157,20 @@ void sched_kfree(FAR void *address) } } #endif + +/**************************************************************************** + * Name: sched_signal_free + * + * Description: + * Signal the worker thread that is has some clean up to do. + * + ****************************************************************************/ + +void sched_signal_free(void) +{ +#ifdef CONFIG_SCHED_WORKQUEUE + /* Signal the worker thread that is has some clean up to do */ + + work_signal(LPWORK); +#endif +} diff --git a/sched/sched/sched_garbage.c b/sched/sched/sched_garbage.c index a5fce0c8d0..68248516c1 100644 --- a/sched/sched/sched_garbage.c +++ b/sched/sched/sched_garbage.c @@ -237,6 +237,10 @@ void sched_garbage_collection(void) /* Handle deferred deallocations for the user heap */ sched_kucleanup(); + + /* Handle the architecure-specific garbage collection */ + + up_sched_garbage_collection(); } /**************************************************************************** @@ -264,5 +268,6 @@ void sched_garbage_collection(void) bool sched_have_garbage(void) { - return (sched_have_kgarbage() || sched_have_kugarbage()); + return (sched_have_kgarbage() || sched_have_kugarbage() || + up_sched_have_garbage()); }