[ccan] [PATCH 0/6] tcon extensions for easier typesafe wrapping

David Gibson david at gibson.dropbear.id.au
Tue Oct 20 15:45:54 AEDT 2015


ccan includes many modules which use macro wrappers to make typesafe
pseudo-templated versions of a basic algorithm or data structure.

This series implements several extensions to the tcon module to enable
yet another approach to this.  The advantage of this new method is
that it's able to store a variety of "template" information into a
type or variable declaration.  That means that a module using this
technique can implement typesafe wrappers which can obtain the type
information they need from that initial declaration avoiding the need
to respecify types or field members in multiple places.

The last two patches in the series apply this approach to the lstack
and lqueue modules, giving them a nicer typesafe interface.

NOTE: The first patch in this series causes ccanlint to fail on the
tcon module.  AFAICT this is a ccanlint bug - it seems to be somehow
getting out of sync and including entirely wrong comment lines into
the example snippets.  I haven't managed to figure out what about the
changes is triggering the ccanlint bug though.

David Gibson (6):
  tcon: Add an alternate way of building type canaries
  tcon: Add tcon_sizeof() helper
  tcon: Encode integer values into "type" canaries
  tcon: Encode information on container members in "type" canaries
  lstack: Streamline interface with TCON_CONTAINER
  lqueue: Streamline interface with TCON_CONTAINER

 ccan/aga/bfs.c                               |  18 +--
 ccan/aga/dfs.c                               |  18 +--
 ccan/lqueue/_info                            |   8 +-
 ccan/lqueue/lqueue.h                         | 154 +++++++++++++----------
 ccan/lqueue/test/run.c                       |  44 +++----
 ccan/lstack/_info                            |   8 +-
 ccan/lstack/lstack.h                         | 141 ++++++++++++---------
 ccan/lstack/test/run.c                       |  31 ++---
 ccan/tcon/_info                              |   5 +
 ccan/tcon/tcon.h                             | 181 +++++++++++++++++++++++++++
 ccan/tcon/test/compile_fail-container1.c     |  39 ++++++
 ccan/tcon/test/compile_fail-container1w.c    |  35 ++++++
 ccan/tcon/test/compile_fail-container2.c     |  39 ++++++
 ccan/tcon/test/compile_fail-container2w.c    |  35 ++++++
 ccan/tcon/test/compile_fail-container3.c     |  40 ++++++
 ccan/tcon/test/compile_fail-container3w.c    |  36 ++++++
 ccan/tcon/test/compile_fail-container4.c     |  40 ++++++
 ccan/tcon/test/compile_fail-container4w.c    |  36 ++++++
 ccan/tcon/test/compile_fail-tcon_cast_wrap.c |  25 ++++
 ccan/tcon/test/compile_fail-wrap.c           |  20 +++
 ccan/tcon/test/compile_ok-sizeof.c           |  35 ++++++
 ccan/tcon/test/compile_ok-value.c            |  51 ++++++++
 ccan/tcon/test/compile_ok-void.c             |   6 +
 ccan/tcon/test/compile_ok.c                  |  11 ++
 ccan/tcon/test/run-container.c               |  46 +++++++
 ccan/tcon/test/run-wrap.c                    |  18 +++
 26 files changed, 931 insertions(+), 189 deletions(-)
 create mode 100644 ccan/tcon/test/compile_fail-container1.c
 create mode 100644 ccan/tcon/test/compile_fail-container1w.c
 create mode 100644 ccan/tcon/test/compile_fail-container2.c
 create mode 100644 ccan/tcon/test/compile_fail-container2w.c
 create mode 100644 ccan/tcon/test/compile_fail-container3.c
 create mode 100644 ccan/tcon/test/compile_fail-container3w.c
 create mode 100644 ccan/tcon/test/compile_fail-container4.c
 create mode 100644 ccan/tcon/test/compile_fail-container4w.c
 create mode 100644 ccan/tcon/test/compile_fail-tcon_cast_wrap.c
 create mode 100644 ccan/tcon/test/compile_fail-wrap.c
 create mode 100644 ccan/tcon/test/compile_ok-sizeof.c
 create mode 100644 ccan/tcon/test/compile_ok-value.c
 create mode 100644 ccan/tcon/test/run-container.c
 create mode 100644 ccan/tcon/test/run-wrap.c

-- 
2.4.3



More information about the ccan mailing list