diff options
author | hpa <hpa> | 2005-09-25 21:35:44 +0000 |
---|---|---|
committer | hpa <hpa> | 2005-09-25 21:35:44 +0000 |
commit | 85ab9fe14674567260cf94ecd4dc845f1988a08b (patch) | |
tree | e241d2eaf71df6dd6b7c268ff047781dfe6b9f7a /com32/libutil/include | |
parent | 77477d3af776cbc8ffce61cb63ae7a27dbe0a941 (diff) | |
download | syslinux-85ab9fe14674567260cf94ecd4dc845f1988a08b.tar.gz syslinux-85ab9fe14674567260cf94ecd4dc845f1988a08b.tar.xz syslinux-85ab9fe14674567260cf94ecd4dc845f1988a08b.zip |
Beginnings of a file-moving API
Diffstat (limited to 'com32/libutil/include')
-rw-r--r-- | com32/libutil/include/loadfile.h | 12 | ||||
-rw-r--r-- | com32/libutil/include/movebits.h | 47 |
2 files changed, 59 insertions, 0 deletions
diff --git a/com32/libutil/include/loadfile.h b/com32/libutil/include/loadfile.h new file mode 100644 index 00000000..fbda589d --- /dev/null +++ b/com32/libutil/include/loadfile.h @@ -0,0 +1,12 @@ +#ifndef LIBUTIL_LOADFILE_H +#define LIBUTIL_LOADFILE_H + +#include <stddef.h> + +/* loadfile() returns the true size of the file, but will guarantee valid, + zero-padded memory out to this boundary. */ +#define LOADFILE_ZERO_PAD 64 + +int loadfile(const char *, void **, size_t *); + +#endif diff --git a/com32/libutil/include/movebits.h b/com32/libutil/include/movebits.h new file mode 100644 index 00000000..de6ee1ff --- /dev/null +++ b/com32/libutil/include/movebits.h @@ -0,0 +1,47 @@ +#ifndef LIBUTIL_MOVEBITS_H +#define LIBUTIL_MOVEBITS_H + +#include <inttypes.h> +#include <setjmp.h> + +struct movelist { + uintptr_t dst; + uintptr_t src; + uintptr_t len; + struct movelist *next; +}; + +struct move_descriptor { + uint32_t dst; + uint32_t src; + uint32_t len; +}; + +/* + * Creates a movelist consisting of only one element, and + * if parent == NULL insert into the movelist chain immediately after + * the parent element. + */ +struct movelist * +make_movelist(struct movelist *parent, uintptr_t dst, + uintptr_t src, uintptr_t len); + +/* + * Convert a movelist into a linear array of struct move_descriptors, + * returning the number of descriptors and freeing the movelist. + * + * Returns (size_t)-1 on failure; if so the movelist is still valid. + */ +size_t +linearize_movelist(struct move_descriptor **d, struct movelist *m); + +/* + * moves is computed from "frags" and "freemem". "space" lists + * free memory areas at our disposal, and is (src, cnt) only. + */ + +int +compute_movelist(struct movelist **moves, struct movelist *frags, + struct movelist *space); + +#endif /* LIBUTIL_MOVEBITS_H */ |