Skip to content

Conversation

@jhunkeler
Copy link
Contributor

Reference-only

* New defines: HAVE_[BZIP2,LZ4,ZLIB]
* Necessary for [de]compression of raw data

# Conflicts:
#	include/asdf/core/ndarray.h
* Example(s) will be build if the cmake option BUILD_EXAMPLES is enabled
* Example binaries are not installed
* Compression related HAVE_* defines are now set by the compiler, not the config header.
* Instead of returning the entire block structure, expose enough header information to decompress a buffer
@jhunkeler jhunkeler marked this pull request as draft October 6, 2025 16:16
@jhunkeler
Copy link
Contributor Author

[ 15%] Building C object examples/CMakeFiles/asdf_dump_ndarray.dir/__/src/core/ndarray_convert.c.o
In file included from /Users/runner/work/libasdf/libasdf/src/core/ndarray_convert.c:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/math.h:54:5: error: #error "Unsupported value of __FLT_EVAL_METHOD__."
   54 | #   error "Unsupported value of __FLT_EVAL_METHOD__."
      |     ^~~~~
make[2]: *** [examples/CMakeFiles/asdf_dump_ndarray.dir/__/src/core/ndarray_convert.c.o] Error 1
make[1]: *** [examples/CMakeFiles/asdf_dump_ndarray.dir/all] Error 2
make: *** [all] Error 2

Always something ™️

@jhunkeler
Copy link
Contributor Author

jhunkeler commented Oct 6, 2025

float.h

    73  /* Characteristics of floating point types, C99 5.2.4.2.2 */
    74
    75  #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__

math.h

    36  /******************************************************************************
    37   * Floating point data types                                                  *
    38   ******************************************************************************/
    39
    40  /*  Define float_t and double_t per C standard, ISO/IEC 9899:2011 7.12 2,
    41      taking advantage of GCC's __FLT_EVAL_METHOD__ (which a compiler may
    42      define anytime and GCC does) that shadows FLT_EVAL_METHOD (which a
    43      compiler must define only in float.h).                                    */
    44  #if __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == -1
    45      typedef float float_t;
    46      typedef double double_t;
    47  #elif __FLT_EVAL_METHOD__ == 1
    48      typedef double float_t;
    49      typedef double double_t;
    50  #elif __FLT_EVAL_METHOD__ == 2
    51      typedef long double float_t;
    52      typedef long double double_t;
    53  #else /* __FLT_EVAL_METHOD__ */
    54  #   error "Unsupported value of __FLT_EVAL_METHOD__."
    55  #endif /* __FLT_EVAL_METHOD__ */

Test case

$ sw_vers
ProductName:            macOS
ProductVersion:         14.7.6
BuildVersion:   

$ uname -m
arm64

flt_eval_method.c

#include <float.h>
#include <math.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
        printf("__FLT_EVAL_METHOD__ = %d\n", __FLT_EVAL_METHOD__);
        return 0;
}

clang

$ clang flt_eval_method.c && ./a.out
__FLT_EVAL_METHOD__ = 0

gcc 13

$ gcc-13 flt_eval_method.c && ./a.out
__FLT_EVAL_METHOD__ = 0

gcc 14

$ gcc-14 flt_eval_method.c && ./a.out
__FLT_EVAL_METHOD__ = 16

}

// Dump the contents of a ndarray
static void show_ndarray(const struct asdf_ndarray *ndarray, const void *data, const int method) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a pretty useful utility to build into the CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants