Patch: dyngen-exec.h for OpenBSD
This is relative to the 20070319 snapshot.
dyngen-exec.h renamed from dyngen-exec.h.orig +10 -1
@@ -27,11 +27,15 @@#define _FILEDEFED#endif +#include "config.h" +/* NOTE: standard headers should be used with special care at this point because host CPU registers are used as global variables. Some host headers do not allow that. */ #include <stddef.h> - +#ifdef __OpenBSD__ +#include <sys/types.h> +#else typedef unsigned char uint8_t ;typedef unsigned short uint16_t ;typedef unsigned int uint32_t ;
@@ -61,6 +65,7 @@ typedef signed long int64_t;typedef signed long long int64_t ;#endif #endif +#endif /* XXX: This may be wrong for 64-bit ILP32 hosts. */ typedef void *host_reg_t ;
@@ -78,11 +83,15 @@ typedef void * host_reg_t;#define UINT32_MAX (4294967295U)#define UINT64_MAX ((uint64_t)(18446744073709551615)) +#ifdef __OpenBSD__ +typedef struct __sFILE FILE ; +#else typedef struct FILE FILE ;extern int fprintf (FILE *,const char *, ...);extern int printf (const char *, ...);#undef NULL#define NULL 0 +#endif #ifdef __i386__#define AREG0 "ebp"
Signature · 12 lines
Todd Fries .. [email protected] _____________________________________________ | \ 1.636.410.0632 (voice) | Free Daemon Consulting, LLC \ 1.405.227.9094 (voice) | http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX) | "..in support of free software solutions." \ 250797 (FWD) | \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A http://todd.fries.net/pgp.txt
dyngen-exec.h line 31
Quoted 11 lines · Todd T. Fries
This is relative to the 20070319 snapshot.
dyngen-exec.h renamed from dyngen-exec.h.orig +2
-0@@ -27,11 +27,15 @@#define _FILEDEFED#endif +#include "config.h" +
Doesn't seem to be necessary in the header.
Quoted 12 lines
dyngen-exec.h renamed from dyngen-exec.h.orig +3
-1/* NOTE: standard headers should be used with special care at this point because host CPU registers are used as global variables. Some host headers do not allow that. */ #include <stddef.h> - +#ifdef __OpenBSD__ +#include <sys/types.h> +#else typedef unsigned char uint8_t ;typedef unsigned short uint16_t ;typedef unsigned int uint32_t ;
dyngen-exec.h typedef signed long int64_t; · line 68
Quoted 4 lines
dyngen-exec.h renamed from dyngen-exec.h.orig +1
-0@@ -61,6 +65,7 @@ typedef signed long int64_t;typedef signed long long int64_t ;#endif #endif +#endif
Is this specialcase really needed for OpenBSD?
Quoted 5 lines
dyngen-exec.h renamed from dyngen-exec.h.orig +0
-0/* XXX: This may be wrong for 64-bit ILP32 hosts. */ typedef void *host_reg_t ;@@ -78,11 +83,15 @@ typedef void * host_reg_t;#define UINT32_MAX (4294967295U)#define UINT64_MAX ((uint64_t)(18446744073709551615))
dyngen-exec.h typedef void * host_reg_t; · line 94
Quoted 10 lines
dyngen-exec.h renamed from dyngen-exec.h.orig +4
-0+#ifdef __OpenBSD__ +typedef struct __sFILE FILE ; +#else typedef struct FILE FILE ;extern int fprintf (FILE *,const char *, ...);extern int printf (const char *, ...);#undef NULL#define NULL 0 +#endif
Shouldn't this cover only the FILE typedef?
Thiemo
Penned by Thiemo Seufer on 20070402 10:54.53, we have:
| > /* NOTE: standard headers should be used with special care at this | > point because host CPU registers are used as global variables. Some | > host headers do not allow that. */ | > #include <stddef.h> | > - | > +#ifdef __OpenBSD__ | > +#include <sys/types.h> | > +#else | > typedef unsigned char uint8_t; | > typedef unsigned short uint16_t; | > typedef unsigned int uint32_t; | > @@ -61,6 +65,7 @@ typedef signed long int64_t; | > typedef signed long long int64_t; | > #endif | > #endif | > +#endif | | Is this specialcase really needed for OpenBSD?
Can you honestly tell me that on all platforms this is true?
Hello? Portability? sys/types.h defines these types portably. Doing so the way this code does it, is not portable.
I left your non portable code to you; if systems in general define these types in sys/types.h then just remove the typedefs, problem solved.
| > /* XXX: This may be wrong for 64-bit ILP32 hosts. */ | > typedef void * host_reg_t; | > @@ -78,11 +83,15 @@ typedef void * host_reg_t; | > #define UINT32_MAX (4294967295U) | > #define UINT64_MAX ((uint64_t)(18446744073709551615)) | > | > +#ifdef __OpenBSD__ | > +typedef struct __sFILE FILE; | > +#else | > typedef struct FILE FILE; | > extern int fprintf(FILE *, const char *, ...); | > extern int printf(const char *, ...); | > #undef NULL | > #define NULL 0 | > +#endif | | Shouldn't this cover only the FILE typedef?
Why is it that qemu knows what the definition of these prototypes are on all systems without consulting the header files. I have a better idea, lets let the header files define the prototypes. Who would have though of that?
.. of course I purposefully intended to remove cruft that is in header files and belongs in header files.
I'll look at your other comments later, but these I see later in the discussion are nearing inclusion with your recommended tweaks.
I'll submit patches to correct things again if necessary.
Thanks,
Signature · 12 lines
Todd Fries .. [email protected] _____________________________________________ | \ 1.636.410.0632 (voice) | Free Daemon Consulting, LLC \ 1.405.227.9094 (voice) | http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX) | "..in support of free software solutions." \ 250797 (FWD) | \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A http://todd.fries.net/pgp.txt
Quoted 21 lines · Todd T. Fries
Penned by Thiemo Seufer on 20070402 10:54.53, we have:
| > /* NOTE: standard headers should be used with special care at this | > point because host CPU registers are used as global variables. Some | > host headers do not allow that. */ | > #include <stddef.h> | > - | > +#ifdef __OpenBSD__ | > +#include <sys/types.h> | > +#else | > typedef unsigned char uint8_t; | > typedef unsigned short uint16_t; | > typedef unsigned int uint32_t; | > @@ -61,6 +65,7 @@ typedef signed long int64_t; | > typedef signed long long int64_t; | > #endif | > #endif | > +#endif | | Is this specialcase really needed for OpenBSD?
Quoted 8 lines
Can you honestly tell me that on all platforms this is true?
Hello? Portability?
sys/types.hdefines these types portably. Doing so the way this code does it, is not portable.I left your non portable code to you; if systems in general define these types in
sys/types.hthen just remove the typedefs, problem solved.
Please consider the NOTE: above those includes.
Quoted 18 lines
| > /* XXX: This may be wrong for 64-bit ILP32 hosts. */ | > typedef void * host_reg_t; | > @@ -78,11 +83,15 @@ typedef void * host_reg_t; | > #define UINT32_MAX (4294967295U) | > #define UINT64_MAX ((uint64_t)(18446744073709551615)) | > | > +#ifdef __OpenBSD__ | > +typedef struct __sFILE FILE; | > +#else | > typedef struct FILE FILE; | > extern int fprintf(FILE *, const char *, ...); | > extern int printf(const char *, ...); | > #undef NULL | > #define NULL 0 | > +#endif | | Shouldn't this cover only the FILE typedef?
Quoted 7 lines
Why is it that qemu knows what the definition of these prototypes are on all systems without consulting the header files. I have a better idea, lets let the header files define the prototypes. Who would have though of that?
.. of course I purposefully intended to remove cruft that is in header files and belongs in header files.
See above.
Thiemo
Quoted 10 lines · Todd T. Fries
Penned by Thiemo Seufer on 20070402 10:54.53, we have:
| > /* NOTE: standard headers should be used with special care at this | > point because host CPU registers are used as global variables. Some | > host headers do not allow that. */ | > #include <stddef.h> | > - | > +#ifdef __OpenBSD__ | > +#include <sys/types.h>Hello? Portability? sys/types.h defines these types portably. Doing so the way this code does it, is not portable.
If you want portability you should be including stdint.h (or inttypes.h for old, broken systems).
Quoted 4 lines
Why is it that qemu knows what the definition of these prototypes are on all systems without consulting the header files. I have a better idea, lets let the header files define the prototypes. Who would have though of that?
See the big NOTE: comment above. dyngen is inherently unportable.
Paul
Quoted 14 lines · Paul Brook
Quoted 11 lines · Todd T. Fries
Penned by Thiemo Seufer on 20070402 10:54.53, we have:
| > /* NOTE: standard headers should be used with special care at this | > point because host CPU registers are used as global variables. Some | > host headers do not allow that. */ | > #include <stddef.h> | > - | > +#ifdef __OpenBSD__ | > +#include <sys/types.h>Hello? Portability?
sys/types.hdefines these types portably. Doing so the way this code does it, is not portable.
Quoted 2 lines
If you want portability you should be including
stdint.h(orinttypes.hfor old, broken systems).
I thought I'd add that this isn't just portability. stdint.h is what C99 mandates although as Paul mentions, some older systems used inttypes.h.
Regards,
Anthony Liguori
Quoted 13 lines
Quoted 5 lines
Why is it that qemu knows what the definition of these prototypes are on all systems without consulting the header files. I have a better idea, lets let the header files define the prototypes. Who would have though of that?
See the big NOTE: comment above. dyngen is inherently unportable.
Paul