summaryrefslogtreecommitdiffhomepage
path: root/mixlib
diff options
context:
space:
mode:
Diffstat (limited to 'mixlib')
-rw-r--r--mixlib/mix_types.h51
1 files changed, 26 insertions, 25 deletions
diff --git a/mixlib/mix_types.h b/mixlib/mix_types.h
index 918046e..e10f8c7 100644
--- a/mixlib/mix_types.h
+++ b/mixlib/mix_types.h
@@ -2,22 +2,22 @@
* This file contains declarations for the basic types used in MIX:
* mix_byte_t, mix_char_t, mix_short_t and mix_word_t.
* ------------------------------------------------------------------
- * Copyright (C) 2000, 2001 Free Software Foundation, Inc.
- *
+ * Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
@@ -66,7 +66,7 @@ typedef guint8 mix_char_t;
/* Conversions for mix_char_t's */
#define mix_char_to_byte(mchar) mix_byte_new(mchar)
-#define mix_byte_to_char(byte) ((mix_char_t)(byte&MIX_CHAR_MAX))
+#define mix_byte_to_char(byte) ((mix_char_t)((byte) & MIX_CHAR_MAX))
extern mix_char_t
mix_ascii_to_char(guchar c);
@@ -78,7 +78,7 @@ mix_char_to_ascii(mix_char_t c);
/*----------------- mix_word_t --------------------------------------------*/
/*
* Represented as a gint32 (glib ensures that this type has 32
- * bits). Bit 30 is the sign, higher bits are 0,
+ * bits). Bit 30 is the sign, higher bits are 0,
* and bits 0-29 are the magnitude.
* Each MIX 'byte' is a 6-bit substring of the magnitude.
*/
@@ -99,7 +99,7 @@ typedef guint32 mix_word_t;
( (x) < 0 \
? ( MIX_WORD_SIGN_BIT | ((mix_word_t)(-(x)) & MIX_WORD_MAX) ) \
: ( (mix_word_t)(x) & MIX_WORD_MAX ) \
-)
+)
/* Create a mix_word_t from individual bytes */
#define mix_word_new_b(b1,b2,b3,b4,b5) \
@@ -117,11 +117,11 @@ mix_bytes_to_word(mix_byte_t *bytes, guint byteno);
/* Access byte within a word */
extern mix_byte_t /* byte -idx- or MIX_BYTE_ZERO if -idx- out of range */
-mix_word_get_byte(mix_word_t word, /* word parsed */
+mix_word_get_byte(mix_word_t word, /* word parsed */
guint idx /* byte: 1 to 5 */);
/* Set a byte within a mix_word_t */
-extern void
+extern void
mix_word_set_byte(mix_word_t *into, /* word to be modified */
guint idx, /* byte: 1 to 5 */
mix_byte_t value /* byte's value */);
@@ -138,9 +138,9 @@ mix_word_set_byte(mix_word_t *into, /* word to be modified */
/* Arithmetic operations */
-extern mix_word_t
+extern mix_word_t
mix_word_add(mix_word_t x, mix_word_t y);
-
+
#define mix_word_sub(x,y) ( mix_word_add((x),mix_word_negative(y)) )
/* Add two words filling a high word if needed.
@@ -153,27 +153,27 @@ mix_word_add_and_carry(mix_word_t x, mix_word_t y,
/* Product, stored in -high_word- and -low_word-, which
can be NULL.
*/
-extern void
-mix_word_mul(mix_word_t x, mix_word_t y,
+extern void
+mix_word_mul(mix_word_t x, mix_word_t y,
mix_word_t *high_word, mix_word_t *low_word);
/* Division. -quotient- and/or -remainder- can be NULL. */
-extern gboolean /* TRUE if overflow */
-mix_word_div(mix_word_t n1, mix_word_t n0, mix_word_t d,
+extern gboolean /* TRUE if overflow */
+mix_word_div(mix_word_t n1, mix_word_t n0, mix_word_t d,
mix_word_t *quotient, mix_word_t *remainder);
/* Shift operations */
-extern void
-mix_word_shift_left(mix_word_t A, mix_word_t X, gulong count,
+extern void
+mix_word_shift_left(mix_word_t A, mix_word_t X, gulong count,
mix_word_t *pA, mix_word_t *pX);
-extern void
-mix_word_shift_right(mix_word_t A, mix_word_t X, gulong count,
+extern void
+mix_word_shift_right(mix_word_t A, mix_word_t X, gulong count,
mix_word_t *pA, mix_word_t *pX);
-extern void
-mix_word_shift_left_circular(mix_word_t A, mix_word_t X, gulong count,
+extern void
+mix_word_shift_left_circular(mix_word_t A, mix_word_t X, gulong count,
mix_word_t *pA, mix_word_t *pX);
-extern void
-mix_word_shift_right_circular(mix_word_t A, mix_word_t X, gulong count,
+extern void
+mix_word_shift_right_circular(mix_word_t A, mix_word_t X, gulong count,
mix_word_t *pA, mix_word_t *pX);
@@ -196,7 +196,7 @@ mix_fspec_is_valid(mix_fspec_t f);
extern mix_word_t /* the specified field or 0 if f is not valid */
mix_word_get_field(mix_fspec_t f, mix_word_t word);
-extern mix_word_t /* -to- with the field -f- from -from- or -to-
+extern mix_word_t /* -to- with the field -f- from -from- or -to-
if -f- is not a valid fspec */
mix_word_set_field(mix_fspec_t f, mix_word_t from, mix_word_t to);
@@ -238,6 +238,7 @@ typedef guint16 mix_short_t;
( (s) & (MIX_SHORT_SIGN_BIT - 1) )
#define mix_short_is_positive(s) ( mix_short_sign(s) == 0 )
#define mix_short_is_negative(s) ( mix_short_sign(s) != 0 )
+#define mix_short_reverse_sign(s) ( (s) ^= MIX_SHORT_SIGN_BIT )
/* create short from a long */
#define mix_short_new(val) \