1. 12 Aug, 2015 1 commit
  2. 01 Aug, 2015 7 commits
  3. 30 Jul, 2015 2 commits
  4. 20 Jul, 2015 1 commit
  5. 09 Jul, 2015 7 commits
  6. 08 Jul, 2015 3 commits
  7. 25 Jun, 2015 2 commits
  8. 18 Jun, 2015 5 commits
    • David Gibson's avatar
      avl: Use definitions from order module · 712dc43d
      David Gibson authored
      The AvlCompare type defined in the avl module is identical in signature to
      the compare function used by qsort() and bsearch().  That has a common
      definition in the new order module, so use that rather than defining its
      own.
      
      In addition use the standard comparison functions from order where possible
      for the avl test code.
      
      Cc: Joey Adams <joeyadams3.14159@gmail.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      712dc43d
    • David Gibson's avatar
      asort: Use order module definitions · 918a733f
      David Gibson authored
      The asort routine takes a user-supplied comparison function.  Use the
      definitions from the new order module to slightly simplify the declaration
      and handling of this function.
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      918a733f
    • David Gibson's avatar
      order: Scalar comparison functions · 37825438
      David Gibson authored
      Extend the order module to provide simple, standard, comparison
      callbacks for scalar types (i.e. integer and floating point types).
      
      In addition to the usual variants comparing a plain scalar, this also
      provides helper macros to construct a suitably typed callback and context
      pointer to order structures by a specified scalar field.
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      37825438
    • David Gibson's avatar
      order: Module for comparison callbacks · c2a3098b
      David Gibson authored
      Many common algorithms take a callback for comparing items - effectively
      giving the items a user defined order.
      
      For example, the standard library qsort() and bsearch() routines take such
      a callback.  The ccan/avl module takes an identical one.  The ccan/asort
      and ccan/asearch modules use a different variant: their callback takes an
      additional context parameter, and is also typed via use of macros and
      typesafe_cb.
      
      This module provides helper types and macros for easily declaring any of
      the common variants on comparison functions: the 2-parameter untyped form
      (as used by qsort), the 3-parameter untyped form (used by the asort back
      end) and the 3-parameter typed form (used by the asort front end).  It
      provides a wrapper macro for doing the typesafe_cb conversion from
      3-parameter typed to 3-parameter untyped.
      
      It also provides a container struct to describe both a comparison callback
      and a context value as a single structure.  This also comes in both
      untyped and typed variants.
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      c2a3098b
    • Rusty Russell's avatar
      ccanlint: handle circular test-depends. · 04b63db6
      Rusty Russell authored
      eg. asort depends on order, but order testdepends on asort.
      
      Probably not the greatest thing to do, but don't barf because of it.
      Reported-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      04b63db6
  9. 13 Jun, 2015 2 commits
  10. 04 Jun, 2015 1 commit
  11. 02 Jun, 2015 1 commit
  12. 01 Jun, 2015 2 commits
  13. 28 May, 2015 4 commits
  14. 27 May, 2015 2 commits
    • David Gibson's avatar
      ptrint: Module for encoding integers into void * pointers · 53079b9c
      David Gibson authored
      For callbacks which need a void * context pointer in the general case,
      there are often simpler cases where an integer would suffice.  These are
      often handled by casting the integer into a pointer, rather than having
      to allocate that integer somewhere.
      
      This adds a module with some helpers for this.  It has some advantages over
      direct casts:
        * It uses pointer arithmetic against NULL instead of casts which should
          make it more portable, even to weird platforms with odd representations
          for NULL.  I don't know the C standard well enough to know if it's
          totally portable though.
        * In particular it means that the truth value of the pointer
          representation matches that of the encoded integer.
        * The conversion functions are inlines providing more type safety than
          raw casts.
        * It uses a ptrint_t * type which can be used to mark such pointer
          encoded integers.  ptrint_t is a deliberately incomplete type so such
          pointers can never be dereferenced.
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      53079b9c
    • Rusty Russell's avatar
      9d4ae5f1