Feh / nocache

minimize caching effects
BSD 2-Clause "Simplified" License
554 stars 53 forks source link

Armv7 #29

Closed iillyyaa closed 8 years ago

iillyyaa commented 8 years ago

Your utility proved to be the best solution to the headache I've been having with tar putting the system under a ton of memory pressure and prompting oom-killer. Thank you very much.

However, to get it to (cross-)compile for out target (custom board with Ti's am335x chip) I had to make the following changes.

I opted to fix the printf incompatibility by a long long cast, since it is the most compatible solution. Since it was in a debug statement, I did't justify using the inttypes macros.

Feh commented 8 years ago

Thanks!

I don’t understand why you want to cast to long long and use %ldd. Is that because on ARM st.st_size is not a size_t? Or is printf missing the %zd expression? I’d actually prefer using size_t where possible, and your change does not remove all %zd occurrences – can you clarify your intentions?

andreygursky commented 8 years ago

Is that because on ARM st.st_size is not a size_t

No, there are no problems with size_t, but with off_t. There is no printf format expression for off_t. It's a problem for gcc-4.9 but it's not a problem for clang (both from Android NDK r11c), which is happy with %zd.

iillyyaa commented 8 years ago

Sorry for the delayed response.

Two compilation errors (really, warnings treated as errors):

  1. nocache.c: file_pageinfo::size is of type off_t. You are using "%zd" formatting characters for it, which isn't a match under gcc compiling for armv7 arch. Switching to "%ld" fixes it for armv7, and doesn't break it for x86_64.
  2. in pageinfo.c: file_pageinfo::nr_pages is of type size_t. You are using "%ld" formatting characters for it, which isn't a match under gcc compiling for armv7 arch. Switching to "%zd" fixes it for armv7, and doesn't break it for x86_64.

Under gcc on x86_64, off_t is aliased to long (and is 64 bit, though this is not relevant). Under gcc for arm7A arch, off_t is also aliased to long (and is 32bit, ditto). However, I do not know whether off_t's equivalence with long is universal, and I don't know how many users your library has and how diverse their platform set it. So, since it's only a DEBUG statement, hence less concerned with saving instructions and preserving good form, I opted for the most compatible solution of casting to (long long) and using "%lld".

Feh commented 8 years ago

Thanks for clarifying!

iillyyaa commented 8 years ago

Thanks again, and sorry for not providing the better explanation off the bat.