chiark / gitweb /
@@@ fltfmt mess
[mLib] / struct / buf.h
index 33dc6ff4df0c6c53ec4e8ac981d9d5169660a858..2cfffa9a7cf2e554b3bd1389ed5f80e83c03e921 100644 (file)
@@ -610,27 +610,26 @@ BUF_DOSUFFIXES(BUF_DECL_PUTSTR_)
 #define dbuf_putstr64b(db, p) (buf_putstr64b(DBUF_BUF(db), (p)))
 #define dbuf_putstrz(db, p) (buf_putstrz(DBUF_BUF(db), (p)))
 
-/* --- @{,d}buf_getf64{,l,b} --- *
+/* --- @buf_getf{32,64}{,l,b} --- *
  *
- * Arguments:  @buf *b@ = pointer to a buffer block
- *             @double *x_out@ = where to put the result
- *
- * Returns:    Zero on success, @-1@ on failure (and the buffer is broken).
+ * Arguments:  @buf *b@ = a buffer to read from
+ *             @float *x_out@, @double *x_out@ = where to put the result
  *
- *             If the system supports NaNs, then any encoded NaN is returned
- *             as the value of @NAN@ in @<math.h>@; otherwise, this function
- *             reports failure.
+ * Returns:    Zero on success, %$-1$% on failure (and the buffer is
+ *             broken).
  *
- *             In general, values are rounded to the nearest available
- *             value, in the way that the system usually rounds.  If the
- *             system doesn't support infinities, then any encoded infinity
- *             is reported as the largest-possible-magnitude finite value
- *             instead.
+ * Use:                Get an IEEE Binary32 or Binary64 value from the buffer.
+ *             Conversion is performed using the `fltfmt' machinery, with
+ *             the usual round-to-nearest/ties-to-even rounding mode.
  */
 
-extern int buf_getf64(buf */*b*/, double */*x_out*/);
-extern int buf_getf64l(buf */*b*/, double */*x_out*/);
-extern int buf_getf64b(buf */*b*/, double */*x_out*/);
+extern int buf_getf32(buf */*b*/, float */*x_out*/);
+extern int buf_getf32l(buf */*b*/, float */*x_out*/);
+extern int buf_getf32b(buf */*b*/, float */*x_out*/);
+#define dbuf_getf32(db, x_out) (buf_getf32(DBUF_BUF(db), (x_out)))
+#define dbuf_getf32l(db, x_out) (buf_getf32l(DBUF_BUF(db), (x_out)))
+#define dbuf_getf32b(db, x_out) (buf_getf32b(DBUF_BUF(db), (x_out)))
+
 extern int dbuf_getf64(dbuf */*db*/, double */*x_out*/);
 extern int dbuf_getf64l(dbuf */*db*/, double */*x_out*/);
 extern int dbuf_getf64b(dbuf */*db*/, double */*x_out*/);
@@ -638,28 +637,26 @@ extern int dbuf_getf64b(dbuf */*db*/, double */*x_out*/);
 #define dbuf_getf64l(db, x_out) (buf_getf64l(DBUF_BUF(db), (x_out)))
 #define dbuf_getf64b(db, x_out) (buf_getf64b(DBUF_BUF(db), (x_out)))
 
-/* --- @{,d}buf_putf64{,l,b} --- *
+/* --- @buf_putf{32,64}{,l,b} --- *
  *
- * Arguments:  @buf *b@ or @dbuf *db@ = pointer to a buffer block
+ * Arguments:  @buf *b@ = a buffer to write to
  *             @double x@ = a number to write
  *
- * Returns:    Zero on success, @-1@ on failure (and the buffer is broken).
+ * Returns:    Zero on success, %$-1$% on failure (and the buffer is
+ *             broken).
  *
- *             On C89, this function can't detect negative zero so these
- *             will be silently written as positive zero.
- *
- *             This function doesn't distinguish NaNs.  Any NaN is written
- *             as a quiet NaN with all payload bits zero.
- *
- *             A finite value with too large a magnitude to be represented
- *             is rounded to the appropriate infinity.  Other finite values
- *             are rounded as necessary, in the usual IEEE 754 round-to-
- *             nearest-or-even way.
+ * Use:                Get an IEEE Binary32 or Binary64 value from the buffer.
+ *             Conversion is performed using the `fltfmt' machinery, with
+ *             the usual round-to-nearest/ties-to-even rounding mode.
  */
 
-extern int buf_putf64(buf */*b*/, double /*x*/);
-extern int buf_putf64l(buf */*b*/, double /*x*/);
-extern int buf_putf64b(buf */*b*/, double /*x*/);
+extern int buf_putf32(buf */*b*/, float /*x*/);
+extern int buf_putf32l(buf */*b*/, float /*x*/);
+extern int buf_putf32b(buf */*b*/, float /*x*/);
+#define dbuf_putf32(db, x) (buf_putf32(DBUF_BUF(db), (x)))
+#define dbuf_putf32l(db, x) (buf_putf32l(DBUF_BUF(db), (x)))
+#define dbuf_putf32b(db, x) (buf_putf32b(DBUF_BUF(db), (x)))
+
 extern int dbuf_putf64(dbuf */*db*/, double /*x*/);
 extern int dbuf_putf64l(dbuf */*db*/, double /*x*/);
 extern int dbuf_putf64b(dbuf */*db*/, double /*x*/);