Skip to content

Commit

Permalink
janitor: add DIV_ROUND_UP and use it.
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Pierre Habouzit authored and Junio C Hamano committed Jul 23, 2009
1 parent f630cfd commit 98cb6f3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#define MSB(x, bits) ((x) & TYPEOF(x)(~0ULL << (bitsizeof(x) - (bits))))
#define HAS_MULTI_BITS(i) ((i) & ((i) - 1)) /* checks if an integer has more than 1 bit set */

#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))

/* Approximation of the length of the decimal representation of this type. */
#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)

Expand Down
2 changes: 1 addition & 1 deletion help.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void pretty_print_string_list(struct cmdnames *cmds, int longest)

if (space < max_cols)
cols = max_cols / space;
rows = (cmds->cnt + cols - 1) / cols;
rows = DIV_ROUND_UP(cmds->cnt, cols);

for (i = 0; i < rows; i++) {
printf(" ");
Expand Down
2 changes: 1 addition & 1 deletion preload-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void preload_index(struct index_state *index, const char **pathspec)
if (threads > MAX_PARALLEL)
threads = MAX_PARALLEL;
offset = 0;
work = (index->cache_nr + threads - 1) / threads;
work = DIV_ROUND_UP(index->cache_nr, threads);
for (i = 0; i < threads; i++) {
struct thread_data *p = data+i;
p->index = index;
Expand Down

0 comments on commit 98cb6f3

Please sign in to comment.