[PATCH] Compile and works on OpenSolaris (tested on BeleniX)
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index ccf0ad8a4dc24c28262014aabdfb42a174b680b8..1248971aca2a75da0fc32074898312ebe0895696 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -360,11 +360,11 @@ static int get_rw_ddir(struct thread_data *td)
                 * Check if it's time to seed a new data direction.
                 */
                if (elapsed >= td->rwmixcycle) {
                 * Check if it's time to seed a new data direction.
                 */
                if (elapsed >= td->rwmixcycle) {
-                       unsigned long v;
+                       int v;
                        long r;
 
                        long r;
 
-                       r = os_random_long(&td->random_state);
-                       v = 100UL * r / (unsigned long) (RAND_MAX + 1.0);
+                       r = os_random_long(&td->rwmix_state);
+                       v = 1 + (int) (100.0 * (r / (RAND_MAX + 1.0)));
                        if (v < td->rwmixread)
                                td->rwmix_ddir = DDIR_READ;
                        else
                        if (v < td->rwmixread)
                                td->rwmix_ddir = DDIR_READ;
                        else
@@ -933,22 +933,6 @@ static int init_io_u(struct thread_data *td)
        return 0;
 }
 
        return 0;
 }
 
-static void cleanup_allocs(struct thread_data *td)
-{
-       if (td->directory)
-               free(td->directory);
-       if (td->iolog_file)
-               free(td->iolog_file);
-       if (td->exec_prerun)
-               free(td->exec_prerun);
-       if (td->exec_postrun)
-               free(td->exec_postrun);
-       if (td->ioscheduler)
-               free(td->ioscheduler);
-       if (td->sysfs_root)
-               free(td->sysfs_root);
-}
-
 static int create_file(struct thread_data *td, unsigned long long size,
                       int extend)
 {
 static int create_file(struct thread_data *td, unsigned long long size,
                       int extend)
 {
@@ -1189,7 +1173,7 @@ static int setup_file(struct thread_data *td)
        }
 
        if (td->odirect)
        }
 
        if (td->odirect)
-               flags |= O_DIRECT;
+               flags |= OS_O_DIRECT;
 
        if (td_write(td) || td_rw(td)) {
                if (td->filetype == FIO_TYPE_FILE) {
 
        if (td_write(td) || td_rw(td)) {
                if (td->filetype == FIO_TYPE_FILE) {
@@ -1404,7 +1388,6 @@ err:
        }
        if (td->mmap)
                munmap(td->mmap, td->file_size);
        }
        if (td->mmap)
                munmap(td->mmap, td->file_size);
-       cleanup_allocs(td);
        cleanup_io(td);
        cleanup_io_u(td);
        td_set_runstate(td, TD_EXITED);
        cleanup_io(td);
        cleanup_io_u(td);
        td_set_runstate(td, TD_EXITED);