Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* PATCH: Rename "struct environ" to "struct gdb_environ"
@ 2005-03-08 22:01 Mark Mitchell
  2005-03-08 22:09 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Mitchell @ 2005-03-08 22:01 UTC (permalink / raw)
  To: gdb-patches


Some versions of the MinGW <stdlib.h> 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  <mark@codesourcery.com>

	* 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"
  \f
  
  /* 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"
  \f
  
  /* 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;
  }
  \f
  /* 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;
  }
  \f
  /* 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;
  \f
  /* 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;
  \f
  /* 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);
  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Rename "struct environ" to "struct gdb_environ"
  2005-03-08 22:01 PATCH: Rename "struct environ" to "struct gdb_environ" Mark Mitchell
@ 2005-03-08 22:09 ` Daniel Jacobowitz
  2005-03-08 22:18   ` Mark Mitchell
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2005-03-08 22:09 UTC (permalink / raw)
  To: Mark Mitchell; +Cc: gdb-patches

On Tue, Mar 08, 2005 at 02:01:38PM -0800, Mark Mitchell wrote:
> 
> Some versions of the MinGW <stdlib.h> 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?

Yes, this is OK.  environ.[ch] and inferior.h also need copyright year
updates - and please add 2004 for inferior.h while you're there.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: Rename "struct environ" to "struct gdb_environ"
  2005-03-08 22:09 ` Daniel Jacobowitz
@ 2005-03-08 22:18   ` Mark Mitchell
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Mitchell @ 2005-03-08 22:18 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

Daniel Jacobowitz wrote:
> On Tue, Mar 08, 2005 at 02:01:38PM -0800, Mark Mitchell wrote:
> 
>>Some versions of the MinGW <stdlib.h> 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?
> 
> 
> Yes, this is OK.  environ.[ch] and inferior.h also need copyright year
> updates - and please add 2004 for inferior.h while you're there.

Done, thanks.

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-08 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-08 22:01 PATCH: Rename "struct environ" to "struct gdb_environ" Mark Mitchell
2005-03-08 22:09 ` Daniel Jacobowitz
2005-03-08 22:18   ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox