Index: src/Makefile
===================================================================
RCS file: /cvs/emc2/src/Makefile,v
retrieving revision 1.266
diff -u -p -r1.266 Makefile
--- src/Makefile	25 Oct 2008 04:54:39 -0000	1.266
+++ src/Makefile	1 Nov 2008 14:25:48 -0000
@@ -144,7 +144,7 @@ INCLUDE += -I$(INCLUDEPY)
 endif
 
 # Compilation options.  Perhaps some of these should come from Makefile.inc?
-OPT := -O2 $(call cc-option,-fno-strict-aliasing) $(call cc-option,-fno-stack-protector)
+OPT := -Os $(call cc-option,-fno-strict-aliasing) $(call cc-option,-fno-stack-protector)
 # NOTE: Wwrite-strings is supposed to be OFF unless explicitly requested, even with -Wall,
 # since it produces a mess of warnings on any code that doesn't use "const" fastidiously
 # There is a bug in some versions of gcc that turns it on.
Index: src/hal/hal.h
===================================================================
RCS file: /cvs/emc2/src/hal/hal.h,v
retrieving revision 1.35
diff -u -p -r1.35 hal.h
--- src/hal/hal.h	27 Apr 2008 01:43:41 -0000	1.35
+++ src/hal/hal.h	1 Nov 2008 14:25:48 -0000
@@ -290,7 +290,9 @@ typedef enum {
 typedef volatile unsigned char hal_bit_t;
 typedef volatile __u32 hal_u32_t;
 typedef volatile __s32 hal_s32_t;
-typedef volatile float hal_float_t;
+typedef double real_t;
+typedef __u64 ireal_t; // integral type as wide as real_t / hal_float_t
+typedef volatile double hal_float_t;
 
 /***********************************************************************
 *                      "LOCKING" FUNCTIONS                             *
Index: src/hal/hal_lib.c
===================================================================
RCS file: /cvs/emc2/src/hal/hal_lib.c,v
retrieving revision 1.59
diff -u -p -r1.59 hal_lib.c
--- src/hal/hal_lib.c	27 Apr 2008 01:43:41 -0000	1.59
+++ src/hal/hal_lib.c	1 Nov 2008 14:25:48 -0000
@@ -575,6 +575,12 @@ int hal_pin_new(const char *name, hal_ty
 	    "HAL: ERROR: pin_new called before init\n");
 	return HAL_INVAL;
     }
+
+    if (type != HAL_BIT && type != HAL_FLOAT && type != HAL_S32 && type != HAL_U32) {
+	rtapi_print_msg(RTAPI_MSG_ERR,
+	    "HAL: ERROR: pin type not one of HAL_BIT, HAL_FLOAT, HAL_S32 or HAL_U32\n");
+	return HAL_INVAL;
+    }
     
     if(dir != HAL_IN && dir != HAL_OUT && dir != HAL_IO) {
 	rtapi_print_msg(RTAPI_MSG_ERR,
@@ -622,7 +628,7 @@ int hal_pin_new(const char *name, hal_ty
     new->type = type;
     new->dir = dir;
     new->signal = 0;
-    new->dummysig = 0;
+    memset(&new->dummysig, 0, sizeof(hal_data_u));
     rtapi_snprintf(new->name, HAL_NAME_LEN, "%s", name);
     /* make 'data_ptr' point to dummy signal */
     *data_ptr_addr = comp->shmem_base + SHMOFF(&(new->dummysig));
@@ -696,12 +702,16 @@ int hal_signal_new(const char *name, hal
     /* allocate memory for the signal value */
     switch (type) {
     case HAL_BIT:
-	data_addr = shmalloc_up(1);
+	data_addr = shmalloc_up(sizeof(hal_bit_t));
 	break;
     case HAL_S32:
+	data_addr = shmalloc_up(sizeof(hal_u32_t));
+	break;
     case HAL_U32:
+	data_addr = shmalloc_up(sizeof(hal_s32_t));
+	break;
     case HAL_FLOAT:
-	data_addr = shmalloc_up(4);
+	data_addr = shmalloc_up(sizeof(hal_float_t));
 	break;
     default:
 	rtapi_mutex_give(&(hal_data->mutex));
@@ -1060,6 +1070,12 @@ int hal_param_new(const char *name, hal_
 	return HAL_INVAL;
     }
 
+    if (type != HAL_BIT && type != HAL_FLOAT && type != HAL_S32 && type != HAL_U32) {
+	rtapi_print_msg(RTAPI_MSG_ERR,
+	    "HAL: ERROR: pin type not one of HAL_BIT, HAL_FLOAT, HAL_S32 or HAL_U32\n");
+	return HAL_INVAL;
+    }
+
     if(dir != HAL_RO && dir != HAL_RW) {
 	rtapi_print_msg(RTAPI_MSG_ERR,
 	    "HAL: ERROR: param direction not one of HAL_RO, or HAL_RW\n");
@@ -2393,7 +2409,7 @@ static void *shmalloc_up(long int size)
 
     /* deal with alignment requirements */
     tmp_bot = hal_data->shmem_bot;
-    if (size >= 8 && __alignof__(long) > 4) {
+    if (size >= 8) {
 	/* align on 8 byte boundary */
 	tmp_bot = (tmp_bot + 7) & (~7);
     } else if (size >= 4) {
@@ -2423,7 +2439,7 @@ static void *shmalloc_dn(long int size)
     /* tentatively allocate memory */
     tmp_top = hal_data->shmem_top - size;
     /* deal with alignment requirements */
-    if (size >= 8 && __alignof__(long) > 4) {
+    if (size >= 8) {
 	/* align on 8 byte boundary */
 	tmp_top &= (~7);
     } else if (size >= 4) {
@@ -2495,7 +2511,7 @@ static hal_pin_t *alloc_pin_struct(void)
 	p->type = 0;
 	p->dir = 0;
 	p->signal = 0;
-	p->dummysig = 0;
+	memset(&p->dummysig, 0, sizeof(hal_data_u));
 	p->name[0] = '\0';
     }
     return p;
@@ -2756,7 +2772,7 @@ static void free_pin_struct(hal_pin_t * 
     pin->type = 0;
     pin->dir = 0;
     pin->signal = 0;
-    pin->dummysig = 0;
+    memset(&pin->dummysig, 0, sizeof(hal_data_u));
     pin->name[0] = '\0';
     /* add it to free list */
     pin->next_ptr = hal_data->pin_free_ptr;
Index: src/hal/hal_priv.h
===================================================================
RCS file: /cvs/emc2/src/hal/hal_priv.h,v
retrieving revision 1.30
diff -u -p -r1.30 hal_priv.h
--- src/hal/hal_priv.h	27 Apr 2008 01:43:41 -0000	1.30
+++ src/hal/hal_priv.h	1 Nov 2008 14:25:48 -0000
@@ -117,6 +117,16 @@ extern "C" {
 *            PRIVATE HAL DATA STRUCTURES AND DECLARATIONS              *
 ************************************************************************/
 
+/** HAL "data union" structure
+ ** This structure may hold any type of hal data
+*/
+typedef union {
+    hal_bit_t b;
+    hal_s32_t s;
+    hal_s32_t u;
+    hal_float_t f;
+} hal_data_u;
+
 /** HAL "list element" data structure.
     This structure is used to implement generic double linked circular
     lists.  Such lists have the following characteristics:
@@ -199,7 +209,7 @@ typedef struct {
     int data_ptr_addr;		/* address of pin data pointer */
     int owner_ptr;		/* component that owns this pin */
     int signal;			/* signal to which pin is linked */
-    long dummysig;		/* if unlinked, data_ptr points here */
+    hal_data_u dummysig;		/* if unlinked, data_ptr points here */
     hal_type_t type;		/* data type */
     hal_pin_dir_t dir;		/* pin direction */
     char name[HAL_NAME_LEN + 1];	/* pin name */
Index: src/hal/components/ddt.comp
===================================================================
RCS file: /cvs/emc2/src/hal/components/ddt.comp,v
retrieving revision 1.7
diff -u -p -r1.7 ddt.comp
--- src/hal/components/ddt.comp	25 Apr 2007 16:27:19 -0000	1.7
+++ src/hal/components/ddt.comp	1 Nov 2008 14:25:48 -0000
@@ -19,11 +19,11 @@ component ddt "Compute the derivative of
 pin in float in;
 pin out float out;
 
-variable float old;
+variable double old;
 
 function _;
 license "GPL";
 ;;
-float tmp = in;
+double tmp = in;
 out = (tmp - old) / (period * 1e-9);
 old = tmp;
Index: src/hal/components/pid.c
===================================================================
RCS file: /cvs/emc2/src/hal/components/pid.c,v
retrieving revision 1.38
diff -u -p -r1.38 pid.c
--- src/hal/components/pid.c	29 Oct 2008 22:16:46 -0000	1.38
+++ src/hal/components/pid.c	1 Nov 2008 14:25:48 -0000
@@ -533,10 +533,10 @@ static int export_pid(int num, hal_pid_t
 	    return retval;
 	}
     } else {
-	addr->error_i = (float *) hal_malloc(sizeof(hal_float_t *));
-	addr->error_d = (float *) hal_malloc(sizeof(hal_float_t *));
-	addr->cmd_d = (float *) hal_malloc(sizeof(hal_float_t *));
-	addr->cmd_dd = (float *) hal_malloc(sizeof(hal_float_t *));
+	addr->error_i = (hal_float_t *) hal_malloc(sizeof(hal_float_t *));
+	addr->error_d = (hal_float_t *) hal_malloc(sizeof(hal_float_t *));
+	addr->cmd_d = (hal_float_t *) hal_malloc(sizeof(hal_float_t *));
+	addr->cmd_dd = (hal_float_t *) hal_malloc(sizeof(hal_float_t *));
     }
 
     *(addr->error_i) = 0.0;
Index: src/hal/components/streamer.h
===================================================================
RCS file: /cvs/emc2/src/hal/components/streamer.h,v
retrieving revision 1.6
diff -u -p -r1.6 streamer.h
--- src/hal/components/streamer.h	26 May 2008 16:49:29 -0000	1.6
+++ src/hal/components/streamer.h	1 Nov 2008 14:25:48 -0000
@@ -13,7 +13,7 @@
 #define MAX_STREAMERS		8
 #define MAX_SAMPLERS		8
 #define MAX_PINS 		20
-#define MAX_SHMEM 		64000
+#define MAX_SHMEM 		128000
 #define STREAMER_SHMEM_KEY 	0x48535430
 #define SAMPLER_SHMEM_KEY	0x48534130
 #define FIFO_MAGIC_NUM		0x4649464F
@@ -23,7 +23,7 @@
 */
 
 typedef union {
-    float f;
+    real_t f;
     char  b;
     hal_s32_t s;
     hal_u32_t u;
Index: src/hal/utils/halcmd_commands.c
===================================================================
RCS file: /cvs/emc2/src/hal/utils/halcmd_commands.c,v
retrieving revision 1.32
diff -u -p -r1.32 halcmd_commands.c
--- src/hal/utils/halcmd_commands.c	10 Aug 2008 13:11:39 -0000	1.32
+++ src/hal/utils/halcmd_commands.c	1 Nov 2008 14:25:48 -0000
@@ -564,7 +564,7 @@ int do_newsig_cmd(char *name, char *type
 static int set_common(hal_type_t type, void *d_ptr, char *value) {
     // This function assumes that the mutex is held
     int retval = 0;
-    float fval;
+    double fval;
     long lval;
     unsigned long ulval;
     char *cp = value;
Index: src/hal/utils/scope_disp.c
===================================================================
RCS file: /cvs/emc2/src/hal/utils/scope_disp.c,v
retrieving revision 1.51
diff -u -p -r1.51 scope_disp.c
--- src/hal/utils/scope_disp.c	22 Aug 2008 20:13:01 -0000	1.51
+++ src/hal/utils/scope_disp.c	1 Nov 2008 14:25:48 -0000
@@ -147,7 +147,7 @@ static void calculate_offset(int chan_nu
 	    };
 	    break;
 	case HAL_FLOAT:
-	    value = dptr->d_float;
+	    value = dptr->d_real;
 	    break;
 	case HAL_S32:
 	    value = dptr->d_s32;
@@ -826,7 +826,7 @@ void draw_waveform(int chan_num, int hig
 	    };
 	    break;
 	case HAL_FLOAT:
-	    fy = dptr->d_float;
+	    fy = dptr->d_real;
 	    break;
 	case HAL_S32:
 	    fy = dptr->d_s32;
Index: src/hal/utils/scope_files.c
===================================================================
RCS file: /cvs/emc2/src/hal/utils/scope_files.c,v
retrieving revision 1.13
diff -u -p -r1.13 scope_files.c
--- src/hal/utils/scope_files.c	29 Jan 2008 07:33:43 -0000	1.13
+++ src/hal/utils/scope_files.c	1 Nov 2008 14:25:48 -0000
@@ -330,7 +330,7 @@ void write_sample(FILE *fp, char *label,
 			};
 			break;
 		case HAL_FLOAT:
-			data_value = dptr->d_float;
+			data_value = dptr->d_real;
 			break;
 		case HAL_S32:
 			data_value = dptr->d_s32;
Index: src/hal/utils/scope_rt.c
===================================================================
RCS file: /cvs/emc2/src/hal/utils/scope_rt.c,v
retrieving revision 1.10
diff -u -p -r1.10 scope_rt.c
--- src/hal/utils/scope_rt.c	10 Jul 2007 13:17:11 -0000	1.10
+++ src/hal/utils/scope_rt.c	1 Nov 2008 14:25:48 -0000
@@ -259,6 +259,17 @@ static void capture_sample(void)
 	    dest->d_u32 = *((unsigned long *) (ctrl_rt->data_addr[n]));
 	    dest++;
 	    break;
+	case 8:
+            {
+                ireal_t sample_a, sample_b;
+                do {
+                    sample_a = *((volatile ireal_t *) (ctrl_rt->data_addr[n]));
+                    sample_b = *((volatile ireal_t *) (ctrl_rt->data_addr[n]));
+                } while( sample_a != sample_b );
+                dest->d_ireal = sample_a;
+                dest++;
+            }
+	    break;
 	default:
 	    break;
 	}
@@ -277,7 +288,6 @@ static int check_trigger(void)
     static int compare_result = 0;
     int prev_compare_result;
     scope_data_t *value, *level;
-    unsigned long tmp1, tmp2;
 
     /* has user forced trigger? */
     if (ctrl_shm->force_trig != 0) {
@@ -310,22 +320,24 @@ static int check_trigger(void)
 	compare_result = value->d_u8;
 	break;
     case HAL_FLOAT:
+	{
+	ireal_t tmp1, tmp2;
 	/* don't want to use the FPU in this function, so we use */
 	/* a hack - see http://en.wikipedia.org/wiki/IEEE_754 */
 	/* this _only_ works with IEEE-754 floating point numbers */
 	/* and will probably fail for infinities, NANs, etc. */
 	/* OK, here we go! */
 	/* get the value as 32 raw bits (unsigned long) */
-	tmp1 = value->d_u32;
+	tmp1 = value->d_ireal;
 	/* get the trigger level as 32 raw bits */
-	tmp2 = level->d_u32;
+	tmp2 = level->d_ireal;
 	/* is the value negative? */
-	if (tmp1 & 0x80000000) {
+	if (tmp1 & 0x8000000000000000ull) {
 	    /* yes, is the trigger level negative? */
-	    if (tmp2 & 0x80000000) {
+	    if (tmp2 & 0x8000000000000000ull) {
 		/* yes, make both positive */
-		tmp1 ^= 0x80000000;
-		tmp2 ^= 0x80000000;
+		tmp1 ^= 0x8000000000000000ull;
+		tmp2 ^= 0x8000000000000000ull;
 		/* and compare them as unsigned ints */
 		/* because of negation, we reverse the compare */
 		compare_result = (tmp1 < tmp2);
@@ -335,7 +347,7 @@ static int check_trigger(void)
 	    }
 	} else {
 	    /* value is positive, is trigger level negative? */
-	    if (tmp2 & 0x80000000) {
+	    if (tmp2 & 0x8000000000000000ull) {
 		/* trigger level negative, value positive */
 		compare_result = 1;
 	    } else {
@@ -344,6 +356,7 @@ static int check_trigger(void)
 		compare_result = (tmp1 > tmp2);
 	    }
 	}
+	}
 	break;
     case HAL_S32:
 	compare_result = (value->d_s32 > level->d_s32);
Index: src/hal/utils/scope_shm.h
===================================================================
RCS file: /cvs/emc2/src/hal/utils/scope_shm.h,v
retrieving revision 1.6
diff -u -p -r1.6 scope_shm.h
--- src/hal/utils/scope_shm.h	10 Jul 2007 13:17:50 -0000	1.6
+++ src/hal/utils/scope_shm.h	1 Nov 2008 14:25:48 -0000
@@ -58,9 +58,10 @@ typedef enum {
 
 typedef union {
     unsigned char d_u8;		/* variable for bit */
-    __u32 d_u32;	/* variable for u32 */
+    __u32 d_u32;		/* variable for u32 */
     __s32 d_s32;		/* variable for s32 */
-    float d_float;		/* variable for float */
+    real_t d_real;		/* variable for float */
+    ireal_t d_ireal;		/* intlike variable for float */
 } scope_data_t;
 
 /** This struct holds control data needed by both realtime and GUI code.
Index: src/hal/utils/scope_trig.c
===================================================================
RCS file: /cvs/emc2/src/hal/utils/scope_trig.c,v
retrieving revision 1.12
diff -u -p -r1.12 scope_trig.c
--- src/hal/utils/scope_trig.c	17 Aug 2007 14:10:16 -0000	1.12
+++ src/hal/utils/scope_trig.c	1 Nov 2008 14:25:48 -0000
@@ -104,7 +104,7 @@ void refresh_trigger(void)
     scope_trig_t *trig;
     scope_chan_t *chan;
     gchar buf[BUFLEN + 1];
-    float fp_level;
+    double fp_level;
 
     trig = &(ctrl_usr->trig);
     /* display edge */
@@ -134,7 +134,7 @@ void refresh_trigger(void)
     /* apply type specific tweaks to trigger level */
     switch (chan->data_type) {
     case HAL_FLOAT:
-	ctrl_shm->trig_level.d_float = fp_level;
+	ctrl_shm->trig_level.d_real = fp_level;
 	break;
     case HAL_S32:
 	if (fp_level > 2147483647.0) {
