comparison audioDB-internals.h @ 563:c6036e0a511a

Work around the non-universality of fdatasync() POSIX, which specifies fdatasync(), also apparently specifies that POSIX_SYNCHRONIZED_IO is defined to a non-zero value if fdatasync() is available -- or at least that's what the man page suggests on Linux. This is probably good enough for us, anyway.
author mas01cr
date Thu, 18 Jun 2009 11:01:31 +0000
parents d3c96cbb91e3
children 633614461994
comparison
equal deleted inserted replaced
562:dfeb5ef768da 563:c6036e0a511a
1 #include <sys/types.h>
2 #include <unistd.h>
3
1 #include <set> 4 #include <set>
2 #include <queue> 5 #include <queue>
3 #include <map> 6 #include <map>
4 #include <string> 7 #include <string>
5 #include <algorithm> 8 #include <algorithm>
177 } 180 }
178 if(write(adb->fd, adb->header, ADB_HEADER_SIZE) != ADB_HEADER_SIZE) { 181 if(write(adb->fd, adb->header, ADB_HEADER_SIZE) != ADB_HEADER_SIZE) {
179 goto error; 182 goto error;
180 } 183 }
181 184
182 /* can be fsync() if fdatasync() is racily exciting and new */ 185 #if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0)
183 fdatasync(adb->fd); 186 fdatasync(adb->fd);
187 #else
188 fsync(adb->fd);
189 #endif
184 if(lseek(adb->fd, pos, SEEK_SET) == (off_t) -1) { 190 if(lseek(adb->fd, pos, SEEK_SET) == (off_t) -1) {
185 goto error; 191 goto error;
186 } 192 }
187 return 0; 193 return 0;
188 194