]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'bb/compat-util-comment-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Oct 2019 02:40:48 +0000 (11:40 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Oct 2019 02:40:48 +0000 (11:40 +0900)
Code cleanup.

* bb/compat-util-comment-fix:
  git-compat-util: fix documentation syntax

1  2 
git-compat-util.h

diff --combined git-compat-util.h
index 8b8b29a867bdaa47595197474d064a0e0305d193,b4bc9c82519c39f1abd81c4f22ccc72d75af9d81..607dca75341201748f00bede9602d4084065275d
@@@ -77,7 -77,7 +77,7 @@@
  #endif
  /*
   * ARRAY_SIZE - get the number of elements in a visible array
-  *  <at> x: the array whose size you want.
+  * @x: the array whose size you want.
   *
   * This does not work on pointers, or arrays declared as [], or
   * function parameters.  With correct compiler support, such usage
@@@ -344,7 -344,6 +344,7 @@@ typedef uintmax_t timestamp_t
  #define PRItime PRIuMAX
  #define parse_timestamp strtoumax
  #define TIME_MAX UINTMAX_MAX
 +#define TIME_MIN 0
  
  #ifndef PATH_SEP
  #define PATH_SEP ':'
@@@ -819,6 -818,9 +819,6 @@@ const char *inet_ntop(int af, const voi
  int git_atexit(void (*handler)(void));
  #endif
  
 -typedef void (*try_to_free_t)(size_t);
 -try_to_free_t set_try_to_free_routine(try_to_free_t);
 -
  static inline size_t st_add(size_t a, size_t b)
  {
        if (unsigned_add_overflows(a, b))
@@@ -1092,10 -1094,10 +1092,10 @@@ static inline int strtol_i(char const *
        return 0;
  }
  
 +void git_stable_qsort(void *base, size_t nmemb, size_t size,
 +                    int(*compar)(const void *, const void *));
  #ifdef INTERNAL_QSORT
 -void git_qsort(void *base, size_t nmemb, size_t size,
 -             int(*compar)(const void *, const void *));
 -#define qsort git_qsort
 +#define qsort git_stable_qsort
  #endif
  
  #define QSORT(base, n, compar) sane_qsort((base), (n), sizeof(*(base)), compar)
@@@ -1106,9 -1108,6 +1106,9 @@@ static inline void sane_qsort(void *bas
                qsort(base, nmemb, size, compar);
  }
  
 +#define STABLE_QSORT(base, n, compar) \
 +      git_stable_qsort((base), (n), sizeof(*(base)), compar)
 +
  #ifndef HAVE_ISO_QSORT_S
  int git_qsort_s(void *base, size_t nmemb, size_t size,
                int (*compar)(const void *, const void *, void *), void *ctx);
@@@ -1313,42 -1312,4 +1313,42 @@@ void unleak_memory(const void *ptr, siz
   */
  #include "banned.h"
  
 +/*
 + * container_of - Get the address of an object containing a field.
 + *
 + * @ptr: pointer to the field.
 + * @type: type of the object.
 + * @member: name of the field within the object.
 + */
 +#define container_of(ptr, type, member) \
 +      ((type *) ((char *)(ptr) - offsetof(type, member)))
 +
 +/*
 + * helper function for `container_of_or_null' to avoid multiple
 + * evaluation of @ptr
 + */
 +static inline void *container_of_or_null_offset(void *ptr, size_t offset)
 +{
 +      return ptr ? (char *)ptr - offset : NULL;
 +}
 +
 +/*
 + * like `container_of', but allows returned value to be NULL
 + */
 +#define container_of_or_null(ptr, type, member) \
 +      (type *)container_of_or_null_offset(ptr, offsetof(type, member))
 +
 +/*
 + * like offsetof(), but takes a pointer to a a variable of type which
 + * contains @member, instead of a specified type.
 + * @ptr is subject to multiple evaluation since we can't rely on __typeof__
 + * everywhere.
 + */
 +#if defined(__GNUC__) /* clang sets this, too */
 +#define OFFSETOF_VAR(ptr, member) offsetof(__typeof__(*ptr), member)
 +#else /* !__GNUC__ */
 +#define OFFSETOF_VAR(ptr, member) \
 +      ((uintptr_t)&(ptr)->member - (uintptr_t)(ptr))
 +#endif /* !__GNUC__ */
 +
  #endif