• Philipp Stephani's avatar
    Add conversions to and from struct timespec to module interface. · bffceab6
    Philipp Stephani authored
    Time values are a fundamental data type, and such conversions are hard
    to implement within modules because of the various forms of time
    values in Emacs Lisp.  Adding dedicated conversion functions can
    significantly simplify module code dealing with times.
    
    This approach uses nanosecond precision.  While Emacs in theory has
    support for higher-precision time values, in practice most languages
    and standards, such as POSIX, C, Java, and Go, have settled on
    nanosecond-precision integers to represent time.
    
    * src/emacs-module.h.in: Add header for struct timespec.
    
    * src/module-env-27.h: Add module functions for time conversion.
    
    * src/emacs-module.c (module_extract_time, module_make_time): New
    functions.
    (initialize_environment): Use them.
    
    * test/data/emacs-module/mod-test.c (Fmod_test_add_nanosecond): New
    test function.
    (emacs_module_init): Define it.
    
    * test/src/emacs-module-tests.el (mod-test-add-nanosecond/valid)
    (mod-test-add-nanosecond/nil, mod-test-add-nanosecond/invalid): New
    unit tests.
    
    * doc/lispref/internals.texi (Module Values): Document time
    conversion functions.
    bffceab6
emacs-module.h.in 2.9 KB