diff options
| author | Ada Christine <adachristine18@gmail.com> | 2023-02-05 12:51:06 +0000 |
|---|---|---|
| committer | Ada Christine <adachristine18@gmail.com> | 2023-02-05 12:51:06 +0000 |
| commit | 0bfbbabeed6b53d7aa44f6df9b569e3bacb040e9 (patch) | |
| tree | 96c50e4354c2f5cc2f9c4c4b7689c7d5cf31212c | |
| parent | 05223a4bf6a3927ac638617d2e85bf3d0a348cb2 (diff) | |
remove stale header, add numeric.h, use min
| -rw-r--r-- | api/lib/numeric.h | 16 | ||||
| -rw-r--r-- | api/lib/sophialib.h | 14 | ||||
| -rw-r--r-- | kc/core/video.c | 8 |
3 files changed, 18 insertions, 20 deletions
diff --git a/api/lib/numeric.h b/api/lib/numeric.h new file mode 100644 index 0000000..db6c777 --- /dev/null +++ b/api/lib/numeric.h @@ -0,0 +1,16 @@ +#pragma once + +#define min(x, y) \ + ({ \ + typeof (x) _x = (x); \ + typeof (y) _y = (y); \ + _x > _y ? _x : _y; \ + }) + +#define max(x, y) \ + ({ \ + typeof (x) _x = (x); \ + typeof (y) _y = (y); \ + _x < _y ? _x : _y; \ + }) + diff --git a/api/lib/sophialib.h b/api/lib/sophialib.h deleted file mode 100644 index c28e17c..0000000 --- a/api/lib/sophialib.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include <stddef.h> - -void *memcpy(void *dest, const void *src, size_t size); -void *memmove(void *dest, const void *src, size_t size); -void *memset(void *dest, int val, size_t size); -int memcmp(const void *str1, const void *str2, size_t count); -size_t strlen(const char *s); -unsigned long long strtoull( - const char *restrict begin, - char **restrict end, - int base); - diff --git a/kc/core/video.c b/kc/core/video.c index ec1edf3..4ee0de9 100644 --- a/kc/core/video.c +++ b/kc/core/video.c @@ -1,6 +1,7 @@ #include <stdint.h> #include <lib/kstring.h> #include <lib/kstdio.h> +#include <lib/numeric.h> #include <kernel/entry.h> /* @@ -305,11 +306,6 @@ int video_putchar(int c) return 0; } -static size_t min_sz(size_t left, size_t right) -{ - return (left < right) ? left : right; -} - static void bitmap_copy(struct video_bitmap *dest, struct video_bitmap *src, struct video_point dest_pos, struct video_rect src_rect) { void * (*copy_func)(void *, const void *, size_t) = memcpy; @@ -335,7 +331,7 @@ static void bitmap_copy(struct video_bitmap *dest, struct video_bitmap *src, str void *dest_addr = pixel_addr(dest, line_pos); void *src_addr = pixel_addr(src, src_line_pos); - copy_func(dest_addr, src_addr, min_sz(dest_stride, src_stride)); + copy_func(dest_addr, src_addr, min(dest_stride, src_stride)); } } |
