From: Bruce Cran <bruce@cran.org.uk>
To: fio@vger.kernel.org
Subject: [patch] Use C99 standard integer types
Date: Wed, 15 Dec 2010 15:09:24 +0000 [thread overview]
Message-ID: <20101215150924.00003add@unknown> (raw)
[-- Attachment #1: Type: text/plain, Size: 415 bytes --]
Since most compilers now have a copy of the C99 inttypes.h header
available, [u]intX_t types should be preferred over compiler-specific
types such as __u32 etc. Using the standard types allows clang to build
fio.
I've attached a patch which updates blktrace_api.h, blktrace.c and
os/binject.h .
The patch also updates Makefile.FreeBSD to use the -pthread flag
since it's preferred over -lpthread .
--
Bruce Cran
[-- Attachment #2: c99.diff --]
[-- Type: application/octet-stream, Size: 3970 bytes --]
diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD
index 9378b19..005458d 100644
--- a/Makefile.FreeBSD
+++ b/Makefile.FreeBSD
@@ -52,7 +52,7 @@ mandir = $(prefix)/man
%.o: %.c
$(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $<
fio: $(OBJS)
- $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(EXTLIBS) -lpthread -lm -lrt
+ $(QUIET_CC)$(CC) $(CFLAGS) -o $@ $(filter %.o,$^) $(EXTLIBS) -pthread -lm -lrt
depend:
$(QUIET_DEP)$(CC) -MM $(ALL_CFLAGS) $(SOURCE) 1> .depend
diff --git a/blktrace.c b/blktrace.c
index 297a8a9..822dbc7 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -1,6 +1,7 @@
/*
* blktrace support code for fio
*/
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -176,7 +177,7 @@ static void trace_add_open_event(struct thread_data *td, int fileno)
flist_add_tail(&ipo->list, &td->io_log_list);
}
-static void trace_add_file(struct thread_data *td, __u32 device)
+static void trace_add_file(struct thread_data *td, uint32_t device)
{
static unsigned int last_maj, last_min;
unsigned int maj = FMAJOR(device);
diff --git a/blktrace_api.h b/blktrace_api.h
index 3df3347..78498bf 100644
--- a/blktrace_api.h
+++ b/blktrace_api.h
@@ -1,7 +1,7 @@
#ifndef BLKTRACEAPI_H
#define BLKTRACEAPI_H
-#include <asm/types.h>
+#include <inttypes.h>
/*
* Trace categories
@@ -92,39 +92,39 @@ enum blktrace_notify {
* The trace itself
*/
struct blk_io_trace {
- __u32 magic; /* MAGIC << 8 | version */
- __u32 sequence; /* event number */
- __u64 time; /* in nanoseconds */
- __u64 sector; /* disk offset */
- __u32 bytes; /* transfer length */
- __u32 action; /* what happened */
- __u32 pid; /* who did it */
- __u32 device; /* device identifier (dev_t) */
- __u32 cpu; /* on what cpu did it happen */
- __u16 error; /* completion error */
- __u16 pdu_len; /* length of data after this trace */
+ uint32_t magic; /* MAGIC << 8 | version */
+ uint32_t sequence; /* event number */
+ uint64_t time; /* in nanoseconds */
+ uint64_t sector; /* disk offset */
+ uint32_t bytes; /* transfer length */
+ uint32_t action; /* what happened */
+ uint32_t pid; /* who did it */
+ uint32_t device; /* device identifier (dev_t) */
+ uint32_t cpu; /* on what cpu did it happen */
+ uint16_t error; /* completion error */
+ uint16_t pdu_len; /* length of data after this trace */
};
/*
* The remap event
*/
struct blk_io_trace_remap {
- __u32 device;
- __u32 device_from;
- __u64 sector;
+ uint32_t device;
+ uint32_t device_from;
+ uint64_t sector;
};
/*
* User setup structure passed with BLKSTARTTRACE
*/
struct blk_user_trace_setup {
- char name[32]; /* output */
- __u16 act_mask; /* input */
- __u32 buf_size; /* input */
- __u32 buf_nr; /* input */
- __u64 start_lba;
- __u64 end_lba;
- __u32 pid;
+ char name[32]; /* output */
+ uint16_t act_mask; /* input */
+ uint32_t buf_size; /* input */
+ uint32_t buf_nr; /* input */
+ uint64_t start_lba;
+ uint64_t end_lba;
+ uint32_t pid;
};
#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
diff --git a/os/binject.h b/os/binject.h
index 1d862c8..f31d910 100644
--- a/os/binject.h
+++ b/os/binject.h
@@ -9,15 +9,15 @@
#define BINJECT_VER_MASK ((1 << BINJECT_MAGIC_SHIFT) - 1)
struct b_user_cmd {
- __u16 magic; /* INPUT */
- __u16 type; /* INPUT */
- __u32 error; /* OUTPUT */
- __u32 flags; /* INPUT */
- __u32 len; /* INPUT */
- __u64 offset; /* INPUT */
- __u64 buf; /* INPUT */
- __u64 usr_ptr; /* PASSED THROUGH */
- __u64 nsec; /* OUTPUT */
+ uint16_t magic; /* INPUT */
+ uint16_t type; /* INPUT */
+ uint32_t error; /* OUTPUT */
+ uint32_t flags; /* INPUT */
+ uint32_t len; /* INPUT */
+ uint64_t offset; /* INPUT */
+ uint64_t buf; /* INPUT */
+ uint64_t usr_ptr; /* PASSED THROUGH */
+ uint64_t nsec; /* OUTPUT */
};
struct b_ioctl_cmd {
next reply other threads:[~2010-12-15 15:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-15 15:09 Bruce Cran [this message]
2010-12-15 15:29 ` [patch] Use C99 standard integer types Jens Axboe
2010-12-15 16:37 ` Bruce Cran
2010-12-15 18:30 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101215150924.00003add@unknown \
--to=bruce@cran.org.uk \
--cc=fio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox