Add glibc support(default)

Change-Id: I7675edcf14df8707ecd424a962e4cc464a4c6ae4
diff --git a/mbtk/aboot-tiny/jacana/sparse_file.c b/mbtk/aboot-tiny/jacana/sparse_file.c
new file mode 100755
index 0000000..19603d9
--- /dev/null
+++ b/mbtk/aboot-tiny/jacana/sparse_file.c
@@ -0,0 +1,52 @@
+#include "sparse_file.h"
+
+/*---------------------------------------------------------------------------*/
+int
+sparse_file_new(sparse_file_t *sparse_file, size_t offset,
+                size_t size, size_t file_size)
+{
+  sparse_header_t *sparse;
+  chunk_header_t *chunk;
+  unsigned chunk_num = 0;
+
+  /* fill the sparse file structure */
+  sparse = (sparse_header_t *)sparse_file->header;
+  sparse->magic = SPARSE_HEADER_MAGIC;
+  sparse->major_version = 1;
+  sparse->minor_version = 0;
+  sparse->file_hdr_sz = sizeof(sparse_header_t);
+  sparse->chunk_hdr_sz = sizeof(chunk_header_t);
+  sparse->blk_sz = SPARSE_BLOCK_SZ;
+  sparse->total_blks = (file_size + SPARSE_BLOCK_SZ - 1) / SPARSE_BLOCK_SZ;
+  sparse->image_checksum = 0;
+  sparse->total_chunks = 3;
+
+  chunk = (chunk_header_t *)(sparse + 1);
+  chunk->chunk_type = CHUNK_TYPE_DONT_CARE;
+  chunk->reserved1 = 0;
+  chunk->chunk_sz = offset / SPARSE_BLOCK_SZ;
+  chunk->total_sz = sizeof(chunk_header_t);
+  chunk_num += chunk->chunk_sz;
+  chunk++;
+
+  chunk->chunk_type = CHUNK_TYPE_RAW;
+  chunk->reserved1 = 0;
+  chunk->chunk_sz = (size + SPARSE_BLOCK_SZ - 1) / SPARSE_BLOCK_SZ;
+  unsigned fill_size = chunk->chunk_sz * SPARSE_BLOCK_SZ - size;
+  chunk->total_sz = size + fill_size + sizeof(chunk_header_t);
+  chunk_num += chunk->chunk_sz;
+
+  sparse_file->header_size = SPARSE_FILE_HEADER_SIZE;
+  sparse_file->data_size = size;
+  sparse_file->fill_size = fill_size;
+  sparse_file->footer_size = SPARSE_FILE_FOOTER_SIZE;
+
+  chunk = (chunk_header_t *)(sparse_file->footer);
+  chunk->chunk_type = CHUNK_TYPE_DONT_CARE;
+  chunk->reserved1 = 0;
+  chunk->chunk_sz = sparse->total_blks - chunk_num;
+  chunk->total_sz = sizeof(chunk_header_t);
+
+  return 0;
+}
+/*---------------------------------------------------------------------------*/