summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2008-05-30 15:02:38 +0200
committerJens Axboe <jens.axboe@oracle.com>2008-05-30 15:02:38 +0200
commit5921e80c5dfc9f96d2f21da6ae58f2b5d3a0b373 (patch)
tree6edeb9e2b3a114351af6df84da29cd8af6554e4b
parentd0c70934dde93a8ee260a84c1bf69ff24484d486 (diff)
downloadfio-5921e80c5dfc9f96d2f21da6ae58f2b5d3a0b373.tar.gz
fio-5921e80c5dfc9f96d2f21da6ae58f2b5d3a0b373.tar.bz2
Make it work on opensolaris
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--Makefile.solaris24
-rw-r--r--arch/arch.h2
-rw-r--r--crc/sha256.c14
-rw-r--r--crc/sha512.c18
-rw-r--r--debug.h2
-rw-r--r--engines/mmap.c1
-rw-r--r--engines/net.c34
-rw-r--r--engines/sync.c1
-rw-r--r--filesetup.c6
-rw-r--r--fio.c20
-rw-r--r--fio.h3
-rw-r--r--hash.h7
-rw-r--r--init.c2
-rw-r--r--log.c1
-rw-r--r--memory.c3
-rw-r--r--mutex.c6
-rw-r--r--options.c5
-rw-r--r--os/os-linux.h3
-rw-r--r--os/os.h11
-rw-r--r--stat.c4
-rw-r--r--verify.c2
21 files changed, 119 insertions, 50 deletions
diff --git a/Makefile.solaris b/Makefile.solaris
index 2f088b5f..fbdef12c 100644
--- a/Makefile.solaris
+++ b/Makefile.solaris
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS = -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+CFLAGS = -Wall -O2 -g -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INC_DEBUG
PROGS = fio
SCRIPTS = fio_generate_plots
OBJS = gettime.o fio.o ioengines.o init.o stat.o log.o time.o filesetup.o \
@@ -21,24 +21,26 @@ OBJS += engines/sync.o
OBJS += engines/null.o
OBJS += engines/net.o
-all: depend $(PROGS) $(SCRIPTS)
+OBJS += lib/strsep.o
+INSTALL = install
+prefix = /usr/local
+bindir = $(prefix)/bin
+mandir = $(prefix)/man
+
+%.o: %.c
+ $(CC) -o $*.o -c $(CFLAGS) $<
fio: $(OBJS)
- $(CC) $(CFLAGS) -o $@ $(OBJS) -lc -lpthread -lm -laio -lrt -ldl
+ $(CC) $(CFLAGS) -o $@ $(OBJS) $(EXTLIBS) -lpthread -lm -ldl -laio -lrt -lnsl -lsocket
-clean:
- -rm -f *.o .depend cscope.out $(PROGS)
+all: $(PROGS) $(SCRIPTS)
-depend:
- @$(CC) -MM $(ALL_CFLAGS) *.c engines/*.c 1> .depend
+clean:
+ -rm -f *.o .depend cscope.out $(PROGS) engines/*.o crc/*.o lib/*.o core.* core
cscope:
@cscope -b
-INSTALL = install
-prefix = /usr/local
-bindir = $(prefix)/bin
-
install: $(PROGS) $(SCRIPTS)
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
diff --git a/arch/arch.h b/arch/arch.h
index 745bf3a4..3962c929 100644
--- a/arch/arch.h
+++ b/arch/arch.h
@@ -37,6 +37,4 @@ static inline unsigned long generic_ffz(unsigned long word)
#error "Unsupported arch"
#endif
-#define BITS_PER_LONG (__WORDSIZE)
-
#endif
diff --git a/crc/sha256.c b/crc/sha256.c
index 8ec29432..fe08ab3a 100644
--- a/crc/sha256.c
+++ b/crc/sha256.c
@@ -18,13 +18,21 @@
*/
#include <string.h>
#include <inttypes.h>
-#include <byteswap.h>
-#include <endian.h>
#include "sha256.h"
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __be32_to_cpu(x) __bswap_32(x)
+static int __be32_to_cpu(uint32_t val)
+{
+ uint32_t c1, c2, c3, c4;
+
+ c1 = (val >> 24) & 0xff;
+ c2 = (val >> 16) & 0xff;
+ c3 = (val >> 8) & 0xff;
+ c4 = val & 0xff;
+
+ return c1 | c2 << 8 | c3 << 16 | c4 << 24;
+}
#else
#define __be32_to_cpu(x) (x)
#endif
diff --git a/crc/sha512.c b/crc/sha512.c
index 1f9ebb43..d9069e30 100644
--- a/crc/sha512.c
+++ b/crc/sha512.c
@@ -13,13 +13,25 @@
#include <string.h>
#include <inttypes.h>
-#include <byteswap.h>
-#include <endian.h>
#include "sha512.h"
#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __be64_to_cpu(x) __bswap_64(x)
+static int __be64_to_cpu(uint64_t val)
+{
+ uint64_t c1, c2, c3, c4, c5, c6, c7, c8;
+
+ c1 = (val >> 56) & 0xff;
+ c2 = (val >> 48) & 0xff;
+ c3 = (val >> 40) & 0xff;
+ c4 = (val >> 32) & 0xff;
+ c5 = (val >> 24) & 0xff;
+ c6 = (val >> 16) & 0xff;
+ c7 = (val >> 8) & 0xff;
+ c8 = val & 0xff;
+
+ return c1 | c2 << 8 | c3 << 16 | c4 << 24 | c5 << 32 | c6 << 40 | c7 << 48 | c8 << 56;
+}
#else
#define __be64_to_cpu(x) (x)
#endif
diff --git a/debug.h b/debug.h
index 883628da..160f48c3 100644
--- a/debug.h
+++ b/debug.h
@@ -39,7 +39,7 @@ extern unsigned int fio_debug_jobno, *fio_debug_jobp;
&& pid != *fio_debug_jobp) \
break; \
log_info("%-8s ", debug_levels[(type)].name); \
- log_info("%-5u ", pid); \
+ log_info("%-5u ", (int) pid); \
log_info(str, ##args); \
} while (0)
diff --git a/engines/mmap.c b/engines/mmap.c
index 3e1e6c8d..5b55a811 100644
--- a/engines/mmap.c
+++ b/engines/mmap.c
@@ -9,7 +9,6 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
-#include <assert.h>
#include <sys/mman.h>
#include "../fio.h"
diff --git a/engines/net.c b/engines/net.c
index 137c5799..0efd3369 100644
--- a/engines/net.c
+++ b/engines/net.c
@@ -41,6 +41,7 @@ static int fio_netio_prep(struct thread_data *td, struct io_u *io_u)
return 0;
}
+#ifdef FIO_HAVE_SPLICE
static int splice_io_u(int fdin, int fdout, unsigned int len)
{
int bytes = 0;
@@ -161,6 +162,19 @@ static int fio_netio_splice_out(struct thread_data *td, struct io_u *io_u)
return ret;
}
+#else
+static int fio_netio_splice_in(struct thread_data *td, struct io_u *io_u)
+{
+ errno = -EOPNOTSUPP;
+ return -1;
+}
+
+static int fio_netio_splice_out(struct thread_data *td, struct io_u *io_u)
+{
+ errno = -EOPNOTSUPP;
+ return -1;
+}
+#endif
static int fio_netio_send(struct thread_data *td, struct io_u *io_u)
{
@@ -169,8 +183,10 @@ static int fio_netio_send(struct thread_data *td, struct io_u *io_u)
/*
* if we are going to write more, set MSG_MORE
*/
+#ifdef MSG_MORE
if (td->this_io_bytes[DDIR_WRITE] + io_u->xfer_buflen < td->o.size)
flags = MSG_MORE;
+#endif
return send(io_u->file->fd, io_u->xfer_buf, io_u->xfer_buflen, flags);
}
@@ -430,6 +446,7 @@ static int fio_netio_setup(struct thread_data *td)
return 0;
}
+#ifdef FIO_HAVE_SPLICE
static int fio_netio_setup_splice(struct thread_data *td)
{
struct netio_data *nd;
@@ -448,12 +465,12 @@ static int fio_netio_setup_splice(struct thread_data *td)
return 1;
}
-static struct ioengine_ops ioengine_rw = {
- .name = "net",
+static struct ioengine_ops ioengine_splice = {
+ .name = "netsplice",
.version = FIO_IOOPS_VERSION,
.prep = fio_netio_prep,
.queue = fio_netio_queue,
- .setup = fio_netio_setup,
+ .setup = fio_netio_setup_splice,
.init = fio_netio_init,
.cleanup = fio_netio_cleanup,
.open_file = fio_netio_open_file,
@@ -461,13 +478,14 @@ static struct ioengine_ops ioengine_rw = {
.flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
FIO_SIGQUIT,
};
+#endif
-static struct ioengine_ops ioengine_splice = {
- .name = "netsplice",
+static struct ioengine_ops ioengine_rw = {
+ .name = "net",
.version = FIO_IOOPS_VERSION,
.prep = fio_netio_prep,
.queue = fio_netio_queue,
- .setup = fio_netio_setup_splice,
+ .setup = fio_netio_setup,
.init = fio_netio_init,
.cleanup = fio_netio_cleanup,
.open_file = fio_netio_open_file,
@@ -479,11 +497,15 @@ static struct ioengine_ops ioengine_splice = {
static void fio_init fio_netio_register(void)
{
register_ioengine(&ioengine_rw);
+#ifdef FIO_HAVE_SPLICE
register_ioengine(&ioengine_splice);
+#endif
}
static void fio_exit fio_netio_unregister(void)
{
unregister_ioengine(&ioengine_rw);
+#ifdef FIO_HAVE_SPLICE
unregister_ioengine(&ioengine_splice);
+#endif
}
diff --git a/engines/sync.c b/engines/sync.c
index e966846c..561e77ba 100644
--- a/engines/sync.c
+++ b/engines/sync.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/uio.h>
#include <errno.h>
#include <assert.h>
diff --git a/filesetup.c b/filesetup.c
index c98bf0c0..d57a3277 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -307,7 +307,7 @@ int generic_open_file(struct thread_data *td, struct fio_file *f)
if (td->o.sync_io)
flags |= O_SYNC;
if (f->filetype != FIO_TYPE_FILE)
- flags |= O_NOATIME;
+ flags |= FIO_O_NOATIME;
open_again:
if (td_write(td)) {
@@ -337,8 +337,8 @@ open_again:
char buf[FIO_VERROR_SIZE];
int __e = errno;
- if (errno == EPERM && (flags & O_NOATIME)) {
- flags &= ~O_NOATIME;
+ if (errno == EPERM && (flags & FIO_O_NOATIME)) {
+ flags &= ~FIO_O_NOATIME;
goto open_again;
}
diff --git a/fio.c b/fio.c
index 37a425e8..c5926289 100644
--- a/fio.c
+++ b/fio.c
@@ -65,8 +65,8 @@ static inline void td_set_runstate(struct thread_data *td, int runstate)
if (td->runstate == runstate)
return;
- dprint(FD_PROCESS, "pid=%d: runstate %d -> %d\n", td->pid, td->runstate,
- runstate);
+ dprint(FD_PROCESS, "pid=%d: runstate %d -> %d\n", (int) td->pid,
+ td->runstate, runstate);
td->runstate = runstate;
}
@@ -80,7 +80,7 @@ static void terminate_threads(int group_id)
for_each_td(td, i) {
if (group_id == TERMINATE_ALL || groupid == td->groupid) {
dprint(FD_PROCESS, "setting terminate on %s/%d\n",
- td->o.name, td->pid);
+ td->o.name, (int) td->pid);
td->terminate = 1;
td->o.start_delay = 0;
@@ -823,7 +823,7 @@ static void *thread_main(void *data)
td->pid = getpid();
- dprint(FD_PROCESS, "jobs pid=%d started\n", td->pid);
+ dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
INIT_LIST_HEAD(&td->io_u_freelist);
INIT_LIST_HEAD(&td->io_u_busylist);
@@ -975,7 +975,7 @@ static void *thread_main(void *data)
err:
if (td->error)
- printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error,
+ printf("fio: pid=%d, err=%d/%s\n", (int) td->pid, td->error,
td->verror);
close_and_free_files(td);
close_ioengine(td);
@@ -1063,8 +1063,8 @@ static void reap_threads(int *nr_running, int *t_rate, int *m_rate)
ret = waitpid(td->pid, &status, flags);
if (ret < 0) {
if (errno == ECHILD) {
- log_err("fio: pid=%d disappeared %d\n", td->pid,
- td->runstate);
+ log_err("fio: pid=%d disappeared %d\n",
+ (int) td->pid, td->runstate);
td_set_runstate(td, TD_REAPED);
goto reaped;
}
@@ -1075,7 +1075,7 @@ static void reap_threads(int *nr_running, int *t_rate, int *m_rate)
if (sig != SIGQUIT)
log_err("fio: pid=%d, got signal=%d\n",
- td->pid, sig);
+ (int) td->pid, sig);
td_set_runstate(td, TD_REAPED);
goto reaped;
}
@@ -1161,8 +1161,8 @@ static void run_threads(void)
if (setup_files(td)) {
exit_value++;
if (td->error)
- log_err("fio: pid=%d, err=%d/%s\n", td->pid,
- td->error, td->verror);
+ log_err("fio: pid=%d, err=%d/%s\n",
+ (int) td->pid, td->error, td->verror);
td_set_runstate(td, TD_REAPED);
todo--;
} else {
diff --git a/fio.h b/fio.h
index 472fe937..b8847a5c 100644
--- a/fio.h
+++ b/fio.h
@@ -1006,7 +1006,8 @@ static inline void dprint_io_u(struct io_u *io_u, const char *p)
struct fio_file *f = io_u->file;
dprint(FD_IO, "%s: io_u %p: off=%llu/len=%lu/ddir=%d", p, io_u,
- io_u->offset, io_u->buflen, io_u->ddir);
+ (unsigned long long) io_u->offset,
+ io_u->buflen, io_u->ddir);
if (fio_debug & (1 << FD_IO)) {
if (f)
log_info("/%s", f->file_name);
diff --git a/hash.h b/hash.h
index acf17bb8..3e7854b1 100644
--- a/hash.h
+++ b/hash.h
@@ -13,6 +13,13 @@
* them can use shifts and additions instead of multiplications for
* machines where multiplications are slow.
*/
+
+#ifdef __WORDSIZE
+#define BITS_PER_LONG __WORDSIZE
+#else
+#define BITS_PER_LONG 32
+#endif
+
#if BITS_PER_LONG == 32
/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
#define GOLDEN_RATIO_PRIME 0x9e370001UL
diff --git a/init.c b/init.c
index 56a1d331..00eb592b 100644
--- a/init.c
+++ b/init.c
@@ -307,7 +307,7 @@ static int fixup_options(struct thread_data *td)
}
if (o->fill_device && !o->size)
- o->size = ULONG_LONG_MAX;
+ o->size = -1ULL;
if (td_rw(td) && td->o.verify != VERIFY_NONE)
log_info("fio: mixed read/write workload with verify. May not "
diff --git a/log.c b/log.c
index 8f92e93f..191f806a 100644
--- a/log.c
+++ b/log.c
@@ -4,6 +4,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
+#include <libgen.h>
#include <assert.h>
#include "list.h"
#include "fio.h"
diff --git a/memory.c b/memory.c
index 257914b1..3bf31d76 100644
--- a/memory.c
+++ b/memory.c
@@ -1,6 +1,9 @@
/*
* Memory helpers
*/
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include <sys/shm.h>
#include <sys/mman.h>
diff --git a/mutex.c b/mutex.c
index e6fb3f0d..414e5532 100644
--- a/mutex.c
+++ b/mutex.c
@@ -12,7 +12,7 @@
void fio_mutex_remove(struct fio_mutex *mutex)
{
close(mutex->mutex_fd);
- munmap(mutex, sizeof(*mutex));
+ munmap((void *) mutex, sizeof(*mutex));
}
struct fio_mutex *fio_mutex_init(int value)
@@ -34,8 +34,8 @@ struct fio_mutex *fio_mutex_init(int value)
goto err;
}
- mutex = mmap(NULL, sizeof(struct fio_mutex), PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, 0);
+ mutex = (void *) mmap(NULL, sizeof(struct fio_mutex),
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mutex == MAP_FAILED) {
perror("mmap mutex");
close(fd);
diff --git a/options.c b/options.c
index b8df1da1..5aad0050 100644
--- a/options.c
+++ b/options.c
@@ -6,6 +6,9 @@
#include <getopt.h>
#include <assert.h>
#include <libgen.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "fio.h"
#include "parse.h"
@@ -1275,7 +1278,7 @@ void fio_options_dup_and_init(struct option *long_options)
o = &options[0];
while (o->name) {
- long_options[i].name = o->name;
+ long_options[i].name = (char *) o->name;
long_options[i].val = FIO_GETOPT_JOB;
if (o->type == FIO_OPT_STR_SET)
long_options[i].has_arg = no_argument;
diff --git a/os/os-linux.h b/os/os-linux.h
index e7c0e47c..6f2372bc 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -25,6 +25,7 @@
#define FIO_HAVE_HUGETLB
#define FIO_HAVE_RAWBIND
#define FIO_HAVE_BLKTRACE
+#define FIO_HAVE_STRSEP
#define OS_MAP_ANON (MAP_ANONYMOUS)
@@ -227,4 +228,6 @@ static inline int fio_lookup_raw(dev_t dev, int *majdev, int *mindev)
return 0;
}
+#define FIO_O_NOATIME O_NOATIME
+
#endif
diff --git a/os/os.h b/os/os.h
index 42cd63d0..b1ed1bb6 100644
--- a/os/os.h
+++ b/os/os.h
@@ -24,6 +24,10 @@
#include <scsi/sg.h>
#endif
+#ifndef FIO_HAVE_STRSEP
+#include "../lib/lib.h"
+#endif
+
#ifndef FIO_HAVE_FADVISE
#define fadvise(fd, off, len, advice) (0)
@@ -36,7 +40,7 @@
#ifndef FIO_HAVE_CPU_AFFINITY
#define fio_setaffinity(td) (0)
-#define fio_getaffinity(pid, mask) (0)
+#define fio_getaffinity(pid, mask) do { } while(0)
#endif
#ifndef FIO_HAVE_IOPRIO
@@ -60,6 +64,10 @@
#endif
#endif
+#ifndef FIO_O_NOATIME
+#define FIO_O_NOATIME 0
+#endif
+
#ifndef FIO_HAVE_RAWBIND
#define fio_lookup_raw(dev, majdev, mindev) 1
#endif
@@ -69,6 +77,7 @@ static inline int is_blktrace(const char *fname)
{
return 0;
}
+struct thread_data;
static inline int load_blktrace(struct thread_data *td, const char *fname)
{
return 1;
diff --git a/stat.c b/stat.c
index fe6acb80..5fecbd04 100644
--- a/stat.c
+++ b/stat.c
@@ -320,11 +320,11 @@ static void show_thread_status(struct thread_stat *ts,
if (!ts->error) {
log_info("%s: (groupid=%d, jobs=%d): err=%2d: pid=%d\n",
ts->name, ts->groupid, ts->members,
- ts->error, ts->pid);
+ ts->error, (int) ts->pid);
} else {
log_info("%s: (groupid=%d, jobs=%d): err=%2d (%s): pid=%d\n",
ts->name, ts->groupid, ts->members,
- ts->error, ts->verror, ts->pid);
+ ts->error, ts->verror, (int) ts->pid);
}
if (ts->description)
diff --git a/verify.c b/verify.c
index 0bb348ff..d6025348 100644
--- a/verify.c
+++ b/verify.c
@@ -112,7 +112,7 @@ static void hexdump(void *buffer, int len)
*/
static inline unsigned int __hdr_size(int verify_type)
{
- unsigned int len;
+ unsigned int len = len;
switch (verify_type) {
case VERIFY_NONE: