gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 82cf820 1/2: Corrections for 32-bit big endian


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 82cf820 1/2: Corrections for 32-bit big endian systems
Date: Thu, 29 Jun 2017 11:52:16 -0400 (EDT)

branch: master
commit 82cf8201c734074724dc455eb2ad067d8ba09487
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Corrections for 32-bit big endian systems
    
    As part of the Debian checks for Gnuastro version 0.3.13 it was found that
    `make check' fails on 32-bit big-endian systems (`mips', `hppa',
    `powerpc'). This was reported in Debian bug #865973 and Adrian Bunk was
    able to find the cause of the bug (many thanks to Adrian).
    
    To solve the problem, a strategy similar to `GAL_TYPE_SIZE_T' was taken, at
    configure time, the width of `long' on the system is found and in
    `gnuastro/types.h', we use that to determine which fixed-width type `long'
    corresponds to and put that in a `GAL_TYPE_LONG'. This type was then used
    for MakeProfile's `--naxis' and `--shift' options.
    
    In a small and separate issue, I recognized that we are not initializing
    `status' in Crop's `onecrop_make_array'. With this commit, it is
    initialized with a value of zero.
    
    This fixes bug #51341.
---
 NEWS                              | 14 ++++++++++----
 THANKS                            |  1 +
 bin/crop/onecrop.c                |  2 +-
 bin/mkprof/args.h                 |  8 ++++----
 configure.ac                      |  6 +++++-
 doc/gnuastro.texi                 | 16 +++++++++++-----
 lib/Makefile.am                   |  1 +
 lib/gnuastro-internal/config.h.in |  1 +
 lib/gnuastro/type.h               | 25 ++++++++++++++++++++-----
 9 files changed, 54 insertions(+), 20 deletions(-)

diff --git a/NEWS b/NEWS
index c2ae348..eec8394 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   Arithmetic: now has a new `--globalhdu' (`-g') option which can be used
   once for all the input images.
 
+  MakeProfiles: the new `--kernel' option can make a kernel image without
+  the need to define a catalog. With this option, a catalog (or
+  accompanying background image) must not be given.
+
 ** Removed features
 
 ** Changed features
@@ -35,10 +39,6 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
   multiple times and the order of its calling will be used for the column
   containing the center in the respective dimension (in FITS format).
 
-  MakeProfiles: The new `--kernel' option can make a kernel image without
-  the need to define a catalog. With this option, a catalog (or
-  accompanying background image) must not be given.
-
   `gal_fits_img_info' now also returns the name and units of the dataset
   (if they aren't NULL). So it takes two extra arguments.
 
@@ -55,6 +55,12 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 
 ** Bug fixes
 
+  MakeProfiles long options on 32bit big endian systems (bug #51341).
+
+
+
+
+
 * Noteworthy changes in release 0.3 (library 1.0.0) (2017-06-01) [stable]
 
   This is a full re-write of Gnuastro. Most importantly, Gnuastro now has a
diff --git a/THANKS b/THANKS
index a8d34d3..63651a2 100644
--- a/THANKS
+++ b/THANKS
@@ -18,6 +18,7 @@ support in Gnuastro. The list is ordered alphabetically.
     Karl Berry                           address@hidden
     Roland Bacon                         address@hidden
     Nicolas Bouché                       address@hidden
+    Adrian Bunk                          address@hidden
     Rosa Calvi                           address@hidden
     Antonio Diaz Diaz                    address@hidden
     Takashi Ichikawa                     address@hidden
diff --git a/bin/crop/onecrop.c b/bin/crop/onecrop.c
index 225de23..d74526f 100644
--- a/bin/crop/onecrop.c
+++ b/bin/crop/onecrop.c
@@ -573,7 +573,7 @@ onecrop_make_array(struct onecropparams *crp, long 
*fpixel_i,
   long naxes[MAXDIM];
   char *outname=crp->name;
   char cpname[FLEN_KEYWORD];
-  int status, type=crp->p->type;
+  int status=0, type=crp->p->type;
   size_t i, ndim=crp->p->imgs->ndim;
   char *cp, *cpf, blankrec[80], titlerec[80];
   char startblank[]="                      / ";
diff --git a/bin/mkprof/args.h b/bin/mkprof/args.h
index 24c8db9..bfa8f5d 100644
--- a/bin/mkprof/args.h
+++ b/bin/mkprof/args.h
@@ -96,7 +96,7 @@ struct argp_option program_options[] =
       "Number of pixels along first FITS axis.",
       GAL_OPTIONS_GROUP_OUTPUT,
       &p->naxes[0],
-      GAL_TYPE_UINT64,
+      GAL_TYPE_LONG,
       GAL_OPTIONS_RANGE_GT_0,
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
@@ -109,7 +109,7 @@ struct argp_option program_options[] =
       "Number of pixels along second FITS axis.",
       GAL_OPTIONS_GROUP_OUTPUT,
       &p->naxes[1],
-      GAL_TYPE_INT64,
+      GAL_TYPE_LONG,
       GAL_OPTIONS_RANGE_GT_0,
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
@@ -223,7 +223,7 @@ struct argp_option program_options[] =
       "Shift profile centers and enlarge image, X axis.",
       ARGS_GROUP_PROFILES,
       &p->shift[0],
-      GAL_TYPE_INT64,
+      GAL_TYPE_LONG,
       GAL_OPTIONS_RANGE_GE_0,
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
@@ -236,7 +236,7 @@ struct argp_option program_options[] =
       "Shift profile centers and enlarge image, Y axis.",
       ARGS_GROUP_PROFILES,
       &p->shift[1],
-      GAL_TYPE_INT64,
+      GAL_TYPE_LONG,
       GAL_OPTIONS_RANGE_GE_0,
       GAL_OPTIONS_NOT_MANDATORY,
       GAL_OPTIONS_NOT_SET
diff --git a/configure.ac b/configure.ac
index c738a63..4b9d39f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,11 +121,15 @@ AC_FUNC_MALLOC
 
 
 
-# Check the size of `size_t'.
+# Check the size of necessary system specific types.
 AC_CHECK_SIZEOF([size_t])
 AC_SUBST(SIZEOF_SIZE_T, [$ac_cv_sizeof_size_t])
 AC_DEFINE_UNQUOTED([GAL_CONFIG_SIZEOF_SIZE_T], [$ac_cv_sizeof_size_t],
                    [On 32bit will be 4, on 64 bit, will be 8])
+AC_CHECK_SIZEOF([long])
+AC_SUBST(SIZEOF_LONG, [$ac_cv_sizeof_long])
+AC_DEFINE_UNQUOTED([GAL_CONFIG_SIZEOF_LONG], [$ac_cv_sizeof_long],
+                   [Depends on bit length of system.])
 
 
 
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index bf942c6..b1ca151 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -16959,11 +16959,12 @@ relevant for you if you intend to use the binary 
operators of
 @cindex 64-bit
 @cindex bit-32
 @cindex bit-64
address@hidden Macro GAL_CONFIG_SIZEOF_SIZE_T
-The size of (number of bytes in) the system's @code{size_t} type. Its value
-is either 4 or 8 for 32-bit and 64-bit systems. You can also get this value
-with the expression address@hidden size_t}' without having to include this
-header.
address@hidden Macro GAL_CONFIG_SIZEOF_LONG
address@hidden Macro GAL_CONFIG_SIZEOF_SIZE_T
+The size of (number of bytes in) the system's @code{long} and @code{size_t}
+types. Their values are commonly either 4 or 8 for 32-bit and 64-bit
+systems. You can also get this value with the expression address@hidden
+size_t}' for example without having to include this header.
 @end deffn
 
 @node Multithreaded programming, Library data types, Configuration 
information, Gnuastro library
@@ -17272,6 +17273,11 @@ Identifier for a @code{size_t} type. This is just an 
alias to
 respectively.
 @end deffn
 
address@hidden {Global integer}  GAL_TYPE_LONG
+Identifier for a @code{long} type. This is just an alias to @code{int32},
+or @code{int64} types for 32-bit, or 64-bit systems respectively.
address@hidden deffn
+
 @deffn {Global integer}  GAL_TYPE_FLOAT32
 Identifier for a 32-bit single precision floating point type or
 @code{float} in C.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index d68448a..db56754 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -125,6 +125,7 @@ gnuastro/config.h: Makefile $(internaldir)/config.h.in
               -e 's|@address@hidden|$(HAVE_BIN_OP_INT64)|g'        \
               -e 's|@address@hidden|$(HAVE_BIN_OP_FLOAT32)|g'    \
               -e 's|@address@hidden|$(HAVE_BIN_OP_FLOAT64)|g'    \
+              -e 's|@address@hidden|$(SIZEOF_LONG)|g'                    \
               -e 's|@address@hidden|$(SIZEOF_SIZE_T)|g'                \
               -e 's|@address@hidden|$(RESTRICT_REPLACEMENT)|g'  \
                $(internaldir)/config.h.in >> address@hidden
diff --git a/lib/gnuastro-internal/config.h.in 
b/lib/gnuastro-internal/config.h.in
index 600cf58..b40ad23 100644
--- a/lib/gnuastro-internal/config.h.in
+++ b/lib/gnuastro-internal/config.h.in
@@ -53,6 +53,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #define GAL_CONFIG_BIN_OP_FLOAT32       @HAVE_BIN_OP_FLOAT32@
 #define GAL_CONFIG_BIN_OP_FLOAT64       @HAVE_BIN_OP_FLOAT64@
 
+#define GAL_CONFIG_SIZEOF_LONG          @SIZEOF_LONG@
 #define GAL_CONFIG_SIZEOF_SIZE_T        @SIZEOF_SIZE_T@
 
 
diff --git a/lib/gnuastro/type.h b/lib/gnuastro/type.h
index e40aca5..6f0090b 100644
--- a/lib/gnuastro/type.h
+++ b/lib/gnuastro/type.h
@@ -88,16 +88,31 @@ enum gal_types
   GAL_TYPE_STRLL,           /* Linked list of strings.                 */
 };
 
-/* `size_t' is 4 and 8 bytes on 32 and 64 bit systems respectively. In both
-   cases, the standard defines `size_t' to be unsigned. During
-   `./configure' the sizeof size_t was found and is stored in
-   `GAL_CONFIG_SIZEOF_SIZE_T'. */
+
+
+/* Define system specific types. For example `size_t' is 4 and 8 bytes on
+   32 and 64 bit systems respectively. In both cases, the standard defines
+   `size_t' to be unsigned. A similar case exists for `long', but it is
+   signed. During `./configure' the sizeof `size_t' and `long' were found
+   and are used to define an alias for these system specific types.
+
+   Note: we are not using `else'. This is done because by any chance, if
+   the length of these types is not what is expected (4 or 8), then the
+   aliases are not defined and the compiler will crash. */
 #if GAL_CONFIG_SIZEOF_SIZE_T == 4
 #define GAL_TYPE_SIZE_T GAL_TYPE_UINT32
-#else
+#elif GAL_CONFIG_SIZEOF_SIZE_T == 8
 #define GAL_TYPE_SIZE_T GAL_TYPE_UINT64
 #endif
 
+#if GAL_CONFIG_SIZEOF_LONG == 4
+#define GAL_TYPE_LONG GAL_TYPE_INT32
+#elif GAL_CONFIG_SIZEOF_LONG == 8
+#define GAL_TYPE_LONG GAL_TYPE_INT64
+#endif
+
+
+
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]