From: Jens Axboe Date: Tue, 15 Dec 2009 07:58:10 +0000 (+0100) Subject: Fix some issues with the OSX port X-Git-Tag: fio-1.37~16 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=3b2e1464ae58caf42c74ab4bdeaa5eae7c38a23f Fix some issues with the OSX port Signed-off-by: Jens Axboe --- diff --git a/compiler/compiler.h b/compiler/compiler.h index 0a08bb12..c1923ddd 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -15,6 +15,8 @@ #define uninitialized_var(x) x = x +#ifndef __weak #define __weak __attribute__((weak)) +#endif #endif diff --git a/helpers.c b/helpers.c index 9c76d305..098195c8 100644 --- a/helpers.c +++ b/helpers.c @@ -32,8 +32,8 @@ int __weak clock_gettime(clockid_t clk_id, struct timespec *ts) ret = gettimeofday(&tv, NULL); - ts->ts_sec = tv.tv_sec; - ts->ts_nsec = tv.tv_usec * 1000; + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; return ret; } diff --git a/helpers.h b/helpers.h index 61a3f2b2..4f8cc0ce 100644 --- a/helpers.h +++ b/helpers.h @@ -1,6 +1,8 @@ #ifndef FIO_HELPERS_H #define FIO_HELPERS_H +#include "compiler/compiler.h" + struct in_addr; extern int __weak posix_memalign(void **ptr, size_t align, size_t size); diff --git a/mutex.c b/mutex.c index a4474374..e148430b 100644 --- a/mutex.c +++ b/mutex.c @@ -11,6 +11,7 @@ #include "mutex.h" #include "arch/arch.h" #include "os/os.h" +#include "helpers.h" void fio_mutex_remove(struct fio_mutex *mutex) { diff --git a/options.c b/options.c index f6280628..1543eb95 100644 --- a/options.c +++ b/options.c @@ -1809,16 +1809,15 @@ static struct fio_keyword fio_keywords[] = { void fio_keywords_init(void) { - unsigned long mb_memory; + unsigned long long mb_memory; char buf[128]; long l; sprintf(buf, "%lu", page_size); fio_keywords[0].replace = strdup(buf); - l = sysconf(_SC_PHYS_PAGES); - mb_memory = l * (page_size / 1024UL); - sprintf(buf, "%lu", mb_memory); + mb_memory = os_phys_mem() / page_size; + sprintf(buf, "%llu", mb_memory); fio_keywords[1].replace = strdup(buf); l = sysconf(_SC_NPROCESSORS_ONLN); diff --git a/os/os.h b/os/os.h index bed12814..a14c4857 100644 --- a/os/os.h +++ b/os/os.h @@ -111,8 +111,11 @@ static inline int os_cache_line_size(void) #ifdef FIO_USE_GENERIC_BDEV_SIZE static inline int blockdev_size(int fd, unsigned long long *bytes) { - off_t end = lseek(fd, 0, SEEK_END); + off_t end; + *bytes = 0; + + end = lseek(fd, 0, SEEK_END); if (end < 0) return errno;