diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-11 15:37:45 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-11 15:37:45 +0300 |
commit | 3f8e26370925c94e07f0bbdd51cddad6601fa125 (patch) | |
tree | 4a26576894a2f5d65fe56c1ea6c5a024a9a62099 /intern/cycles/util | |
parent | 9ec944bbab7a5ba75a526387f8eab52af7f6405e (diff) | |
parent | c10f5d15c25cbc5ee319835c90d5d2a4dda53497 (diff) |
Merge branch 'blender2.7'
Diffstat (limited to 'intern/cycles/util')
-rw-r--r-- | intern/cycles/util/util_system.cpp | 20 | ||||
-rw-r--r-- | intern/cycles/util/util_system.h | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/intern/cycles/util/util_system.cpp b/intern/cycles/util/util_system.cpp index a22bd25ce77..6255596cd06 100644 --- a/intern/cycles/util/util_system.cpp +++ b/intern/cycles/util/util_system.cpp @@ -32,6 +32,7 @@ # include <sys/types.h> #else # include <unistd.h> +# include <sys/ioctl.h> #endif CCL_NAMESPACE_BEGIN @@ -113,6 +114,25 @@ bool system_cpu_run_thread_on_node(int node) return numaAPI_RunThreadOnNode(node); } +int system_console_width() +{ + int columns = 0; + +#ifdef _WIN32 + CONSOLE_SCREEN_BUFFER_INFO csbi; + if(GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) { + columns = csbi.dwSize.X; + } +#else + struct winsize w; + if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == 0) { + columns = w.ws_col; + } +#endif + + return (columns > 0) ? columns : 80; +} + int system_cpu_num_active_group_processors() { if(!system_cpu_ensure_initialized()) { diff --git a/intern/cycles/util/util_system.h b/intern/cycles/util/util_system.h index 0c001f11f0e..1e7cf1d9f2a 100644 --- a/intern/cycles/util/util_system.h +++ b/intern/cycles/util/util_system.h @@ -27,6 +27,9 @@ bool system_cpu_ensure_initialized(); /* Get total number of threads in all NUMA nodes / CPU groups. */ int system_cpu_thread_count(); +/* Get width in characters of the current console output. */ +int system_console_width(); + /* Get number of available nodes. * * This is in fact an index of last node plus one and it's not guaranteed |