Skip to content

Commit

Permalink
Remove "using namespace std" from vvp header files and fix the fallout.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinwhitaker committed Nov 4, 2021
1 parent 23390c1 commit 9cc09b8
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 49 deletions.
8 changes: 0 additions & 8 deletions tgt-vvp/vvp_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#if defined(__cplusplus)
# if !defined(__GNUC__)
using namespace std;
# elif (__GNUC__ == 3)
using namespace std;
# endif
#endif

# undef HAVE_STDINT_H
# undef HAVE_INTTYPES_H

Expand Down
2 changes: 2 additions & 0 deletions vvp/arith.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# include <cstdlib>
# include <cmath>

using namespace std;

vvp_arith_::vvp_arith_(unsigned wid)
: wid_(wid), op_a_(wid), op_b_(wid), x_val_(wid)
{
Expand Down
2 changes: 2 additions & 0 deletions vvp/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
# include <cassert>
# include "ivl_alloc.h"

using namespace std;

unsigned long count_net_arrays = 0;
unsigned long count_net_array_words = 0;
unsigned long count_var_arrays = 0;
Expand Down
8 changes: 3 additions & 5 deletions vvp/compile.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IVL_compile_H
#define IVL_compile_H
/*
* Copyright (c) 2001-2020 Stephen Williams ([email protected])
* Copyright (c) 2001-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand All @@ -27,13 +27,11 @@
# include "sv_vpi_user.h"
# include "vvp_net.h"

using namespace std;

/*
* The file names are kept in this vector. Entry 0 is "N/A" and 1 is
* for interactive commands.
*/
extern vector<const char*> file_names;
extern std::vector<const char*> file_names;

/*
* The functions described here are the compile time support
Expand All @@ -54,7 +52,7 @@ extern bool verbose_flag;
* If this file opened, then write debug information to this
* file. This is used for debugging the VVP runtime itself.
*/
extern ofstream debug_file;
extern std::ofstream debug_file;

/*
* Connect a list of symbols to a contiguous set of ipoints.
Expand Down
3 changes: 2 additions & 1 deletion vvp/concat.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2010 Stephen Williams ([email protected])
* Copyright (c) 2004-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand All @@ -23,6 +23,7 @@
# include <iostream>
# include <cassert>

using namespace std;

vvp_fun_concat::vvp_fun_concat(unsigned w0, unsigned w1,
unsigned w2, unsigned w3)
Expand Down
8 changes: 0 additions & 8 deletions vvp/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#if defined(__cplusplus)
# if !defined(__GNUC__)
using namespace std;
# elif (__GNUC__ == 3)
using namespace std;
# endif
#endif

# define SIZEOF_UNSIGNED_LONG_LONG 0
#ifndef SIZEOF_UNSIGNED_LONG
# define SIZEOF_UNSIGNED_LONG 0
Expand Down
4 changes: 3 additions & 1 deletion vvp/delay.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005-2020 Stephen Williams <[email protected]>
* Copyright (c) 2005-2021 Stephen Williams <[email protected]>
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -31,6 +31,8 @@
#include <cmath>
#include "ivl_alloc.h"

using namespace std;

void vvp_delay_t::calculate_min_delay_()
{
min_delay_ = rise_;
Expand Down
4 changes: 3 additions & 1 deletion vvp/enum_type.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2012 Stephen Williams ([email protected])
* Copyright (c) 2010-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand All @@ -25,6 +25,8 @@
# include <iostream>
# include <cassert>

using namespace std;

struct enumconst_s : public __vpiHandle {
enumconst_s();
int get_type_code(void) const;
Expand Down
2 changes: 2 additions & 0 deletions vvp/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const char COPYRIGHT[] =
# include <windows.h>
#endif

using namespace std;

ofstream debug_file;

#if defined(__MINGW32__) && !defined(HAVE_GETOPT_H)
Expand Down
4 changes: 3 additions & 1 deletion vvp/parse.y
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

%{
/*
* Copyright (c) 2001-2020 Stephen Williams ([email protected])
* Copyright (c) 2001-202` Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -29,6 +29,8 @@
# include "ivl_alloc.h"
# include "version_base.h"

using namespace std;

/*
* These are bits in the lexor.
*/
Expand Down
4 changes: 3 additions & 1 deletion vvp/part.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2016 Stephen Williams ([email protected])
* Copyright (c) 2004-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand All @@ -26,6 +26,8 @@
# include <iostream>
# include <cassert>

using namespace std;

struct vvp_fun_part_state_s {
vvp_fun_part_state_s() : bitsr(0.0) {}

Expand Down
3 changes: 2 additions & 1 deletion vvp/resolv.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2013 Stephen Williams ([email protected])
* Copyright (c) 2001-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand All @@ -25,6 +25,7 @@
# include <algorithm>
# include <cassert>

using namespace std;

/*
* The core functor for a resolver node stores all the input values
Expand Down
2 changes: 2 additions & 0 deletions vvp/schedule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
# include "ivl_alloc.h"
#endif

using namespace std;

unsigned long count_assign_events = 0;
unsigned long count_gen_events = 0;
unsigned long count_thread_events = 0;
Expand Down
4 changes: 3 additions & 1 deletion vvp/udp.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005-2019 Stephen Williams ([email protected])
* Copyright (c) 2005-2021 Stephen Williams ([email protected])
*
* (This is a rewrite of code that was ...
* Copyright (c) 2001 Stephan Boettcher <[email protected]>)
Expand Down Expand Up @@ -35,6 +35,8 @@
#include "ivl_alloc.h"
#endif

using namespace std;

// We may need these later when we build the VPI interface to
// UDP definitions.
#ifdef CHECK_WITH_VALGRIND
Expand Down
4 changes: 2 additions & 2 deletions vvp/udp.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IVL_udp_H
#define IVL_udp_H
/*
* Copyright (c) 2005-2014 Stephen Williams ([email protected])
* Copyright (c) 2005-2021 Stephen Williams ([email protected])
*
* (This is a rewrite of code that was ...
* Copyright (c) 2001 Stephan Boettcher <[email protected]>)
Expand Down Expand Up @@ -109,7 +109,7 @@ struct udp_levels_table {
unsigned long mask1;
unsigned long maskx;
};
extern ostream& operator<< (ostream&o, const struct udp_levels_table&t);
extern std::ostream& operator<< (std::ostream&o, const struct udp_levels_table&t);

class vvp_udp_comb_s : public vvp_udp_s {

Expand Down
3 changes: 3 additions & 0 deletions vvp/vpi_callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
# include <cstdio>
# include <cassert>
# include <cstdlib>

using namespace std;

/*
* Callback handles are created when the VPI function registers a
* callback. The handle is stored by the run time, and it triggered
Expand Down
2 changes: 2 additions & 0 deletions vvp/vpi_vthr_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
# include <cassert>
# include "ivl_alloc.h"

using namespace std;

/*
* Hex digits that represent 4-value bits of Verilog are not as
* trivially obvious to display as if the bits were the usual 2-value
Expand Down
4 changes: 2 additions & 2 deletions vvp/vvp_darray.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IVL_vvp_darray_H
#define IVL_vvp_darray_H
/*
* Copyright (c) 2012-2020 Stephen Williams ([email protected])
* Copyright (c) 2012-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -247,6 +247,6 @@ class vvp_queue_vec4 : public vvp_queue {
std::deque<vvp_vector4_t> queue;
};

extern string get_fileline();
extern std::string get_fileline();

#endif /* IVL_vvp_darray_H */
4 changes: 3 additions & 1 deletion vvp/vvp_island.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2020 Stephen Williams ([email protected])
* Copyright (c) 2008-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -32,6 +32,8 @@
# include <cstring>
# include "ivl_alloc.h"

using namespace std;

static bool at_EOS = false;

void island_send_value(vvp_net_t*net, const vvp_vector8_t&val)
Expand Down
4 changes: 3 additions & 1 deletion vvp/vvp_net.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2020 Stephen Williams ([email protected])
* Copyright (c) 2004-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -41,6 +41,8 @@
# include "ivl_alloc.h"
#endif

using namespace std;

/* This is the size of an unsigned long in bits. This is just a
convenience macro. */
# define CPU_WORD_BITS (8*sizeof(unsigned long))
Expand Down
17 changes: 7 additions & 10 deletions vvp/vvp_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@
#ifdef HAVE_IOSFWD
# include <iosfwd>
#else
class ostream;
# include <iostream>
#endif

# include "ivl_alloc.h"

using namespace std;


/* Data types */
class vvp_scalar_t;

Expand Down Expand Up @@ -186,7 +183,7 @@ inline vvp_bit4_t operator & (vvp_bit4_t a, vvp_bit4_t b)


extern vvp_bit4_t operator ^ (vvp_bit4_t a, vvp_bit4_t b);
extern ostream& operator<< (ostream&o, vvp_bit4_t a);
extern std::ostream& operator<< (std::ostream&o, vvp_bit4_t a);

/* Return >0, ==0 or <0 if the from-to transition represents a
posedge, no edge, or negedge. */
Expand Down Expand Up @@ -529,7 +526,7 @@ inline vvp_vector4_t operator ~ (const vvp_vector4_t&that)
return res;
}

extern ostream& operator << (ostream&, const vvp_vector4_t&);
extern std::ostream& operator << (std::ostream&, const vvp_vector4_t&);

extern vvp_bit4_t compare_gtge(const vvp_vector4_t&a,
const vvp_vector4_t&b,
Expand Down Expand Up @@ -739,7 +736,7 @@ extern vvp_vector4_t c4string_to_vector4(const char*str);
extern bool crstring_test(const char*str);
extern double crstring_to_double(const char*str);

extern ostream& operator<< (ostream&, const vvp_vector2_t&);
extern std::ostream& operator<< (std::ostream&, const vvp_vector2_t&);

inline vvp_vector2_t::vvp_vector2_t(const vvp_vector2_t&that)
{
Expand Down Expand Up @@ -892,7 +889,7 @@ inline vvp_scalar_t resolve(vvp_scalar_t a, vvp_scalar_t b)
return fully_featured_resolv_(a,b);
}

extern ostream& operator<< (ostream&, vvp_scalar_t);
extern std::ostream& operator<< (std::ostream&, vvp_scalar_t);

/*
* This class is a way to carry vectors of strength modeled
Expand Down Expand Up @@ -976,7 +973,7 @@ extern bool c8string_test(const char*str);
extern vvp_vector8_t c8string_to_vector8(const char*str);

/* Print a vector8 value to a stream. */
extern ostream& operator<< (ostream&, const vvp_vector8_t&);
extern std::ostream& operator<< (std::ostream&, const vvp_vector8_t&);

inline vvp_vector8_t::vvp_vector8_t(unsigned size__)
: size_(size__)
Expand Down Expand Up @@ -1075,7 +1072,7 @@ template <class T> class vvp_sub_pointer_t {
};

typedef vvp_sub_pointer_t<vvp_net_t> vvp_net_ptr_t;
template <class T> ostream& operator << (ostream&out, vvp_sub_pointer_t<T> val)
template <class T> std::ostream& operator << (std::ostream&out, vvp_sub_pointer_t<T> val)
{ out << val.ptr() << "[" << val.port() << "]"; return out; }

/*
Expand Down
6 changes: 2 additions & 4 deletions vvp/vvp_net_sig.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IVL_vvp_net_sig_H
#define IVL_vvp_net_sig_H
/*
* Copyright (c) 2004-2020 Stephen Williams ([email protected])
* Copyright (c) 2004-2021 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -33,11 +33,9 @@
#ifdef HAVE_IOSFWD
# include <iosfwd>
#else
class ostream;
# include <iostream>
#endif

using namespace std;

/* vvp_fun_signal
* This node is the place holder in a vvp network for signals,
* including nets of various sort. The output from a signal follows
Expand Down
Loading

0 comments on commit 9cc09b8

Please sign in to comment.