• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ cc_log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cc_log函数的典型用法代码示例。如果您正苦于以下问题:C++ cc_log函数的具体用法?C++ cc_log怎么用?C++ cc_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了cc_log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: verify_object

static int
verify_object(struct conf *conf, struct manifest *mf, struct object *obj,
              struct hashtable *stated_files, struct hashtable *hashed_files)
{
	for (uint32_t i = 0; i < obj->n_file_info_indexes; i++) {
		struct file_info *fi = &mf->file_infos[obj->file_info_indexes[i]];
		char *path = mf->files[fi->index];
		struct file_stats *st = hashtable_search(stated_files, path);
		if (!st) {
			struct stat file_stat;
			if (x_stat(path, &file_stat) != 0) {
				return 0;
			}
			st = x_malloc(sizeof(*st));
			st->size = file_stat.st_size;
			st->mtime = file_stat.st_mtime;
			st->ctime = file_stat.st_ctime;
			hashtable_insert(stated_files, x_strdup(path), st);
		}

		if (fi->size != st->size) {
			return 0;
		}

		if (conf->sloppiness & SLOPPY_FILE_STAT_MATCHES) {
			if (fi->mtime == st->mtime && fi->ctime == st->ctime) {
				cc_log("mtime/ctime hit for %s", path);
				continue;
			} else {
				cc_log("mtime/ctime miss for %s", path);
			}
		}

		struct file_hash *actual = hashtable_search(hashed_files, path);
		if (!actual) {
			struct mdfour hash;
			hash_start(&hash);
			int result = hash_source_code_file(conf, &hash, path);
			if (result & HASH_SOURCE_CODE_ERROR) {
				cc_log("Failed hashing %s", path);
				return 0;
			}
			if (result & HASH_SOURCE_CODE_FOUND_TIME) {
				return 0;
			}
			actual = x_malloc(sizeof(*actual));
			hash_result_as_bytes(&hash, actual->hash);
			actual->size = hash.totalN;
			hashtable_insert(hashed_files, x_strdup(path), actual);
		}
		if (memcmp(fi->hash, actual->hash, mf->hash_size) != 0
		    || fi->size != actual->size) {
			return 0;
		}
	}

	return 1;
}
开发者ID:ezyang,项目名称:ccache,代码行数:58,代码来源:manifest.c


示例2: manifest_get

/*
 * Try to get the object hash from a manifest file. Caller frees. Returns NULL
 * on failure.
 */
struct file_hash *
manifest_get(struct conf *conf, const char *manifest_path)
{
	int fd;
	gzFile f = NULL;
	struct manifest *mf = NULL;
	struct hashtable *hashed_files = NULL; /* path --> struct file_hash */
	struct hashtable *stated_files = NULL; /* path --> struct file_stats */
	uint32_t i;
	struct file_hash *fh = NULL;

	fd = open(manifest_path, O_RDONLY | O_BINARY);
	if (fd == -1) {
		/* Cache miss. */
		cc_log("No such manifest file");
		goto out;
	}
	f = gzdopen(fd, "rb");
	if (!f) {
		close(fd);
		cc_log("Failed to gzdopen manifest file");
		goto out;
	}
	mf = read_manifest(f);
	if (!mf) {
		cc_log("Error reading manifest file");
		goto out;
	}

	hashed_files = create_hashtable(1000, hash_from_string, strings_equal);
	stated_files = create_hashtable(1000, hash_from_string, strings_equal);

	/* Check newest object first since it's a bit more likely to match. */
	for (i = mf->n_objects; i > 0; i--) {
		if (verify_object(conf, mf, &mf->objects[i - 1],
		                  stated_files, hashed_files)) {
			fh = x_malloc(sizeof(*fh));
			*fh = mf->objects[i - 1].hash;
			goto out;
		}
	}

out:
	if (hashed_files) {
		hashtable_destroy(hashed_files, 1);
	}
	if (stated_files) {
		hashtable_destroy(stated_files, 1);
	}
	if (f) {
		gzclose(f);
	}
	if (mf) {
		free_manifest(mf);
	}
	return fh;
}
开发者ID:chirayudesai,项目名称:ccache,代码行数:61,代码来源:manifest.c


示例3: ccache

/* the main ccache driver function */
static void ccache(int argc, char *argv[])
{
	/* find the real compiler */
	find_compiler(argc, argv);

	/* use the real compiler if HOME is not set */
	if (!cache_dir) {
		cc_log("Unable to determine home directory\n");
		cc_log("ccache is disabled\n");
		failed();
	}
	
	/* we might be disabled */
	if (getenv("CCACHE_DISABLE")) {
		cc_log("ccache is disabled\n");
		failed();
	}

	if (getenv("CCACHE_STRIPC")) {
		strip_c_option = 1;
	}

	if (getenv("CCACHE_UNIFY")) {
		enable_unify = 1;
	}

	detect_swig();

	/* process argument list, returning a new set of arguments for pre-processing */
	process_args(orig_args->argc, orig_args->argv);

	/* run with -E to find the hash */
	find_hash(stripped_args);

	/* if we can return from cache at this point then do */
	from_cache(1);

	if (getenv("CCACHE_READONLY")) {
		cc_log("read-only set - doing real compile\n");
		failed();
	}
	
	/* run real compiler, sending output to cache */
	to_cache(stripped_args);

	/* return from cache */
	from_cache(0);

	/* oh oh! */
	cc_log("secondary from_cache failed!\n");
	stats_update(STATS_ERROR);
	failed();
}
开发者ID:0xb1dd1e,项目名称:swig,代码行数:54,代码来源:ccache.c


示例4: clean_up_dir

// Clean up one cache subdirectory.
void
clean_up_dir(struct conf *conf, const char *dir, double limit_multiple)
{
	cc_log("Cleaning up cache directory %s", dir);

	// When "max files" or "max cache size" is reached, one of the 16 cache
	// subdirectories is cleaned up. When doing so, files are deleted (in LRU
	// order) until the levels are below limit_multiple.
	cache_size_threshold = (uint64_t)round(conf->max_size * limit_multiple / 16);
	files_in_cache_threshold =
		(size_t)round(conf->max_files * limit_multiple / 16);

	num_files = 0;
	cache_size = 0;
	files_in_cache = 0;

	// Build a list of files.
	traverse(dir, traverse_fn);

	// Clean the cache.
	cc_log("Before cleanup: %.0f KiB, %.0f files",
	       (double)cache_size / 1024,
	       (double)files_in_cache);
	bool cleaned = sort_and_clean();
	cc_log("After cleanup: %.0f KiB, %.0f files",
	       (double)cache_size / 1024,
	       (double)files_in_cache);

	if (cleaned) {
		cc_log("Cleaned up cache directory %s", dir);
		stats_add_cleanup(dir, 1);
	}

	stats_set_sizes(dir, files_in_cache, cache_size);

	// Free it up.
	for (unsigned i = 0; i < num_files; i++) {
		free(files[i]->fname);
		free(files[i]);
		files[i] = NULL;
	}
	if (files) {
		free(files);
	}
	allocated = 0;
	files = NULL;

	num_files = 0;
	cache_size = 0;
	files_in_cache = 0;
}
开发者ID:orgads,项目名称:ccache,代码行数:52,代码来源:cleanup.c


示例5: execute

/*
  execute a compiler backend, capturing all output to the given paths
  the full path to the compiler to run is in argv[0]
*/
int
execute(char **argv, const char *path_stdout, const char *path_stderr)
{
	pid_t pid;
	int status;

	cc_log_argv("Executing ", argv);

	pid = fork();
	if (pid == -1) fatal("Failed to fork: %s", strerror(errno));

	if (pid == 0) {
		int fd;

		tmp_unlink(path_stdout);
		fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
		if (fd == -1) {
			cc_log("Error creating %s: %s", path_stdout, strerror(errno));
			exit(FAILED_TO_CREATE_STDOUT);
		}
		dup2(fd, 1);
		close(fd);

		tmp_unlink(path_stderr);
		fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
		if (fd == -1) {
			cc_log("Error creating %s: %s", path_stderr, strerror(errno));
			exit(FAILED_TO_CREATE_STDERR);
		}
		dup2(fd, 2);
		close(fd);

		exit(execv(argv[0], argv));
	}

	if (waitpid(pid, &status, 0) != pid) {
		fatal("waitpid failed: %s", strerror(errno));
	}

	if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) {
		return -1;
	}

	if (status == FAILED_TO_CREATE_STDOUT) {
		fatal("Could not create %s (permission denied?)", path_stdout);
	} else if (status == FAILED_TO_CREATE_STDERR) {
		fatal("Could not create %s (permission denied?)", path_stderr);
	}

	return WEXITSTATUS(status);
}
开发者ID:dgivone,项目名称:ccache,代码行数:55,代码来源:execute.c


示例6: wipe_dir

// Wipe one cache subdirectory.
void
wipe_dir(const char *dir)
{
	cc_log("Clearing out cache directory %s", dir);

	files_in_cache = 0;

	traverse(dir, wipe_fn);

	if (files_in_cache > 0) {
		cc_log("Cleared out cache directory %s", dir);
		stats_add_cleanup(dir, 1);
	}

	files_in_cache = 0;
}
开发者ID:orgads,项目名称:ccache,代码行数:17,代码来源:cleanup.c


示例7: stats_write

/* write out a stats file */
void
stats_write(const char *path, struct counters *counters)
{
	size_t i;
	char *tmp_file;
	FILE *f;

	tmp_file = format("%s.tmp.%s", path, tmp_string());
	f = fopen(tmp_file, "wb");
	if (!f && errno == ENOENT) {
		if (create_parent_dirs(path) == 0) {
			f = fopen(tmp_file, "wb");
		}
	}
	if (!f) {
		cc_log("Failed to open %s", tmp_file);
		goto end;
	}
	for (i = 0; i < counters->size; i++) {
		if (fprintf(f, "%u\n", counters->data[i]) < 0) {
			fatal("Failed to write to %s", tmp_file);
		}
	}
	fclose(f);
	x_rename(tmp_file, path);

end:
	free(tmp_file);
}
开发者ID:dgivone,项目名称:ccache,代码行数:30,代码来源:stats.c


示例8: hash_source_code_string

/*
 * Hash a string. Returns a bitmask of HASH_SOURCE_CODE_* results.
 */
int
hash_source_code_string(
  struct conf *conf, struct mdfour *hash, const char *str, size_t len,
  const char *path)
{
	int result = HASH_SOURCE_CODE_OK;

	/*
	 * Check for __DATE__ and __TIME__ if the sloppiness configuration tells us
	 * we should.
	 */
	if (!(conf->sloppiness & SLOPPY_TIME_MACROS)) {
		result |= check_for_temporal_macros(str, len);
	}

	/*
	 * Hash the source string.
	 */
	hash_buffer(hash, str, len);

	if (result & HASH_SOURCE_CODE_FOUND_DATE) {
		/*
		 * Make sure that the hash sum changes if the (potential) expansion of
		 * __DATE__ changes.
		 */
		time_t t = time(NULL);
		struct tm *now = localtime(&t);
		cc_log("Found __DATE__ in %s", path);
		hash_delimiter(hash, "date");
		hash_buffer(hash, &now->tm_year, sizeof(now->tm_year));
		hash_buffer(hash, &now->tm_mon, sizeof(now->tm_mon));
		hash_buffer(hash, &now->tm_mday, sizeof(now->tm_mday));
	}
	if (result & HASH_SOURCE_CODE_FOUND_TIME) {
		/*
		 * We don't know for sure that the program actually uses the __TIME__
		 * macro, but we have to assume it anyway and hash the time stamp. However,
		 * that's not very useful since the chance that we get a cache hit later
		 * the same second should be quite slim... So, just signal back to the
		 * caller that __TIME__ has been found so that the direct mode can be
		 * disabled.
		 */
		cc_log("Found __TIME__ in %s", path);
	}

	return result;
}
开发者ID:YorkZ,项目名称:ccache,代码行数:50,代码来源:hashutil.c


示例9: lockfile_release

/*
 * Release the lockfile for the given path. Assumes that we are the legitimate
 * owner.
 */
void
lockfile_release(const char *path)
{
	char *lockfile = format("%s.lock", path);
	cc_log("Releasing lock %s", lockfile);
	unlink(lockfile);
	free(lockfile);
}
开发者ID:jmartens,项目名称:ccache-win32,代码行数:12,代码来源:lockfile.c


示例10: delete_file

static void delete_file(const char *path, size_t size)
{
	if (unlink(path) == 0) {
		cache_size -= size;
		files_in_cache--;
	} else if (errno != ENOENT) {
		cc_log("Failed to unlink %s (%s)", path, strerror(errno));
	}
}
开发者ID:HumbleRepose,项目名称:ccache,代码行数:9,代码来源:cleanup.c


示例11: setup_uncached_err

/* Make a copy of stderr that will not be cached, so things like
   distcc can send networking errors to it. */
static void setup_uncached_err(void)
{
	char *buf;
	int uncached_fd;
	
	uncached_fd = dup(2);
	if (uncached_fd == -1) {
		cc_log("dup(2) failed\n");
		failed();
	}

	/* leak a pointer to the environment */
	x_asprintf(&buf, "UNCACHED_ERR_FD=%d", uncached_fd);

	if (putenv(buf) == -1) {
		cc_log("putenv failed\n");
		failed();
	}
}
开发者ID:wereHamster,项目名称:ccache,代码行数:21,代码来源:ccache.c


示例12: cc_dump_debug_log_buffer

// Copy the current log memory buffer to an output file.
void
cc_dump_debug_log_buffer(const char *path)
{
	FILE *file = fopen(path, "w");
	if (file) {
		(void) fwrite(debug_log_buffer, 1, debug_log_size, file);
		fclose(file);
	} else {
		cc_log("Failed to open %s: %s", path, strerror(errno));
	}
}
开发者ID:ccache,项目名称:ccache,代码行数:12,代码来源:util.c


示例13: hash_file

bool
hash_file(struct hash *hash, const char *fname)
{
	int fd = open(fname, O_RDONLY|O_BINARY);
	if (fd == -1) {
		cc_log("Failed to open %s: %s", fname, strerror(errno));
		return false;
	}

	bool ret = hash_fd(hash, fd);
	close(fd);
	return ret;
}
开发者ID:ccache,项目名称:ccache,代码行数:13,代码来源:hash.c


示例14: delete_sibling_file

static void delete_sibling_file(const char *base, const char *extension)
{
	struct stat st;
	char *path;

	x_asprintf(&path, "%s%s", base, extension);
	if (lstat(path, &st) == 0) {
		delete_file(path, file_size(&st) / 1024);
	} else if (errno != ENOENT) {
		cc_log("Failed to stat %s (%s)", path, strerror(errno));
	}
	free(path);
}
开发者ID:HumbleRepose,项目名称:ccache,代码行数:13,代码来源:cleanup.c


示例15: delete_sibling_file

static void
delete_sibling_file(const char *base, const char *extension)
{
	struct stat st;
	char *path;

	path = format("%s%s", base, extension);
	if (lstat(path, &st) == 0) {
		delete_file(path, file_size(&st));
	} else if (errno != ENOENT) {
		cc_log("Failed to stat %s: %s", path, strerror(errno));
	}
	free(path);
}
开发者ID:venkrao,项目名称:ccache-1,代码行数:14,代码来源:cleanup.c


示例16: fatal

// Something went badly wrong!
void
fatal(const char *format, ...)
{
	va_list ap;
	va_start(ap, format);
	char msg[8192];
	vsnprintf(msg, sizeof(msg), format, ap);
	va_end(ap);

	cc_log("FATAL: %s", msg);
	fprintf(stderr, "ccache: error: %s\n", msg);

	x_exit(1);
}
开发者ID:ccache,项目名称:ccache,代码行数:15,代码来源:util.c


示例17: delete_file

static void
delete_file(const char *path, size_t size, bool update_counters)
{
	bool deleted = x_try_unlink(path) == 0;
	if (!deleted && errno != ENOENT && errno != ESTALE) {
		cc_log("Failed to unlink %s (%s)", path, strerror(errno));
	} else if (update_counters) {
		// The counters are intentionally subtracted even if there was no file to
		// delete since the final cache size calculation will be incorrect if they
		// aren't. (This can happen when there are several parallel ongoing
		// cleanups of the same directory.)
		cache_size -= size;
		files_in_cache--;
	}
}
开发者ID:orgads,项目名称:ccache,代码行数:15,代码来源:cleanup.c


示例18: verify_object

static int
verify_object(struct conf *conf, struct manifest *mf, struct object *obj,
              struct hashtable *hashed_files)
{
	uint32_t i;
	struct file_info *fi;
	struct {int result; struct file_hash fh;} *actual;
	struct mdfour hash;
	int result;

	for (i = 0; i < obj->n_file_info_indexes; i++) {
		fi = &mf->file_infos[obj->file_info_indexes[i]];
		actual = hashtable_search(hashed_files, mf->files[fi->index]);
		if (!actual) {
			actual = x_malloc(sizeof(*actual));
			hash_start(&hash);
			result = hash_source_code_file(conf, &hash, mf->files[fi->index]);
			if (result & HASH_SOURCE_CODE_ERROR) {
				cc_log("Failed hashing %s", mf->files[fi->index]);
				cloud_hook_reset_includes();
				free(actual);
				return 0;
			}
			if (result & HASH_SOURCE_CODE_FOUND_TIME) {
				cloud_hook_reset_includes();
				free(actual);
				return 0;
			}
			actual->result = result;
			hash_result_as_bytes(&hash, actual->fh.hash);
			actual->fh.size = hash.totalN;
			hashtable_insert(hashed_files, x_strdup(mf->files[fi->index]), actual);
		}
		if (memcmp(fi->hash, actual->fh.hash, mf->hash_size) != 0
		    || fi->size != actual->fh.size) {
			cloud_hook_reset_includes();
			return 0;
		}
		/* Passing the hash here is an optimization, but it's not
		   the right hash if a time macro was present.  */
		cloud_hook_include_file(mf->files[fi->index],
		                        actual->result ? NULL : &actual->fh);
	}

	return 1;
}
开发者ID:akif-rahim,项目名称:CS,代码行数:46,代码来源:manifest.c


示例19: find_executable

// Find an executable by name in $PATH. Exclude any that are links to
// exclude_name.
char *
find_executable(const char *name, const char *exclude_name)
{
	if (is_absolute_path(name)) {
		return x_strdup(name);
	}

	char *path = conf->path;
	if (str_eq(path, "")) {
		path = getenv("PATH");
	}
	if (!path) {
		cc_log("No PATH variable");
		return NULL;
	}

	return find_executable_in_path(name, exclude_name, path);
}
开发者ID:orgads,项目名称:ccache,代码行数:20,代码来源:execute.c


示例20: to_cache_stats_helper

/* update cached file sizes and count helper function for to_cache() */
static void to_cache_stats_helper(struct stat *pstat, char *cached_filename, char *tmp_outfiles, int *files_size, int *cached_files_count)
{
#if ENABLE_ZLIB
	/* do an extra stat on the cache file for the size statistics */
	if (stat(cached_filename, pstat) != 0) {
		cc_log("failed to stat cache files - %s\n", strerror(errno));
		stats_update(STATS_ERROR);
		if (tmp_outfiles) {
			unlink(tmp_outfiles);
		}
		failed();
	}
#else
        (void)cached_filename;
        (void)tmp_outfiles;
#endif
	(*files_size) += file_size(pstat);
	(*cached_files_count)++;
}
开发者ID:0xb1dd1e,项目名称:swig,代码行数:20,代码来源:ccache.c



注:本文中的cc_log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ccc3函数代码示例发布时间:2022-05-30
下一篇:
C++ cc_err_xlate函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap