diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-09-25 12:58:47 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:03:22 -0700 |
commit | 3f5a1da9cced68a0c945a755f120da25f6d264e6 (patch) | |
tree | d9b8f81a02d5faff35c0cea92340656c94eb1a31 /compat.h | |
parent | [PATCH] Use $(CC) everywhere in Makefile. (diff) | |
download | sparse-3f5a1da9cced68a0c945a755f120da25f6d264e6.tar.gz sparse-3f5a1da9cced68a0c945a755f120da25f6d264e6.tar.bz2 sparse-3f5a1da9cced68a0c945a755f120da25f6d264e6.zip |
Add system-specific compatibility functions to make
up for various system deficiencies.
This makes sparse easier to port to silly things like
MinGW or Solaris. In particular:
- strtold() is a C99 thing, not everybody has it
- MinGW has problems with mmap(MAP_ANONYMOUS) and doesn't zero it.
- st_ino/st_dev is POSIX identity testing, not supported by MinGW
Diffstat (limited to 'compat.h')
-rw-r--r-- | compat.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/compat.h b/compat.h new file mode 100644 index 0000000..fecfcb1 --- /dev/null +++ b/compat.h @@ -0,0 +1,31 @@ +#ifndef COMPAT_H +#define COMPAT_H + +/* + * Various systems get these things wrong. So + * we create a small compat library for them. + * + * - zeroed anonymous mmap + * Missing in mingw + * - "string to long double" (C99 strtold()) + * Missing in Solaris and mingw + * - checking for file identity (POSIX st_dev && st_ino comparison) + * mingw needs to check the name (st_dev/st_ino are zero) + */ +struct stream; +struct stat; + +/* + * Our "blob" allocator works on chunks that are multiples + * of this size (the underlying allocator may be a mmap that + * cannot handle smaller chunks, for example, so trying to + * allocate blobs that aren't aligned is not going to work). + */ +#define CHUNK 32768 + +void *blob_alloc(unsigned long size); +void blob_free(void *addr, unsigned long size); +long double string_to_ld(const char *nptr, char **endptr); +int identical_files(struct stream* s, struct stat *st, const char * name); + +#endif |