Skip to content

Commit 1b13e06

Browse files
Fix getline termios use for cuda builds (#706)
* Fix getline termios use for cuda builds * Committing clang-format changes --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 783a7bd commit 1b13e06

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

packages/seacas/libraries/aprepro_lib/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ TRIBITS_INCLUDE_DIRECTORIES(
2222
option(GENERATE_FLEX_FILES "Generate source files using flex" OFF)
2323
option(GENERATE_BISON_FILES "Generate source files using bison" OFF)
2424

25+
if(TPL_ENABLE_CUDA)
26+
SET_SOURCE_FILES_PROPERTIES(apr_getline.cc PROPERTIES COMPILE_DEFINITIONS NO_TERMIOS=1)
27+
endif()
28+
2529
if(GENERATE_BISON_FILES)
2630
set(BISON_LIB_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/apr_parser.cc)
2731
else()

packages/seacas/libraries/aprepro_lib/apr_getline.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
/*
3-
* Copyright (C) 1991, 1992, 1993, 2021, 2022, 2023, 2024 by Chris Thewalt (thewalt@ce.berkeley.edu)
3+
* Copyright (C) 1991, 1992, 1993, 2021, 2022, 2023, 2024, 2025 by Chris Thewalt
4+
* (thewalt@ce.berkeley.edu)
45
*
56
* Permission to use, copy, modify, and distribute this software
67
* for any purpose and without fee is hereby granted, provided
@@ -119,14 +120,14 @@ namespace {
119120
#endif
120121

121122
namespace {
122-
#ifdef __unix__
123+
#if defined(__unix__) && !defined(NO_TERMIOS)
123124
#include <termios.h>
124125
struct termios io_new_termios, io_old_termios;
125126
#endif
126127

127128
void gl_char_init() /* turn off input echo */
128129
{
129-
#ifdef __unix__
130+
#if defined(__unix__) && !defined(NO_TERMIOS)
130131
tcgetattr(0, &io_old_termios);
131132
io_new_termios = io_old_termios;
132133
io_new_termios.c_iflag &= ~(BRKINT | ISTRIP | IXON | IXOFF);
@@ -140,7 +141,7 @@ namespace {
140141

141142
void gl_char_cleanup() /* undo effects of gl_char_init */
142143
{
143-
#ifdef __unix__
144+
#if defined(__unix__) && !defined(NO_TERMIOS)
144145
tcsetattr(0, TCSANOW, &io_old_termios);
145146
#endif /* __unix__ */
146147
}
@@ -197,7 +198,7 @@ namespace {
197198
int gl_getc()
198199
/* get a character without echoing it to screen */
199200
{
200-
#ifdef __unix__
201+
#if defined(__unix__)
201202
char ch;
202203
while (read(0, &ch, 1) == -1) {
203204
if (errno != EINTR) {

packages/seacas/libraries/ioss/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ IF (NOT ${PROJECT_NAME}_ENABLE_Zoltan)
4848
ADD_DEFINITIONS(-DNO_ZOLTAN_SUPPORT)
4949
ENDIF()
5050

51+
if(TPL_ENABLE_CUDA)
52+
SET_SOURCE_FILES_PROPERTIES(Ioss_Getline.C PROPERTIES COMPILE_DEFINITIONS NO_TERMIOS=1)
53+
endif()
54+
5155
IF (NOT TPL_ENABLE_ParMETIS)
5256
ADD_DEFINITIONS(-DNO_PARMETIS_SUPPORT)
5357
ENDIF()

packages/seacas/libraries/ioss/src/Ioss_Getline.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ namespace {
126126
#endif
127127

128128
namespace {
129-
#if defined(__EMSCRIPTEN__) || defined(__unix__)
129+
#if defined(__EMSCRIPTEN__) || (defined(__unix__) && !defined(NO_TERMIOS))
130130
#ifdef __EMSCRIPTEN__
131131
#include <termios.h>
132132
#elif __unix__
@@ -138,7 +138,7 @@ namespace {
138138

139139
void gl_char_init() /* turn off input echo */
140140
{
141-
#ifdef __unix__
141+
#if defined(__unix__) && !defined(NO_TERMIOS)
142142
tcgetattr(0, &io_old_termios);
143143
io_new_termios = io_old_termios;
144144
io_new_termios.c_iflag &= ~(BRKINT | ISTRIP | IXON | IXOFF);
@@ -152,7 +152,7 @@ namespace {
152152

153153
void gl_char_cleanup() /* undo effects of gl_char_init */
154154
{
155-
#ifdef __unix__
155+
#if defined(__unix__) && !defined(NO_TERMIOS)
156156
tcsetattr(0, TCSANOW, &io_old_termios);
157157
#endif /* __unix__ */
158158
}
@@ -209,7 +209,7 @@ namespace {
209209
int gl_getc()
210210
/* get a character without echoing it to screen */
211211
{
212-
#ifdef __unix__
212+
#if defined(__unix__)
213213
char ch;
214214
int c;
215215
while ((c = read(0, &ch, 1)) == -1) {

packages/seacas/libraries/supes/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ TRIBITS_INCLUDE_DIRECTORIES(
1616
"${CMAKE_CURRENT_SOURCE_DIR}/fre_fld"
1717
)
1818

19+
if(TPL_ENABLE_CUDA)
20+
SET_SOURCE_FILES_PROPERTIES(ext_lib/getline_int.c PROPERTIES COMPILE_DEFINITIONS NO_TERMIOS=1)
21+
endif()
22+
1923
SET(SOURCES
2024
ext_lib/exmemy.c ext_lib/extime.c ext_lib/ixlchr.c
2125
ext_lib/exname.c ext_lib/exupcs.c ext_lib/ixlnum.c

packages/seacas/libraries/supes/ext_lib/getline_int.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
21
/*
3-
* Copyright(C) 1999-2023 National Technology & Engineering Solutions
2+
* Copyright(C) 1999-2023, 2025 National Technology & Engineering Solutions
43
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
54
* NTESS, the U.S. Government retains certain rights in this software.
65
*
@@ -30,8 +29,6 @@
3029
#define __unix__ 1
3130
#endif
3231

33-
#include <termios.h>
34-
struct termios gl_new_termios, gl_old_termios;
3532
#endif
3633

3734
/********************* C library headers ********************************/
@@ -111,9 +108,14 @@ static char *copy_string(char *dest, char const *source, long int elements)
111108
#include <bios.h>
112109
#endif
113110

111+
#if defined(__unix__) && !defined(NO_TERMIOS)
112+
#include <termios.h>
113+
struct termios gl_new_termios, gl_old_termios;
114+
#endif
115+
114116
static void gl_char_init(void) /* turn off input echo */
115117
{
116-
#ifdef __unix__
118+
#if defined(__unix__) && !defined(NO_TERMIOS)
117119
tcgetattr(0, &gl_old_termios);
118120
gl_new_termios = gl_old_termios;
119121
gl_new_termios.c_iflag &= ~(BRKINT | ISTRIP | IXON | IXOFF);
@@ -127,7 +129,7 @@ static void gl_char_init(void) /* turn off input echo */
127129

128130
static void gl_char_cleanup(void) /* undo effects of gl_char_init */
129131
{
130-
#ifdef __unix__
132+
#if defined(__unix__) && !defined(NO_TERMIOS)
131133
tcsetattr(0, TCSANOW, &gl_old_termios);
132134
#endif /* __unix__ */
133135
}
@@ -184,11 +186,11 @@ static int gl_getc(void)
184186
/* get a character without echoing it to screen */
185187
{
186188
int c;
187-
#ifdef __unix__
189+
#if defined(__unix__)
188190
char ch;
189191
#endif
190192

191-
#ifdef __unix__
193+
#if defined(__unix__)
192194
while ((c = read(0, &ch, 1)) == -1) {
193195
if (errno != EINTR)
194196
break;

0 commit comments

Comments
 (0)