@@ -625,7 +625,7 @@ static inline int git_has_dir_sep(const char *path)
625
625
626
626
#include "compat/bswap.h"
627
627
628
- struct strbuf ;
628
+ #include "wrapper.h"
629
629
630
630
/* General helper functions */
631
631
NORETURN void usage (const char * err );
@@ -1045,36 +1045,6 @@ static inline int cast_size_t_to_int(size_t a)
1045
1045
# define xalloca (size ) (xmalloc(size))
1046
1046
# define xalloca_free (p ) (free(p))
1047
1047
#endif
1048
- char * xstrdup (const char * str );
1049
- void * xmalloc (size_t size );
1050
- void * xmallocz (size_t size );
1051
- void * xmallocz_gently (size_t size );
1052
- void * xmemdupz (const void * data , size_t len );
1053
- char * xstrndup (const char * str , size_t len );
1054
- void * xrealloc (void * ptr , size_t size );
1055
- void * xcalloc (size_t nmemb , size_t size );
1056
- void xsetenv (const char * name , const char * value , int overwrite );
1057
- void * xmmap (void * start , size_t length , int prot , int flags , int fd , off_t offset );
1058
- const char * mmap_os_err (void );
1059
- void * xmmap_gently (void * start , size_t length , int prot , int flags , int fd , off_t offset );
1060
- int xopen (const char * path , int flags , ...);
1061
- ssize_t xread (int fd , void * buf , size_t len );
1062
- ssize_t xwrite (int fd , const void * buf , size_t len );
1063
- ssize_t xpread (int fd , void * buf , size_t len , off_t offset );
1064
- int xdup (int fd );
1065
- FILE * xfopen (const char * path , const char * mode );
1066
- FILE * xfdopen (int fd , const char * mode );
1067
- int xmkstemp (char * temp_filename );
1068
- int xmkstemp_mode (char * temp_filename , int mode );
1069
- char * xgetcwd (void );
1070
- FILE * fopen_for_writing (const char * path );
1071
- FILE * fopen_or_warn (const char * path , const char * mode );
1072
-
1073
- /*
1074
- * Like strncmp, but only return zero if s is NUL-terminated and exactly len
1075
- * characters long. If it is not, consider it greater than t.
1076
- */
1077
- int xstrncmpz (const char * s , const char * t , size_t len );
1078
1048
1079
1049
/*
1080
1050
* 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)
1176
1146
return (size_t ) len ;
1177
1147
}
1178
1148
1179
- __attribute__((format (printf , 3 , 4 )))
1180
- int xsnprintf (char * dst , size_t max , const char * fmt , ...);
1181
-
1182
1149
#ifndef HOST_NAME_MAX
1183
1150
#define HOST_NAME_MAX 256
1184
1151
#endif
1185
1152
1186
- int xgethostname (char * buf , size_t len );
1187
-
1188
1153
/* in ctype.c, for kwset users */
1189
1154
extern const unsigned char tolower_trans_tbl [256 ];
1190
1155
@@ -1425,72 +1390,6 @@ void bug_fl(const char *file, int line, const char *fmt, ...);
1425
1390
#endif
1426
1391
#endif
1427
1392
1428
- enum fsync_action {
1429
- FSYNC_WRITEOUT_ONLY ,
1430
- FSYNC_HARDWARE_FLUSH
1431
- };
1432
-
1433
- /*
1434
- * Issues an fsync against the specified file according to the specified mode.
1435
- *
1436
- * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating
1437
- * systems to flush the OS cache without issuing a flush command to the storage
1438
- * controller. If those interfaces are unavailable, the function fails with
1439
- * ENOSYS.
1440
- *
1441
- * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that
1442
- * changes are durable. It is not expected to fail.
1443
- */
1444
- int git_fsync (int fd , enum fsync_action action );
1445
-
1446
- /*
1447
- * Writes out trace statistics for fsync using the trace2 API.
1448
- */
1449
- void trace_git_fsync_stats (void );
1450
-
1451
- /*
1452
- * Preserves errno, prints a message, but gives no warning for ENOENT.
1453
- * Returns 0 on success, which includes trying to unlink an object that does
1454
- * not exist.
1455
- */
1456
- int unlink_or_warn (const char * path );
1457
- /*
1458
- * Tries to unlink file. Returns 0 if unlink succeeded
1459
- * or the file already didn't exist. Returns -1 and
1460
- * appends a message to err suitable for
1461
- * 'error("%s", err->buf)' on error.
1462
- */
1463
- int unlink_or_msg (const char * file , struct strbuf * err );
1464
- /*
1465
- * Preserves errno, prints a message, but gives no warning for ENOENT.
1466
- * Returns 0 on success, which includes trying to remove a directory that does
1467
- * not exist.
1468
- */
1469
- int rmdir_or_warn (const char * path );
1470
- /*
1471
- * Calls the correct function out of {unlink,rmdir}_or_warn based on
1472
- * the supplied file mode.
1473
- */
1474
- int remove_or_warn (unsigned int mode , const char * path );
1475
-
1476
- /*
1477
- * Call access(2), but warn for any error except "missing file"
1478
- * (ENOENT or ENOTDIR).
1479
- */
1480
- #define ACCESS_EACCES_OK (1U << 0)
1481
- int access_or_warn (const char * path , int mode , unsigned flag );
1482
- int access_or_die (const char * path , int mode , unsigned flag );
1483
-
1484
- /* Warn on an inaccessible file if errno indicates this is an error */
1485
- int warn_on_fopen_errors (const char * path );
1486
-
1487
- /*
1488
- * Open with O_NOFOLLOW, or equivalent. Note that the fallback equivalent
1489
- * may be racy. Do not use this as protection against an attacker who can
1490
- * simultaneously create paths.
1491
- */
1492
- int open_nofollow (const char * path , int flags );
1493
-
1494
1393
#ifndef SHELL_PATH
1495
1394
# define SHELL_PATH "/bin/sh"
1496
1395
#endif
@@ -1630,13 +1529,4 @@ static inline void *container_of_or_null_offset(void *ptr, size_t offset)
1630
1529
((uintptr_t)&(ptr)->member - (uintptr_t)(ptr))
1631
1530
#endif /* !__GNUC__ */
1632
1531
1633
- void sleep_millisec (int millisec );
1634
-
1635
- /*
1636
- * Generate len bytes from the system cryptographically secure PRNG.
1637
- * Returns 0 on success and -1 on error, setting errno. The inability to
1638
- * satisfy the full request is an error.
1639
- */
1640
- int csprng_bytes (void * buf , size_t len );
1641
-
1642
1532
#endif
0 commit comments