Skip to contentSkip to conversation

Fix compilation issues under darwin

PATCH Applied Alexandre Raymond 6 participants 27 messages May 27, 2011 – Jun 9, 2011

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Fix compilation issues under darwin

Hello everyone,

The following series contains trivial patches to fix several minor issues encountered while compiling qemu under OSX 10.6.7.

I used [./configure --disable-bsd-user --disable-darwin-user --enable-io-thread] to configure the build.

Cheers,
Alexandre

Alexandre Raymond (6):
Fix incorrect check for fdatasync() in configure
Cocoa: avoid displaying window when command-line contains '-h' Fix compilation warning due to incorrectly specified type Fix missing prototype under cocoa for qemu_main Remove warning in printf due to type mismatch
Avoid compilation warning regarding kvm under darwin

 audio/coreaudio.c       |    2 +-
 configure               |    8 +++++++-
 target-lm32/translate.c |    2 +-
 target-s390x/helper.c   |    1 -
 ui/cocoa.m              |    3 ++-
 vl.c                    |    1 +
 6 files changed, 12 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.5
#1 lore raw

PATCH 1/6 Fix incorrect check for fdatasync() in configure

For some reason, darwin provides a symbol for fdatasync(), but doesn't officially support it.

The manpage for fdatasync on Linux states the following:

"On POSIX systems on which fdatasync() is available, _POSIX_SYNCHRONIZED_IO is defined in <unistd.h> to a value greater than 0."

In fact, unistd.h defines this value to "-1", at least on OSX 10.6.7.

Add this check to the configure file.

---
 configure |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
configure +7 -1
index a318d37..b21ef75 100755
@@ -2477,7 +2477,13 @@ fi
 fdatasync=no
 cat > $TMPC << EOF
 #include <unistd.h>
-int main(void) { return fdatasync(0); }
+int main(void) {
+#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
+return fdatasync(0);
+#else
+#abort Not supported
+#endif
+}
 EOF
 if compile_prog "" "" ; then
     fdatasync=yes
Signature · 1 line
1.7.5
#5 lore raw

PATCH 2/6 Cocoa: avoid displaying window when command-line contains '-h'

In reply to Alexandre Raymond

There was already a check in place to avoid displaying a window in certain modes such as vnc, nographic or curses.

Add a check for '-h' to avoid displaying a window for a split- second before showing the usage information.

---
 ui/cocoa.m |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
ui/cocoa.m +2 -1
index 20f91bc..7fb8d96 100644
@@ -865,7 +865,8 @@ int main (int argc, const char * argv[]) {
 
     /* In case we don't need to display a window, let's not do that */
     for (i = 1; i < argc; i++) {
-        if (!strcmp(argv[i], "-vnc") ||
+        if (!strcmp(argv[i], "-h") ||
+            !strcmp(argv[i], "-vnc") ||
             !strcmp(argv[i], "-nographic") ||
             !strcmp(argv[i], "-curses")) {
                 return qemu_main(gArgc, gArgv);
Signature · 1 line
1.7.5
#7 lore raw

PATCH 3/6 Fix compilation warning due to incorrectly specified type

In reply to Alexandre Raymond

In audio/coreaudio.c, a variable named "str" was assigned "const char" values, which resulted in the following warnings:

-----8<-----
audio/coreaudio.c: In function ‘coreaudio_logstatus’:
audio/coreaudio.c:59: warning: initialization discards qualifiers from pointer target type audio/coreaudio.c:63: warning: assignment discards qualifiers from pointer target type (...)
-----8<-----

---
 audio/coreaudio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
audio/coreaudio.c +1 -1
index 0a26413..3bd75cd 100644
@@ -56,7 +56,7 @@ typedef struct coreaudioVoiceOut {
 
 static void coreaudio_logstatus (OSStatus status)
 {
-    char *str = "BUG";
+    const char *str = "BUG";
 
     switch(status) {
     case kAudioHardwareNoError:
Signature · 1 line
1.7.5
#10 lore raw

PATCH 4/6 Fix missing prototype under cocoa for qemu_main

In reply to Alexandre Raymond

The following error message was encountered when compiling with cocoa support because qemu_main did not have a prototype.

-----8<-----
qemu/vl.c:2037: warning: no previous prototype for ‘qemu_main’ -----8<-----

Add its prototype in the COCOA ifdef, similar to what is done for SDL.

---
 vl.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
vl.c +1 -0
index b362871..b983646 100644
@@ -107,6 +107,7 @@ int main(int argc, char **argv)
 #endif /* CONFIG_SDL */
 
 #ifdef CONFIG_COCOA
+int qemu_main(int argc, char **argv, char **envp);
 #undef main
 #define main qemu_main
 #endif /* CONFIG_COCOA */
Signature · 1 line
1.7.5
#16 lore raw

PATCH 5/6 Remove warning in printf due to type mismatch

In reply to Alexandre Raymond

----8<----
qemu/target-lm32/translate.c: In function ‘gen_intermediate_code_internal’:
qemu/target-lm32/translate.c:1135: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 4 has type ‘int’ ----8<----

Both gen_opc_ptr and gen_opc_buf are "uint16_t *", so a simple '%d' should be able to describe their relative difference.

---
 target-lm32/translate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-lm32/translate.c +1 -1
index eb21158..0f69f27 100644
@@ -1132,7 +1132,7 @@ static void gen_intermediate_code_internal(CPUState *env,
     if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
         qemu_log("\n");
         log_target_disas(pc_start, dc->pc - pc_start, 0);
-        qemu_log("\nisize=%d osize=%zd\n",
+        qemu_log("\nisize=%d osize=%d\n",
             dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
     }
 #endif
Signature · 1 line
1.7.5
#23 lore raw

PATCH 6/6 Avoid compilation warning regarding kvm under darwin

In reply to Alexandre Raymond

----8<----
qemu/target-s390x/helper.c:32:23: warning: linux/kvm.h: No such file or director ----8<----

kvm.h, which is included right after this line, already includes linux/kvm.h with the proper CONFIG_KVM guard. Remove redundant include.

---
 target-s390x/helper.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
target-s390x/helper.c +0 -1
index c79af46..5dc42f1 100644
@@ -29,7 +29,6 @@
 #include "qemu-timer.h"
 
 #if !defined(CONFIG_USER_ONLY)
-#include <linux/kvm.h>
 #include "kvm.h"
 #endif
 
Signature · 1 line
1.7.5
Acked-by on v1 3/6
#8 lore raw

Re: [Qemu-devel] [PATCH 3/6] Fix compilation warning due to incorrectly specified type

In reply to Alexandre Raymond

Am 27.05.2011 19:22, schrieb Alexandre Raymond:

Quoted 21 lines

In audio/coreaudio.c, a variable named "str" was assigned "const char" values, which resulted in the following warnings:

-----8<-----
audio/coreaudio.c: In function ‘coreaudio_logstatus’:
audio/coreaudio.c:59: warning: initialization discards qualifiers from pointer target type audio/coreaudio.c:63: warning: assignment discards qualifiers from pointer target type (...)
-----8<-----

---
  audio/coreaudio.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
audio/coreaudio.c +0 -0
index 0a26413..3bd75cd 100644

audio/coreaudio.c typedef struct coreaudioVoiceOut { · line 62

Quoted 8 lines
audio/coreaudio.c +1 -1
@@ -56,7 +56,7 @@ typedef struct coreaudioVoiceOut {
 
  static void coreaudio_logstatus (OSStatus status)
  {
-    char *str = "BUG";
+    const char *str = "BUG";
 
      switch(status) {
      case kAudioHardwareNoError:
#24 lore raw

Re: [Qemu-devel] [PATCH 6/6] Avoid compilation warning regarding kvm under darwin

In reply to Alexandre Raymond

Am 27.05.2011 19:22, schrieb Alexandre Raymond:

Quoted 17 lines

----8<----
qemu/target-s390x/helper.c:32:23: warning: linux/kvm.h: No such file or director ----8<----

kvm.h, which is included right after this line, already includes linux/kvm.h with the proper CONFIG_KVM guard. Remove redundant include.

---
target-s390x/helper.c | 1 -

1 files changed, 0 insertions(+), 1 deletions(-)
target-s390x/helper.c +0 -0
index c79af46..5dc42f1 100644

target-s390x/helper.c line 33

Quoted 6 lines
target-s390x/helper.c +0 -1
@@ -29,7 +29,6 @@
 #include "qemu-timer.h"
 
 #if !defined(CONFIG_USER_ONLY)
-#include <linux/kvm.h>
 #include "kvm.h"
 #endif

See http://patchwork.ozlabs.org/patch/97191/.

Regards,
Stefan W.

#17 lore raw

Re: [Qemu-devel] [PATCH 5/6] Remove warning in printf due to type mismatch

In reply to Alexandre Raymond

Am 27.05.2011 19:22, schrieb Alexandre Raymond:

Quoted 26 lines

----8<----
qemu/target-lm32/translate.c: In function ‘gen_intermediate_code_internal’:
qemu/target-lm32/translate.c:1135: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 4 has type ‘int’ ----8<----

Both gen_opc_ptr and gen_opc_buf are "uint16_t *", so a simple '%d' should be able to describe their relative difference.

---
target-lm32/translate.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
target-lm32/translate.c +1 -1
index eb21158..0f69f27 100644
@@ -1132,7 +1132,7 @@ static void 
 gen_intermediate_code_internal(CPUState *env,
 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
 qemu_log("\n");
 log_target_disas(pc_start, dc->pc - pc_start, 0);
- qemu_log("\nisize=%d osize=%zd\n",
+ qemu_log("\nisize=%d osize=%d\n",
 dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
 }
Quoted 1 line

#endif

Nack.

The original code is correct, because the difference of two pointers is always of type ssize_t (well, obviously not with your compiler, but then I assume that your compiler is broken).

This pattern is quite common in QEMU, so it looks like there is another problem here (otherwise you would get more errors of this kind).

Cheers,
Stefan W.

#18 lore raw

Re: [Qemu-devel] [PATCH 5/6] Remove warning in printf due to type mismatch

Quoted 33 lines · Stefan Weil

Am 27.05.2011 19:22, schrieb Alexandre Raymond:

Quoted 28 lines

----8<----
qemu/target-lm32/translate.c: In function ‘gen_intermediate_code_internal’:
qemu/target-lm32/translate.c:1135: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 4 has type ‘int’ ----8<----

Both gen_opc_ptr and gen_opc_buf are "uint16_t *", so a simple '%d' should be able to describe their relative difference.

---
target-lm32/translate.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
target-lm32/translate.c +1 -1
index eb21158..0f69f27 100644
@@ -1132,7 +1132,7 @@ static void
 gen_intermediate_code_internal(CPUState *env,
 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
 qemu_log("\n");
 log_target_disas(pc_start, dc->pc - pc_start, 0);
- qemu_log("\nisize=%d osize=%zd\n",
+ qemu_log("\nisize=%d osize=%d\n",
 dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
 }
Quoted 1 line

#endif

Nack.

Quoted 3 lines

The original code is correct, because the difference of two pointers is always of type ssize_t (well, obviously not with your compiler, but then I assume that your compiler is broken).

ISO/IEC 9899:1999 §6.5.6 on pointer subtraction:

The size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h> header.

The pedantically correct way to print a pointer difference is the 't' type modifier. Ibid. §7.19.6.1 on fprintf():

t Specifies that a following d, i, o, u, x, or X conversion
specifier applies to a ptrdiff_t or the corresponding unsigned integer type argument; or that a following n conversion specifier applies to a pointer to a ptrdiff_t argument.

ssize_t is POSIX, not ISO C. It can differ from ptrdiff_t only if ptrdiff_t has a different size than size_t, which would be kind of sick. ISO C permits all kinds of sickness. Whether tolerating a particular sickness is worth our while is another question.

[...]

#19 lore raw

Re: [Qemu-devel] [PATCH 5/6] Remove warning in printf due to type mismatch

Am 27.05.2011 21:11, schrieb Markus Armbruster:

Quoted 52 lines
Quoted 33 lines · Stefan Weil

Am 27.05.2011 19:22, schrieb Alexandre Raymond:

Quoted 28 lines

----8<----
qemu/target-lm32/translate.c: In function ‘gen_intermediate_code_internal’:
qemu/target-lm32/translate.c:1135: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 4 has type ‘int’ ----8<----

Both gen_opc_ptr and gen_opc_buf are "uint16_t *", so a simple '%d' should be able to describe their relative difference.

---
target-lm32/translate.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
target-lm32/translate.c +1 -1
index eb21158..0f69f27 100644
@@ -1132,7 +1132,7 @@ static void
 gen_intermediate_code_internal(CPUState *env,
 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
 qemu_log("\n");
 log_target_disas(pc_start, dc->pc - pc_start, 0);
- qemu_log("\nisize=%d osize=%zd\n",
+ qemu_log("\nisize=%d osize=%d\n",
 dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
 }
Quoted 1 line

#endif

Nack.

Quoted 3 lines

The original code is correct, because the difference of two pointers is always of type ssize_t (well, obviously not with your compiler, but then I assume that your compiler is broken).

ISO/IEC 9899:1999 §6.5.6 on pointer subtraction:

The size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h> header.

The pedantically correct way to print a pointer difference is the 't' type modifier. Ibid. §7.19.6.1 on fprintf():

t Specifies that a following d, i, o, u, x, or X conversion specifier applies to a ptrdiff_t or the corresponding unsigned integer type argument; or that a following n conversion specifier applies to a pointer to a ptrdiff_t argument.

Quoted 6 lines

ssize_t is POSIX, not ISO C. It can differ from ptrdiff_t only if ptrdiff_t has a different size than size_t, which would be kind of sick. ISO C permits all kinds of sickness. Whether tolerating a particular sickness is worth our while is another question.

[...]

That's correct. And ptrdiff_t needs %td.

Alexandre, could you please try %td instead of %zd?

Cheers,
Stefan W.

#20 lore raw

Re: [Qemu-devel] [PATCH 5/6] Remove warning in printf due to type mismatch

Hi Stefan and Markus,

Thanks for your feedback :)

"%td" doesn't generate warnings on Linux nor on OSX.

Alexandre

Quoted 71 lines · Stefan Weil

Am 27.05.2011 21:11, schrieb Markus Armbruster:

Quoted 55 lines
Quoted 35 lines · Stefan Weil

Am 27.05.2011 19:22, schrieb Alexandre Raymond:

Quoted 30 lines

----8<----
qemu/target-lm32/translate.c: In function ‘gen_intermediate_code_internal’:
qemu/target-lm32/translate.c:1135: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 4 has type ‘int’ ----8<----

Both gen_opc_ptr and gen_opc_buf are "uint16_t *", so a simple '%d' should
be able to describe their relative difference.

---
target-lm32/translate.c | 2 +-

1 files changed, 1 insertions(+), 1 deletions(-)
target-lm32/translate.c +1 -1
index eb21158..0f69f27 100644
@@ -1132,7 +1132,7 @@ static void
 gen_intermediate_code_internal(CPUState *env,
 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
 qemu_log("\n");
 log_target_disas(pc_start, dc->pc - pc_start, 0);
- qemu_log("\nisize=%d osize=%zd\n",
+ qemu_log("\nisize=%d osize=%d\n",
 dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
 }
Quoted 1 line

#endif

Nack.

Quoted 3 lines

The original code is correct, because the difference of two pointers is always of type ssize_t (well, obviously not with your compiler, but then I assume that your compiler is broken).

ISO/IEC 9899:1999 §6.5.6 on pointer subtraction:

The size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t defined in the <stddef.h> header.

The pedantically correct way to print a pointer difference is the 't' type modifier. Ibid. §7.19.6.1 on fprintf():

t Specifies that a following d, i, o, u, x, or X conversion specifier applies to a ptrdiff_t or the corresponding unsigned integer type argument; or that a following n conversion specifier applies to a pointer to a ptrdiff_t argument.

Quoted 6 lines

ssize_t is POSIX, not ISO C. It can differ from ptrdiff_t only if ptrdiff_t has a different size than size_t, which would be kind of sick. ISO C permits all kinds of sickness. Whether tolerating a particular sickness is worth our while is another question.

[...]

That's correct. And ptrdiff_t needs %td.

Alexandre, could you please try %td instead of %zd?

Cheers,
Stefan W.

#21 lore raw

Re: [Qemu-devel] [PATCH 5/6] Remove warning in printf due to type mismatch

Quoted 5 lines · Alexandre Raymond

Hi Stefan and Markus,

Thanks for your feedback :)

"%td" doesn't generate warnings on Linux nor on OSX.

Stefan, what about Windows?

Paolo

#22 lore raw

Re: [Qemu-devel] [PATCH 5/6] Remove warning in printf due to type mismatch

Am 28.05.2011 08:55, schrieb Paolo Bonzini:

Quoted 10 lines · Alexandre Raymond
Quoted 5 lines

Hi Stefan and Markus,

Thanks for your feedback :)

"%td" doesn't generate warnings on Linux nor on OSX.

Stefan, what about Windows?

Paolo

%td is ok for Windows, too.
Alexandre, please send an update of your patch using %td.

Stefan W.

#25 lore raw
In reply to Alexandre Raymond

Hello,

Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

Quoted 5 lines

The following series contains trivial patches to fix several minor issues encountered while compiling qemu under OSX 10.6.7.

I used [./configure --disable-bsd-user --disable-darwin-user --enable-io-thread] to configure the build.

In the future, please cc me for Darwin. I'll review them tomorrow.

Thanks,
Andreas

#6 lore raw

Re: [Qemu-devel] [PATCH 2/6] Cocoa: avoid displaying window when command-line contains '-h'

In reply to Alexandre Raymond

Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

Quoted 16 lines

There was already a check in place to avoid displaying a window in certain modes such as vnc, nographic or curses.

Add a check for '-h' to avoid displaying a window for a split- second before showing the usage information.

---
ui/cocoa.m | 3 ++-

1 files changed, 2 insertions(+), 1 deletions(-)
ui/cocoa.m +0 -0
index 20f91bc..7fb8d96 100644

ui/cocoa.m int main (int argc, const char * argv[]) { · line 872

Quoted 9 lines
ui/cocoa.m +2 -1
@@ -865,7 +865,8 @@ int main (int argc, const char * argv[]) {
 
    /* In case we don't need to display a window, let's not do that */
    for (i = 1; i < argc; i++) {
-        if (!strcmp(argv[i], "-vnc") ||
+        if (!strcmp(argv[i], "-h") ||
+            !strcmp(argv[i], "-vnc") ||
            !strcmp(argv[i], "-nographic") ||
            !strcmp(argv[i], "-curses")) {
                return qemu_main(gArgc, gArgv);

Nack. I have a patch from Tristan queued (sorry, forgot to send pull request before my vacation), please rebase against that.

Cf. http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/cocoa-for-upstream

Also, your patch fails to detect -help.

BTW -M ? and others face a similar detection issue, so I believe while adding to this list is a handy short-term fix, we need a better solution there. Suggestions and patches welcome.

Andreas

#26 lore raw
In reply to Andreas Färber
Quoted 4 lines · Andreas Färber

Hello,

Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

Quoted 8 lines
Quoted 6 lines

The following series contains trivial patches to fix several minor issues encountered while compiling qemu under OSX 10.6.7.

I used [./configure --disable-bsd-user --disable-darwin-user --enable-io-thread]
to configure the build.

In the future, please cc me for Darwin. I'll review them tomorrow.

Okay these patches will go through the Andreas' tree. I won't be merging any of them into qemu-trivial.

Stefan

#2 lore raw

Re: [Qemu-devel] [PATCH 1/6] Fix incorrect check for fdatasync() in configure

In reply to Alexandre Raymond

Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

Quoted 7 lines

For some reason, darwin provides a symbol for fdatasync(), but doesn't officially support it.

The manpage for fdatasync on Linux states the following:

"On POSIX systems on which fdatasync() is available, _POSIX_SYNCHRONIZED_IO is defined in <unistd.h> to a value greater than 0."

The Open Group Base Specification Issue 7 says this on fdatasync():

"The functionality shall be equivalent to fsync() with the symbol _POSIX_SYNCHRONIZED_IO defined, with the exception that all I/O operations shall be completed as defined for synchronized I/O data integrity completion."

On unistd.h it goes on to say:

"_POSIX_SYNCHRONIZED_IO
[SIO]
The implementation supports the Synchronized Input and Output option. If this symbol is defined in <unistd.h>, it shall be defined to be -1, 0, or 200809L."

The change history has nothing on that define and its value -1, so I'm not convinced that this really is The Right Way to check.

Quoted 5 lines

In fact, unistd.h defines this value to "-1", at least on OSX 10.6.7.

Add this check to the configure file.

Andreas

Quoted 25 lines

---
configure | 8 +++++++-

1 files changed, 7 insertions(+), 1 deletions(-)
configure +0 -0
index a318d37..b21ef75 100755
@@ -2477,7 +2477,13 @@ fi

fdatasync=no
cat > $TMPC << EOF
#include <unistd.h>

configure +7 -1
-int main(void) { return fdatasync(0); }
+int main(void) {
+#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
+return fdatasync(0);
+#else
+#abort Not supported
+#endif
+}

EOF
if compile_prog "" "" ; then
fdatasync=yes

Signature · 1 line
1.7.5
#9 lore raw

Re: [Qemu-devel] [PATCH 3/6] Fix compilation warning due to incorrectly specified type

In reply to Stefan Weil

Am 27.05.2011 um 19:42 schrieb Stefan Weil:

Quoted 27 lines

Am 27.05.2011 19:22, schrieb Alexandre Raymond:

Quoted 26 lines

In audio/coreaudio.c, a variable named "str" was assigned "const char" values, which resulted in the following warnings:

-----8<-----
audio/coreaudio.c: In function ‘coreaudio_logstatus’:
audio/coreaudio.c:59: warning: initialization discards qualifiers from pointer target type audio/coreaudio.c:63: warning: assignment discards qualifiers from pointer target type (...)
-----8<-----

---
 audio/coreaudio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
audio/coreaudio.c +1 -1
index 0a26413..3bd75cd 100644
@@ -56,7 +56,7 @@ typedef struct coreaudioVoiceOut {
 
 static void coreaudio_logstatus (OSStatus status)
 {
-    char *str = "BUG";
+    const char *str = "BUG";
 
Quoted 5 lines

audio/coreaudio.c typedef struct coreaudioVoiceOut { · line 62

Quoted 3 lines
audio/coreaudio.c +0 -0
     switch(status) {
     case kAudioHardwareNoError:

Thanks, applied to the cocoa branch.

Andreas

#11 lore raw

Re: [Qemu-devel] [PATCH 4/6] Fix missing prototype under cocoa for qemu_main

In reply to Alexandre Raymond

Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

Quoted 19 lines

The following error message was encountered when compiling with cocoa support because qemu_main did not have a prototype.

-----8<-----
qemu/vl.c:2037: warning: no previous prototype for ‘qemu_main’ -----8<-----

Add its prototype in the COCOA ifdef, similar to what is done for SDL.

---
vl.c | 1 +

1 files changed, 1 insertions(+), 0 deletions(-)
vl.c +0 -0
index b362871..b983646 100644

vl.c int main(int argc, char **argv) · line 113

Quoted 7 lines
vl.c +1 -0
@@ -107,6 +107,7 @@ int main(int argc, char **argv)
 #endif /* CONFIG_SDL */
 
 #ifdef CONFIG_COCOA
+int qemu_main(int argc, char **argv, char **envp);
 #undef main
 #define main qemu_main
 #endif /* CONFIG_COCOA */

We've seen at least two different ways of fixing this.

I believe my last one was forgotten, waiting for someone to test with SDL. The idea was to have the prototype in a header shared between vl.c and cocoa.m, so that we don't have to duplicate the prototype. I'll see if I can dig it out or will post a new patch.

Andreas

#3 lore raw

Re: [Qemu-devel] [PATCH 1/6] Fix incorrect check for fdatasync() in configure

In reply to Andreas Färber

Hi Andreas,

According to this excerpt from The Open Group Base Specifications Issue 6 (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html),
'>0' indeed means that the functionality is implemented and can be used.
----8<----
The following symbolic constants, if defined in <unistd.h>, shall have a value of -1, 0, or greater, unless otherwise specified below. If these are undefined, the fpathconf(), pathconf(), or sysconf() functions can be used to determine whether the option is provided for a particular invocation of the application.

If a symbolic constant is defined with the value -1, the option is not supported. Headers, data types, and function interfaces required only for the option need not be supplied. An application that attempts to use anything associated only with the option is considered to be requiring an extension.

If a symbolic constant is defined with a value greater than zero, the option shall always be supported when the application is executed. All headers, data types, and functions shall be present and shall operate as specified.

If a symbolic constant is defined with the value zero, all headers, data types, and functions shall be present. The application can check at runtime to see whether the option is supported by calling fpathconf(), pathconf(), or sysconf() with the indicated name parameter.
----8<----

Alexandre

Quoted 64 lines · Andreas Färber

Am 27.05.2011 um 19:22 schrieb Alexandre Raymond:

Quoted 8 lines

For some reason, darwin provides a symbol for fdatasync(), but doesn't officially support it.

The manpage for fdatasync on Linux states the following:

"On POSIX  systems  on  which fdatasync() is available, _POSIX_SYNCHRONIZED_IO is defined in <unistd.h> to a value greater than 0."

The Open Group Base Specification Issue 7 says this on fdatasync():

"The functionality shall be equivalent to fsync() with the symbol _POSIX_SYNCHRONIZED_IO defined, with the exception that all I/O operations shall be completed as defined for synchronized I/O data integrity completion."

On unistd.h it goes on to say:

"_POSIX_SYNCHRONIZED_IO
[SIO]
The implementation supports the Synchronized Input and Output option. If this symbol is defined in <unistd.h>, it shall be defined to be -1, 0, or 200809L."

The change history has nothing on that define and its value -1, so I'm not convinced that this really is The Right Way to check.

Quoted 5 lines

In fact, unistd.h defines this value to "-1", at least on OSX 10.6.7.

Add this check to the configure file.

Andreas

Quoted 25 lines

---
configure |    8 +++++++-

1 files changed, 7 insertions(+), 1 deletions(-)
configure +0 -0
index a318d37..b21ef75 100755
@@ -2477,7 +2477,13 @@ fi

fdatasync=no
cat > $TMPC << EOF
#include <unistd.h>

configure +7 -1
-int main(void) { return fdatasync(0); }
+int main(void) {
+#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
+return fdatasync(0);
+#else
+#abort Not supported
+#endif
+}

EOF
if compile_prog "" "" ; then
   fdatasync=yes
--
1.7.5

#4 lore raw

Re: [Qemu-devel] [PATCH 1/6] Fix incorrect check for fdatasync() in configure

Hi Alexandre,

Am 29.05.2011 um 17:46 schrieb Alexandre Raymond:

Quoted 22 lines

According to this excerpt from The Open Group Base Specifications Issue 6 (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html),
'>0' indeed means that the functionality is implemented and can be used.
----8<----
The following symbolic constants, if defined in <unistd.h>, shall have a value of -1, 0, or greater, unless otherwise specified below. If these are undefined, the fpathconf(), pathconf(), or sysconf() functions can be used to determine whether the option is provided for a particular invocation of the application.

If a symbolic constant is defined with the value -1, the option is not supported. Headers, data types, and function interfaces required only for the option need not be supplied. An application that attempts to use anything associated only with the option is considered to be requiring an extension.

If a symbolic constant is defined with a value greater than zero, the option shall always be supported when the application is executed. All headers, data types, and functions shall be present and shall operate as specified.

Quoted 6 lines

If a symbolic constant is defined with the value zero, all headers, data types, and functions shall be present. The application can check at runtime to see whether the option is supported by calling fpathconf(), pathconf(), or sysconf() with the indicated name parameter.
----8<----

Indeed, confirmed in Issue 7, thanks a lot. Could you please provide me with an updated commit message saying so? Then I'll apply it.

Andreas

#12 lore raw

PATCH 1/1 cocoa: Provide central qemu_main() prototype

In reply to Andreas Färber

This fixes a missing prototype warning in vl.c and obsoletes the prototype in cocoa.m. Adjust callers in cocoa.m to supply third argument, which is currently only used on Linux/ppc.

The prototype is designed so that it could be shared with SDL and other frontends, if desired.

Cc Alexandre Raymond <[email protected]>
---
 qemu-common.h |    5 +++++
 ui/cocoa.m    |    6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)
qemu-common.h +5 -0
index b851b20..218289c 100644
@@ -131,6 +131,11 @@ static inline char *realpath(const char *path, char *resolved_path)
 
 #endif /* !defined(NEED_CPU_H) */
 
+/* main function, renamed */
+#if defined(CONFIG_COCOA)
+int qemu_main(int argc, char **argv, char **envp);
+#endif
+
 /* bottom halves */
 typedef void QEMUBHFunc(void *opaque);
 
ui/cocoa.m +3 -3
index 1ff1ac6..6566e46 100644
@@ -23,6 +23,7 @@
  */
 
 #import <Cocoa/Cocoa.h>
+#include <crt_externs.h>
 
 #include "qemu-common.h"
 #include "console.h"
@@ -61,7 +62,6 @@ typedef struct {
     int bitsPerPixel;
 } QEMUScreen;
 
-int qemu_main(int argc, char **argv); // main defined in qemu/vl.c
 NSWindow *normalWindow;
 id cocoaView;
 static DisplayChangeListener *dcl;
@@ -794,7 +794,7 @@ static int cocoa_keycode_to_qemu(int keycode)
     COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
 
     int status;
-    status = qemu_main(argc, argv);
+    status = qemu_main(argc, argv, *_NSGetEnviron());
     exit(status);
 }
 
@@ -876,7 +876,7 @@ int main (int argc, const char * argv[]) {
                 !strcmp(opt, "-nographic") ||
                 !strcmp(opt, "-version") ||
                 !strcmp(opt, "-curses")) {
-                return qemu_main(gArgc, gArgv);
+                return qemu_main(gArgc, gArgv, *_NSGetEnviron());
             }
         }
     }
Signature · 1 line
1.7.5.3
#13 lore raw

Re: [Qemu-devel] [PATCH] cocoa: Provide central qemu_main() prototype

Hi Andreas,

Just thinking out loud here : wouldn't it make more sense to put the main() of each gui framework directly in its corresponding file and select the right one in the makefile using the configure options?

so you'd have
-no gui -> ui/no_gui.c:main() -> qemu_main() === compile with no_gui.c + vl.c
-sdl -> ui/sdl.c:main() -> qemu_main() === compile with sdl.c + vl.c -cocoa -> ui/cocoa.m:main() -> qemu_main() === compile with cocoa.m + vl.c

with ui/no_gui.c, ui/sdl.c and ui/cocoa.m each having their own main():
----8<----
...

int main(...) {
    return qemu_main(....);
}

...
----8<----

and definitively rename main() to qemu_main() in vl.c ?

Alexandre

Quoted 72 lines · Andreas Färber

This fixes a missing prototype warning in vl.c and obsoletes the prototype in cocoa.m. Adjust callers in cocoa.m to supply third argument, which is currently only used on Linux/ppc.

The prototype is designed so that it could be shared with SDL and other frontends, if desired.

Cc Alexandre Raymond <[email protected]>

---
 qemu-common.h |    5 +++++
 ui/cocoa.m    |    6 +++---

 2 files changed, 8 insertions(+), 3 deletions(-)
qemu-common.h +5 -0
index b851b20..218289c 100644
@@ -131,6 +131,11 @@ static inline char *realpath(const char *path, char *resolved_path)
 
  #endif /* !defined(NEED_CPU_H) */
 
+/* main function, renamed */
+#if defined(CONFIG_COCOA)
+int qemu_main(int argc, char **argv, char **envp);
+#endif
+
  /* bottom halves */
  typedef void QEMUBHFunc(void *opaque);
 
ui/cocoa.m +2 -2
index 1ff1ac6..6566e46 100644
@@ -23,6 +23,7 @@
  */
 
  #import <Cocoa/Cocoa.h>
+#include <crt_externs.h>
 
  #include "qemu-common.h"
  #include "console.h"
@@ -61,7 +62,6 @@ typedef struct {
     int bitsPerPixel;
  } QEMUScreen;
 
-int qemu_main(int argc, char **argv); // main defined in qemu/vl.c
  NSWindow *normalWindow;
  id cocoaView;
  static DisplayChangeListener *dcl;
@@ -794,7 +794,7 @@ static int cocoa_keycode_to_qemu(int keycode)
     COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
 
     int status;
-    status = qemu_main(argc, argv);
+    status = qemu_main(argc, argv, *_NSGetEnviron());
     exit(status);
  }
 
@@ -876,7 +876,7 @@ int main (int argc, const char * argv[]) {

                !strcmp(opt, "-nographic") || !strcmp(opt, "-version") || !strcmp(opt, "-curses")) {
-                return qemu_main(gArgc, gArgv);
+                return qemu_main(gArgc, gArgv, *_NSGetEnviron()); }
        }
    }
--
1.7.5.3

#14 lore raw

Re: [Qemu-devel] [PATCH] cocoa: Provide central qemu_main() prototype

Am 30.05.2011 um 01:53 schrieb Alexandre Raymond:

Quoted 14 lines

Just thinking out loud here : wouldn't it make more sense to put the main() of each gui framework directly in its corresponding file and select the right one in the makefile using the configure options?

so you'd have
-no gui -> ui/no_gui.c:main() -> qemu_main() === compile with
no_gui.c + vl.c

(quoted diff) +1 -2
-sdl -> ui/sdl.c:main() -> qemu_main() === compile with sdl.c + vl.c
-cocoa -> ui/cocoa.m:main() -> qemu_main() === compile with cocoa.m  
+ vl.c

with ui/no_gui.c, ui/sdl.c and ui/cocoa.m each having their own main():
----8<----
...

Quoted 7 lines
int main(...) {
   return qemu_main(....);
}

...
----8<----

and definitively rename main() to qemu_main() in vl.c ?

Anthony, waiting on your comment here as it's an overall UI architectural question.

To me that sounds the wrong direction to fix this... The only frontend that forces another main() function on us seems to be SDL under some circumstances. For Cocoa that was a QEMU-internal choice.

Instead of always renaming our main() function, maybe we can introduce some general hooks from our main() that the frontends can use to initialize them? One hook would need to be before processing of options (since launching a Cocoa app may add some Cocoa-specific parameters from the desktop or AppleScript/Automator) and another one once the options are processed and it's clear what display mode we're in.

So should we go ahead with my patch for the next pull or do some reorganization touching all frontends?

Andreas

Quoted 73 lines

On Sun, May 29, 2011 at 3:58 PM, Andreas Färber <[email protected]

Quoted 72 lines

wrote:
This fixes a missing prototype warning in vl.c and obsoletes the prototype in cocoa.m. Adjust callers in cocoa.m to supply third argument, which is currently only used on Linux/ppc.

The prototype is designed so that it could be shared with SDL and other frontends, if desired.

Cc Alexandre Raymond <[email protected]>
---
 qemu-common.h |    5 +++++
 ui/cocoa.m    |    6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)
qemu-common.h +5 -0
index b851b20..218289c 100644
@@ -131,6 +131,11 @@ static inline char *realpath(const char *path,  
 char *resolved_path)
 
 #endif /* !defined(NEED_CPU_H) */
 
+/* main function, renamed */
+#if defined(CONFIG_COCOA)
+int qemu_main(int argc, char **argv, char **envp);
+#endif
+
 /* bottom halves */
 typedef void QEMUBHFunc(void *opaque);
ui/cocoa.m +3 -4
index 1ff1ac6..6566e46 100644
@@ -23,6 +23,7 @@
 */
 
 #import <Cocoa/Cocoa.h>
+#include <crt_externs.h>
 
 #include "qemu-common.h"
 #include "console.h"
@@ -61,7 +62,6 @@ typedef struct {
    int bitsPerPixel;
 } QEMUScreen;
 
-int qemu_main(int argc, char **argv); // main defined in qemu/vl.c
 NSWindow *normalWindow;
 id cocoaView;
 static DisplayChangeListener *dcl;
@@ -794,7 +794,7 @@ static int cocoa_keycode_to_qemu(int keycode)
    COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
 
    int status;
-    status = qemu_main(argc, argv);
+    status = qemu_main(argc, argv, *_NSGetEnviron());
    exit(status);
 }
 
@@ -876,7 +876,7 @@ int main (int argc, const char * argv[]) {
                !strcmp(opt, "-nographic") ||
                !strcmp(opt, "-version") ||
                !strcmp(opt, "-curses")) {
-                return qemu_main(gArgc, gArgv);
+                return qemu_main(gArgc, gArgv, *_NSGetEnviron());
            }
        }
    }
--

1.7.5.3

#15 lore raw

Re: [Qemu-devel] [PATCH] cocoa: Provide central qemu_main() prototype

In reply to Andreas Färber

Am 29.05.2011 um 21:58 schrieb Andreas Färber:

Quoted 9 lines

This fixes a missing prototype warning in vl.c and obsoletes the prototype in cocoa.m. Adjust callers in cocoa.m to supply third argument, which is currently only used on Linux/ppc.

The prototype is designed so that it could be shared with SDL and other frontends, if desired.

Cc Alexandre Raymond <[email protected]>

Applied to the cocoa branch.

Andreas

Quoted 64 lines

---

qemu-common.h |    5 +++++
ui/cocoa.m    |    6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
qemu-common.h +5 -0
index b851b20..218289c 100644
@@ -131,6 +131,11 @@ static inline char *realpath(const char *path,  
 char *resolved_path)
 
 #endif /* !defined(NEED_CPU_H) */
 
+/* main function, renamed */
+#if defined(CONFIG_COCOA)
+int qemu_main(int argc, char **argv, char **envp);
+#endif
+
 /* bottom halves */
 typedef void QEMUBHFunc(void *opaque);
ui/cocoa.m +3 -3
index 1ff1ac6..6566e46 100644
@@ -23,6 +23,7 @@
 */
 
 #import <Cocoa/Cocoa.h>
+#include <crt_externs.h>
 
 #include "qemu-common.h"
 #include "console.h"
@@ -61,7 +62,6 @@ typedef struct {
    int bitsPerPixel;
 } QEMUScreen;
 
-int qemu_main(int argc, char **argv); // main defined in qemu/vl.c
 NSWindow *normalWindow;
 id cocoaView;
 static DisplayChangeListener *dcl;
@@ -794,7 +794,7 @@ static int cocoa_keycode_to_qemu(int keycode)
    COCOA_DEBUG("QemuCocoaAppController: startEmulationWithArgc\n");
 
    int status;
-    status = qemu_main(argc, argv);
+    status = qemu_main(argc, argv, *_NSGetEnviron());
    exit(status);
 }
 
@@ -876,7 +876,7 @@ int main (int argc, const char * argv[]) {
                !strcmp(opt, "-nographic") ||
                !strcmp(opt, "-version") ||
                !strcmp(opt, "-curses")) {
-                return qemu_main(gArgc, gArgv);
+                return qemu_main(gArgc, gArgv, *_NSGetEnviron());
            }
        }
    }
Signature · 1 line
1.7.5.3