From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [Ada] replace call to bzero in terminals.c by call to memset
Date: Mon, 16 May 2022 08:43:11 +0000 [thread overview]
Message-ID: <20220516084311.GA3843644@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
bzero is marked as legacy in POSIX.1-2001, and using it triggers a
deprecation warnings on some systems such as QNX. This change adjusts
the one place where we use it in terminals.c to use memset instead.
This, in turns, allows us to get rid of a hack for HP/UX and Solaris.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* terminals.c: Remove bzero #define on HP/UX or Solaris
platforms.
(child_setup_tty): Replace bzero call by equivalent call to
memset.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1307 bytes --]
diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c
--- a/gcc/ada/terminals.c
+++ b/gcc/ada/terminals.c
@@ -1123,12 +1123,6 @@ __gnat_setup_winsize (void *desc ATTRIBUTE_UNUSED,
#define CDISABLE _POSIX_VDISABLE
-/* On HP-UX and Sun system, there is a bzero function but with a different
- signature. Use memset instead */
-#if defined (__hpux__) || defined (__sun__) || defined (_AIX)
-# define bzero(s,n) memset (s,0,n)
-#endif
-
/* POSIX does not specify how to open the master side of a terminal.Several
methods are available (system specific):
1- using a cloning device (USE_CLONE_DEVICE)
@@ -1289,8 +1283,15 @@ child_setup_tty (int fd)
struct termios s;
int status;
- /* ensure that s is filled with 0 */
- bzero (&s, sizeof (s));
+ /* Ensure that s is filled with 0.
+
+ Note that we avoid using bzero for a few reasons:
+ - On HP-UX and Sun system, there is a bzero function but with
+ a different signature, thus making the use of bzero more
+ complicated on these platforms (we used to define a bzero
+ macro that rewrote calls to bzero into calls to memset);
+ - bzero is deprecated (marked as LEGACY in POSIX.1-2001). */
+ memset (&s, 0, sizeof (s));
/* Get the current terminal settings */
status = tcgetattr (fd, &s);
reply other threads:[~2022-05-16 8:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220516084311.GA3843644@adacore.com \
--to=derodat@adacore.com \
--cc=brobecker@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).