]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
termios: SPEED_MAX and BAUD_MAX constants
authorH. Peter Anvin <hpa@zytor.com>
Sun, 13 Jul 2025 05:19:43 +0000 (22:19 -0700)
committerAndreas K. Hüttel <dilfridge@gentoo.org>
Sun, 20 Jul 2025 15:17:41 +0000 (17:17 +0200)
Add constants indicating the maximum values of speed_t and baud_t.
Hopefully if and when the baud_t interface is standardized then
BAUD_MAX will be included in the standardization from the start.

Historically, the __MAX_BAUD symbol has indicated the maximum speed_t
value on at least some platforms (including glibc).  However, this
name would be problematic for future standardization, because it
confusingly implies a reference to baud_t, not speed_t, and it is
inconsistent with other limit symbols, which are all of the form *_MAX
(e.g. SIZE_MAX for size_t.)

[ v3: dropped leading underscores, leave __MAX_BAUD outside
      #ifdef __USE_MISC since it is a legacy symbol, and
      namespace-protected with a double underscore.
      (Collin Funk, Adhermerval Zanella Netto) ]

[ v4: moved from __USE_MISC to __USE_GNU (Collin Funk) ]

Signed-off-by: "H. Peter Anvin" (Intel) <hpa@zytor.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
bits/termios-baud.h
termios/termios.h

index bafde1a6505cb57d7c36f3834b2570cce4cc1d0e..697ad807589852affef7f90f93f79a0a4d4f260e 100644 (file)
@@ -69,4 +69,7 @@
 #define B5000000       5000000U
 #define B10000000     10000000U
 
-#define __MAX_BAUD  4294967295U
+#ifdef __USE_GNU
+#define SPEED_MAX  4294967295U /* maximum valid speed_t value */
+#endif
+#define __MAX_BAUD 4294967295U /* legacy alias for SPEED_MAX */
index 3347c880a57fb39d76a2c1294c4e4c5479485e29..91cbe875e485307d572d015532e9e0eaf3c86371 100644 (file)
@@ -64,6 +64,7 @@ extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __THROW;
 #ifdef __USE_GNU
 /* Interfaces that are explicitly numeric representations of baud rates */
 typedef speed_t baud_t;
+#define BAUD_MAX SPEED_MAX
 
 /* Return the output baud rate stored in *TERMIOS_P.  */
 extern baud_t cfgetobaud (const struct termios *__termios_p) __THROW;