From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30972 invoked by alias); 8 Mar 2005 22:01:48 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30778 invoked from network); 8 Mar 2005 22:01:38 -0000 Received: from unknown (HELO sethra.codesourcery.com) (65.74.133.9) by sourceware.org with SMTP; 8 Mar 2005 22:01:38 -0000 Received: from sethra.codesourcery.com (localhost.localdomain [127.0.0.1]) by sethra.codesourcery.com (8.12.11/8.12.11) with ESMTP id j28M1cbp018162 for ; Tue, 8 Mar 2005 14:01:38 -0800 Received: (from mitchell@localhost) by sethra.codesourcery.com (8.12.11/8.12.11/Submit) id j28M1cBE018158; Tue, 8 Mar 2005 14:01:38 -0800 Date: Tue, 08 Mar 2005 22:01:00 -0000 Message-Id: <200503082201.j28M1cBE018158@sethra.codesourcery.com> From: Mark Mitchell To: gdb-patches@sources.redhat.com Subject: PATCH: Rename "struct environ" to "struct gdb_environ" Reply-to: mark@codesourcery.com X-SW-Source: 2005-03/txt/msg00128.txt.bz2 Some versions of the MinGW defines an "environ" macro. That conflicts with "struct environ" in GDB. This patch replaces "struct environ" with "struct gdb_environ" to avoid the problem. OK to apply? -- Mark Mitchell CodeSourcery, LLC mark@codesourcery.com 2005-03-08 Mark Mitchell * environ.h (struct environ): Rename to ... (struct gdb_environ): ... this. (make_environ): Update prototype. (free_environ): Likewise. (init_environ): Likewise. (get_in_environ): Likewise. (set_in_environ): Likewise. (unset_in_environ): Likewise. (environ_vector): Likewise. * environ.c (make_environ): Replace "struct environ" with "struct gdb_environ". (free_environ): Likewise. (init_environ): Likewise. (environ_vector): Likewise. (get_in_environ): Likewise. (set_in_environ): Likewise. (unset_in_environ): Likewise. * infcmd.c (inferior_environ): Likewise. * inferior.h (inferior_environ): Likewise. Index: environ.c =================================================================== RCS file: /cvs/src/src/gdb/environ.c,v retrieving revision 1.10 diff -c -5 -p -r1.10 environ.c *** environ.c 23 Nov 2003 20:41:16 -0000 1.10 --- environ.c 8 Mar 2005 21:44:09 -0000 *************** *** 26,52 **** #include "gdb_string.h" /* Return a new environment object. */ ! struct environ * make_environ (void) { ! struct environ *e; ! e = (struct environ *) xmalloc (sizeof (struct environ)); e->allocated = 10; e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *)); e->vector[0] = 0; return e; } /* Free an environment and all the strings in it. */ void ! free_environ (struct environ *e) { char **vector = e->vector; while (*vector) xfree (*vector++); --- 26,52 ---- #include "gdb_string.h" /* Return a new environment object. */ ! struct gdb_environ * make_environ (void) { ! struct gdb_environ *e; ! e = (struct gdb_environ *) xmalloc (sizeof (struct gdb_environ)); e->allocated = 10; e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *)); e->vector[0] = 0; return e; } /* Free an environment and all the strings in it. */ void ! free_environ (struct gdb_environ *e) { char **vector = e->vector; while (*vector) xfree (*vector++); *************** free_environ (struct environ *e) *** 57,67 **** /* Copy the environment given to this process into E. Also copies all the strings in it, so we can be sure that all strings in these environments are safe to free. */ void ! init_environ (struct environ *e) { extern char **environ; int i; if (environ == NULL) --- 57,67 ---- /* Copy the environment given to this process into E. Also copies all the strings in it, so we can be sure that all strings in these environments are safe to free. */ void ! init_environ (struct gdb_environ *e) { extern char **environ; int i; if (environ == NULL) *************** init_environ (struct environ *e) *** 89,107 **** /* Return the vector of environment E. This is used to get something to pass to execve. */ char ** ! environ_vector (struct environ *e) { return e->vector; } /* Return the value in environment E of variable VAR. */ char * ! get_in_environ (const struct environ *e, const char *var) { int len = strlen (var); char **vector = e->vector; char *s; --- 89,107 ---- /* Return the vector of environment E. This is used to get something to pass to execve. */ char ** ! environ_vector (struct gdb_environ *e) { return e->vector; } /* Return the value in environment E of variable VAR. */ char * ! get_in_environ (const struct gdb_environ *e, const char *var) { int len = strlen (var); char **vector = e->vector; char *s; *************** get_in_environ (const struct environ *e, *** 113,123 **** } /* Store the value in E of VAR as VALUE. */ void ! set_in_environ (struct environ *e, const char *var, const char *value) { int i; int len = strlen (var); char **vector = e->vector; char *s; --- 113,123 ---- } /* Store the value in E of VAR as VALUE. */ void ! set_in_environ (struct gdb_environ *e, const char *var, const char *value) { int i; int len = strlen (var); char **vector = e->vector; char *s; *************** set_in_environ (struct environ *e, const *** 160,170 **** } /* Remove the setting for variable VAR from environment E. */ void ! unset_in_environ (struct environ *e, char *var) { int len = strlen (var); char **vector = e->vector; char *s; --- 160,170 ---- } /* Remove the setting for variable VAR from environment E. */ void ! unset_in_environ (struct gdb_environ *e, char *var) { int len = strlen (var); char **vector = e->vector; char *s; Index: environ.h =================================================================== RCS file: /cvs/src/src/gdb/environ.h,v retrieving revision 1.3 diff -c -5 -p -r1.3 environ.h *** environ.h 6 Mar 2001 08:21:07 -0000 1.3 --- environ.h 8 Mar 2005 21:44:09 -0000 *************** *** 19,29 **** #if !defined (ENVIRON_H) #define ENVIRON_H 1 /* We manipulate environments represented as these structures. */ ! struct environ { /* Number of usable slots allocated in VECTOR. VECTOR always has one slot not counted here, to hold the terminating zero. */ int allocated; --- 19,29 ---- #if !defined (ENVIRON_H) #define ENVIRON_H 1 /* We manipulate environments represented as these structures. */ ! struct gdb_environ { /* Number of usable slots allocated in VECTOR. VECTOR always has one slot not counted here, to hold the terminating zero. */ int allocated; *************** struct environ *** 32,51 **** and the next one contains zero. Then come some unused slots. */ char **vector; }; ! extern struct environ *make_environ (void); ! extern void free_environ (struct environ *); ! extern void init_environ (struct environ *); ! extern char *get_in_environ (const struct environ *, const char *); ! extern void set_in_environ (struct environ *, const char *, const char *); ! extern void unset_in_environ (struct environ *, char *); ! extern char **environ_vector (struct environ *); #endif /* defined (ENVIRON_H) */ --- 32,51 ---- and the next one contains zero. Then come some unused slots. */ char **vector; }; ! extern struct gdb_environ *make_environ (void); ! extern void free_environ (struct gdb_environ *); ! extern void init_environ (struct gdb_environ *); ! extern char *get_in_environ (const struct gdb_environ *, const char *); ! extern void set_in_environ (struct gdb_environ *, const char *, const char *); ! extern void unset_in_environ (struct gdb_environ *, char *); ! extern char **environ_vector (struct gdb_environ *); #endif /* defined (ENVIRON_H) */ Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.134 diff -c -5 -p -r1.134 infcmd.c *** infcmd.c 21 Feb 2005 03:25:56 -0000 1.134 --- infcmd.c 8 Mar 2005 21:44:10 -0000 *************** enum step_over_calls_kind step_over_call *** 196,206 **** int step_multi; /* Environment to use for running inferior, in format described in environ.h. */ ! struct environ *inferior_environ; /* Accessor routines. */ char * get_inferior_args (void) --- 196,206 ---- int step_multi; /* Environment to use for running inferior, in format described in environ.h. */ ! struct gdb_environ *inferior_environ; /* Accessor routines. */ char * get_inferior_args (void) Index: inferior.h =================================================================== RCS file: /cvs/src/src/gdb/inferior.h,v retrieving revision 1.69 diff -c -5 -p -r1.69 inferior.h *** inferior.h 12 Sep 2004 15:05:05 -0000 1.69 --- inferior.h 8 Mar 2005 21:44:10 -0000 *************** extern int inferior_ignoring_startup_exe *** 143,153 **** */ extern int inferior_ignoring_leading_exec_events; /* Inferior environment. */ ! extern struct environ *inferior_environ; extern void clear_proceed_status (void); extern void proceed (CORE_ADDR, enum target_signal, int); --- 143,153 ---- */ extern int inferior_ignoring_leading_exec_events; /* Inferior environment. */ ! extern struct gdb_environ *inferior_environ; extern void clear_proceed_status (void); extern void proceed (CORE_ADDR, enum target_signal, int);