1. 21 May, 2018 2 commits
    • Duy Nguyen's avatar
      commit-slab: support shared commit-slab · 878f0bb8
      Duy Nguyen authored
      define_shared_commit_slab() could be used in a header file to define a
      commit-slab. One of these C files must include commit-slab-impl.h and
      "call" implement_shared_commit_slab().
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Duy Nguyen's avatar
      commit-slab.h: code split · a9f1f1f9
      Duy Nguyen authored
      The struct declaration and implementation macros are moved to
      commit-slab-hdr.h and commit-slab-impl.h respectively.
      This right now is not needed for current users but if we make a public
      commit-slab type, we may want to avoid including the slab
      implementation in a header file which gets replicated in every c file
      that includes it.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  2. 22 Sep, 2017 1 commit
  3. 16 Jun, 2017 1 commit
  4. 11 Aug, 2016 1 commit
    • Ville Skyttä's avatar
      Spelling fixes · 2e3a16b2
      Ville Skyttä authored
          <BAD>                     <CORRECTED>
          accidently                accidentally
          commited                  committed
          dependancy                dependency
          emtpy                     empty
          existance                 existence
          explicitely               explicitly
          git-upload-achive         git-upload-archive
          hierachy                  hierarchy
          indegee                   indegree
          intial                    initial
          mulitple                  multiple
          non-existant              non-existent
          precendence.              precedence.
          priviledged               privileged
          programatically           programmatically
          psuedo-binary             pseudo-binary
          soemwhere                 somewhere
          successfull               successful
          transfering               transferring
          uncommited                uncommitted
          unkown                    unknown
          usefull                   useful
          writting                  writing
      Signed-off-by: Ville Skyttä's avatarVille Skyttä <ville.skytta@iki.fi>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  5. 09 Aug, 2016 1 commit
    • Johannes Sixt's avatar
      commit-slab.h: avoid duplicated global static variables · af920e36
      Johannes Sixt authored
      The gigantic define_commit_slab() macro repeats the definition of a
      static variable that occurs earlier in the macro text. The purpose of
      the repeated definition at the end of the macro is that it takes the
      semicolon that occurs where the macro is used.
      We cannot just remove the first definition of the variable because it
      is referenced elsewhere in the macro text, and defining the macro later
      would produce undefined identifier errors. We cannot have a "forward"
      declaration, either. (This works only with "extern" global variables.)
      The solution is to use a declaration of a struct that is already defined
      earlier. This language construct can serve the same purpose as the
      duplicated static variable definition, but without the confusion.
      Signed-off-by: default avatarJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  6. 22 May, 2015 1 commit
    • Junio C Hamano's avatar
      commit-slab: introduce slabname##_peek() function · 862e730e
      Junio C Hamano authored
      There is no API to ask "Does this commit have associated data in
      slab?".  If an application wants to (1) parse just a few commits at
      the beginning of a process, (2) store data for only these commits,
      and then (3) start processing many commits, taking into account the
      data stored (for a few of them) in the slab, the application would
      use slabname##_at() to allocate a space to store data in (2), but
      there is no API other than slabname##_at() to use in step (3).  This
      allocates and wastes new space for these commits the caller is only
      interested in checking if they have data stored in step (2).
      Introduce slabname##_peek(), which is similar to slabname##_at() but
      returns NULL when there is no data already associated to it in such
      a use case.
      Helped-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  7. 18 Sep, 2014 1 commit
  8. 13 Jun, 2014 1 commit
  9. 02 Dec, 2013 1 commit
  10. 27 Nov, 2013 2 commits
  11. 29 Jul, 2013 1 commit
    • Ramsay Jones's avatar
      commit-slab.h: Fix memory allocation and addressing · d7a1d629
      Ramsay Jones authored
      The slab initialization code includes the calculation of the
      slab 'elem_size', which is in turn used to determine the size
      (capacity) of the slab. Each element of the slab represents an
      array, of length 'stride', of 'elemtype'. (Note that it may be
      clearer if the define_commit_slab macro parameter was called
      'basetype' rather than 'elemtype'). However, the 'elem_size'
      calculation incorrectly uses 'sizeof(struct slabname)' in the
      expression, rather than 'sizeof(elemtype)'.
      Within the slab access routine, <slabname>_at(), the given commit
      'index' is transformed into an (slab#, slot#) pair used to address
      the required element (a pointer to the first element of the array
      of 'elemtype' associated with that commit). The current code to
      calculate these address coordinates multiplies the commit index
      by the 'stride' which, at least for the slab#, produces the wrong
      result. Using the commit index directly, without scaling by the
      'stride', produces the correct 'logical' address.
      Also, when allocating a new slab, the size of the allocation only
      allows for a slab containing elements of single element arrays of
      'elemtype'. This should allow for elements of an array of length
      'stride' of 'elemtype'. In order to fix this, we need to change
      the element size parameter to xcalloc() by multiplying the current
      element size (sizeof(**s->slab)) by the s->stride.
      Having changed the calculation of the slot#, we now need to convert
      the logical 'nth_slot', by scaling with s->stride, into the correct
      physical address.
      Signed-off-by: default avatarRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  12. 07 Jun, 2013 1 commit
    • Junio C Hamano's avatar
      commit-slab: introduce a macro to define a slab for new type · a84b794a
      Junio C Hamano authored
      Introduce a header file to define a macro that can define the struct
      type, initializer, accessor and cleanup functions to manage a commit
      slab.  Update the "indegree" topological sort facility using it.
      To associate 32 flag bits with each commit, you can write:
      	define_commit_slab(flag32, uint32);
      to declare "struct flag32" type, define an instance of it with
      	struct flag32 flags;
      and initialize it by calling
      After that, a call to flag32_at() function
      	uint32 *fp = flag32_at(&flags, commit);
      will return a pointer pointing at a uint32 for that commit.  Once
      you are done with these flags, clean them up with
      Callers that cannot hard-code how wide the data to be associated
      with the commit be at compile time can use the "_with_stride"
      variant to initialize the slab.
      Suppose you want to give one bit per existing ref, and paint commits
      down to find which refs are descendants of each commit.  Saying
      	typedef uint32 bits320[5];
      	define_commit_slab(flagbits, bits320);
      at compile time will still limit your code with hard-coded limit,
      because you may find that you have more than 320 refs at runtime.
      The code can declare a commit slab "struct flagbits" like this
      	define_commit_slab(flagbits, unsigned char);
      	struct flagbits flags;
      and initialize it by:
      	nrefs = ... count number of refs ...
      	init_flagbits_with_stride(&flags, (nrefs + 7) / 8);
      so that
      	unsigned char *fp = flagbits_at(&flags, commit);
      will return a pointer pointing at an array of 40 "unsigned char"s
      associated with the commit, once you figure out nrefs is 320 at
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>