mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Masaki Muranaka <monaka@monami-ya.jp>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] Refactor malloc.h.
Date: Wed, 5 Jun 2013 08:38:15 +0200	[thread overview]
Message-ID: <20130605063815.GM32299@pengutronix.de> (raw)
In-Reply-To: <1370349512-75630-2-git-send-email-monaka@monami-ya.jp>

On Tue, Jun 04, 2013 at 09:38:31PM +0900, Masaki Muranaka wrote:
> From: Masaki Muranaka <monaka@monami-ya.com>
> 
>  Some functions should be defined in stdlib.h or unistd.h.
> 
> Signed-off-by: Masaki Muranaka <monaka@monami-ya.jp>
> ---
>  include/malloc.h       |  8 +++-----
>  include/malloc_isoc.h  | 11 +++++++++++
>  include/malloc_posix.h |  8 ++++++++
>  include/stdlib.h       |  1 +
>  include/unistd.h       |  6 ++++++
>  5 files changed, 29 insertions(+), 5 deletions(-)
>  create mode 100644 include/malloc_isoc.h
>  create mode 100644 include/malloc_posix.h
>  create mode 100644 include/unistd.h
> 
> diff --git a/include/malloc.h b/include/malloc.h
> index 7b9b062..9554597 100644
> --- a/include/malloc.h
> +++ b/include/malloc.h
> @@ -5,20 +5,18 @@
>  
>  /* Public routines */
>  
> -void* malloc(size_t);
> -void free(void*);
> -void* realloc(void*, size_t);
> +#include <malloc_isoc.h>
> +#include <malloc_posix.h>
> +
>  void* memalign(size_t, size_t);
>  void* vallocc(size_t);
>  void* pvalloc(size_t);
> -void* calloc(size_t, size_t);
>  void cfree(void*);
>  int malloc_trim(size_t);
>  size_t malloc_usable_size(void*);
>  void malloc_stats(void);
>  int mallopt(int, int);
>  struct mallinfo mallinfo(void);
> -void *sbrk(ptrdiff_t increment);
>  
>  #endif
>  
> diff --git a/include/malloc_isoc.h b/include/malloc_isoc.h
> new file mode 100644
> index 0000000..728cdd9
> --- /dev/null
> +++ b/include/malloc_isoc.h
> @@ -0,0 +1,11 @@
> +#ifndef BAREBOX_MALLOC_ISOC_H__
> +#define BAREBOX_MALLOC_ISOC_H__
> +
> +#include <types.h>
> +
> +void* malloc(size_t);
> +void free(void*);
> +void* realloc(void*, size_t);
> +void* calloc(size_t, size_t);
> +
> +#endif /* BAREBOX_MALLOC_ISOC_H__ */

I think you can just add these to stdlib.h...

> diff --git a/include/malloc_posix.h b/include/malloc_posix.h
> new file mode 100644
> index 0000000..d10675d
> --- /dev/null
> +++ b/include/malloc_posix.h
> @@ -0,0 +1,8 @@
> +#ifndef BAREBOX_MALLOC_POSIX_H__
> +#define BAREBOX_MALLOC_POSIX_H__
> +
> +#include <types.h>
> +
> +void *sbrk(ptrdiff_t increment);
> +
> +#endif /* BAREBOX_MALLOC_POSIX_H__ */

...and this to unistd.h without introducing extra files.

You're right that in barebox it's often not clear whether some code
belongs to 'kernel' or 'userspace', but in the end it doesn't make
much difference. It's good to have standard functions in their
standard include/ locations.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-06-05  6:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-04 12:38 [PATCH 1/3] Remove unnesessory malloc.h inclusions Masaki Muranaka
2013-06-04 12:38 ` [PATCH 2/3] Refactor malloc.h Masaki Muranaka
2013-06-05  6:38   ` Sascha Hauer [this message]
2013-06-04 12:38 ` [PATCH 3/3] Use stdlib.h instead of malloc.h Masaki Muranaka
2013-06-05  6:34 ` [PATCH 1/3] Remove unnesessory malloc.h inclusions Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2013-06-02 14:53 Masaki Muranaka
2013-06-02 14:53 ` [PATCH 2/3] Refactor malloc.h Masaki Muranaka
2013-06-03  7:26   ` Sascha Hauer
2013-06-03  8:02     ` Masaki Muranaka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130605063815.GM32299@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=monaka@monami-ya.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox