Skip to contentSkip to conversation

Introduce short names for fixed width integer types

PATCH In review Avi Kivity 6 participants 9 messages Aug 8, 2011 – Aug 9, 2011 KVM

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 Introduce short names for fixed width integer types

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Following Linux, introduce shorter names, for example U64 for uint64_t.

---
 qemu-common.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
qemu-common.h +9 -0
index 0fdecf1..52a2300 100644
@@ -112,6 +112,15 @@ static inline char *realpath(const char *path, char *resolved_path)
 int qemu_main(int argc, char **argv, char **envp);
 #endif
 
+typedef int8_t   S8;
+typedef uint8_t  U8;
+typedef int16_t  S16;
+typedef uint16_t U16;
+typedef int32_t  S32;
+typedef uint32_t U32;
+typedef int64_t  S64;
+typedef uint64_t U64;
+
 /* bottom halves */
 typedef void QEMUBHFunc(void *opaque);
 
Signature · 1 line
1.7.5.3
#1 lore raw
Quoted 5 lines · Avi Kivity

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Following Linux, introduce shorter names, for example U64 for uint64_t.

Except Linux uses lower case letters.

I personally think Linux style is wrong here. The int8_t types are standard types.

Besides, we save lots of characters by using 4-space tabs instead of 8-space tabs. We can afford to spend some of those saved characters on using proper type names :-)

Regards,

Anthony Liguori

Quoted 26 lines
---
  qemu-common.h |    9 +++++++++
  1 files changed, 9 insertions(+), 0 deletions(-)
qemu-common.h +9 -0
index 0fdecf1..52a2300 100644
@@ -112,6 +112,15 @@ static inline char *realpath(const char *path, char *resolved_path)
  int qemu_main(int argc, char **argv, char **envp);
  #endif
 
+typedef int8_t   S8;
+typedef uint8_t  U8;
+typedef int16_t  S16;
+typedef uint16_t U16;
+typedef int32_t  S32;
+typedef uint32_t U32;
+typedef int64_t  S64;
+typedef uint64_t U64;
+
  /* bottom halves */
  typedef void QEMUBHFunc(void *opaque);
 
author
#2 lore raw
Quoted 4 lines · Anthony Liguori
Quoted 3 lines · Avi Kivity

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Quoted 9 lines
Quoted 2 lines

Following Linux, introduce shorter names, for example U64 for uint64_t.

Except Linux uses lower case letters.

I personally think Linux style is wrong here. The int8_t types are standard types.

Besides, we save lots of characters by using 4-space tabs instead of 8-space tabs. We can afford to spend some of those saved characters on using proper type names :-)

It's not about saving space, it's about improving readability. We have about 21k uses of these types, they deserve short names.

Signature · 1 line
error compiling committee.c: too many arguments to function
#3 lore raw
Quoted 13 lines · Avi Kivity
Quoted 12 lines · Anthony Liguori
Quoted 5 lines · Avi Kivity

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Following Linux, introduce shorter names, for example U64 for uint64_t.

Except Linux uses lower case letters.

I personally think Linux style is wrong here. The int8_t types are standard types.

Quoted 7 lines
Quoted 4 lines

Besides, we save lots of characters by using 4-space tabs instead of 8-space tabs. We can afford to spend some of those saved characters on using proper type names :-)

It's not about saving space, it's about improving readability. We have about 21k uses of these types, they deserve short names.

This is one of the few areas that we're actually consistent with today.
Introducing a new set of types will just create inconsistency.

Most importantly, these are standard types. Every modern library and C program should be using them. TBH, having short names is just a bad case of NIH.

Regards,

Anthony Liguori

author
#4 lore raw
Quoted 5 lines · Anthony Liguori

This is one of the few areas that we're actually consistent with today. Introducing a new set of types will just create inconsistency.

Most importantly, these are standard types. Every modern library and C program should be using them. TBH, having short names is just a bad case of NIH.

Those are exactly the same types, compatible with all the libraries. NIH would be redefining them ourselves (and breaking pointer compatibility etc.)

Signature · 1 line
error compiling committee.c: too many arguments to function
#5 lore raw
In reply to Anthony Liguori

Am 08.08.2011 15:00, schrieb Anthony Liguori:

Quoted 11 lines · Avi Kivity
Quoted 5 lines

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Following Linux, introduce shorter names, for example U64 for uint64_t.

Except Linux uses lower case letters.

I personally think Linux style is wrong here. The int8_t types are standard types.

I fully agree, we should use the standard types.

Quoted 3 lines

Besides, we save lots of characters by using 4-space tabs instead of 8-space tabs. We can afford to spend some of those saved characters on using proper type names :-)

Heh, I like this reasoning. :-)

Kevin

#6 lore raw
In reply to Avi Kivity
Quoted 5 lines · Avi Kivity

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Following Linux, introduce shorter names, for example U64 for uint64_t.

Strongly disagree. uint64_t &c are standard types and it's immediately clear to a competent C programmer what they are. Random qemu-specific funny named types just introduces an unnecessary level of indirection.

We only just recently managed to get rid of the nonstandard typenames for these from fpu/...

-- PMM

#7 lore raw
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Avi Kivity

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Following Linux, introduce shorter names, for example U64 for uint64_t.

Quoted 8 lines

Strongly disagree. uint64_t &c are standard types and it's immediately clear to a competent C programmer what they are. Random qemu-specific funny named types just introduces an unnecessary level of indirection.

We only just recently managed to get rid of the nonstandard typenames for these from fpu/...

Seconded.

Signature · 1 line
mailto:[email protected]
#8 lore raw
In reply to Peter Maydell
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Avi Kivity

QEMU deals with a lot of fixed width integer types; their names (uint64_t etc) are clumsy to use and take up a lot of space.

Following Linux, introduce shorter names, for example U64 for uint64_t.

Quoted 7 lines

Strongly disagree. uint64_t &c are standard types and it's immediately clear to a competent C programmer what they are. Random qemu-specific funny named types just introduces an unnecessary level of indirection.

We only just recently managed to get rid of the nonstandard typenames for these from fpu/...

Agreed. And if we want to change them to be "linux-like", can we just use the linux names? Using a name with uppercase just looks doubly wrong on my eyes.

Later, Juan.