Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Wan <calvinwan@google.com>2023-07-05 20:09:20 +0300
committerJunio C Hamano <gitster@pobox.com>2023-07-05 21:41:18 +0300
commit382f6940afc4f2c5f1e939d0ca8ba835056cf2d0 (patch)
treeba01c3201c6130f581a4a53ed2bdbb1e233b8330 /git-compat-util.h
parentfda5d9595d5172fcbba34742e92d6c7ed4cbe5ef (diff)
git-compat-util: move wrapper.c funcs to its header
Since the functions in wrapper.c are widely used across the codebase, include it by default in git-compat-util.h. A future patch will remove now unnecessary inclusions of wrapper.h from other files. Signed-off-by: Calvin Wan <calvinwan@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h112
1 files changed, 1 insertions, 111 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index fe9e86bad0..f8e68baf29 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -625,7 +625,7 @@ static inline int git_has_dir_sep(const char *path)
#include "compat/bswap.h"
-struct strbuf;
+#include "wrapper.h"
/* General helper functions */
NORETURN void usage(const char *err);
@@ -1045,36 +1045,6 @@ static inline int cast_size_t_to_int(size_t a)
# define xalloca(size) (xmalloc(size))
# define xalloca_free(p) (free(p))
#endif
-char *xstrdup(const char *str);
-void *xmalloc(size_t size);
-void *xmallocz(size_t size);
-void *xmallocz_gently(size_t size);
-void *xmemdupz(const void *data, size_t len);
-char *xstrndup(const char *str, size_t len);
-void *xrealloc(void *ptr, size_t size);
-void *xcalloc(size_t nmemb, size_t size);
-void xsetenv(const char *name, const char *value, int overwrite);
-void *xmmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
-const char *mmap_os_err(void);
-void *xmmap_gently(void *start, size_t length, int prot, int flags, int fd, off_t offset);
-int xopen(const char *path, int flags, ...);
-ssize_t xread(int fd, void *buf, size_t len);
-ssize_t xwrite(int fd, const void *buf, size_t len);
-ssize_t xpread(int fd, void *buf, size_t len, off_t offset);
-int xdup(int fd);
-FILE *xfopen(const char *path, const char *mode);
-FILE *xfdopen(int fd, const char *mode);
-int xmkstemp(char *temp_filename);
-int xmkstemp_mode(char *temp_filename, int mode);
-char *xgetcwd(void);
-FILE *fopen_for_writing(const char *path);
-FILE *fopen_or_warn(const char *path, const char *mode);
-
-/*
- * Like strncmp, but only return zero if s is NUL-terminated and exactly len
- * characters long. If it is not, consider it greater than t.
- */
-int xstrncmpz(const char *s, const char *t, size_t len);
/*
* FREE_AND_NULL(ptr) is like free(ptr) followed by ptr = NULL. Note
@@ -1176,15 +1146,10 @@ static inline size_t xsize_t(off_t len)
return (size_t) len;
}
-__attribute__((format (printf, 3, 4)))
-int xsnprintf(char *dst, size_t max, const char *fmt, ...);
-
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 256
#endif
-int xgethostname(char *buf, size_t len);
-
/* in ctype.c, for kwset users */
extern const unsigned char tolower_trans_tbl[256];
@@ -1425,72 +1390,6 @@ void bug_fl(const char *file, int line, const char *fmt, ...);
#endif
#endif
-enum fsync_action {
- FSYNC_WRITEOUT_ONLY,
- FSYNC_HARDWARE_FLUSH
-};
-
-/*
- * Issues an fsync against the specified file according to the specified mode.
- *
- * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating
- * systems to flush the OS cache without issuing a flush command to the storage
- * controller. If those interfaces are unavailable, the function fails with
- * ENOSYS.
- *
- * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that
- * changes are durable. It is not expected to fail.
- */
-int git_fsync(int fd, enum fsync_action action);
-
-/*
- * Writes out trace statistics for fsync using the trace2 API.
- */
-void trace_git_fsync_stats(void);
-
-/*
- * Preserves errno, prints a message, but gives no warning for ENOENT.
- * Returns 0 on success, which includes trying to unlink an object that does
- * not exist.
- */
-int unlink_or_warn(const char *path);
- /*
- * Tries to unlink file. Returns 0 if unlink succeeded
- * or the file already didn't exist. Returns -1 and
- * appends a message to err suitable for
- * 'error("%s", err->buf)' on error.
- */
-int unlink_or_msg(const char *file, struct strbuf *err);
-/*
- * Preserves errno, prints a message, but gives no warning for ENOENT.
- * Returns 0 on success, which includes trying to remove a directory that does
- * not exist.
- */
-int rmdir_or_warn(const char *path);
-/*
- * Calls the correct function out of {unlink,rmdir}_or_warn based on
- * the supplied file mode.
- */
-int remove_or_warn(unsigned int mode, const char *path);
-
-/*
- * Call access(2), but warn for any error except "missing file"
- * (ENOENT or ENOTDIR).
- */
-#define ACCESS_EACCES_OK (1U << 0)
-int access_or_warn(const char *path, int mode, unsigned flag);
-int access_or_die(const char *path, int mode, unsigned flag);
-
-/* Warn on an inaccessible file if errno indicates this is an error */
-int warn_on_fopen_errors(const char *path);
-
-/*
- * Open with O_NOFOLLOW, or equivalent. Note that the fallback equivalent
- * may be racy. Do not use this as protection against an attacker who can
- * simultaneously create paths.
- */
-int open_nofollow(const char *path, int flags);
-
#ifndef SHELL_PATH
# define SHELL_PATH "/bin/sh"
#endif
@@ -1630,13 +1529,4 @@ static inline void *container_of_or_null_offset(void *ptr, size_t offset)
((uintptr_t)&(ptr)->member - (uintptr_t)(ptr))
#endif /* !__GNUC__ */
-void sleep_millisec(int millisec);
-
-/*
- * Generate len bytes from the system cryptographically secure PRNG.
- * Returns 0 on success and -1 on error, setting errno. The inability to
- * satisfy the full request is an error.
- */
-int csprng_bytes(void *buf, size_t len);
-
#endif