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