Merge pull request #374 from libtom/fix/cygwin

fix aesgcm on cygwin
This commit is contained in:
Steffen Jaeckel 2018-04-08 02:56:20 +02:00 committed by GitHub
commit 49b3425de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,15 +39,27 @@ static off_t fsize(const char *filename)
return -1; return -1;
} }
#if defined(__linux__) && defined(__GLIBC_PREREQ)
#if __GLIBC_PREREQ(2, 14)
#define HAS_SYNCFS
#endif
#endif
static int mv(const char *old_name, const char *new_name) static int mv(const char *old_name, const char *new_name)
{ {
int fd; int fd;
if (rename(old_name, new_name) == -1) return -1; if (rename(old_name, new_name) == -1) return -1;
fd = open(new_name, 0); fd = open(new_name, 0);
if (fd == -1) return -1; if (fd == -1) return -1;
#if !defined(_WIN32)
if (fsync(fd) != 0) goto OUT; if (fsync(fd) != 0) goto OUT;
#if defined(HAS_SYNCFS)
syncfs(fd); syncfs(fd);
#else
sync();
#endif
OUT: OUT:
#endif
close(fd); close(fd);
return 0; return 0;
} }