Merge branch 'master' into ord

This commit is contained in:
James Cherry 2020-04-25 13:33:17 -07:00
commit 658be26021
13 changed files with 343 additions and 305 deletions

View File

@ -1,16 +1,27 @@
# This is "close" to correct but has a number of bugs that prevent
# using it on the source tree.
Language: Cpp Language: Cpp
BasedOnStyle: Google BasedOnStyle: Google
AlignOperands: false AlignOperands: false
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: InlineOnly AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: TopLevel AlwaysBreakAfterReturnType: TopLevel
BinPackArguments: false
# fails # fails
BinPackParameters: false BinPackParameters: false
BraceWrapping: BraceWrapping:
AfterClass: true AfterClass: true
AfterStruct: true AfterStruct: true
AfterFunction: true AfterFunction: true
BeforeElse: true
BreakBeforeBraces: Custom BreakBeforeBraces: Custom
# fails # fails if all initializers fit on one line
BreakConstructorInitializers: AfterColon BreakConstructorInitializers: AfterColon
ColumnLimit: 0
# fails
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
IncludeBlocks: Preserve

View File

@ -24,7 +24,9 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14)
cmake_policy(SET CMP0086 NEW) cmake_policy(SET CMP0086 NEW)
endif() endif()
project(STA VERSION 2.1.0) project(STA VERSION 2.1.0
LANGUAGES CXX
)
option(CUDD_DIR "CUDD BDD package directory") option(CUDD_DIR "CUDD BDD package directory")
@ -474,11 +476,14 @@ target_link_libraries(sta
OpenSTA OpenSTA
sta_swig sta_swig
${TCL_LIBRARY} ${TCL_LIBRARY}
${ZLIB_LIBRARIES}
) )
if (ZLIB_LIBRARIES)
target_link_libraries(sta ${ZLIB_LIBRARIES})
endif()
if (CUDD_LIB) if (CUDD_LIB)
target_link_libraries(sta ${CUDD_LIB}) target_link_libraries(sta ${CUDD_LIB})
endif() endif()
message(STATUS "STA executable: ${STA_HOME}/app/sta") message(STATUS "STA executable: ${STA_HOME}/app/sta")

View File

@ -7,7 +7,6 @@ RUN yum group install -y "Development Tools" \
&& yum install -y https://centos7.iuscommunity.org/ius-release.rpm \ && yum install -y https://centos7.iuscommunity.org/ius-release.rpm \
&& yum install -y wget git centos-release-scl devtoolset-8 \ && yum install -y wget git centos-release-scl devtoolset-8 \
devtoolset-8-libatomic-devel tcl-devel tcl tk libstdc++ tk-devel pcre-devel \ devtoolset-8-libatomic-devel tcl-devel tcl tk libstdc++ tk-devel pcre-devel \
python36u python36u-libs python36u-devel python36u-pip && \
yum clean -y all && \ yum clean -y all && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*

View File

@ -35,12 +35,10 @@ if (NOT TCL_LIB_PATHS)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(TCL_LIB_PATHS /usr/local/lib) set(TCL_LIB_PATHS /usr/local/lib)
set(TCL_NO_DEFAULT_PATH TRUE) set(TCL_NO_DEFAULT_PATH TRUE)
endif() elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") set(TCL_LIB_PATHS /usr/lib /usr/local/lib)
set(TCL_LIB_PATHS /usr/lib
/usr/local/lib
)
set(TCL_NO_DEFAULT_PATH FALSE) set(TCL_NO_DEFAULT_PATH FALSE)
endif()
endif() endif()
if (NOT TCL_LIBRARY) if (NOT TCL_LIBRARY)

View File

@ -515,9 +515,14 @@ Graph::makeArrivals(Vertex *vertex,
} }
Arrival * Arrival *
Graph::arrivals(Vertex *vertex) const Graph::arrivals(Vertex *vertex)
{ {
return arrivals_.pointer(vertex->arrivals()); Arrival *arrivals;
{
UniqueLock lock(arrivals_lock_);
arrivals = arrivals_.pointer(vertex->arrivals());
}
return arrivals;
} }
void void
@ -1169,6 +1174,16 @@ Vertex::setHasRequireds(bool has_req)
has_requireds_ = has_req; has_requireds_ = has_req;
} }
void
Vertex::deletePaths()
{
arrivals_ = arrival_null;
prev_paths_ = prev_path_null;
tag_group_index_ = tag_group_index_max;
has_requireds_ = false;
crpr_path_pruning_disabled_ = false;
}
LogicValue LogicValue
Vertex::simValue() const Vertex::simValue() const
{ {

View File

@ -100,7 +100,7 @@ public:
VertexId vertexCount() { return vertices_->size(); } VertexId vertexCount() { return vertices_->size(); }
Arrival *makeArrivals(Vertex *vertex, Arrival *makeArrivals(Vertex *vertex,
uint32_t count); uint32_t count);
Arrival *arrivals(Vertex *vertex) const; Arrival *arrivals(Vertex *vertex);
void clearArrivals(); void clearArrivals();
PathVertexRep *makePrevPaths(Vertex *vertex, PathVertexRep *makePrevPaths(Vertex *vertex,
uint32_t count); uint32_t count);
@ -274,8 +274,7 @@ public:
bool isRoot() const{ return level_ == 0; } bool isRoot() const{ return level_ == 0; }
LevelColor color() const { return static_cast<LevelColor>(color_); } LevelColor color() const { return static_cast<LevelColor>(color_); }
void setColor(LevelColor color); void setColor(LevelColor color);
ArrivalId arrivals() const { return arrivals_; } ArrivalId arrivals() { return arrivals_; }
void setArrivals(ArrivalId id);
PrevPathId prevPaths() const { return prev_paths_; } PrevPathId prevPaths() const { return prev_paths_; }
void setPrevPaths(PrevPathId id); void setPrevPaths(PrevPathId id);
// Requireds optionally follow arrivals in the same array. // Requireds optionally follow arrivals in the same array.
@ -325,6 +324,8 @@ public:
// ObjectTable interface. // ObjectTable interface.
ObjectIdx objectIdx() const { return object_idx_; } ObjectIdx objectIdx() const { return object_idx_; }
void setObjectIdx(ObjectIdx idx); void setObjectIdx(ObjectIdx idx);
// private to Search.cc
void deletePaths();
static int transitionCount() { return 2; } // rise/fall static int transitionCount() { return 2; } // rise/fall
@ -332,6 +333,7 @@ protected:
void init(Pin *pin, void init(Pin *pin,
bool is_bidirect_drvr, bool is_bidirect_drvr,
bool is_reg_clk); bool is_reg_clk);
void setArrivals(ArrivalId id);
Pin *pin_; Pin *pin_;
ArrivalId arrivals_; ArrivalId arrivals_;

View File

@ -19,6 +19,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <string> #include <string>
#include <mutex>
#include "DisallowCopyAssign.hh" #include "DisallowCopyAssign.hh"
struct Tcl_Interp; struct Tcl_Interp;
@ -113,6 +114,7 @@ protected:
char *buffer_; char *buffer_;
// Length of string in buffer. // Length of string in buffer.
size_t buffer_length_; size_t buffer_length_;
std::mutex buffer_lock_;
private: private:
DISALLOW_COPY_AND_ASSIGN(Report); DISALLOW_COPY_AND_ASSIGN(Report);

View File

@ -482,7 +482,6 @@ protected:
const PathAnalysisPt *path_ap); const PathAnalysisPt *path_ap);
void deletePaths(); void deletePaths();
void deletePaths(Vertex *vertex); void deletePaths(Vertex *vertex);
void deletePaths1(Vertex *vertex);
TagGroup *findTagGroup(TagGroupBldr *group_bldr); TagGroup *findTagGroup(TagGroupBldr *group_bldr);
void deleteFilterTags(); void deleteFilterTags();
void deleteFilterTagGroups(); void deleteFilterTagGroups();

View File

@ -132,7 +132,7 @@ PathVertexRep::tag(const StaState *sta) const
Arrival Arrival
PathVertexRep::arrival(const StaState *sta) const PathVertexRep::arrival(const StaState *sta) const
{ {
const Graph *graph = sta->graph(); Graph *graph = sta->graph();
const Search *search = sta->search(); const Search *search = sta->search();
Tag *tag = search->tag(tag_index_); Tag *tag = search->tag(tag_index_);
Vertex *vertex = graph->vertex(vertex_id_); Vertex *vertex = graph->vertex(vertex_id_);

View File

@ -397,7 +397,7 @@ Search::deletePaths()
VertexIterator vertex_iter(graph_); VertexIterator vertex_iter(graph_);
while (vertex_iter.hasNext()) { while (vertex_iter.hasNext()) {
Vertex *vertex = vertex_iter.next(); Vertex *vertex = vertex_iter.next();
deletePaths1(vertex); vertex->deletePaths();
} }
graph_->clearArrivals(); graph_->clearArrivals();
graph_->clearPrevPaths(); graph_->clearPrevPaths();
@ -405,23 +405,13 @@ Search::deletePaths()
} }
} }
void
Search::deletePaths1(Vertex *vertex)
{
vertex->setArrivals(arrival_null);
vertex->setPrevPaths(prev_path_null);
vertex->setTagGroupIndex(tag_group_index_max);
vertex->setHasRequireds(false);
vertex->setCrprPathPruningDisabled(false);
}
void void
Search::deletePaths(Vertex *vertex) Search::deletePaths(Vertex *vertex)
{ {
tnsNotifyBefore(vertex); tnsNotifyBefore(vertex);
if (worst_slacks_) if (worst_slacks_)
worst_slacks_->worstSlackNotifyBefore(vertex); worst_slacks_->worstSlackNotifyBefore(vertex);
deletePaths1(vertex); vertex->deletePaths();
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
@ -720,7 +710,7 @@ void
Search::arrivalInvalidDelete(Vertex *vertex) Search::arrivalInvalidDelete(Vertex *vertex)
{ {
arrivalInvalid(vertex); arrivalInvalid(vertex);
deletePaths1(vertex); vertex->deletePaths();
} }
void void

View File

@ -194,7 +194,7 @@ proc check_path_divider { divider } {
################################################################ ################################################################
define_cmd_args "set_units" \ define_cmd_args "set_units" \
{[-capacitance cap_unit] [-resistance res_unit] [-time time_unit]\ {[-time time_unit] [-capacitance cap_unit] [-resistance res_unit]\
[-voltage voltage_unit] [-current current_unit] [-power power_unit]\ [-voltage voltage_unit] [-current current_unit] [-power power_unit]\
[-distance distance_unit]} [-distance distance_unit]}
@ -206,11 +206,12 @@ proc set_units { args } {
keys {-capacitance -resistance -time -voltage -current -power -distance} \ keys {-capacitance -resistance -time -voltage -current -power -distance} \
flags {} flags {}
check_argc_eq0 "set_units" $args check_argc_eq0 "set_units" $args
check_unit "capacitance" -capacitance "f" keys
check_unit "time" -time "s" keys check_unit "time" -time "s" keys
check_unit "capacitance" -capacitance "f" keys
check_unit "resistance" -resistance "ohm" keys
check_unit "voltage" -voltage "v" keys check_unit "voltage" -voltage "v" keys
check_unit "current" -current "A" keys check_unit "current" -current "A" keys
check_unit "resistance" -resistance "ohm" keys check_unit "power" -power "W" keys
check_unit "distance" -distance "m" keys check_unit "distance" -distance "m" keys
} }
@ -1512,11 +1513,11 @@ proc set_sense { args } {
if { [info exists keys(-type)] } { if { [info exists keys(-type)] } {
set type $keys(-type) set type $keys(-type)
if { $type == "data" } { if { $type == "data" } {
sdc_warn "set_sense -type data not supported." sta_warn "set_sense -type data not supported."
} elseif { $type == "clock" } { } elseif { $type == "clock" } {
set_clock_sense_cmd1 "set_sense" $args set_clock_sense_cmd1 "set_sense" $args
} else { } else {
sdc_error "set_sense -type clock|data" sta_error "set_sense -type clock|data"
} }
} }
} }
@ -1527,7 +1528,7 @@ define_cmd_args "set_clock_sense" \
[-clock clocks] pins} [-clock clocks] pins}
proc set_clock_sense { args } { proc set_clock_sense { args } {
sdc_warn "set_clock_sense is deprecated as of SDC 2.1. Use set_sense -type clock." sta_warn "set_clock_sense is deprecated as of SDC 2.1. Use set_sense -type clock."
set_clock_sense_cmd1 "set_clock_sense" $args set_clock_sense_cmd1 "set_clock_sense" $args
} }
@ -1904,19 +1905,15 @@ proc set_false_path { args } {
check_exception_pins $from $to check_exception_pins $from $to
if { $arg_error } { if { $arg_error } {
delete_from_thrus_to $from $thrus $to delete_from_thrus_to $from $thrus $to
sta_error "set_false_path command failed." } else {
}
check_for_key_args $cmd args check_for_key_args $cmd args
if { $args != {} } { if { $args != {} } {
delete_from_thrus_to $from $thrus $to sta_warn "'$args' ignored."
sta_error "positional arguments not supported."
} }
if { ($from == "NULL" && $thrus == "" && $to == "NULL") } { if { ($from == "NULL" && $thrus == "" && $to == "NULL") } {
delete_from_thrus_to $from $thrus $to delete_from_thrus_to $from $thrus $to
sta_error "-from, -through or -to required." sta_warn "-from, -through or -to required."
} } else {
if [info exists flags(-reset_path)] { if [info exists flags(-reset_path)] {
reset_path_cmd $from $thrus $to $min_max reset_path_cmd $from $thrus $to $min_max
} }
@ -1924,6 +1921,8 @@ proc set_false_path { args } {
set comment [parse_comment_key keys] set comment [parse_comment_key keys]
make_false_path $from $thrus $to $min_max $comment make_false_path $from $thrus $to $min_max $comment
}
}
} }
################################################################ ################################################################
@ -2049,9 +2048,7 @@ proc set_path_delay { cmd args min_max } {
set to [parse_to_arg keys flags arg_error] set to [parse_to_arg keys flags arg_error]
if { $arg_error } { if { $arg_error } {
delete_from_thrus_to $from $thrus $to delete_from_thrus_to $from $thrus $to
sta_error "set_path_delay command failed." } else {
}
check_for_key_args $cmd args check_for_key_args $cmd args
if { [llength $args] == 0 } { if { [llength $args] == 0 } {
delete_from_thrus_to $from $thrus $to delete_from_thrus_to $from $thrus $to
@ -2061,8 +2058,7 @@ proc set_path_delay { cmd args min_max } {
check_float "$cmd delay" $delay check_float "$cmd delay" $delay
set delay [time_ui_sta $delay] set delay [time_ui_sta $delay]
} else { } else {
delete_from_thrus_to $from $thrus $to sta_warn "'$args' ignored."
sta_error "extra positional arguments."
} }
set ignore_clk_latency [info exists flags(-ignore_clock_latency)] set ignore_clk_latency [info exists flags(-ignore_clock_latency)]
@ -2075,6 +2071,7 @@ proc set_path_delay { cmd args min_max } {
make_path_delay $from $thrus $to $min_max $ignore_clk_latency \ make_path_delay $from $thrus $to $min_max $ignore_clk_latency \
$delay $comment $delay $comment
}
} }
################################################################ ################################################################
@ -2182,9 +2179,7 @@ proc set_multicycle_path { args } {
check_exception_pins $from $to check_exception_pins $from $to
if { $arg_error } { if { $arg_error } {
delete_from_thrus_to $from $thrus $to delete_from_thrus_to $from $thrus $to
sta_error "set_multicycle_path command failed." } else {
}
check_for_key_args $cmd args check_for_key_args $cmd args
if { [llength $args] == 0 } { if { [llength $args] == 0 } {
delete_from_thrus_to $from $thrus $to delete_from_thrus_to $from $thrus $to
@ -2193,8 +2188,7 @@ proc set_multicycle_path { args } {
set path_multiplier $args set path_multiplier $args
check_integer "path multiplier" $path_multiplier check_integer "path multiplier" $path_multiplier
} else { } else {
delete_from_thrus_to $from $thrus $to sta_warn "'$args' ignored."
sta_error "extra positional arguments."
} }
set start [info exists flags(-start)] set start [info exists flags(-start)]
@ -2216,6 +2210,7 @@ proc set_multicycle_path { args } {
make_multicycle_path $from $thrus $to $min_max $use_end_clk \ make_multicycle_path $from $thrus $to $min_max $use_end_clk \
$path_multiplier $comment $path_multiplier $comment
}
} }
################################################################ ################################################################
@ -2793,7 +2788,7 @@ proc parse_from_arg { keys_var arg_error_var } {
if {$from_pins == {} && $from_insts == {} && $from_clks == {}} { if {$from_pins == {} && $from_insts == {} && $from_clks == {}} {
upvar 1 $arg_error_var arg_error upvar 1 $arg_error_var arg_error
set arg_error 1 set arg_error 1
sta_error "no valid objects specified for $key." sta_warn "no valid objects specified for $key."
return "NULL" return "NULL"
} }
return [make_exception_from $from_pins $from_clks $from_insts $tr] return [make_exception_from $from_pins $from_clks $from_insts $tr]
@ -2810,10 +2805,13 @@ proc parse_thrus_arg { args_var arg_error_var } {
set tr "" set tr ""
if { $arg == "-through" } { if { $arg == "-through" } {
set tr "rise_fall" set tr "rise_fall"
set key "-through"
} elseif { $arg == "-rise_through" } { } elseif { $arg == "-rise_through" } {
set tr "rise" set tr "rise"
set key "-rise_through"
} elseif { $arg == "-fall_through" } { } elseif { $arg == "-fall_through" } {
set tr "fall" set tr "fall"
set key "-fall_through"
} }
if { $tr != "" } { if { $tr != "" } {
if { [llength $args] > 1 } { if { [llength $args] > 1 } {
@ -2823,7 +2821,7 @@ proc parse_thrus_arg { args_var arg_error_var } {
if {$pins == {} && $insts == {} && $nets == {}} { if {$pins == {} && $insts == {} && $nets == {}} {
upvar 1 $arg_error_var arg_error upvar 1 $arg_error_var arg_error
set arg_error 1 set arg_error 1
sta_error "no valid objects specified for -through." sta_warn "no valid objects specified for $key"
} else { } else {
lappend thrus [make_exception_thru $pins $nets $insts $tr] lappend thrus [make_exception_thru $pins $nets $insts $tr]
} }
@ -2872,7 +2870,7 @@ proc parse_to_arg1 { keys_var end_rf arg_error_var } {
if {$to_pins == {} && $to_insts == {} && $to_clks == {}} { if {$to_pins == {} && $to_insts == {} && $to_clks == {}} {
upvar 1 $arg_error_var arg_error upvar 1 $arg_error_var arg_error
set arg_error 1 set arg_error 1
puts "Error: no valid objects specified for $key." sta_warn "no valid objects specified for $key."
return "NULL" return "NULL"
} }
return [make_exception_to $to_pins $to_clks $to_insts $to_rf $end_rf] return [make_exception_to $to_pins $to_clks $to_insts $to_rf $end_rf]

View File

@ -88,6 +88,7 @@ Report::print(const string &str)
void void
Report::vprint(const char *fmt, va_list args) Report::vprint(const char *fmt, va_list args)
{ {
std::unique_lock<std::mutex> lock(buffer_lock_);
printToBuffer(fmt, args); printToBuffer(fmt, args);
printString(buffer_, buffer_length_); printString(buffer_, buffer_length_);
} }
@ -121,6 +122,7 @@ Report::printError(const char *buffer, size_t length)
void void
Report::vprintError(const char *fmt, va_list args) Report::vprintError(const char *fmt, va_list args)
{ {
std::unique_lock<std::mutex> lock(buffer_lock_);
printToBuffer(fmt, args); printToBuffer(fmt, args);
printError(buffer_, buffer_length_); printError(buffer_, buffer_length_);
} }

View File

@ -16,18 +16,18 @@
#include "ReportTcl.hh" #include "ReportTcl.hh"
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
namespace sta { namespace sta {
using ::Tcl_Channel;
using ::Tcl_GetChannelType;
using ::Tcl_ChannelType;
using ::ClientData; using ::ClientData;
using ::Tcl_GetChannelInstanceData; using ::Tcl_Channel;
using ::Tcl_DriverOutputProc;
using ::Tcl_ChannelOutputProc; using ::Tcl_ChannelOutputProc;
using ::Tcl_ChannelType;
using ::Tcl_DriverOutputProc;
using ::Tcl_GetChannelInstanceData;
using ::Tcl_GetChannelType;
extern "C" { extern "C" {
@ -38,29 +38,42 @@ extern "C" {
#endif #endif
static int static int
encapOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite, encapOutputProc(ClientData instanceData,
CONST84 char *buf,
int toWrite,
int *errorCodePtr); int *errorCodePtr);
static int static int
encapErrorOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite, encapErrorOutputProc(ClientData instanceData,
CONST84 char *buf,
int toWrite,
int *errorCodePtr); int *errorCodePtr);
static int static int
encapCloseProc(ClientData instanceData, Tcl_Interp *interp); encapCloseProc(ClientData instanceData, Tcl_Interp *interp);
static int static int
encapSetOptionProc(ClientData instanceData, Tcl_Interp *interp, encapSetOptionProc(ClientData instanceData,
CONST84 char *optionName, CONST84 char *value); Tcl_Interp *interp,
CONST84 char *optionName,
CONST84 char *value);
static int static int
encapGetOptionProc(ClientData instanceData, Tcl_Interp *interp, encapGetOptionProc(ClientData instanceData,
CONST84 char *optionName, Tcl_DString *dsPtr); Tcl_Interp *interp,
CONST84 char *optionName,
Tcl_DString *dsPtr);
static int static int
encapInputProc(ClientData instanceData, char *buf, int bufSize, encapInputProc(ClientData instanceData,
char *buf,
int bufSize,
int *errorCodePtr); int *errorCodePtr);
static int static int
encapSeekProc(ClientData instanceData, long offset, int seekMode, encapSeekProc(ClientData instanceData,
long offset,
int seekMode,
int *errorCodePtr); int *errorCodePtr);
static void static void
encapWatchProc(ClientData instanceData, int mask); encapWatchProc(ClientData instanceData, int mask);
static int static int
encapGetHandleProc(ClientData instanceData, int direction, encapGetHandleProc(ClientData instanceData,
int direction,
ClientData *handlePtr); ClientData *handlePtr);
static int static int
encapBlockModeProc(ClientData instanceData, int mode); encapBlockModeProc(ClientData instanceData, int mode);
@ -68,7 +81,7 @@ encapBlockModeProc(ClientData instanceData, int mode);
#ifdef TCL_CHANNEL_VERSION_5 #ifdef TCL_CHANNEL_VERSION_5
Tcl_ChannelType tcl_encap_type_stdout = { Tcl_ChannelType tcl_encap_type_stdout = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_4, TCL_CHANNEL_VERSION_4,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -88,7 +101,7 @@ Tcl_ChannelType tcl_encap_type_stdout = {
}; };
Tcl_ChannelType tcl_encap_type_stderr = { Tcl_ChannelType tcl_encap_type_stderr = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_4, TCL_CHANNEL_VERSION_4,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -111,7 +124,7 @@ Tcl_ChannelType tcl_encap_type_stderr = {
#ifdef TCL_CHANNEL_VERSION_4 #ifdef TCL_CHANNEL_VERSION_4
// Tcl 8.4.12 // Tcl 8.4.12
Tcl_ChannelType tcl_encap_type_stdout = { Tcl_ChannelType tcl_encap_type_stdout = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_4, TCL_CHANNEL_VERSION_4,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -130,7 +143,7 @@ Tcl_ChannelType tcl_encap_type_stdout = {
}; };
Tcl_ChannelType tcl_encap_type_stderr = { Tcl_ChannelType tcl_encap_type_stderr = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_4, TCL_CHANNEL_VERSION_4,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -152,7 +165,7 @@ Tcl_ChannelType tcl_encap_type_stderr = {
#ifdef TCL_CHANNEL_VERSION_3 #ifdef TCL_CHANNEL_VERSION_3
// Tcl 8.4 // Tcl 8.4
Tcl_ChannelType tcl_encap_type_stdout = { Tcl_ChannelType tcl_encap_type_stdout = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_3, TCL_CHANNEL_VERSION_3,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -170,7 +183,7 @@ Tcl_ChannelType tcl_encap_type_stdout = {
}; };
Tcl_ChannelType tcl_encap_type_stderr = { Tcl_ChannelType tcl_encap_type_stderr = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_3, TCL_CHANNEL_VERSION_3,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -192,7 +205,7 @@ Tcl_ChannelType tcl_encap_type_stderr = {
// Tcl 8.3.2 // Tcl 8.3.2
Tcl_ChannelType tcl_encap_type_stdout = { Tcl_ChannelType tcl_encap_type_stdout = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_2, TCL_CHANNEL_VERSION_2,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -209,7 +222,7 @@ Tcl_ChannelType tcl_encap_type_stdout = {
}; };
Tcl_ChannelType tcl_encap_type_stderr = { Tcl_ChannelType tcl_encap_type_stderr = {
const_cast<char*>("file"), const_cast<char *>("file"),
TCL_CHANNEL_VERSION_2, TCL_CHANNEL_VERSION_2,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -229,7 +242,7 @@ Tcl_ChannelType tcl_encap_type_stderr = {
// Tcl 8.2 // Tcl 8.2
Tcl_ChannelType tcl_encap_type_stdout = { Tcl_ChannelType tcl_encap_type_stdout = {
const_cast<char*>("file"), const_cast<char *>("file"),
encapBlockModeProc, encapBlockModeProc,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -243,7 +256,7 @@ Tcl_ChannelType tcl_encap_type_stdout = {
}; };
Tcl_ChannelType tcl_encap_type_stderr = { Tcl_ChannelType tcl_encap_type_stderr = {
const_cast<char*>("file"), const_cast<char *>("file"),
encapBlockModeProc, encapBlockModeProc,
encapCloseProc, encapCloseProc,
encapInputProc, encapInputProc,
@ -264,12 +277,8 @@ Tcl_ChannelType tcl_encap_type_stderr = {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
ReportTcl::ReportTcl() : ReportTcl::ReportTcl() :
Report(), Report(), interp_(nullptr), tcl_stdout_(nullptr), tcl_stderr_(nullptr),
interp_(nullptr), tcl_encap_stdout_(nullptr), tcl_encap_stderr_(nullptr)
tcl_stdout_(nullptr),
tcl_stderr_(nullptr),
tcl_encap_stdout_(nullptr),
tcl_encap_stderr_(nullptr)
{ {
} }
@ -290,10 +299,16 @@ ReportTcl::setTclInterp(Tcl_Interp *interp)
interp_ = interp; interp_ = interp;
tcl_stdout_ = Tcl_GetStdChannel(TCL_STDOUT); tcl_stdout_ = Tcl_GetStdChannel(TCL_STDOUT);
tcl_stderr_ = Tcl_GetStdChannel(TCL_STDERR); tcl_stderr_ = Tcl_GetStdChannel(TCL_STDERR);
tcl_encap_stdout_ = Tcl_StackChannel(interp, &tcl_encap_type_stdout, this, tcl_encap_stdout_ = Tcl_StackChannel(interp,
TCL_WRITABLE, tcl_stdout_); &tcl_encap_type_stdout,
tcl_encap_stderr_ = Tcl_StackChannel(interp, &tcl_encap_type_stderr, this, this,
TCL_WRITABLE, tcl_stderr_); TCL_WRITABLE,
tcl_stdout_);
tcl_encap_stderr_ = Tcl_StackChannel(interp,
&tcl_encap_type_stderr,
this,
TCL_WRITABLE,
tcl_stderr_);
} }
size_t size_t
@ -315,8 +330,9 @@ ReportTcl::printTcl(Tcl_Channel channel, const char *buffer, size_t length)
Tcl_DriverOutputProc *output_proc = Tcl_ChannelOutputProc(ch_type); Tcl_DriverOutputProc *output_proc = Tcl_ChannelOutputProc(ch_type);
int error_code; int error_code;
ClientData clientData = Tcl_GetChannelInstanceData(channel); ClientData clientData = Tcl_GetChannelInstanceData(channel);
return output_proc(clientData, const_cast<char*>(buffer), return output_proc(clientData,
static_cast<int>(length), const_cast<char *>(buffer),
length,
&error_code); &error_code);
} }
@ -389,19 +405,20 @@ ReportTcl::redirectStringEnd()
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
static int static int
encapOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite, encapOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite, int *)
int *)
{ {
ReportTcl *report = reinterpret_cast<ReportTcl*>(instanceData); ReportTcl *report = reinterpret_cast<ReportTcl *>(instanceData);
return static_cast<int>(report->printString(buf, toWrite)); return report->printString(buf, toWrite);
} }
static int static int
encapErrorOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite, encapErrorOutputProc(ClientData instanceData,
CONST84 char *buf,
int toWrite,
int *) int *)
{ {
ReportTcl *report = reinterpret_cast<ReportTcl*>(instanceData); ReportTcl *report = reinterpret_cast<ReportTcl *>(instanceData);
return static_cast<int>(report->printString(buf, toWrite)); return report->printString(buf, toWrite);
} }
static int static int
@ -413,7 +430,7 @@ encapInputProc(ClientData, char *, int, int *)
static int static int
encapCloseProc(ClientData instanceData, Tcl_Interp *) encapCloseProc(ClientData instanceData, Tcl_Interp *)
{ {
ReportTcl *report = reinterpret_cast<ReportTcl*>(instanceData); ReportTcl *report = reinterpret_cast<ReportTcl *>(instanceData);
report->logEnd(); report->logEnd();
report->redirectFileEnd(); report->redirectFileEnd();
report->redirectStringEnd(); report->redirectStringEnd();
@ -455,4 +472,4 @@ encapBlockModeProc(ClientData, int)
return 0; return 0;
} }
} // namespace } // namespace sta