Towards 64bit DataHandles

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Towards 64bit DataHandles

Stefan Westerfeld
   Hi!

I am currently trying to change all BEAST code so that it can deal
properly with "really long" samples (with more than 2^31 values). Here
is the first part of the changes.

A side effect is that by defining the new type int64 to long long, the
printf format strings between AMD64 and i386 will finally match, so that
the compile warnings will disappear on AMD64. We can make this change to
BEAST (whereas for glib it can not be done), because we depend on
gccisms already. For a related discussion see:

http://mail.gnome.org/archives/beast/2005-January/msg00005.html

   Cu... Stefan

Here is is the patch:

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/beast/ChangeLog,v
retrieving revision 1.921
diff -u -p -r1.921 ChangeLog
--- ChangeLog 5 Jan 2006 00:28:33 -0000 1.921
+++ ChangeLog 20 Jan 2006 20:19:40 -0000
@@ -1,3 +1,9 @@
+Fri Jan 20 20:45:13 2006  Stefan Westerfeld  <[hidden email]>
+
+ * tools/bseloopfuncs.c:
+ * tools/bsewavetool.cc: Adapted printf format strings to the GslLong
+ change ("%ld" -> "%lld").
+
 Thu Jan  5 01:22:36 2006  Tim Janik  <[hidden email]>
 
  * web/sound-browser.doxi: build sound browser page with included php.
Index: bse/ChangeLog
===================================================================
RCS file: /cvs/gnome/beast/bse/ChangeLog,v
retrieving revision 1.589
diff -u -p -r1.589 ChangeLog
--- bse/ChangeLog 2 Jan 2006 22:24:58 -0000 1.589
+++ bse/ChangeLog 20 Jan 2006 20:19:45 -0000
@@ -1,3 +1,18 @@
+Fri Jan 20 14:46:43 2006  Stefan Westerfeld  <[hidden email]>
+
+ * gsldefs.h: GslLong is now 64-bit on any platform (before, it was
+ only 64 bit on 64 bit platforms).
+
+ * tests/testwavechunk.c:
+ * gsldatahandle-mad.c:
+ * gsldatahandle-vorbis.c:
+ * gsldatautils.c:
+ * gslwavechunk.c:
+ * gslwaveosc.c: Adapted printf format strings to the GslLong change
+ ("%ld" -> "%lld").
+
+ * gsldatahandle.[hc]: Changed GslLong -> int64.
+
 Fri Dec 23 00:57:58 2005  Tim Janik  <[hidden email]>
 
  * bseconstvalues.h: provide BSE_MIN_TRANSPOSE and BSE_MAX_TRANSPOSE
Index: bse/gsldatahandle-mad.c
===================================================================
RCS file: /cvs/gnome/beast/bse/gsldatahandle-mad.c,v
retrieving revision 1.23
diff -u -p -r1.23 gsldatahandle-mad.c
--- bse/gsldatahandle-mad.c 20 May 2005 11:43:23 -0000 1.23
+++ bse/gsldatahandle-mad.c 20 Jan 2006 20:19:45 -0000
@@ -557,7 +557,7 @@ dh_mad_read (GslDataHandle *dhandle,
     }
   else /* something went wrong here, _badly_ */
     {
-      sfi_diag ("MAD-init: pcm position screwed (pos: %lu, handle-pos: %lu), aborting read",
+      sfi_diag ("MAD-init: pcm position screwed (pos: %llu, handle-pos: %llu), aborting read",
                 pos, handle->pcm_pos);
       return -1;
     }
@@ -624,7 +624,7 @@ dh_mad_coarse_seek (GslDataHandle *dhand
     }
  }
 
-      MAD_DEBUG ("seek-done: at %lu (f:%lu) want %lu (f:%lu) got %lu (f:%lu) diff %ld (diff-requested %ld)",
+      MAD_DEBUG ("seek-done: at %llu (f:%llu) want %llu (f:%llu) got %llu (f:%llu) diff %lld (diff-requested %lld)",
  opos, opos / handle->frame_size,
  pos, pos / handle->frame_size,
  handle->pcm_pos, handle->pcm_pos / handle->frame_size,
Index: bse/gsldatahandle-vorbis.c
===================================================================
RCS file: /cvs/gnome/beast/bse/gsldatahandle-vorbis.c,v
retrieving revision 1.20
diff -u -p -r1.20 gsldatahandle-vorbis.c
--- bse/gsldatahandle-vorbis.c 20 Jan 2005 16:56:25 -0000 1.20
+++ bse/gsldatahandle-vorbis.c 20 Jan 2006 20:19:45 -0000
@@ -186,7 +186,7 @@ dh_vorbis_open (GslDataHandle      *dhan
   if (err < 0)
     {
       if (0)
-        g_printerr ("failed to open ogg at offset %d (real offset=%ld) (add-zoffset=%d): %s\n",
+        g_printerr ("failed to open ogg at offset %d (real offset=%lld) (add-zoffset=%d): %s\n",
                     vhandle->rfile_byte_offset,
                     vfile->byte_offset,
                     vhandle->rfile_add_zoffset,
@@ -263,7 +263,7 @@ dh_vorbis_coarse_seek (GslDataHandle *dh
       vhandle->pcm_length = 0;
     }
   if (0)
-    g_printerr ("OggS-SEEK: at %lu want %lu got %lu (diff-requested %ld)\n",
+    g_printerr ("OggS-SEEK: at %llu want %llu got %llu (diff-requested %lld)\n",
  opos, pos, vhandle->pcm_pos, pos - opos);
 
   return vhandle->pcm_pos * dhandle->setup.n_channels;
Index: bse/gsldatahandle.c
===================================================================
RCS file: /cvs/gnome/beast/bse/gsldatahandle.c,v
retrieving revision 1.30
diff -u -p -r1.30 gsldatahandle.c
--- bse/gsldatahandle.c 13 Jan 2005 21:00:50 -0000 1.30
+++ bse/gsldatahandle.c 20 Jan 2006 20:19:46 -0000
@@ -113,7 +113,7 @@ gsl_data_handle_open (GslDataHandle *dha
       if (!error && (setup.n_values < 0 ||
      setup.n_channels < 1))
  {
-  sfi_warning ("invalid parameters in data handle open() (%p()): nv=%ld nc=%u",
+  sfi_warning ("invalid parameters in data handle open() (%p()): nv=%lld nc=%u",
                        dhandle->vtable->open, setup.n_values, setup.n_channels);
   dhandle->vtable->close (dhandle);
   error = BSE_ERROR_FORMAT_INVALID;
@@ -160,13 +160,13 @@ gsl_data_handle_close (GslDataHandle *dh
     gsl_data_handle_unref (dhandle);
 }
 
-GslLong
+int64
 gsl_data_handle_read (GslDataHandle *dhandle,
-      GslLong        value_offset,
-      GslLong        n_values,
+      int64          value_offset,
+      int64          n_values,
       gfloat        *values)
 {
-  GslLong l;
+  int64 l;
   
   g_return_val_if_fail (dhandle != NULL, -1);
   g_return_val_if_fail (dhandle->open_count > 0, -1);
@@ -195,10 +195,10 @@ gsl_data_handle_get_source (GslDataHandl
   return src_handle;
 }
 
-GslLong
+int64
 gsl_data_handle_length (GslDataHandle *dhandle)
 {
-  GslLong l;
+  int64 l;
   
   g_return_val_if_fail (dhandle != NULL, 0);
   g_return_val_if_fail (dhandle->open_count > 0, 0);
@@ -279,7 +279,7 @@ gsl_data_handle_needs_cache (GslDataHand
 typedef struct {
   GslDataHandle     dhandle;
   guint             n_channels;
-  GslLong           n_values;
+  int64             n_values;
   const gfloat     *values;
   void            (*free_values) (gpointer);
   gchar           **xinfos;
@@ -326,10 +326,10 @@ mem_handle_destroy (GslDataHandle *dhand
     free_values ((gpointer) mem_values);
 }
 
-static GslLong
+static int64
 mem_handle_read (GslDataHandle *dhandle,
- GslLong        voffset,
- GslLong        n_values,
+ int64          voffset,
+ int64          n_values,
  gfloat        *values)
 {
   MemHandle *mhandle = (MemHandle*) dhandle;
@@ -346,7 +346,7 @@ gsl_data_handle_new_mem (guint         n
  guint         bit_depth,
                          gfloat        mix_freq,
                          gfloat        osc_freq,
- GslLong       n_values,
+ int64         n_values,
  const gfloat *values,
  void        (*free) (gpointer values))
 {
@@ -461,10 +461,10 @@ xinfo_handle_open (GslDataHandle      *d
   return BSE_ERROR_NONE;
 }
 
-static GslLong
+static int64
 xinfo_handle_read (GslDataHandle *dhandle,
-                   GslLong        voffset,
-                   GslLong        n_values,
+                   int64          voffset,
+                   int64          n_values,
                    gfloat        *values)
 {
   XInfoHandle *chandle = (XInfoHandle*) dhandle;
@@ -699,14 +699,14 @@ reverse_handle_destroy (GslDataHandle *d
   sfi_delete_struct (ReversedHandle, rhandle);
 }
 
-static GslLong
+static int64
 reverse_handle_read (GslDataHandle *dhandle,
-     GslLong        voffset,
-     GslLong        n_values,
+     int64          voffset,
+     int64          n_values,
      gfloat        *values)
 {
   ReversedHandle *rhandle = (ReversedHandle*) dhandle;
-  GslLong left, new_offset = dhandle->setup.n_values - (voffset + n_values);
+  int64  left, new_offset = dhandle->setup.n_values - (voffset + n_values);
   gfloat *t, *p = values;
   
   g_assert (new_offset >= 0);
@@ -714,7 +714,7 @@ reverse_handle_read (GslDataHandle *dhan
   left = n_values;
   do
     {
-      GslLong l = gsl_data_handle_read (rhandle->src_handle, new_offset, left, p);
+      int64 l = gsl_data_handle_read (rhandle->src_handle, new_offset, left, p);
       
       if (l < 0)
  return l; /* pass on errors */
@@ -773,9 +773,9 @@ gsl_data_handle_new_reverse (GslDataHand
 typedef struct {
   GslDataHandle     dhandle;
   GslDataHandle   *src_handle; /* mirror ChainHandle */
-  GslLong    cut_offset;
-  GslLong    n_cut_values;
-  GslLong    tail_cut;
+  int64    cut_offset;
+  int64    n_cut_values;
+  int64    tail_cut;
 } CutHandle;
 
 static BseErrorType
@@ -806,18 +806,18 @@ cut_handle_destroy (GslDataHandle *dhand
   sfi_delete_struct (CutHandle, chandle);
 }
 
-static GslLong
+static int64
 cut_handle_read (GslDataHandle *dhandle,
- GslLong        voffset,
- GslLong        n_values,
+ int64          voffset,
+ int64          n_values,
  gfloat        *values)
 {
   CutHandle *chandle = (CutHandle*) dhandle;
-  GslLong orig_n_values = n_values;
+  int64 orig_n_values = n_values;
   
   if (voffset < chandle->cut_offset)
     {
-      GslLong l = MIN (chandle->cut_offset - voffset, n_values);
+      int64 l = MIN (chandle->cut_offset - voffset, n_values);
       
       l = gsl_data_handle_read (chandle->src_handle, voffset, l, values);
       if (l < 0)
@@ -829,7 +829,7 @@ cut_handle_read (GslDataHandle *dhandle,
   
   if (voffset >= chandle->cut_offset && n_values)
     {
-      GslLong l = gsl_data_handle_read (chandle->src_handle, voffset + chandle->n_cut_values, n_values, values);
+      int64 l = gsl_data_handle_read (chandle->src_handle, voffset + chandle->n_cut_values, n_values, values);
       
       if (l < 0 && orig_n_values == n_values)
  return l;       /* pass on errors */
@@ -844,9 +844,9 @@ cut_handle_read (GslDataHandle *dhandle,
 
 static GslDataHandle*
 gsl_data_handle_new_translate (GslDataHandle *src_handle,
-       GslLong        cut_offset,
-       GslLong        n_cut_values,
-       GslLong      tail_cut)
+       int64          cut_offset,
+       int64          n_cut_values,
+       int64      tail_cut)
 {
   static GslDataHandleFuncs cut_handle_vtable = {
     cut_handle_open,
@@ -892,8 +892,8 @@ gsl_data_handle_new_translate (GslDataHa
  */
 GslDataHandle*
 gsl_data_handle_new_cut (GslDataHandle *src_handle,
- GslLong        cut_offset,
- GslLong        n_cut_values)
+ int64          cut_offset,
+ int64          n_cut_values)
 {
   return gsl_data_handle_new_translate (src_handle, cut_offset, n_cut_values, 0);
 }
@@ -911,8 +911,8 @@ gsl_data_handle_new_cut (GslDataHandle *
  */
 GslDataHandle*
 gsl_data_handle_new_crop (GslDataHandle *src_handle,
-  GslLong        n_head_cut,
-  GslLong        n_tail_cut)
+  int64          n_head_cut,
+  int64          n_tail_cut)
 {
   return gsl_data_handle_new_translate (src_handle, 0, n_head_cut, n_tail_cut);
 }
@@ -922,9 +922,9 @@ gsl_data_handle_new_crop (GslDataHandle
 typedef struct {
   GslDataHandle     dhandle;
   GslDataHandle   *src_handle; /* mirror ChainHandle */
-  GslLong    requested_paste_offset;
-  GslLong    paste_offset;
-  GslLong    n_paste_values;
+  int64    requested_paste_offset;
+  int64    paste_offset;
+  int64    n_paste_values;
   guint    paste_bit_depth;
   const gfloat   *paste_values;
   void            (*free_values) (gpointer);
@@ -979,14 +979,14 @@ insert_handle_destroy (GslDataHandle *dh
     free_values ((gpointer) paste_values);
 }
 
-static GslLong
+static int64
 insert_handle_read (GslDataHandle *dhandle,
-    GslLong        voffset,
-    GslLong        n_values,
+    int64          voffset,
+    int64          n_values,
     gfloat        *values)
 {
   InsertHandle *ihandle = (InsertHandle*) dhandle;
-  GslLong l, orig_n_values = n_values;
+  int64 l, orig_n_values = n_values;
   
   if (voffset < ihandle->src_handle->setup.n_values &&
       voffset < ihandle->paste_offset)
@@ -1035,8 +1035,8 @@ insert_handle_read (GslDataHandle *dhand
 GslDataHandle*
 gsl_data_handle_new_insert (GslDataHandle *src_handle,
     guint          paste_bit_depth,
-    GslLong        insertion_offset,
-    GslLong        n_paste_values,
+    int64          insertion_offset,
+    int64          n_paste_values,
     const gfloat  *paste_values,
     void         (*free) (gpointer values))
 {
@@ -1082,10 +1082,10 @@ gsl_data_handle_new_insert (GslDataHandl
 typedef struct {
   GslDataHandle     dhandle;
   GslDataHandle   *src_handle; /* mirror ChainHandle */
-  GslLong    requested_first;
-  GslLong    requested_last;
-  GslLong    loop_start;
-  GslLong    loop_width;
+  int64    requested_first;
+  int64    requested_last;
+  int64    loop_start;
+  int64    loop_width;
 } LoopHandle;
 
 static BseErrorType
@@ -1104,7 +1104,7 @@ loop_handle_open (GslDataHandle      *dh
     {
       lhandle->loop_start = lhandle->requested_first;
       lhandle->loop_width = lhandle->requested_last - lhandle->requested_first + 1;
-      setup->n_values = GSL_MAXLONG;
+      setup->n_values = G_MAXINT64;
     }
   else /* cannot loop */
     {
@@ -1126,10 +1126,10 @@ loop_handle_destroy (GslDataHandle *dhan
   sfi_delete_struct (LoopHandle, lhandle);
 }
 
-static GslLong
+static int64
 loop_handle_read (GslDataHandle *dhandle,
-  GslLong        voffset,
-  GslLong        n_values,
+  int64          voffset,
+  int64          n_values,
   gfloat        *values)
 {
   LoopHandle *lhandle = (LoopHandle*) dhandle;
@@ -1140,7 +1140,7 @@ loop_handle_read (GslDataHandle *dhandle
  values);
   else
     {
-      GslLong noffset = voffset - lhandle->loop_start;
+      int64 noffset = voffset - lhandle->loop_start;
       
       noffset %= lhandle->loop_width;
       
@@ -1153,8 +1153,8 @@ loop_handle_read (GslDataHandle *dhandle
 
 GslDataHandle*
 gsl_data_handle_new_looped (GslDataHandle *src_handle,
-    GslLong        loop_first,
-    GslLong        loop_last)
+    int64          loop_first,
+    int64          loop_last)
 {
   static GslDataHandleFuncs loop_handle_vtable = {
     loop_handle_open,
@@ -1174,7 +1174,7 @@ gsl_data_handle_new_looped (GslDataHandl
   success = gsl_data_handle_common_init (&lhandle->dhandle, NULL);
   if (success)
     {
-      lhandle->dhandle.name = g_strdup_printf ("%s// #loop(0x%lx:0x%lx) /", src_handle->name, loop_first, loop_last);
+      lhandle->dhandle.name = g_strdup_printf ("%s// #loop(0x%llx:0x%llx) /", src_handle->name, loop_first, loop_last);
       lhandle->dhandle.vtable = &loop_handle_vtable;
       lhandle->src_handle = gsl_data_handle_ref (src_handle);
       lhandle->requested_first = loop_first;
@@ -1235,10 +1235,10 @@ dcache_handle_close (GslDataHandle *dhan
   gsl_data_cache_close (chandle->dcache);
 }
 
-static GslLong
+static int64
 dcache_handle_read (GslDataHandle *dhandle,
-    GslLong        voffset,
-    GslLong        n_values,
+    int64          voffset,
+    int64          n_values,
     gfloat        *values)
 {
   DCacheHandle *chandle = (DCacheHandle*) dhandle;
@@ -1296,13 +1296,13 @@ gsl_data_handle_new_dcached (GslDataCach
 typedef struct {
   GslDataHandle     dhandle;
   GslHFile   *hfile;
-  GslLong    byte_offset;
+  int64            byte_offset;
   guint             byte_order;
   guint    n_channels;
   GslWaveFormatType format;
   guint    add_zoffset : 1;
-  GslLong    requested_offset;
-  GslLong    requested_length;
+  int64            requested_offset;
+  int64            requested_length;
   gchar           **xinfos;
   gfloat            mix_freq;
 } WaveHandle;
@@ -1377,11 +1377,11 @@ wave_handle_open (GslDataHandle      *dh
     return gsl_error_from_errno (errno, BSE_ERROR_FILE_OPEN_FAILED);
   else
     {
-      GslLong l, fwidth = wave_format_byte_width (whandle->format);
+      int64 l, fwidth = wave_format_byte_width (whandle->format);
       whandle->byte_offset = whandle->requested_offset;
       if (whandle->add_zoffset)
  {
-  GslLong zoffset = gsl_hfile_zoffset (whandle->hfile);
+  int64 zoffset = gsl_hfile_zoffset (whandle->hfile);
   if (zoffset >= 0)
     whandle->byte_offset += zoffset + 1;
  }
@@ -1420,15 +1420,15 @@ wave_handle_close (GslDataHandle *dhandl
   whandle->hfile = NULL;
 }
 
-static GslLong
+static int64
 wave_handle_read (GslDataHandle *dhandle,
-  GslLong        voffset,
-  GslLong        n_values,
+  int64          voffset,
+  int64          n_values,
   gfloat        *values)
 {
   WaveHandle *whandle = (WaveHandle*) dhandle;
   gpointer buffer = values;
-  GslLong l, byte_offset;
+  int64 l, byte_offset;
   
   byte_offset = voffset * wave_format_byte_width (whandle->format); /* float offset into bytes */
   byte_offset += whandle->byte_offset;
@@ -1486,8 +1486,8 @@ gsl_wave_handle_new (const gchar      *f
      guint             byte_order,
                      gfloat            mix_freq,
                      gfloat            osc_freq,
-     GslLong           byte_offset,
-     GslLong           n_values,
+     int64             byte_offset,
+     int64             n_values,
                      gchar           **xinfos)
 {
   static GslDataHandleFuncs wave_handle_vtable = {
@@ -1537,8 +1537,8 @@ gsl_wave_handle_new_zoffset (const gchar
      guint             byte_order,
                              gfloat            mix_freq,
                              gfloat            osc_freq,
-                             GslLong           byte_offset,
-     GslLong           byte_size,
+                             int64             byte_offset,
+     int64             byte_size,
                              gchar           **xinfos)
 {
   GslDataHandle *dhandle = gsl_wave_handle_new (file_name, n_channels, format,
Index: bse/gsldatahandle.h
===================================================================
RCS file: /cvs/gnome/beast/bse/gsldatahandle.h,v
retrieving revision 1.23
diff -u -p -r1.23 gsldatahandle.h
--- bse/gsldatahandle.h 6 Jan 2005 22:45:20 -0000 1.23
+++ bse/gsldatahandle.h 20 Jan 2006 20:19:46 -0000
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
 /* --- typedefs & structures --- */
 typedef struct {
   guint n_channels;
-  GslLong n_values;
+  int64 n_values;
   gchar       **xinfos;
   guint         bit_depth : 8;
   guint         needs_cache : 1;
@@ -56,9 +56,9 @@ struct _GslDataHandleFuncs
 {
   BseErrorType (*open) (GslDataHandle *data_handle,
  GslDataHandleSetup *setup);
-  GslLong (*read) (GslDataHandle *data_handle,
- GslLong voffset, /* in values */
- GslLong n_values,
+  int64 (*read) (GslDataHandle *data_handle,
+ int64 voffset, /* in values */
+ int64 n_values,
  gfloat *values);
   void (*close) (GslDataHandle *data_handle);
   GslDataHandle* (*get_source)          (GslDataHandle          *data_handle);
@@ -72,7 +72,7 @@ GslDataHandle*  gsl_data_handle_ref (G
 void  gsl_data_handle_unref (GslDataHandle  *dhandle);
 BseErrorType  gsl_data_handle_open (GslDataHandle  *dhandle);
 void  gsl_data_handle_close (GslDataHandle  *dhandle);
-GslLong  gsl_data_handle_length (GslDataHandle  *data_handle);
+int64  gsl_data_handle_length (GslDataHandle  *data_handle);
 #define          gsl_data_handle_n_values(      dh) \
                                  gsl_data_handle_length (dh)
 guint  gsl_data_handle_n_channels (GslDataHandle  *data_handle);
@@ -80,36 +80,36 @@ guint  gsl_data_handle_bit_depth (GslD
 gfloat  gsl_data_handle_mix_freq (GslDataHandle  *data_handle);
 gfloat  gsl_data_handle_osc_freq (GslDataHandle  *data_handle);
 const gchar*  gsl_data_handle_name (GslDataHandle  *data_handle);
-GslLong  gsl_data_handle_read (GslDataHandle  *data_handle,
- GslLong   value_offset,
- GslLong   n_values,
+int64  gsl_data_handle_read (GslDataHandle  *data_handle,
+ int64   value_offset,
+ int64   n_values,
  gfloat  *values);
 GslDataHandle*    gsl_data_handle_get_source    (GslDataHandle    *dhandle);
 GslDataHandle*  gsl_data_handle_new_cut (GslDataHandle  *src_handle,
- GslLong   cut_offset,
- GslLong   n_cut_values);
+ int64   cut_offset,
+ int64   n_cut_values);
 GslDataHandle*  gsl_data_handle_new_crop (GslDataHandle  *src_handle,
- GslLong   n_head_cut,
- GslLong   n_tail_cut);
+ int64     n_head_cut,
+ int64   n_tail_cut);
 GslDataHandle*  gsl_data_handle_new_reverse (GslDataHandle  *src_handle);
 GslDataHandle*  gsl_data_handle_new_insert (GslDataHandle  *src_handle,
  guint             pasted_bit_depth,
- GslLong   insertion_offset,
- GslLong   n_paste_values,
+ int64   insertion_offset,
+ int64   n_paste_values,
  const gfloat  *paste_values,
  void            (*free) (gpointer values));
 GslDataHandle*  gsl_data_handle_new_mem (guint   n_channels,
  guint             bit_depth,
                                                  gfloat            mix_freq,
                                                  gfloat            osc_freq,
- GslLong   n_values,
+ int64   n_values,
  const gfloat  *values,
  void            (*free) (gpointer values));
 GslDataHandle*  gsl_data_handle_new_dcached (GslDataCache  *dcache);
 /* cheap and inefficient, testpurpose only */
 GslDataHandle*  gsl_data_handle_new_looped (GslDataHandle  *src_handle,
- GslLong   loop_first,
- GslLong   loop_last);
+ int64   loop_first,
+ int64   loop_last);
 
 /* --- xinfo handling --- */
 GslDataHandle* gsl_data_handle_new_add_xinfos     (GslDataHandle *src_handle,
@@ -144,8 +144,8 @@ GslDataHandle*  gsl_wave_handle_new (c
  guint   byte_order,
                                                  gfloat            mix_freq,
                                                  gfloat            osc_freq,
- GslLong   byte_offset,
- GslLong   n_values,
+ int64   byte_offset,
+ int64   n_values,
                                                  gchar           **xinfos);
 GslDataHandle*  gsl_wave_handle_new_zoffset (const gchar  *file_name,
  guint   n_channels,
@@ -153,8 +153,8 @@ GslDataHandle*  gsl_wave_handle_new_zof
  guint   byte_order,
                                                  gfloat            mix_freq,
                                                  gfloat            osc_freq,
- GslLong   byte_offset,
- GslLong   byte_size,
+ int64   byte_offset,
+ int64   byte_size,
                                                  gchar           **xinfos);
 guint  gsl_wave_format_bit_depth (GslWaveFormatType format);
 guint  gsl_wave_format_byte_width (GslWaveFormatType format);
Index: bse/gsldatautils.c
===================================================================
RCS file: /cvs/gnome/beast/bse/gsldatautils.c,v
retrieving revision 1.23
diff -u -p -r1.23 gsldatautils.c
--- bse/gsldatautils.c 19 Apr 2005 14:13:12 -0000 1.23
+++ bse/gsldatautils.c 20 Jan 2006 20:19:46 -0000
@@ -379,7 +379,7 @@ gsl_data_detect_signal (GslDataHandle *h
     }
   if (xcheck - minsamp > 0)
     g_printerr("###################");
-  g_printerr ("active area %ld .. %ld, signal>16 at: %ld\t diff: %ld\n",minsamp,maxsamp,xcheck, xcheck-minsamp);
+  g_printerr ("active area %lld .. %lld, signal>16 at: %lld\t diff: %lld\n",minsamp,maxsamp,xcheck, xcheck-minsamp);
 
   /* release open reference */
   gsl_data_handle_close (handle);
@@ -540,7 +540,7 @@ gsl_data_find_tailmatch (GslDataHandle  
     {
       start = offset + l;
       end = offset + l + lsize - 1;
-      g_print ("\nimproved: %f < %f: [0x%lx..0x%lx] (%lu)\n", score, best_score, start, end, lsize);
+      g_print ("\nimproved: %f < %f: [0x%llx..0x%llx] (%llu)\n", score, best_score, start, end, lsize);
       best_score = score;
     }
   else
@@ -556,7 +556,7 @@ gsl_data_find_tailmatch (GslDataHandle  
     }
   gsl_data_handle_close (shandle);
 
-  g_print ("\nhalted: %f: [0x%lx..0x%lx] (%lu)\n", best_score, start, end, end - start + 1);
+  g_print ("\nhalted: %f: [0x%llx..0x%llx] (%llu)\n", best_score, start, end, end - start + 1);
   
   *loop_start_p = start;
   *loop_end_p = end;
@@ -766,7 +766,7 @@ gsl_data_clip_sample (GslDataHandle    
   gsl_data_handle_open (clip_handle);
   gsl_data_handle_unref (clip_handle);
   if (info)
-    sfi_info ("Clipping: start=%llu end=%llu length=%ld (delta=%ld)", head, tail, gsl_data_handle_n_values (clip_handle),
+    sfi_info ("Clipping: start=%llu end=%llu length=%lld (delta=%lld)", head, tail, gsl_data_handle_n_values (clip_handle),
               gsl_data_handle_n_values (clip_handle) - gsl_data_handle_n_values (dhandle));
   result->clipped_head = head > 0;
   result->clipped_tail = last_value != tail;
@@ -794,7 +794,7 @@ gsl_data_clip_sample (GslDataHandle    
       gsl_data_handle_open (fade_handle);
       gsl_data_handle_unref (fade_handle);
       if (info)
-        sfi_info ("Adding fade-in ramp: ramp_length=%ld length=%ld", l, gsl_data_handle_n_values (fade_handle));
+        sfi_info ("Adding fade-in ramp: ramp_length=%lld length=%lld", l, gsl_data_handle_n_values (fade_handle));
     }
   else
     {
Index: bse/gsldefs.h
===================================================================
RCS file: /cvs/gnome/beast/bse/gsldefs.h,v
retrieving revision 1.27
diff -u -p -r1.27 gsldefs.h
--- bse/gsldefs.h 19 Apr 2005 14:13:12 -0000 1.27
+++ bse/gsldefs.h 20 Jan 2006 20:19:46 -0000
@@ -36,9 +36,15 @@ typedef struct _GslDataHandleFuncs GslDa
 typedef struct _GslWaveChunk GslWaveChunk;
 typedef struct _GslWaveChunkBlock GslWaveChunkBlock;
 /* ssize_t/off_t type used within Gsl */
-typedef glong  GslLong;
-#define GSL_MAXLONG  G_MAXLONG
-#define GSL_MINLONG  G_MINLONG
+
+/*
+ * FIXME: GslLong is a temporary typedef - it should go away after all
+ * code that uses GslLong has been ported to use int64 (as defined in
+ * sfitypes.h).
+ */
+typedef int64  GslLong;
+#define GSL_MAXLONG  MAXINT64;
+#define GSL_MINLONG  MININT64;
 
 
 /* --- functions --- */
Index: bse/gslwavechunk.c
===================================================================
RCS file: /cvs/gnome/beast/bse/gslwavechunk.c,v
retrieving revision 1.17
diff -u -p -r1.17 gslwavechunk.c
--- bse/gslwavechunk.c 4 Jan 2005 23:10:09 -0000 1.17
+++ bse/gslwavechunk.c 20 Jan 2006 20:19:46 -0000
@@ -292,7 +292,7 @@ wave_identify_offset (GslWaveChunk *wchu
       iter->rel_pos = wchunk->n_pad_values;
       iter->ubound = iter->rel_pos + MIN (STATIC_ZERO_SIZE - 2 * wchunk->n_pad_values, wchunk->head.first - pos);
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_UNDEF, pre-head %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+ g_print ("PHASE_UNDEF, pre-head %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
       return PHASE_UNDEF (wchunk);
     }
   if (UNLIKELY (pos > wchunk->tail.last)) /* outside wave boundaries */
@@ -301,14 +301,14 @@ wave_identify_offset (GslWaveChunk *wchu
       iter->rel_pos = wchunk->n_pad_values;
       iter->ubound = iter->rel_pos + MIN (STATIC_ZERO_SIZE - 2 * wchunk->n_pad_values, pos - wchunk->tail.last);
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_UNDEF, post-tail %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+ g_print ("PHASE_UNDEF, post-tail %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
       return PHASE_UNDEF (wchunk);
     }
   if (pos <= wchunk->head.last)
     {
       iter->rel_pos = pos - wchunk->head.first;
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_HEAD %ld %ld %ld\n", wchunk->head.first, iter->rel_pos, wchunk->head.last);
+ g_print ("PHASE_HEAD %lld %lld %lld\n", wchunk->head.first, iter->rel_pos, wchunk->head.last);
       return PHASE_HEAD (wchunk);
     }
   else if (pos <= wchunk->enter.last) /* before loop */
@@ -317,21 +317,21 @@ wave_identify_offset (GslWaveChunk *wchu
  {
   iter->rel_pos = pos - wchunk->enter.first;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_ENTER %ld %ld %ld\n", wchunk->enter.first, iter->rel_pos, wchunk->enter.last);
+    g_print ("PHASE_ENTER %lld %lld %lld\n", wchunk->enter.first, iter->rel_pos, wchunk->enter.last);
   return PHASE_ENTER (wchunk);
  }
       iter->rel_pos = pos - wchunk->head.last;
       iter->lbound = wchunk->head.last;
       iter->ubound = wchunk->enter.first;
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_NORM, pre-enter %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+ g_print ("PHASE_NORM, pre-enter %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
       return PHASE_NORM (wchunk);
     }
   else if (pos >= wchunk->tail.first)
     {
       iter->rel_pos = pos - wchunk->tail.first;
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_TAIL %ld %ld %ld\n", wchunk->tail.first, iter->rel_pos, wchunk->tail.last);
+ g_print ("PHASE_TAIL %lld %lld %lld\n", wchunk->tail.first, iter->rel_pos, wchunk->tail.last);
       return PHASE_TAIL (wchunk);
     }
   else if (pos >= wchunk->leave.first) /* after loop */
@@ -340,7 +340,7 @@ wave_identify_offset (GslWaveChunk *wchu
  {
   iter->rel_pos = pos - wchunk->leave.first;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_LEAVE %ld %ld %ld\n", wchunk->leave.first, iter->rel_pos, wchunk->leave.last);
+    g_print ("PHASE_LEAVE %lld %lld %lld\n", wchunk->leave.first, iter->rel_pos, wchunk->leave.last);
   return PHASE_LEAVE (wchunk);
  }
       iter->rel_pos = pos - wchunk->leave.last;
@@ -349,7 +349,7 @@ wave_identify_offset (GslWaveChunk *wchu
   iter->lbound = wchunk->tail_start_norm;
   iter->ubound = wchunk->leave_end_norm;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_NORM_BACKWARD, post-leave %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+    g_print ("PHASE_NORM_BACKWARD, post-leave %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
   return PHASE_NORM_BACKWARD (wchunk);
  }
       else
@@ -357,7 +357,7 @@ wave_identify_offset (GslWaveChunk *wchu
   iter->lbound = wchunk->leave_end_norm;
   iter->ubound = wchunk->tail_start_norm;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_NORM, post-leave %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+    g_print ("PHASE_NORM, post-leave %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
   return PHASE_NORM (wchunk);
  }
     }
@@ -373,35 +373,35 @@ wave_identify_offset (GslWaveChunk *wchu
     {
       iter->rel_pos = wchunk->wrap.length - one - wchunk->wrap.last + pos;
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_WRAP %ld %ld %ld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
+ g_print ("PHASE_WRAP %lld %lld %lld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
       return PHASE_WRAP (wchunk);
     }
   if (pos >= wchunk->ppwrap.first)
     {
       iter->rel_pos = pos - wchunk->ppwrap.first;
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_PPWRAP %ld %ld %ld\n", wchunk->ppwrap.first, iter->rel_pos, wchunk->ppwrap.last);
+ g_print ("PHASE_PPWRAP %lld %lld %lld\n", wchunk->ppwrap.first, iter->rel_pos, wchunk->ppwrap.last);
       return PHASE_PPWRAP (wchunk);
     }
   iter->ubound = wchunk->loop_last - one - wchunk->wrap.last;
   iter->lbound = wchunk->loop_last - one - wchunk->ppwrap.first;
   iter->rel_pos = pos - wchunk->wrap.last;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_NORM_BACKWARD, pploop %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+    g_print ("PHASE_NORM_BACKWARD, pploop %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
   return PHASE_NORM_BACKWARD (wchunk);
  }
       if (pos >= wchunk->wrap.first)
  {
   iter->rel_pos = pos - wchunk->wrap.first;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_WRAP %ld %ld %ld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
+    g_print ("PHASE_WRAP %lld %lld %lld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
   return PHASE_WRAP (wchunk);
  }
       iter->rel_pos = pos - wchunk->ppwrap.last;
       iter->ubound = wchunk->loop_first + one + wchunk->wrap.first - loop_width;
       iter->lbound = wchunk->loop_first + one + wchunk->ppwrap.last - loop_width;
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_NORM, pploop %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+ g_print ("PHASE_NORM, pploop %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
       return PHASE_NORM (wchunk);
     }
   else if (wchunk->loop_type == GSL_WAVE_LOOP_JUMP) /* in jump loop */
@@ -414,28 +414,28 @@ wave_identify_offset (GslWaveChunk *wchu
  {
   iter->rel_pos = pos - wchunk->wrap.first;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_WRAP %ld %ld %ld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
+    g_print ("PHASE_WRAP %lld %lld %lld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
   return PHASE_WRAP (wchunk);
  }
       if (pos <= wchunk->wrap.last)
  {
   iter->rel_pos = wchunk->wrap.length - one - wchunk->wrap.last + pos;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_WRAP %ld %ld %ld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
+    g_print ("PHASE_WRAP %lld %lld %lld\n", wchunk->wrap.first, iter->rel_pos, wchunk->wrap.last);
   return PHASE_WRAP (wchunk);
  }
       iter->rel_pos = pos - wchunk->wrap.last;
       iter->lbound = wchunk->loop_first + wchunk->wrap.last;
       iter->ubound = wchunk->loop_first + wchunk->wrap.first;
       if (PRINT_DEBUG_INFO)
- g_print ("PHASE_NORM, jloop %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+ g_print ("PHASE_NORM, jloop %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
       return PHASE_NORM (wchunk);
     }
   iter->rel_pos = pos - wchunk->head.last;
   iter->lbound = wchunk->head.last;
   iter->ubound = wchunk->enter.first;
   if (PRINT_DEBUG_INFO)
-    g_print ("PHASE_NORM, noloop %ld %ld %ld\n", iter->lbound, iter->rel_pos, iter->ubound);
+    g_print ("PHASE_NORM, noloop %lld %lld %lld\n", iter->lbound, iter->rel_pos, iter->ubound);
   return PHASE_NORM (wchunk);
 }
 
Index: bse/gslwaveosc.c
===================================================================
RCS file: /cvs/gnome/beast/bse/gslwaveosc.c,v
retrieving revision 1.22
diff -u -p -r1.22 gslwaveosc.c
--- bse/gslwaveosc.c 28 Jul 2005 12:05:50 -0000 1.22
+++ bse/gslwaveosc.c 20 Jan 2006 20:19:47 -0000
@@ -336,7 +336,7 @@ gsl_wave_osc_retrigger (GslWaveOscData *
   gsl_wave_chunk_use_block (wosc->wchunk, &wosc->block);
   wosc->x = wosc->block.start + CLAMP (wosc->config.channel, 0, wosc->wchunk->n_channels - 1);
 
-  DEBUG ("wave lookup: want=%f got=%f length=%lu\n",
+  DEBUG ("wave lookup: want=%f got=%f length=%llu\n",
  base_freq, wosc->wchunk->osc_freq, wosc->wchunk->wave_length);
 
   wosc->last_freq_level = BSE_SIGNAL_FROM_FREQ (base_freq);
Index: bse/tests/testwavechunk.c
===================================================================
RCS file: /cvs/gnome/beast/bse/tests/testwavechunk.c,v
retrieving revision 1.14
diff -u -p -r1.14 testwavechunk.c
--- bse/tests/testwavechunk.c 27 Dec 2004 23:27:59 -0000 1.14
+++ bse/tests/testwavechunk.c 20 Jan 2006 20:19:47 -0000
@@ -76,7 +76,7 @@ run_tests (GslWaveLoopType loop_type,
     g_error ("failed to open wave chunk: %s", bse_error_blurb (error));
   gsl_wave_chunk_unref (wchunk);
   if (verbosity >= VERBOSITY_SETUP)
-    g_print ("SETUP: loop_type=%u loop_first=%ld loop_last=%ld loop_count=%d playdir=%+d\n",
+    g_print ("SETUP: loop_type=%u loop_first=%lld loop_last=%lld loop_count=%d playdir=%+d\n",
      wchunk->loop_type, wchunk->loop_first, wchunk->loop_last, wchunk->loop_count, play_dir);
   gsl_wave_chunk_debug_block (wchunk, - DEBUG_SIZE / 2, DEBUG_SIZE, cmpblock - DEBUG_SIZE / 2);
 
@@ -112,13 +112,13 @@ run_tests (GslWaveLoopType loop_type,
       verbosity = 99;
     }
   if (verbosity >= VERBOSITY_CHECKS)
-    g_print ("%s: offset=%d (block.offset=%ld) value=%.16f found=%.16f\n",
+    g_print ("%s: offset=%d (block.offset=%lld) value=%.16f found=%.16f\n",
      fabs (cmpblock[i] - v) > 1e-15 ? "MISMATCH" : "match",
      i, (i - block.offset), cmpblock[i], v);
  }
       if (abort)
  {
-  g_error ("mismatches occoured, setup: loop_type=%u loop_first=%ld loop_last=%ld loop_count=%d (length=%ld)",
+  g_error ("mismatches occoured, setup: loop_type=%u loop_first=%lld loop_last=%lld loop_count=%d (length=%lld)",
    wchunk->loop_type, wchunk->loop_first, wchunk->loop_last, wchunk->loop_count,
    gsl_data_handle_length (wchunk->dcache->dhandle));
  }
@@ -144,8 +144,8 @@ print_block (GslWaveChunk      *wchunk,
   if (verbosity >= VERBOSITY_BLOCKS)
     {
       g_print ("BLOCK:");
-      g_print (" offset=%ld", block->offset);
-      g_print (" length=%ld", block->length);
+      g_print (" offset=%lld", block->offset);
+      g_print (" length=%lld", block->length);
       g_print (" dirstride=%d", block->dirstride);
     }
 
Index: sfi/ChangeLog
===================================================================
RCS file: /cvs/gnome/beast/sfi/ChangeLog,v
retrieving revision 1.281
diff -u -p -r1.281 ChangeLog
--- sfi/ChangeLog 15 Nov 2005 21:03:41 -0000 1.281
+++ sfi/ChangeLog 20 Jan 2006 20:19:48 -0000
@@ -1,3 +1,11 @@
+Tue Jan 17 23:38:02 2006  Stefan Westerfeld  <[hidden email]>
+
+ * sfitypes.h: Introduce int64 and uint64 types - within the scope of
+ BEAST, we guarantee that their printf format is always "%lld" (as
+ opposed to gint64/guint64, which requires different printf formats on
+ 32-bit and 64-bit platforms).  Use the new int64 type for SfiNum and
+ SfiTime.
+
 Tue Nov 15 21:57:46 2005  Tim Janik  <[hidden email]>
 
  * sfiprimitives.h:
Index: sfi/sfitypes.h
===================================================================
RCS file: /cvs/gnome/beast/sfi/sfitypes.h,v
retrieving revision 1.17
diff -u -p -r1.17 sfitypes.h
--- sfi/sfitypes.h 20 May 2004 12:23:17 -0000 1.17
+++ sfi/sfitypes.h 20 Jan 2006 20:19:48 -0000
@@ -25,14 +25,30 @@ G_BEGIN_DECLS
 
 
 /* --- Sfi typedefs --- */
+
+/* 64 bit types - FIXME: assert in configure script that sizeof (long long) == 8 */
+typedef long long               sfi_int64;
+typedef unsigned long long      sfi_uint64;
+#define SFI_MININT64            (0x8000000000000000LL)
+#define SFI_MAXINT64            (0x7fffffffffffffffLL)
+#define SFI_MAXUINT64           (0xffffffffffffffffULL)
+
+#if (1) /* internal: do not make these available when compiling third party code */
+#define int64                   sfi_int64
+#define uint64                  sfi_uint64
+#define MININT64                SFI_MININT64
+#define MAXINT64                SFI_MAXINT64
+#define MAXUINT64               SFI_MAXUINT64
+#endif
+
 typedef gboolean SfiBool;
 typedef gint SfiInt;
 #define SFI_MAXINT (+2147483647)
 #define SFI_MININT (-SFI_MAXINT - 1)
-typedef gint64 SfiNum;
-#define SFI_MAXNUM ((SfiNum) +9223372036854775807LL)
-#define SFI_MINNUM (-SFI_MAXNUM - 1)
-typedef gint64 SfiTime;
+typedef sfi_int64 SfiNum;
+#define SFI_MINNUM SFI_MININT64
+#define SFI_MAXNUM SFI_MAXINT64
+typedef sfi_int64 SfiTime;
 typedef SfiInt SfiNote;
 typedef gdouble SfiReal;
 #define SFI_MINREAL (2.2250738585072014e-308) /* IEEE754 double */
Index: tests/bse/loophandle.c
===================================================================
RCS file: /cvs/gnome/beast/tests/bse/loophandle.c,v
retrieving revision 1.1
diff -u -p -r1.1 loophandle.c
--- tests/bse/loophandle.c 4 Dec 2005 17:15:14 -0000 1.1
+++ tests/bse/loophandle.c 20 Jan 2006 20:19:48 -0000
@@ -127,7 +127,7 @@ gsl_data_handle_new_looped_reference (Gs
   success = gsl_data_handle_common_init (&lhandle->dhandle, NULL);
   if (success)
     {
-      lhandle->dhandle.name = g_strdup_printf ("%s// #loop(0x%lx:0x%lx) /", src_handle->name, loop_first, loop_last);
+      lhandle->dhandle.name = g_strdup_printf ("%s// #loop(0x%llx:0x%llx) /", src_handle->name, loop_first, loop_last);
       lhandle->dhandle.vtable = &loop_handle_reference_vtable;
       lhandle->src_handle = gsl_data_handle_ref (src_handle);
       lhandle->requested_first = loop_first;
@@ -161,7 +161,7 @@ check_loop (GslDataHandle *src_handle,
 
   GslDataPeekBuffer peek_buffer  = { +1 /* incremental direction */, 0, };
   GslDataPeekBuffer peek_buffer_reference = { +1 /* incremental direction */, 0, };
-  sfi_info ("check_loop<%ld,%ld>", loop_start, loop_end);
+  sfi_info ("check_loop<%lld,%lld>", loop_start, loop_end);
 
   BseErrorType error;
   error = gsl_data_handle_open (loop_handle);
@@ -186,7 +186,7 @@ check_loop (GslDataHandle *src_handle,
 
       if (a != b)
  {
-  sfi_error ("bad read in loop<%ld,%ld> position %ld: a = %f, b = %f", loop_start, loop_end, i, a, b);
+  sfi_error ("bad read in loop<%lld,%lld> position %lld: a = %f, b = %f", loop_start, loop_end, i, a, b);
   exit (1);
  }
     }
Index: tools/bseloopfuncs.c
===================================================================
RCS file: /cvs/gnome/beast/tools/bseloopfuncs.c,v
retrieving revision 1.8
diff -u -p -r1.8 bseloopfuncs.c
--- tools/bseloopfuncs.c 1 Dec 2005 12:21:08 -0000 1.8
+++ tools/bseloopfuncs.c 20 Jan 2006 20:19:49 -0000
@@ -390,7 +390,7 @@ gsl_data_find_loop5 (GslDataHandle     *
         }
     }
   gsl_progress_wipe (&pstate);
-  g_printerr ("  LOOP: %6lu - %6lu [%6lu] (block: %6lu - %6lu [%6lu]) (score:%+g at:%5.1f%%)\n",
+  g_printerr ("  LOOP: %6llu - %6llu [%6llu] (block: %6llu - %6llu [%6llu]) (score:%+g at:%5.1f%%)\n",
               config->loop_start, config->loop_start + config->loop_length, config->loop_length,
               bstart, bstart + blength, blength,
               config->score, score_pcount * 100.0 / pdist);
@@ -507,7 +507,7 @@ gsl_data_find_loop4 (GslDataHandle     *
                              config->score, config->loop_length, lstart, llength);
       }
   gsl_progress_wipe (&pstate);
-  g_printerr ("  LOOP: %6lu - %6lu [%6lu] (block: %6lu - %6lu [%6lu]) (score:%+g at:%5.1f%%)\n",
+  g_printerr ("  LOOP: %6llu - %6llu [%6llu] (block: %6llu - %6llu [%6llu]) (score:%+g at:%5.1f%%)\n",
               config->loop_start, config->loop_start + config->loop_length, config->loop_length,
               bstart, bstart + blength, blength,
               config->score, score_pcount * 100.0 / pdist);
@@ -645,7 +645,7 @@ gsl_data_find_loop2 (GslDataHandle     *
     }
   gsl_progress_wipe (&pstate);
   ll = config->loop_length;
-  g_printerr ("loop size: %lu\n", ll);
+  g_printerr ("loop size: %llu\n", ll);
 
   /* test every possible position */
   minll = ll;
@@ -832,7 +832,7 @@ gsl_data_find_loop1 (GslDataHandle    *d
   gsl_progress_wipe (&pstate);
   if (!found_loop)
     goto seek_loop_done;
-  g_printerr ("  lLOOP: %6lu - %6lu [%6lu] (block: %6lu - %6lu [%6lu]) (score:%+g)\n",
+  g_printerr ("  lLOOP: %6llu - %6llu [%6llu] (block: %6llu - %6llu [%6llu]) (score:%+g)\n",
               config->loop_start, config->loop_start + config->loop_length, config->loop_length,
               config->block_start, config->block_start + config->block_length, config->block_length,
               config->score);
@@ -860,7 +860,7 @@ gsl_data_find_loop1 (GslDataHandle    *d
         }
     }
   gsl_progress_wipe (&pstate);
-  g_printerr ("  pLOOP: %6lu - %6lu [%6lu] (block: %6lu - %6lu [%6lu]) (weighted-frame-score:%+g)\n",
+  g_printerr ("  pLOOP: %6llu - %6llu [%6llu] (block: %6llu - %6llu [%6llu]) (weighted-frame-score:%+g)\n",
               config->loop_start, config->loop_start + config->loop_length, config->loop_length,
               config->block_start, config->block_start + config->block_length, config->block_length,
               config->score);
@@ -894,7 +894,7 @@ gsl_data_find_loop1 (GslDataHandle    *d
           gsl_progress_notify (&pstate, ++pcount * 100.0 / pdist, "frame-score:%+g", config->score);
         }
       gsl_progress_wipe (&pstate);
-      g_printerr ("  sLOOP: %6lu - %6lu [%6lu] (block: %6lu - %6lu [%6lu]) (frame[%d]-score:%+g)\n",
+      g_printerr ("  sLOOP: %6llu - %6llu [%6llu] (block: %6llu - %6llu [%6llu]) (frame[%d]-score:%+g)\n",
                   config->loop_start, config->loop_start + config->loop_length, config->loop_length,
                   config->block_start, config->block_start + config->block_length, config->block_length,
                   frame, config->score);
@@ -1048,10 +1048,10 @@ gsl_data_find_loop0 (GslDataHandle      
  {
   perc_count = 0;
   perc_val++;
-  g_printerr ("processed %lu%%       \r", perc_val);
+  g_printerr ("processed %llu%%       \r", perc_val);
  }
     }
-  g_printerr ("\nbest match (%s): len in samples=%ld, len=%ld, score=%f\n",
+  g_printerr ("\nbest match (%s): len in samples=%lld, len=%lld, score=%f\n",
       (cfg->cmp_strategy == GSL_DATA_TAIL_LOOP_CMP_CORRELATION) ? "correlation" : "least squares",
       bestloopsize, bestloopsize, bestscore);
 
Index: tools/bsewavetool.cc
===================================================================
RCS file: /cvs/gnome/beast/tools/bsewavetool.cc,v
retrieving revision 1.28
diff -u -p -r1.28 bsewavetool.cc
--- tools/bsewavetool.cc 1 Dec 2005 15:46:20 -0000 1.28
+++ tools/bsewavetool.cc 20 Jan 2006 20:19:49 -0000
@@ -1451,7 +1451,7 @@ public:
  GslLong size = 1;
  gdouble freq = gsl_data_handle_osc_freq (chunk->dhandle);
 
- sfi_info ("THINOUT: chunk %f: error %f, size %ld", freq, error, size);
+ sfi_info ("THINOUT: chunk %f: error %f, size %lld", freq, error, size);
 
  chunk_data.sizes.push_back (size);
  chunk_data.errors.push_back (error);
--
Stefan Westerfeld, Hamburg/Germany, http://space.twc.de/~stefan
_______________________________________________
beast mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/beast
Reply | Threaded
Open this post in threaded view
|

Re: Towards 64bit DataHandles

Tim Janik



On Sat, 21 Jan 2006, Stefan Westerfeld wrote:


[...]

the most part of the patch is trivial and can go in.


> Index: sfi/sfitypes.h
> ===================================================================
> RCS file: /cvs/gnome/beast/sfi/sfitypes.h,v
> retrieving revision 1.17
> diff -u -p -r1.17 sfitypes.h
> --- sfi/sfitypes.h 20 May 2004 12:23:17 -0000 1.17
> +++ sfi/sfitypes.h 20 Jan 2006 20:19:48 -0000
> @@ -25,14 +25,30 @@ G_BEGIN_DECLS
>
>
> /* --- Sfi typedefs --- */
> +
> +/* 64 bit types - FIXME: assert in configure script that sizeof (long long) == 8 */
> +typedef long long               sfi_int64;
> +typedef unsigned long long      sfi_uint64;
> +#define SFI_MININT64            (0x8000000000000000LL)
> +#define SFI_MAXINT64            (0x7fffffffffffffffLL)
> +#define SFI_MAXUINT64           (0xffffffffffffffffULL)
> +
> +#if (1) /* internal: do not make these available when compiling third party code */
> +#define int64                   sfi_int64
> +#define uint64                  sfi_uint64
> +#define MININT64                SFI_MININT64
> +#define MAXINT64                SFI_MAXINT64
> +#define MAXUINT64               SFI_MAXUINT64
> +#endif
> +

eek, the above is a mess, but can go in as a temporary measure
(albeit with as little definitions/typedefs as possible) until
i commit a wider range of new typedefs.
also, you should decide on what constants you want, in the above
code, you used G_MAXINT64, and here you define SFI_MAXINT64 and
MAXINT64, allthough we already have SFI_MAXNUM.

best is probably to keep using G_MAXINT64 and not define SFI_MAXINT64
or MAXINT64 at all.

> typedef gboolean SfiBool;
> typedef gint SfiInt;
> #define SFI_MAXINT (+2147483647)
> #define SFI_MININT (-SFI_MAXINT - 1)
> -typedef gint64 SfiNum;
> -#define SFI_MAXNUM ((SfiNum) +9223372036854775807LL)
> -#define SFI_MINNUM (-SFI_MAXNUM - 1)
> -typedef gint64 SfiTime;
> +typedef sfi_int64 SfiNum;
> +#define SFI_MINNUM SFI_MININT64
> +#define SFI_MAXNUM SFI_MAXINT64
> +typedef sfi_int64 SfiTime;

but please don't mess with the existing definition, touvhing this
code is entirely unneccessary for your changes.

> typedef SfiInt SfiNote;
> typedef gdouble SfiReal;
> #define SFI_MINREAL (2.2250738585072014e-308) /* IEEE754 double */

---
ciaoTJ
_______________________________________________
beast mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/beast
Reply | Threaded
Open this post in threaded view
|

Re: Towards 64bit DataHandles

Stefan Westerfeld
   Hi!

On Fri, Jan 20, 2006 at 11:48:33PM +0100, Tim Janik wrote:

> >Index: sfi/sfitypes.h
> >===================================================================
> >RCS file: /cvs/gnome/beast/sfi/sfitypes.h,v
> >retrieving revision 1.17
> >diff -u -p -r1.17 sfitypes.h
> >--- sfi/sfitypes.h 20 May 2004 12:23:17 -0000 1.17
> >+++ sfi/sfitypes.h 20 Jan 2006 20:19:48 -0000
> >@@ -25,14 +25,30 @@ G_BEGIN_DECLS
> >
> >
> >/* --- Sfi typedefs --- */
> >+
> >+/* 64 bit types - FIXME: assert in configure script that sizeof (long
> >long) == 8 */
> >+typedef long long               sfi_int64;
> >+typedef unsigned long long      sfi_uint64;
> >+#define SFI_MININT64            (0x8000000000000000LL)
> >+#define SFI_MAXINT64            (0x7fffffffffffffffLL)
> >+#define SFI_MAXUINT64           (0xffffffffffffffffULL)
> >+
> >+#if (1) /* internal: do not make these available when compiling third
> >party code */
> >+#define int64                   sfi_int64
> >+#define uint64                  sfi_uint64
> >+#define MININT64                SFI_MININT64
> >+#define MAXINT64                SFI_MAXINT64
> >+#define MAXUINT64               SFI_MAXUINT64
> >+#endif
> >+
>
> eek, the above is a mess, but can go in as a temporary measure
> (albeit with as little definitions/typedefs as possible) until
> i commit a wider range of new typedefs.
> also, you should decide on what constants you want, in the above
> code, you used G_MAXINT64, and here you define SFI_MAXINT64 and
> MAXINT64, allthough we already have SFI_MAXNUM.
>
> best is probably to keep using G_MAXINT64 and not define SFI_MAXINT64
> or MAXINT64 at all.

Ok, I followed your advice, and omitted introducing any new MIN/MAXINT
defines. The typedefs I added look now like:

/* 64 bit types - FIXME: assert in configure script that sizeof (long long) == 8 */
typedef long long               sfi_int64;
typedef unsigned long long      sfi_uint64;

#if (1) /* internal: do not make these available when compiling third party code */
#define int64                   sfi_int64
#define uint64                  sfi_uint64
#endif

Just change them in the way you like. That I only conditionally #define
int64 here is intended for generated code like bstgenapi.h, which
includes <sfi/sfi.h>. We probably don't want to introduce int64 without
namespace into code only using the BSE C API (could be third party
code).

The condition is still missing though, just add it if you have reshaped
things the way you like.

> >typedef gboolean SfiBool;
> >typedef gint SfiInt;
> >#define SFI_MAXINT (+2147483647)
> >#define SFI_MININT (-SFI_MAXINT - 1)
> >-typedef gint64 SfiNum;
> >-#define SFI_MAXNUM ((SfiNum) +9223372036854775807LL)
> >-#define SFI_MINNUM (-SFI_MAXNUM - 1)
> >-typedef gint64 SfiTime;
> >+typedef sfi_int64 SfiNum;
> >+#define SFI_MINNUM SFI_MININT64
> >+#define SFI_MAXNUM SFI_MAXINT64
> >+typedef sfi_int64 SfiTime;
>
> but please don't mess with the existing definition, touvhing this
> code is entirely unneccessary for your changes.

Ok, so I committed my patch without these changes now. However, I
strongly recommend to redefine SfiNum and SfiTime to sfi_int64. Why?
Because the printf format string of gint64 is not constant across the
range of platforms BEAST can be compiled on (AMD64 => "%ld", i386 =>
"%lld").

   Cu... Stefan
--
Stefan Westerfeld, Hamburg/Germany, http://space.twc.de/~stefan
_______________________________________________
beast mailing list
[hidden email]
http://mail.gnome.org/mailman/listinfo/beast