From: guido at CNRI.Reston.VA.US (Guido van Rossum)
Date: Tue, 6 Apr 1999 20:07:42 -0700 (PDT)
Subject: fix for posix_fsync under SunOS 4.1.x
In-Reply-To: Your message of "Sat, 03 Apr 1999 07:29:50 GMT."
             <199904030729.XAA24695@igce.igc.org> 
Message-ID: <199904070307.UAA12597@igce.igc.org>
Content-Length: 1564
X-UID: 682                                                  

>> Here's a patch to make sure that posix_fsync will compile on all operating
>> systems (specifically needed for SunOS 4.1.x).
>> 
>> This unified diff was made against Python 1.5.2 beta 2 .
>> 
>> -scott
>> 
>> --- Modules/posixmodule.c~	Tue Feb 16 11:38:04 1999
>> +++ Modules/posixmodule.c	Fri Apr  2 22:18:03 1999
>> @@ -647,6 +647,8 @@
>>  "fsync(fildes) -> None\n\
>>  force write of file with filedescriptor to disk.";
>>  
>> +extern int fsync(int); /* Prototype just in case */
>> +
>>  static PyObject *
>>  posix_fsync(self, args)
>>         PyObject *self;
>
>On how many other operating systems have you tried this patch?  I have
>found that almost invariably when you use an extern declaration of a
>standard function that is defined in the system headers on most modern
>systems, there's at least one system out there where what they have in
>the headers causes a conflict with what you declare!  It would be
>better if you put it insude an #ifdef specific for the SunOS 4.x
>platform.

I've only tried it on SunOS 4 and Solaris 2.

I originally put my extern inside

	#ifdef HAVE_UNISTD_H
	/* XXX These are for SunOS4.1.3 but shouldn't hurt elsewhere */
	extern int rename();
	extern int pclose();
	extern int lstat();
	extern int symlink();
	#else /* !HAVE_UNISTD_H */

But then I noticed that posix_fdatasync had

	extern int fdatasync(int); /* Prototype just in case */

	static PyObject *
	posix_fdatasync(self, args)

so I did it that way to be "consistent".

I don't really know which way is better (or if a third way is needed).

-scott




