1*7c478bd9Sstevel@tonic-gate /*- 2*7c478bd9Sstevel@tonic-gate * See the file LICENSE for redistribution information. 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * Copyright (c) 1997, 1998 5*7c478bd9Sstevel@tonic-gate * Sleepycat Software. All rights reserved. 6*7c478bd9Sstevel@tonic-gate */ 7*7c478bd9Sstevel@tonic-gate 8*7c478bd9Sstevel@tonic-gate #include "config.h" 9*7c478bd9Sstevel@tonic-gate 10*7c478bd9Sstevel@tonic-gate #ifndef lint 11*7c478bd9Sstevel@tonic-gate static const char sccsid[] = "@(#)os_fsync.c 10.7 (Sleepycat) 10/12/98"; 12*7c478bd9Sstevel@tonic-gate #endif /* not lint */ 13*7c478bd9Sstevel@tonic-gate 14*7c478bd9Sstevel@tonic-gate #ifndef NO_SYSTEM_INCLUDES 15*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 16*7c478bd9Sstevel@tonic-gate 17*7c478bd9Sstevel@tonic-gate #include <errno.h> 18*7c478bd9Sstevel@tonic-gate #include <fcntl.h> /* XXX: Required by __hp3000s900 */ 19*7c478bd9Sstevel@tonic-gate #include <unistd.h> 20*7c478bd9Sstevel@tonic-gate #endif 21*7c478bd9Sstevel@tonic-gate 22*7c478bd9Sstevel@tonic-gate #include "db_int.h" 23*7c478bd9Sstevel@tonic-gate #include "os_jump.h" 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate #ifdef __hp3000s900 26*7c478bd9Sstevel@tonic-gate int 27*7c478bd9Sstevel@tonic-gate __mpe_fsync(fd) 28*7c478bd9Sstevel@tonic-gate int fd; 29*7c478bd9Sstevel@tonic-gate { 30*7c478bd9Sstevel@tonic-gate extern FCONTROL(short, short, void *); 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate FCONTROL(_MPE_FILENO(fd), 2, NULL); /* Flush the buffers */ 33*7c478bd9Sstevel@tonic-gate FCONTROL(_MPE_FILENO(fd), 6, NULL); /* Write the EOF */ 34*7c478bd9Sstevel@tonic-gate return (0); 35*7c478bd9Sstevel@tonic-gate } 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifdef __hp3000s900 39*7c478bd9Sstevel@tonic-gate #define fsync(fd) __mpe_fsync(fd); 40*7c478bd9Sstevel@tonic-gate #endif 41*7c478bd9Sstevel@tonic-gate #ifdef _WIN32 42*7c478bd9Sstevel@tonic-gate #define fsync(fd) _commit(fd); 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * __os_fsync -- 47*7c478bd9Sstevel@tonic-gate * Flush a file descriptor. 48*7c478bd9Sstevel@tonic-gate * 49*7c478bd9Sstevel@tonic-gate * PUBLIC: int __os_fsync __P((int)); 50*7c478bd9Sstevel@tonic-gate */ 51*7c478bd9Sstevel@tonic-gate int 52*7c478bd9Sstevel@tonic-gate __os_fsync(fd) 53*7c478bd9Sstevel@tonic-gate int fd; 54*7c478bd9Sstevel@tonic-gate { 55*7c478bd9Sstevel@tonic-gate int ret; 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate ret = __db_jump.j_fsync != NULL ? __db_jump.j_fsync(fd) : fsync(fd); 58*7c478bd9Sstevel@tonic-gate return (ret == 0 ? 0 : errno); 59*7c478bd9Sstevel@tonic-gate } 60