os/ossrv/genericopenlibs/openenvcore/libc/src/fdatasync.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Name        : fdatasync.cpp
    15 // Part of     : LIBC
    16 // Contains the source for fchdir
    17 // Version     : 1.0
    18 //
    19 
    20 
    21  
    22 #include <unistd.h>
    23 
    24 /*
    25 The fdatasync() function shall force all currently queued I/O operations associated
    26 with the file indicated by file descriptor fildes to the synchronized I/O completion
    27 state.The functionality shall be equivalent to fsync() with the symbol  -> 
    28 _POSIX_SYNCHRONIZED_IO defined, with the exception that all I/O operations shall be
    29 completed as defined for synchronized I/O data integrity completion.If successful, 
    30 the fdatasync() function shall return the value 0; otherwise, the function shall
    31 return the value -1 and set errno to indicate the error.
    32 */
    33 
    34 extern "C" {
    35 
    36 EXPORT_C int fdatasync(int filedesc)
    37 	{
    38 	int retVal = -1;
    39 	#ifndef _POSIX_SYNCHRONIZED_IO
    40 	#define _POSIX_SYNCHRONIZED_IO
    41  	#define FLAG_FOR_FSYNC 1
    42  	#endif
    43 	//Calls fsync that provides equivalent functionality.	
    44 	retVal =  fsync(filedesc);
    45 	
    46 	#ifdef FLAG_FOR_FSYNC
    47 	#undef _POSIX_SYNCHRONIZED_IO;
    48 	#undef FLAG_FOR_FSYNC
    49 	#endif 
    50 	
    51 	return retVal;
    52 	}
    53 
    54 } //extern "C"
    55