git/trace.c

/*
 * GIT - The information manager from hell
 *
 * Copyright (C) 2000-2002 Michael R. Elkins <[email protected]>
 * Copyright (C) 2002-2004 Oswald Buddenhagen <[email protected]>
 * Copyright (C) 2004 Theodore Y. Ts'o <[email protected]>
 * Copyright (C) 2006 Mike McCormack
 * Copyright (C) 2006 Christian Couder
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, see <https://www.gnu.org/licenses/>.
 */

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "abspath.h"
#include "repository.h"
#include "quote.h"
#include "setup.h"
#include "trace.h"

struct trace_key trace_default_key =;
struct trace_key trace_perf_key =;
struct trace_key trace_setup_key =;

/* Get a trace file descriptor from "key" env variable. */
static int get_trace_fd(struct trace_key *key, const char *override_envvar)
{}

void trace_override_envvar(struct trace_key *key, const char *value)
{}

void trace_disable(struct trace_key *key)
{}

static int prepare_trace_line(const char *file, int line,
			      struct trace_key *key, struct strbuf *buf)
{}

static void trace_write(struct trace_key *key, const void *buf, unsigned len)
{}

void trace_verbatim(struct trace_key *key, const void *buf, unsigned len)
{}

static void print_trace_line(struct trace_key *key, struct strbuf *buf)
{}

static void trace_vprintf_fl(const char *file, int line, struct trace_key *key,
			     const char *format, va_list ap)
{}

static void trace_argv_vprintf_fl(const char *file, int line,
				  const char **argv, const char *format,
				  va_list ap)
{}

void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
		     const struct strbuf *data)
{}

static uint64_t perf_start_times[10];
static int perf_indent;

uint64_t trace_performance_enter(void)
{}

static void trace_performance_vprintf_fl(const char *file, int line,
					 uint64_t nanos, const char *format,
					 va_list ap)
{}

void trace_printf_key_fl(const char *file, int line, struct trace_key *key,
			 const char *format, ...)
{}

void trace_argv_printf_fl(const char *file, int line, const char **argv,
			  const char *format, ...)
{}

void trace_performance_fl(const char *file, int line, uint64_t nanos,
			      const char *format, ...)
{}

void trace_performance_leave_fl(const char *file, int line,
				uint64_t nanos, const char *format, ...)
{}

static const char *quote_crnl(const char *path)
{}

void trace_repo_setup(void)
{}

int trace_want(struct trace_key *key)
{}

#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_CLOCK_MONOTONIC)

static inline uint64_t highres_nanos(void)
{}

#elif defined (GIT_WINDOWS_NATIVE)

static inline uint64_t highres_nanos(void)
{
	static uint64_t high_ns, scaled_low_ns;
	static int scale;
	LARGE_INTEGER cnt;

	if (!scale) {
		if (!QueryPerformanceFrequency(&cnt))
			return 0;

		/* high_ns = number of ns per cnt.HighPart */
		high_ns = (1000000000LL << 32) / (uint64_t) cnt.QuadPart;

		/*
		 * Number of ns per cnt.LowPart is 10^9 / frequency (or
		 * high_ns >> 32). For maximum precision, we scale this factor
		 * so that it just fits within 32 bit (i.e. won't overflow if
		 * multiplied with cnt.LowPart).
		 */
		scaled_low_ns = high_ns;
		scale = 32;
		while (scaled_low_ns >= 0x100000000LL) {
			scaled_low_ns >>= 1;
			scale--;
		}
	}

	/* if QPF worked on initialization, we expect QPC to work as well */
	QueryPerformanceCounter(&cnt);

	return (high_ns * cnt.HighPart) +
	       ((scaled_low_ns * cnt.LowPart) >> scale);
}

#else
#define highres_nanos
#endif

static inline uint64_t gettimeofday_nanos(void)
{}

/*
 * Returns nanoseconds since the epoch (01/01/1970), for performance tracing
 * (i.e. favoring high precision over wall clock time accuracy).
 */
uint64_t getnanotime(void)
{}

static struct strbuf command_line =;

static void print_command_performance_atexit(void)
{}

void trace_command_performance(const char **argv)
{}