diff --git a/mm/Makefile b/mm/Makefile index 03331ebd9ce..2aa90e5e439 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -48,10 +48,17 @@ else endif endif -# Core allocator logic +# Sources and paths ASRCS = -CSRCS = mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c +CSRCS = + +DEPPATH = --dep-path . +VPATH = . + +# Core allocator logic + +CSRCS += mm_initialize.c mm_sem.c mm_addfreechunk.c mm_size2ndx.c CSRCS += mm_shrinkchunk.c CSRCS += mm_brkaddr.c mm_calloc.c mm_extend.c mm_free.c mm_mallinfo.c CSRCS += mm_malloc.c mm_memalign.c mm_realloc.c mm_zalloc.c @@ -88,16 +95,7 @@ endif # An optional granule allocator -ifeq ($(CONFIG_GRAN),y) -CSRCS += mm_graninit.c mm_granreserve.c mm_granalloc.c mm_granmark.c -CSRCS += mm_granfree.c mm_grancritical.c - -# A page allocator based on the granule allocator - -ifeq ($(CONFIG_MM_PGALLOC),y) -CSRCS += mm_pgalloc.c -endif -endif +include mm_gran/Make.defs BINDIR ?= bin @@ -145,10 +143,10 @@ endif .depend: Makefile $(SRCS) ifeq ($(CONFIG_BUILD_PROTECTED),y) - $(Q) $(MKDEP) --obj-path ubin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_ubin.dep - $(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) $(KDEFINE) -- $(SRCS) >Make_kbin.dep + $(Q) $(MKDEP) --obj-path ubin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_ubin.dep + $(Q) $(MKDEP) --obj-path kbin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) $(KDEFINE) -- $(SRCS) >Make_kbin.dep else - $(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_bin.dep + $(Q) $(MKDEP) --obj-path bin --obj-suffix $(OBJEXT) $(DEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make_bin.dep endif $(Q) touch $@ diff --git a/mm/mm_gran/Make.defs b/mm/mm_gran/Make.defs new file mode 100644 index 00000000000..b561ac8da94 --- /dev/null +++ b/mm/mm_gran/Make.defs @@ -0,0 +1,52 @@ +############################################################################ +# mm/mm_gran/Make.defs +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +# An optional granule allocator + +ifeq ($(CONFIG_GRAN),y) +CSRCS += mm_graninit.c mm_granreserve.c mm_granalloc.c mm_granmark.c +CSRCS += mm_granfree.c mm_grancritical.c + +# A page allocator based on the granule allocator + +ifeq ($(CONFIG_MM_PGALLOC),y) +CSRCS += mm_pgalloc.c +endif + +# Add the granule directory to the build + +DEPPATH += --dep-path mm_gran +VPATH += :mm_gran +endif diff --git a/mm/mm_gran.h b/mm/mm_gran/mm_gran.h similarity index 97% rename from mm/mm_gran.h rename to mm/mm_gran/mm_gran.h index 8836a5b4295..2156f96efb1 100644 --- a/mm/mm_gran.h +++ b/mm/mm_gran/mm_gran.h @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_gran.h + * mm/mm_gran/mm_gran.h * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __MM_MM_GRAN_H -#define __MM_MM_GRAN_H +#ifndef __MM_MM_GRAN_MM_GRAHN_H +#define __MM_MM_GRAN_MM_GRAHN_H /**************************************************************************** * Included Files @@ -148,4 +148,4 @@ void gran_leave_critical(FAR struct gran_s *priv); void gran_mark_allocated(FAR struct gran_s *priv, uintptr_t alloc, unsigned int ngranules); -#endif /* __MM_MM_GRAN_H */ +#endif /* __MM_MM_GRAN_MM_GRAHN_H */ diff --git a/mm/mm_granalloc.c b/mm/mm_gran/mm_granalloc.c similarity index 99% rename from mm/mm_granalloc.c rename to mm/mm_gran/mm_granalloc.c index 6e6d375d1e8..cc4a9cb6d46 100644 --- a/mm/mm_granalloc.c +++ b/mm/mm_gran/mm_granalloc.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_granalloc.c + * mm/mm_gran/mm_granalloc.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -43,7 +43,7 @@ #include -#include "mm_gran.h" +#include "mm_gran/mm_gran.h" #ifdef CONFIG_GRAN diff --git a/mm/mm_grancritical.c b/mm/mm_gran/mm_grancritical.c similarity index 98% rename from mm/mm_grancritical.c rename to mm/mm_gran/mm_grancritical.c index 190aa3e7d4f..04d2de35c1a 100644 --- a/mm/mm_grancritical.c +++ b/mm/mm_gran/mm_grancritical.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_grancritical.c + * mm/mm_gran/mm_grancritical.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -46,7 +46,7 @@ #include #include -#include "mm_gran.h" +#include "mm_gran/mm_gran.h" #ifdef CONFIG_GRAN diff --git a/mm/mm_granfree.c b/mm/mm_gran/mm_granfree.c similarity index 98% rename from mm/mm_granfree.c rename to mm/mm_gran/mm_granfree.c index fcab11af989..707dbaa2da1 100644 --- a/mm/mm_granfree.c +++ b/mm/mm_gran/mm_granfree.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_granfree.c + * mm/mm_gran/mm_granfree.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -43,7 +43,7 @@ #include -#include "mm_gran.h" +#include "mm_gran/mm_gran.h" #ifdef CONFIG_GRAN diff --git a/mm/mm_graninit.c b/mm/mm_gran/mm_graninit.c similarity index 99% rename from mm/mm_graninit.c rename to mm/mm_gran/mm_graninit.c index 53c5723286e..1dc31911409 100644 --- a/mm/mm_graninit.c +++ b/mm/mm_gran/mm_graninit.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_graninit.c + * mm/mm_gran/mm_graninit.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -45,7 +45,7 @@ #include #include -#include "mm_gran.h" +#include "mm_gran/mm_gran.h" #ifdef CONFIG_GRAN diff --git a/mm/mm_granmark.c b/mm/mm_gran/mm_granmark.c similarity index 98% rename from mm/mm_granmark.c rename to mm/mm_gran/mm_granmark.c index a2c9e9054ec..805dbc1dad0 100644 --- a/mm/mm_granmark.c +++ b/mm/mm_gran/mm_granmark.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_granmark.c + * mm/mm_gran/mm_granmark.c * * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -43,7 +43,7 @@ #include -#include "mm_gran.h" +#include "mm_gran/mm_gran.h" #ifdef CONFIG_GRAN diff --git a/mm/mm_granreserve.c b/mm/mm_gran/mm_granreserve.c similarity index 98% rename from mm/mm_granreserve.c rename to mm/mm_gran/mm_granreserve.c index da2a4a38e47..bf73671c3ba 100644 --- a/mm/mm_granreserve.c +++ b/mm/mm_gran/mm_granreserve.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_granreserve.c + * mm/mm_gran/mm_granreserve.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -43,7 +43,7 @@ #include -#include "mm_gran.h" +#include "mm_gran/mm_gran.h" #ifdef CONFIG_GRAN diff --git a/mm/mm_pgalloc.c b/mm/mm_gran/mm_pgalloc.c similarity index 99% rename from mm/mm_pgalloc.c rename to mm/mm_gran/mm_pgalloc.c index 403e1fd2f0b..67e8653f431 100644 --- a/mm/mm_pgalloc.c +++ b/mm/mm_gran/mm_pgalloc.c @@ -1,5 +1,5 @@ /**************************************************************************** - * mm/mm_pgalloc.c + * mm/mm_gran/mm_pgalloc.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -44,7 +44,7 @@ #include #include -#include "mm_gran.h" +#include "mm_gran/mm_gran.h" #ifdef CONFIG_MM_PGALLOC