Avoid conflicts with Solaris <sys/regset.h> defines that clash with our names

When building on Solaris with _XOPEN_SOURCE set to a recent XPG release,
<stdlib.h> and other core headers start including <sys/regset.h>, which
has a bunch of unfortunately named macros such as "CS", "ES", etc. for
x86 & x64 registers which clash with existing variable & struct member
names in Xorg - so #undef these so they don't interfere with our use.

(Yes, have filed a bug against the system headers for exposing these,
 but this solves the problem for building on existing releases.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Alan Coopersmith 2013-11-07 21:05:33 -08:00 committed by Keith Packard
parent d7f9be0f85
commit c4c154d18e
4 changed files with 34 additions and 1 deletions

View File

@ -38,6 +38,16 @@
****************************************************************************/
#include <stdlib.h>
#if defined(__sun) && defined(CS) /* avoid conflicts with Solaris sys/regset.h */
# undef CS
# undef DS
# undef SS
# undef ES
# undef FS
# undef GS
#endif
#include "x86emu/x86emui.h"
/*----------------------------- Implementation ----------------------------*/

View File

@ -112,6 +112,15 @@ struct i386_special_regs {
* CS, DS, ES, SS.
*/
#if defined(__sun) && defined(CS) /* avoid conflicts with Solaris sys/regset.h */
# undef CS
# undef DS
# undef SS
# undef ES
# undef FS
# undef GS
#endif
struct i386_segment_regs {
u16 CS, DS, SS, ES, FS, GS;
};

View File

@ -73,7 +73,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#endif
/* avoid conflicts with Solaris sys/regset.h */
# if defined(__sun) && defined(CS)
# undef CS
# undef DS
# undef SS
# undef ES
# undef FS
# undef GS
# endif
#endif /* NO_SYS_HEADERS */
/*--------------------------- Inline Functions ----------------------------*/
#ifdef __cplusplus

View File

@ -1393,6 +1393,10 @@ typedef struct {
short first, last; /* if for extension, major opcode interval */
} SetInfoRec, *SetInfoPtr;
#if defined(ERR) && defined(__sun)
#undef ERR /* Avoid conflict with Solaris <sys/regset.h> */
#endif
/* These constant are used to index into an array of SetInfoRec. */
enum { REQ, /* set info for requests */
REP, /* set info for replies */