summaryrefslogtreecommitdiff
path: root/numlib/numsup.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-07 13:29:54 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-09-07 13:29:54 +0200
commita879b4e708b3e46c9697ba6581687eeb5b02a320 (patch)
treef85acc5cb1a7c0b03a050c879c20cab3deb9f40e /numlib/numsup.h
parent556dffcdad42b938bc196819aa463247de709765 (diff)
parentc07d0c2d2f6f7b0eb6e92cc6204bf05037957e82 (diff)
state from 2014-09-07 13:30 MESZ
Diffstat (limited to 'numlib/numsup.h')
-rw-r--r--numlib/numsup.h70
1 files changed, 68 insertions, 2 deletions
diff --git a/numlib/numsup.h b/numlib/numsup.h
index 7db7676..b949379 100644
--- a/numlib/numsup.h
+++ b/numlib/numsup.h
@@ -41,6 +41,8 @@
/* This really needs checking for each different platform. */
/* Using C99 and MSC covers a lot of cases, */
/* and the fallback default is pretty reliable with modern compilers and machines. */
+/* Note that MSWin is LLP64 == 32 bit long, while OS X/Linux is LP64 == 64 bit long. */
+/* so long shouldn't really be used in any code.... */
/* (duplicated in icc.h) */
#if (__STDC_VERSION__ >= 199901L) /* C99 */
@@ -97,7 +99,7 @@
#else /* !_MSC_VER */
/* The following works on a lot of modern systems, including */
-/* LP64 model 64 bit modes */
+/* LLP64 and LP64 models, but won't work with ILP64 which needs int32 */
#define INR8 signed char /* 8 bit signed */
#define INR16 signed short /* 16 bit signed */
@@ -185,7 +187,7 @@
struct _a1log {
int refc; /* Reference count */
- char *tag; /* Optional tag name */
+ char *tag; /* Optional tag name */
int verb; /* Current verbosity level (public) */
int debug; /* Current debug level (public) */
@@ -277,6 +279,17 @@ extern char cr_char;
/* =========================================================== */
+/* reallocate and clear new allocation */
+void *recalloc( /* Return new address */
+void *ptr, /* Current address */
+size_t cnum, /* Current number and unit size */
+size_t csize,
+size_t nnum, /* New number and unit size */
+size_t nsize
+);
+
+/* =========================================================== */
+
/* Numerical recipes vector/matrix support functions */
/* Note that the index arguments are the inclusive low and high values */
@@ -372,6 +385,59 @@ char *ctime_32(const INR32 *timer);
/* A static buffer is used. There is no \n at the end */
char *ctime_64(const INR64 *timer);
+/*******************************************/
+/* Native to/from byte buffer functions */
+/*******************************************/
+
+/* No overflow detection is done - numbers are clipped */
+
+/* be = Big Endian */
+/* le = Little Endian */
+
+/* Unsigned 8 bit */
+unsigned int read_ORD8(ORD8 *p);
+void write_ORD8(unsigned int d, ORD8 *p);
+
+/* Signed 8 bit */
+int read_INR8(ORD8 *p);
+void write_INR8(int d, ORD8 *p);
+
+/* Unsigned 16 bit */
+unsigned int read_ORD16_be(ORD8 *p);
+unsigned int read_ORD16_le(ORD8 *p);
+void write_ORD16_be(unsigned int d, ORD8 *p);
+void write_ORD16_le(unsigned int d, ORD8 *p);
+
+/* Signed 16 bit */
+int read_INR16_be(ORD8 *p);
+int read_INR16_le(ORD8 *p);
+void write_INR16_be(int d, ORD8 *p);
+void write_INR16_le(int d, ORD8 *p);
+
+/* Unsigned 32 bit */
+unsigned int read_ORD32_be(ORD8 *p);
+unsigned int read_ORD32_le(ORD8 *p);
+void write_ORD32_be(unsigned int d, ORD8 *p);
+void write_ORD32_le(unsigned int d, ORD8 *p);
+
+/* Signed 32 bit */
+int read_INR32_be(ORD8 *p);
+int read_INR32_le(ORD8 *p);
+void write_INR32_be(int d, ORD8 *p);
+void write_INR32_le(int d, ORD8 *p);
+
+/* Unsigned 64 bit */
+ORD64 read_ORD64_be(ORD8 *p);
+ORD64 read_ORD64_le(ORD8 *p);
+void write_ORD64_be(ORD64 d, ORD8 *p);
+void write_ORD64_le(ORD64 d, ORD8 *p);
+
+/* Signed 64 bit */
+INR64 read_INR64_be(ORD8 *p);
+INR64 read_INR64_le(ORD8 *p);
+void write_INR64_be(INR64 d, ORD8 *p);
+void write_INR64_le(INR64 d, ORD8 *p);
+
#ifdef __cplusplus
}
#endif