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