Mercurial > sos > sos
changeset 59:f9aba6b4a9cf
I now have good min and max functions (I think...)
author | Jonathan Pevarnek <pevarnj@gmail.com> |
---|---|
date | Wed, 13 Apr 2011 23:55:59 -0400 |
parents | 3434edb8697c |
children | 21089dc88985 |
files | include/std.h src/fs.c |
diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/include/std.h Wed Apr 13 20:35:55 2011 -0400 +++ b/include/std.h Wed Apr 13 23:55:59 2011 -0400 @@ -5,8 +5,14 @@ #define assert(x) do { if(!(x)) die(); } while (0) -#define Min(x, y) ((x)>(y)?(y):(x)) -#define Max(x, y) ((x)>(y)?(x):(y)) +//min and max function definitions +#define __fxn(TYPE) \ + static inline TYPE Max_##TYPE(TYPE a, TYPE b) { return (a>b) ? a : b; } \ + static inline TYPE Min_##TYPE(TYPE a, TYPE b) { return (a>b) ? b : a; } + __fxn(int) + __fxn(u64) + __fxn(u32) +#undef __fxn void init_all(u64 __memsize);
--- a/src/fs.c Wed Apr 13 20:35:55 2011 -0400 +++ b/src/fs.c Wed Apr 13 23:55:59 2011 -0400 @@ -92,7 +92,7 @@ Inode *filePtr; filePtr = readFSBlock(inPtr->blocks[i]); if(!filePtr) return -1; - memcpy(ptr, filePtr, Min(size, FSBLKSIZE)); + memcpy(ptr, filePtr, Min_u32(size, FSBLKSIZE)); ptr += FSBLKSIZE; size -= FSBLKSIZE; }