mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] Remove unnesessory malloc.h inclusions.
@ 2013-06-04 12:38 Masaki Muranaka
  2013-06-04 12:38 ` [PATCH 2/3] Refactor malloc.h Masaki Muranaka
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Masaki Muranaka @ 2013-06-04 12:38 UTC (permalink / raw)
  To: barebox

Signed-off-by: Masaki Muranaka <monaka@monami-ya.jp>
---
 commands/barebox-update.c | 1 -
 commands/bootm.c          | 1 -
 commands/cat.c            | 1 -
 commands/cp.c             | 1 -
 commands/crc.c            | 1 -
 commands/dfu.c            | 1 -
 commands/edit.c           | 1 -
 commands/exec.c           | 1 -
 commands/global.c         | 1 -
 commands/i2c.c            | 1 -
 commands/insmod.c         | 1 -
 commands/let.c            | 1 -
 commands/linux16.c        | 1 -
 commands/loadxy.c         | 1 -
 commands/ls.c             | 1 -
 commands/md.c             | 1 -
 commands/memcmp.c         | 1 -
 commands/memcpy.c         | 1 -
 commands/meminfo.c        | 1 -
 commands/memset.c         | 1 -
 commands/miitool.c        | 1 -
 commands/mm.c             | 1 -
 commands/mw.c             | 1 -
 commands/nand.c           | 1 -
 commands/nandtest.c       | 1 -
 commands/of_node.c        | 1 -
 commands/oftree.c         | 1 -
 commands/partition.c      | 1 -
 commands/readline.c       | 1 -
 commands/readlink.c       | 1 -
 commands/spi.c            | 1 -
 commands/splash.c         | 1 -
 commands/time.c           | 1 -
 commands/ubiformat.c      | 1 -
 commands/uimage.c         | 1 -
 commands/usbserial.c      | 1 -
 common/console.c          | 1 -
 common/image.c            | 1 -
 38 files changed, 38 deletions(-)

diff --git a/commands/barebox-update.c b/commands/barebox-update.c
index f550572..bb6e108 100644
--- a/commands/barebox-update.c
+++ b/commands/barebox-update.c
@@ -18,7 +18,6 @@
 #include <common.h>
 #include <command.h>
 #include <getopt.h>
-#include <malloc.h>
 #include <errno.h>
 #include <bbu.h>
 #include <fs.h>
diff --git a/commands/bootm.c b/commands/bootm.c
index 6ce2ca9..b47f6ec 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -24,7 +24,6 @@
 #include <driver.h>
 #include <command.h>
 #include <image.h>
-#include <malloc.h>
 #include <environment.h>
 #include <asm/byteorder.h>
 #include <xfuncs.h>
diff --git a/commands/cat.c b/commands/cat.c
index 1c112fc..476e1bb 100644
--- a/commands/cat.c
+++ b/commands/cat.c
@@ -27,7 +27,6 @@
 #include <linux/ctype.h>
 #include <errno.h>
 #include <xfuncs.h>
-#include <malloc.h>
 
 #define BUFSIZE 1024
 
diff --git a/commands/cp.c b/commands/cp.c
index 45f08d8..03369d9 100644
--- a/commands/cp.c
+++ b/commands/cp.c
@@ -27,7 +27,6 @@
 #include <linux/stat.h>
 #include <libbb.h>
 #include <fs.h>
-#include <malloc.h>
 #include <libgen.h>
 #include <getopt.h>
 
diff --git a/commands/crc.c b/commands/crc.c
index a0071b0..78b3eca 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -24,7 +24,6 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <xfuncs.h>
-#include <malloc.h>
 #include <linux/ctype.h>
 
 static int file_crc(char* filename, ulong start, ulong size, ulong *crc,
diff --git a/commands/dfu.c b/commands/dfu.c
index af6573a..b1e54b9 100644
--- a/commands/dfu.c
+++ b/commands/dfu.c
@@ -19,7 +19,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <fs.h>
 #include <xfuncs.h>
diff --git a/commands/edit.c b/commands/edit.c
index 295d0a7..8c72521 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -22,7 +22,6 @@
 
 #include <common.h>
 #include <command.h>
-#include <malloc.h>
 #include <fs.h>
 #include <linux/ctype.h>
 #include <fcntl.h>
diff --git a/commands/exec.c b/commands/exec.c
index bd7d54a..af08f2a 100644
--- a/commands/exec.c
+++ b/commands/exec.c
@@ -23,7 +23,6 @@
 #include <fcntl.h>
 #include <linux/stat.h>
 #include <errno.h>
-#include <malloc.h>
 #include <xfuncs.h>
 
 static int do_exec(int argc, char *argv[])
diff --git a/commands/global.c b/commands/global.c
index 427a231..e3e7a58 100644
--- a/commands/global.c
+++ b/commands/global.c
@@ -17,7 +17,6 @@
  *
  */
 #include <common.h>
-#include <malloc.h>
 #include <command.h>
 #include <globalvar.h>
 #include <environment.h>
diff --git a/commands/i2c.c b/commands/i2c.c
index 626255d..f3ec556 100644
--- a/commands/i2c.c
+++ b/commands/i2c.c
@@ -18,7 +18,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <i2c/i2c.h>
 
diff --git a/commands/insmod.c b/commands/insmod.c
index f547e9d..3a0dfbc 100644
--- a/commands/insmod.c
+++ b/commands/insmod.c
@@ -3,7 +3,6 @@
 #include <module.h>
 #include <errno.h>
 #include <fs.h>
-#include <malloc.h>
 
 static int do_insmod(int argc, char *argv[])
 {
diff --git a/commands/let.c b/commands/let.c
index 644ede5..cae6c97 100644
--- a/commands/let.c
+++ b/commands/let.c
@@ -20,7 +20,6 @@
 #include <environment.h>
 #include <errno.h>
 #include <init.h>
-#include <malloc.h>
 #include <xfuncs.h>
 #include <math.h>
 
diff --git a/commands/linux16.c b/commands/linux16.c
index 30fa2de..3ce49dc 100644
--- a/commands/linux16.c
+++ b/commands/linux16.c
@@ -25,7 +25,6 @@
 #include <fs.h>
 #include <errno.h>
 #include <getopt.h>
-#include <malloc.h>
 #include <boot.h>
 #include <asm/syslib.h>
 
diff --git a/commands/loadxy.c b/commands/loadxy.c
index 52ecdca..1059512 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -36,7 +36,6 @@
 #include <getopt.h>
 #include <fcntl.h>
 #include <fs.h>
-#include <malloc.h>
 
 #define DEF_FILE	"image.bin"
 
diff --git a/commands/ls.c b/commands/ls.c
index f2d9903..9aa8d41 100644
--- a/commands/ls.c
+++ b/commands/ls.c
@@ -22,7 +22,6 @@
 #include <fs.h>
 #include <linux/stat.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <stringlist.h>
 
diff --git a/commands/md.c b/commands/md.c
index 03c5905..46d17a5 100644
--- a/commands/md.c
+++ b/commands/md.c
@@ -25,7 +25,6 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/memcmp.c b/commands/memcmp.c
index 4a03862..ddb5dbf 100644
--- a/commands/memcmp.c
+++ b/commands/memcmp.c
@@ -25,7 +25,6 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/memcpy.c b/commands/memcpy.c
index 98f099f..939451e 100644
--- a/commands/memcpy.c
+++ b/commands/memcpy.c
@@ -25,7 +25,6 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/meminfo.c b/commands/meminfo.c
index 6e1e8c3..7b2019c 100644
--- a/commands/meminfo.c
+++ b/commands/meminfo.c
@@ -19,7 +19,6 @@
 #include <common.h>
 #include <command.h>
 #include <complete.h>
-#include <malloc.h>
 
 static int do_meminfo(int argc, char *argv[])
 {
diff --git a/commands/memset.c b/commands/memset.c
index 48e55bc..57bce5f 100644
--- a/commands/memset.c
+++ b/commands/memset.c
@@ -25,7 +25,6 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/miitool.c b/commands/miitool.c
index 3a9ac45..495a285 100644
--- a/commands/miitool.c
+++ b/commands/miitool.c
@@ -29,7 +29,6 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/mm.c b/commands/mm.c
index f51fd27..442f804 100644
--- a/commands/mm.c
+++ b/commands/mm.c
@@ -19,7 +19,6 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/mw.c b/commands/mw.c
index d7d73a8..01d08ff 100644
--- a/commands/mw.c
+++ b/commands/mw.c
@@ -25,7 +25,6 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/nand.c b/commands/nand.c
index 39fb64e..62b7405 100644
--- a/commands/nand.c
+++ b/commands/nand.c
@@ -19,7 +19,6 @@
 #include <fs.h>
 #include <linux/stat.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <xfuncs.h>
 #include <init.h>
diff --git a/commands/nandtest.c b/commands/nandtest.c
index ba15ecf..9f7cbff 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -15,7 +15,6 @@
 #include <command.h>
 #include <fs.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <ioctl.h>
 #include <linux/mtd/mtd-abi.h>
diff --git a/commands/of_node.c b/commands/of_node.c
index 0249d97..d9803e6 100644
--- a/commands/of_node.c
+++ b/commands/of_node.c
@@ -23,7 +23,6 @@
 #include <of.h>
 #include <command.h>
 #include <fs.h>
-#include <malloc.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
 #include <errno.h>
diff --git a/commands/oftree.c b/commands/oftree.c
index 468235a..f0f502a 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -29,7 +29,6 @@
 #include <of.h>
 #include <command.h>
 #include <fs.h>
-#include <malloc.h>
 #include <linux/ctype.h>
 #include <linux/err.h>
 #include <asm/byteorder.h>
diff --git a/commands/partition.c b/commands/partition.c
index fdd6041..01ce941 100644
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -31,7 +31,6 @@
 #include <command.h>
 #include <complete.h>
 #include <driver.h>
-#include <malloc.h>
 #include <partition.h>
 #include <errno.h>
 #include <xfuncs.h>
diff --git a/commands/readline.c b/commands/readline.c
index 60670fa..7d13ab2 100644
--- a/commands/readline.c
+++ b/commands/readline.c
@@ -19,7 +19,6 @@
 
 #include <common.h>
 #include <command.h>
-#include <malloc.h>
 #include <xfuncs.h>
 #include <environment.h>
 
diff --git a/commands/readlink.c b/commands/readlink.c
index d2671e0..8f16b31 100644
--- a/commands/readlink.c
+++ b/commands/readlink.c
@@ -25,7 +25,6 @@
 #include <libgen.h>
 #include <environment.h>
 #include <fs.h>
-#include <malloc.h>
 #include <getopt.h>
 
 static int do_readlink(int argc, char *argv[])
diff --git a/commands/spi.c b/commands/spi.c
index 2f6b430..c0da77b 100644
--- a/commands/spi.c
+++ b/commands/spi.c
@@ -8,7 +8,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <spi/spi.h>
 
diff --git a/commands/splash.c b/commands/splash.c
index 0955c01..d69c7b5 100644
--- a/commands/splash.c
+++ b/commands/splash.c
@@ -1,7 +1,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <fb.h>
 #include <gui/image_renderer.h>
diff --git a/commands/time.c b/commands/time.c
index 987c25e..b40bd59 100644
--- a/commands/time.c
+++ b/commands/time.c
@@ -2,7 +2,6 @@
 #include <command.h>
 #include <clock.h>
 #include <asm-generic/div64.h>
-#include <malloc.h>
 
 static int do_time(int argc, char *argv[])
 {
diff --git a/commands/ubiformat.c b/commands/ubiformat.c
index 121816f..d508119 100644
--- a/commands/ubiformat.c
+++ b/commands/ubiformat.c
@@ -37,7 +37,6 @@
 #include <crc.h>
 #include <stdlib.h>
 #include <clock.h>
-#include <malloc.h>
 #include <ioctl.h>
 #include <libbb.h>
 #include <linux/mtd/mtd.h>
diff --git a/commands/uimage.c b/commands/uimage.c
index 345e496..415347c 100644
--- a/commands/uimage.c
+++ b/commands/uimage.c
@@ -4,7 +4,6 @@
 #include <libbb.h>
 #include <fcntl.h>
 #include <fs.h>
-#include <malloc.h>
 #include <errno.h>
 #include <getopt.h>
 
diff --git a/commands/usbserial.c b/commands/usbserial.c
index a884a28..041d7f2 100644
--- a/commands/usbserial.c
+++ b/commands/usbserial.c
@@ -21,7 +21,6 @@
 #include <common.h>
 #include <command.h>
 #include <errno.h>
-#include <malloc.h>
 #include <getopt.h>
 #include <fs.h>
 #include <xfuncs.h>
diff --git a/common/console.c b/common/console.c
index a0a06f6..86aecbe 100644
--- a/common/console.c
+++ b/common/console.c
@@ -20,7 +20,6 @@
 #include <config.h>
 #include <common.h>
 #include <stdarg.h>
-#include <malloc.h>
 #include <param.h>
 #include <console.h>
 #include <driver.h>
diff --git a/common/image.c b/common/image.c
index 9252d5e..ceb216f 100644
--- a/common/image.c
+++ b/common/image.c
@@ -25,7 +25,6 @@
 #include <rtc.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <malloc.h>
 #include <fs.h>
 #else
 #include <time.h>
-- 
1.8.3


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] Refactor malloc.h.
  2013-06-04 12:38 [PATCH 1/3] Remove unnesessory malloc.h inclusions Masaki Muranaka
@ 2013-06-04 12:38 ` Masaki Muranaka
  2013-06-05  6:38   ` Sascha Hauer
  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
  2 siblings, 1 reply; 8+ messages in thread
From: Masaki Muranaka @ 2013-06-04 12:38 UTC (permalink / raw)
  To: barebox

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__ */
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__ */
diff --git a/include/stdlib.h b/include/stdlib.h
index dc72013..0d82bbf 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -12,5 +12,6 @@ void srand(unsigned int seed);
 /* fill a buffer with pseudo-random data */
 void get_random_bytes(char *buf, int len);
 
+#include <malloc_isoc.h>
 
 #endif /* __STDLIB_H */
diff --git a/include/unistd.h b/include/unistd.h
new file mode 100644
index 0000000..a6abfa6
--- /dev/null
+++ b/include/unistd.h
@@ -0,0 +1,6 @@
+#ifndef BAREBOX_UNISTD_H__
+#define BAREBOX_UNISTD_H__
+
+#include <malloc_posix.h>
+
+#endif /* BAREBOX_UNISTD_H__ */
-- 
1.8.3


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] Use stdlib.h instead of malloc.h
  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-04 12:38 ` Masaki Muranaka
  2013-06-05  6:34 ` [PATCH 1/3] Remove unnesessory malloc.h inclusions Sascha Hauer
  2 siblings, 0 replies; 8+ messages in thread
From: Masaki Muranaka @ 2013-06-04 12:38 UTC (permalink / raw)
  To: barebox

From: Masaki Muranaka <monaka@monami-ya.com>

Signed-off-by: Masaki Muranaka <monaka@monami-ya.jp>
---
 commands/digest.c      | 2 +-
 commands/loadb.c       | 2 +-
 commands/mem.c         | 2 +-
 commands/of_property.c | 2 +-
 common/command.c       | 2 +-
 common/digest.c        | 2 +-
 common/env.c           | 2 +-
 common/environment.c   | 2 +-
 common/hush.c          | 2 +-
 common/password.c      | 3 +--
 common/startup.c       | 2 +-
 common/uimage.c        | 2 +-
 12 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/commands/digest.c b/commands/digest.c
index c9bb132..6470a2e 100644
--- a/commands/digest.c
+++ b/commands/digest.c
@@ -23,7 +23,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <xfuncs.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <digest.h>
 
 static int do_digest(char *algorithm, int argc, char *argv[])
diff --git a/commands/loadb.c b/commands/loadb.c
index a2f3315..d7895c9 100644
--- a/commands/loadb.c
+++ b/commands/loadb.c
@@ -38,7 +38,7 @@
 #include <getopt.h>
 #include <fs.h>
 #include <fcntl.h>
-#include <malloc.h>
+#include <stdlib.h>
 
 #define XON_CHAR	17
 #define XOFF_CHAR	19
diff --git a/commands/mem.c b/commands/mem.c
index 568050d..1caa92c 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -25,7 +25,7 @@
 #include <command.h>
 #include <init.h>
 #include <driver.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/commands/of_property.c b/commands/of_property.c
index 44bb388..1919b3d 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -23,7 +23,7 @@
 #include <of.h>
 #include <command.h>
 #include <fs.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
 #include <errno.h>
diff --git a/common/command.c b/common/command.c
index 7f2b777..b3804b8 100644
--- a/common/command.c
+++ b/common/command.c
@@ -24,7 +24,7 @@
 #include <common.h>
 #include <command.h>
 #include <xfuncs.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <environment.h>
 #include <linux/list.h>
 #include <init.h>
diff --git a/common/digest.c b/common/digest.c
index ae414ba..80e8502 100644
--- a/common/digest.c
+++ b/common/digest.c
@@ -18,7 +18,7 @@
 
 #include <common.h>
 #include <digest.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <fs.h>
 #include <fcntl.h>
 #include <linux/stat.h>
diff --git a/common/env.c b/common/env.c
index 33a871f..e8a57f4 100644
--- a/common/env.c
+++ b/common/env.c
@@ -24,7 +24,7 @@
 
 #include <common.h>
 #include <driver.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <xfuncs.h>
 #include <errno.h>
 #include <init.h>
diff --git a/common/environment.c b/common/environment.c
index 78cd45c..c0bd629 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -27,7 +27,7 @@
 #ifdef __BAREBOX__
 #include <common.h>
 #include <command.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <fs.h>
 #include <fcntl.h>
diff --git a/common/hush.c b/common/hush.c
index a3235ba..a7e4571 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -106,7 +106,7 @@
  * General Public License for more details.
  *
  */
-#include <malloc.h>         /* malloc, free, realloc*/
+#include <stdlib.h>         /* malloc, free, realloc*/
 #include <xfuncs.h>
 #include <linux/ctype.h>    /* isalpha, isdigit */
 #include <common.h>        /* readline */
diff --git a/common/password.c b/common/password.c
index d157a11..830f724 100644
--- a/common/password.c
+++ b/common/password.c
@@ -22,8 +22,7 @@
 #include <fs.h>
 #include <fcntl.h>
 #include <digest.h>
-#include <malloc.h>
-#include <xfuncs.h>
+#include <stdlib.h>
 #include <clock.h>
 
 #if defined(CONFIG_PASSWD_SUM_MD5)
diff --git a/common/startup.c b/common/startup.c
index ff00ca7..d709089 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -28,7 +28,7 @@
 #include <common.h>
 #include <init.h>
 #include <command.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <debug_ll.h>
 #include <fs.h>
 #include <linux/stat.h>
diff --git a/common/uimage.c b/common/uimage.c
index 06f97f0..c9ae311 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -19,7 +19,7 @@
  */
 #include <common.h>
 #include <image.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <libbb.h>
 #include <uncompress.h>
-- 
1.8.3


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] Remove unnesessory malloc.h inclusions.
  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-04 12:38 ` [PATCH 3/3] Use stdlib.h instead of malloc.h Masaki Muranaka
@ 2013-06-05  6:34 ` Sascha Hauer
  2 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-06-05  6:34 UTC (permalink / raw)
  To: Masaki Muranaka; +Cc: barebox

On Tue, Jun 04, 2013 at 09:38:30PM +0900, Masaki Muranaka wrote:
> Signed-off-by: Masaki Muranaka <monaka@monami-ya.jp>
> ---
>  commands/barebox-update.c | 1 -
>  commands/bootm.c          | 1 -
>  commands/cat.c            | 1 -
>  commands/cp.c             | 1 -
>  commands/crc.c            | 1 -
>  commands/dfu.c            | 1 -
>  commands/edit.c           | 1 -
>  commands/exec.c           | 1 -
>  commands/global.c         | 1 -
>  commands/i2c.c            | 1 -
>  commands/insmod.c         | 1 -
>  commands/let.c            | 1 -
>  commands/linux16.c        | 1 -
>  commands/loadxy.c         | 1 -
>  commands/ls.c             | 1 -
>  commands/md.c             | 1 -
>  commands/memcmp.c         | 1 -
>  commands/memcpy.c         | 1 -
>  commands/meminfo.c        | 1 -
>  commands/memset.c         | 1 -
>  commands/miitool.c        | 1 -
>  commands/mm.c             | 1 -
>  commands/mw.c             | 1 -
>  commands/nand.c           | 1 -
>  commands/nandtest.c       | 1 -
>  commands/of_node.c        | 1 -
>  commands/oftree.c         | 1 -
>  commands/partition.c      | 1 -
>  commands/readline.c       | 1 -
>  commands/readlink.c       | 1 -
>  commands/spi.c            | 1 -
>  commands/splash.c         | 1 -
>  commands/time.c           | 1 -
>  commands/ubiformat.c      | 1 -
>  commands/uimage.c         | 1 -
>  commands/usbserial.c      | 1 -
>  common/console.c          | 1 -
>  common/image.c            | 1 -
>  38 files changed, 38 deletions(-)

This still produces a lot of warnings:

commands/bootm.c:191:2: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/memcmp.c:125:2: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/memset.c:82:2: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/edit.c:175:2: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
include/stringlist.h:27:3: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/cp.c:75:4: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/cat.c:78:2: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/readline.c:33:3: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/time.c:41:2: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/global.c:34:3: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/readlink.c:58:3: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
commands/oftree.c:197:2: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]

I think you have to replace it with stdlib.h in these files rather than
removing malloc.h (Of course after the free() prototype has been moved
to stdlib.h)

-- 
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] Refactor malloc.h.
  2013-06-04 12:38 ` [PATCH 2/3] Refactor malloc.h Masaki Muranaka
@ 2013-06-05  6:38   ` Sascha Hauer
  0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2013-06-05  6:38 UTC (permalink / raw)
  To: Masaki Muranaka; +Cc: barebox

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] Refactor malloc.h.
  2013-06-03  7:26   ` Sascha Hauer
@ 2013-06-03  8:02     ` Masaki Muranaka
  0 siblings, 0 replies; 8+ messages in thread
From: Masaki Muranaka @ 2013-06-03  8:02 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hello,

My wish is to use POSIX/ISO-C-hosted way in commands/ and lib/
They are similar to user-land in Unix.

But I'm not sure if it's better replacing all malloc.h to stdlib.h.
common/, fs/ and some places are equivalent to kernel inside.
There are not always required to confirm to POSIX/ISO-C-hosted.



2013/6/3 Sascha Hauer <s.hauer@pengutronix.de>:
> On Sun, Jun 02, 2013 at 11:53:48PM +0900, Masaki Muranaka wrote:
>>  Some functions should be defined in stdlib.h or unistd.h.
>> ---
>>  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);
>
> Wouldn't it be nicer to move the prototypes to unistd.h / stdlib.h
> instead of adding new files?
>
> 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 |



-- 
--
Masaki Muranaka
Monami-ya LLC, Japan.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] Refactor malloc.h.
  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
  0 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2013-06-03  7:26 UTC (permalink / raw)
  To: Masaki Muranaka; +Cc: barebox

On Sun, Jun 02, 2013 at 11:53:48PM +0900, Masaki Muranaka wrote:
>  Some functions should be defined in stdlib.h or unistd.h.
> ---
>  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);

Wouldn't it be nicer to move the prototypes to unistd.h / stdlib.h
instead of adding new files?

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/3] Refactor malloc.h.
  2013-06-02 14:53 Masaki Muranaka
@ 2013-06-02 14:53 ` Masaki Muranaka
  2013-06-03  7:26   ` Sascha Hauer
  0 siblings, 1 reply; 8+ messages in thread
From: Masaki Muranaka @ 2013-06-02 14:53 UTC (permalink / raw)
  To: barebox

 Some functions should be defined in stdlib.h or unistd.h.
---
 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__ */
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__ */
diff --git a/include/stdlib.h b/include/stdlib.h
index dc72013..0d82bbf 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -12,5 +12,6 @@ void srand(unsigned int seed);
 /* fill a buffer with pseudo-random data */
 void get_random_bytes(char *buf, int len);
 
+#include <malloc_isoc.h>
 
 #endif /* __STDLIB_H */
diff --git a/include/unistd.h b/include/unistd.h
new file mode 100644
index 0000000..a6abfa6
--- /dev/null
+++ b/include/unistd.h
@@ -0,0 +1,6 @@
+#ifndef BAREBOX_UNISTD_H__
+#define BAREBOX_UNISTD_H__
+
+#include <malloc_posix.h>
+
+#endif /* BAREBOX_UNISTD_H__ */
-- 
1.8.3


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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-05  6:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox