Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Mitchell <mark@codesourcery.com>
To: gdb-patches@sources.redhat.com
Subject: PATCH: Rename "struct environ" to "struct gdb_environ"
Date: Tue, 08 Mar 2005 22:01:00 -0000	[thread overview]
Message-ID: <200503082201.j28M1cBE018158@sethra.codesourcery.com> (raw)


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);
  


             reply	other threads:[~2005-03-08 22:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-08 22:01 Mark Mitchell [this message]
2005-03-08 22:09 ` Daniel Jacobowitz
2005-03-08 22:18   ` Mark Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200503082201.j28M1cBE018158@sethra.codesourcery.com \
    --to=mark@codesourcery.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox