Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Corinna Vinschen
On Feb 22 01:51, Christopher Faylor wrote:
> On Fri, Feb 22, 2013 at 12:18:48AM -0600, Yaakov wrote:
> >On Thu, 21 Feb 2013 14:42:36 -0500, Christopher Faylor wrote:
> >> I wasn't fulling grokking the fact that Cygwin explicitly defined the
> >> get_osfhandle without an underscore in io.h.  Sigh.  That's probably my
> >> fault too.
> >> 
> >> But we definitely shouldn't be going back to adding "_" decorations.  I
> >> have deleted a few of these and no one has complained.  I know that
> >> isn't a scientific sampling but it's hard to believe that someone has
> >> written code which actually goes out of its way to prepend an underscore
> >> in front of a standard UNIX function name, especially since we do not,
> >> AFAIK, define these functions in any header file.
> >> 
> >> So, I guess I don't understand why we need to add an underscore now
> >> when we have gotten by with the incorrect declaration for get_osfhandle
> >> all of these years.
> >
> >Because even if it caused a warning in C, the link still succeeded with
> >the underscored symbol.
> 
> Ok.  I think we should also change io.h to only define _get_osfhandle on
> both 64-bit and the trunk version of cygwin.  Ditto for _setmode.  And,
> IMO, the access() declaration should be removed from io.h entirely.

access should go, no doubt about it.

For get_osfhandle and setmode I would prefer maintaining backward
compatibility with existing applications.  Both variations, with and
without underscore are definitely in use.

What about exporting the underscored variants only, but define the
non-underscored ones:

  extern long _get_osfhandle(int);
  #define get_osfhandle(i) _get_osfhandle(i)

  extern int _setmode (int __fd, int __mode);
  #define setmode(f,m) _setmode((f),(m))


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Corinna Vinschen
On Feb 22 09:00, Corinna Vinschen wrote:
> On Feb 22 01:51, Christopher Faylor wrote:
> > On Fri, Feb 22, 2013 at 12:18:48AM -0600, Yaakov wrote:
> > >On Thu, 21 Feb 2013 14:42:36 -0500, Christopher Faylor wrote:
> > >> I wasn't fulling grokking the fact that Cygwin explicitly defined the
> > >> get_osfhandle without an underscore in io.h.  Sigh.  That's probably my
> > >> fault too.
> > >> 
> > >> But we definitely shouldn't be going back to adding "_" decorations.  I
> > >> have deleted a few of these and no one has complained.  I know that
> > >> isn't a scientific sampling but it's hard to believe that someone has
> > >> written code which actually goes out of its way to prepend an underscore
> > >> in front of a standard UNIX function name, especially since we do not,
> > >> AFAIK, define these functions in any header file.
> > >> 
> > >> So, I guess I don't understand why we need to add an underscore now
> > >> when we have gotten by with the incorrect declaration for get_osfhandle
> > >> all of these years.
> > >
> > >Because even if it caused a warning in C, the link still succeeded with
> > >the underscored symbol.
> > 
> > Ok.  I think we should also change io.h to only define _get_osfhandle on
> > both 64-bit and the trunk version of cygwin.  Ditto for _setmode.  And,
> > IMO, the access() declaration should be removed from io.h entirely.
> 
> access should go, no doubt about it.
> 
> For get_osfhandle and setmode I would prefer maintaining backward
> compatibility with existing applications.  Both variations, with and
> without underscore are definitely in use.
> 
> What about exporting the underscored variants only, but define the
> non-underscored ones:
> 
>   extern long _get_osfhandle(int);
>   #define get_osfhandle(i) _get_osfhandle(i)
> 
>   extern int _setmode (int __fd, int __mode);
>   #define setmode(f,m) _setmode((f),(m))

Just to be clear:  On 32 bit we should keep the exported symbols, too.
On 64 bit we can drop the non-underscored ones (which just requires
to rebuild gawk for me) and only keep the defines for backward
compatibility.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Cygwin/X
On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:
> > access should go, no doubt about it.
> > 
> > For get_osfhandle and setmode I would prefer maintaining backward
> > compatibility with existing applications.  Both variations, with and
> > without underscore are definitely in use.
> > 
> > What about exporting the underscored variants only, but define the
> > non-underscored ones:
> > 
> >   extern long _get_osfhandle(int);
> >   #define get_osfhandle(i) _get_osfhandle(i)
> > 
> >   extern int _setmode (int __fd, int __mode);
> >   #define setmode(f,m) _setmode((f),(m))
> 
> Just to be clear:  On 32 bit we should keep the exported symbols, too.
> On 64 bit we can drop the non-underscored ones (which just requires
> to rebuild gawk for me) and only keep the defines for backward
> compatibility.

Like this?


Yaakov
2013-02-22  Yaakov Selkowitz 
	Corinna Vinschen 

	* cygwin64.din (_get_osfhandle): Rename from get_osfhandle.
	(_setmode): Rename from setmode.
	* include/io.h: Ditto. Define unprefixed names with preprocessor
	macros for backwards source compatibility.
	(access): Remove.
	* syscalls.cc (get_osfhandle): Undefine compatibility macro.

Index: cygwin64.din
===
RCS file: /cvs/src/src/winsup/cygwin/Attic/cygwin64.din,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 cygwin64.din
--- cygwin64.din	15 Feb 2013 13:36:36 -	1.1.2.7
+++ cygwin64.din	22 Feb 2013 09:26:46 -
@@ -437,7 +437,7 @@ get_avphys_pages SIGFE
 get_current_dir_name SIGFE
 get_nprocs SIGFE
 get_nprocs_conf SIGFE
-get_osfhandle SIGFE
+_get_osfhandle = get_osfhandle SIGFE
 get_phys_pages SIGFE
 getaddrinfo = cygwin_getaddrinfo SIGFE
 getc SIGFE
@@ -1014,7 +1014,7 @@ setlinebuf SIGFE
 setlocale NOSIGFE
 setlogmask NOSIGFE
 setmntent SIGFE
-setmode = cygwin_setmode SIGFE
+_setmode = cygwin_setmode SIGFE
 setpassent NOSIGFE
 setpgid SIGFE
 setpgrp SIGFE
Index: syscalls.cc
===
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.638.2.10
diff -u -p -r1.638.2.10 syscalls.cc
--- syscalls.cc	9 Feb 2013 20:38:03 -	1.638.2.10
+++ syscalls.cc	22 Feb 2013 09:26:46 -
@@ -2891,6 +2891,8 @@ truncate (const char *pathname, _off_t l
 }
 #endif
 
+#undef get_osfhandle
+
 extern "C" long
 get_osfhandle (int fd)
 {
Index: include/io.h
===
RCS file: /cvs/src/src/winsup/cygwin/include/io.h,v
retrieving revision 1.3
diff -u -p -r1.3 io.h
--- include/io.h	17 Sep 2001 21:29:19 -	1.3
+++ include/io.h	22 Feb 2013 09:26:46 -
@@ -18,9 +18,10 @@ extern "C" {
 /*
  * Function to return a Win32 HANDLE from a fd.
  */
-extern long get_osfhandle(int);
-extern int setmode (int __fd, int __mode);
-int access(const char *__path, int __amode);
+extern long _get_osfhandle(int);
+#define get_osfhandle(i) _get_osfhandle(i);
+extern int _setmode (int __fd, int __mode);
+#define setmode(f,m) _setmode((f),(m))
 
 #ifdef __cplusplus
 };


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Corinna Vinschen
On Feb 22 03:40, Yaakov wrote:
> On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:
> > > access should go, no doubt about it.
> > > 
> > > For get_osfhandle and setmode I would prefer maintaining backward
> > > compatibility with existing applications.  Both variations, with and
> > > without underscore are definitely in use.
> > > 
> > > What about exporting the underscored variants only, but define the
> > > non-underscored ones:
> > > 
> > >   extern long _get_osfhandle(int);
> > >   #define get_osfhandle(i) _get_osfhandle(i)
> > > 
> > >   extern int _setmode (int __fd, int __mode);
> > >   #define setmode(f,m) _setmode((f),(m))
> > 
> > Just to be clear:  On 32 bit we should keep the exported symbols, too.
> > On 64 bit we can drop the non-underscored ones (which just requires
> > to rebuild gawk for me) and only keep the defines for backward
> > compatibility.
> 
> Like this?

Almost.  The _setmode needs a tweak, too.  I also think it makes
sense to rename the functions inside of syscalls.cc:

Index: cygwin.din
===
RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v
retrieving revision 1.256.2.1
diff -u -p -r1.256.2.1 cygwin.din
--- cygwin.din  22 Nov 2012 11:05:50 -  1.256.2.1
+++ cygwin.din  22 Feb 2013 09:49:26 -
@@ -678,8 +678,8 @@ get_avphys_pages SIGFE
 get_current_dir_name SIGFE
 get_nprocs SIGFE
 get_nprocs_conf SIGFE
-get_osfhandle SIGFE
-_get_osfhandle = get_osfhandle SIGFE
+_get_osfhandle SIGFE
+get_osfhandle = _get_osfhandle SIGFE
 get_phys_pages SIGFE
 getaddrinfo = cygwin_getaddrinfo SIGFE
 getc SIGFE
Index: cygwin64.din
===
RCS file: /cvs/src/src/winsup/cygwin/Attic/cygwin64.din,v
retrieving revision 1.1.2.7
diff -u -p -r1.1.2.7 cygwin64.din
--- cygwin64.din15 Feb 2013 13:36:36 -  1.1.2.7
+++ cygwin64.din22 Feb 2013 09:49:26 -
@@ -437,7 +437,7 @@ get_avphys_pages SIGFE
 get_current_dir_name SIGFE
 get_nprocs SIGFE
 get_nprocs_conf SIGFE
-get_osfhandle SIGFE
+_get_osfhandle SIGFE
 get_phys_pages SIGFE
 getaddrinfo = cygwin_getaddrinfo SIGFE
 getc SIGFE
@@ -1014,7 +1014,7 @@ setlinebuf SIGFE
 setlocale NOSIGFE
 setlogmask NOSIGFE
 setmntent SIGFE
-setmode = cygwin_setmode SIGFE
+_setmode = cygwin_setmode SIGFE
 setpassent NOSIGFE
 setpgid SIGFE
 setpgrp SIGFE
Index: syscalls.cc
===
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.638.2.10
diff -u -p -r1.638.2.10 syscalls.cc
--- syscalls.cc 9 Feb 2013 20:38:03 -   1.638.2.10
+++ syscalls.cc 22 Feb 2013 09:49:29 -
@@ -2754,7 +2754,7 @@ getmode (int fd)
previous mode.  */
 
 extern "C" int
-setmode (int fd, int mode)
+_setmode (int fd, int mode)
 {
   cygheap_fdget cfd (fd);
   if (cfd < 0)
@@ -2792,7 +2792,7 @@ setmode (int fd, int mode)
 extern "C" int
 cygwin_setmode (int fd, int mode)
 {
-  int res = setmode (fd, mode);
+  int res = _setmode (fd, mode);
   if (res != -1)
 {
   _my_tls.locals.setmode_file = fd;
@@ -2892,7 +2892,7 @@ truncate (const char *pathname, _off_t l
 #endif
 
 extern "C" long
-get_osfhandle (int fd)
+_get_osfhandle (int fd)
 {
   long res;
 
Index: include/io.h
===
RCS file: /cvs/src/src/winsup/cygwin/include/io.h,v
retrieving revision 1.3
diff -u -p -r1.3 io.h
--- include/io.h17 Sep 2001 21:29:19 -  1.3
+++ include/io.h22 Feb 2013 09:49:29 -
@@ -18,9 +18,10 @@ extern "C" {
 /*
  * Function to return a Win32 HANDLE from a fd.
  */
-extern long get_osfhandle(int);
-extern int setmode (int __fd, int __mode);
-int access(const char *__path, int __amode);
+extern long _get_osfhandle(int);
+#define get_osfhandle(i) _get_osfhandle(i)
+extern int _setmode (int __fd, int __mode);
+#define setmode(f,m) _setmode((f),(m))
 
 #ifdef __cplusplus
 };


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Corinna Vinschen
On Feb 22 10:51, Corinna Vinschen wrote:
> On Feb 22 03:40, Yaakov wrote:
> > On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:
> > > > access should go, no doubt about it.
> > > > 
> > > > For get_osfhandle and setmode I would prefer maintaining backward
> > > > compatibility with existing applications.  Both variations, with and
> > > > without underscore are definitely in use.
> > > > 
> > > > What about exporting the underscored variants only, but define the
> > > > non-underscored ones:
> > > > 
> > > >   extern long _get_osfhandle(int);
> > > >   #define get_osfhandle(i) _get_osfhandle(i)
> > > > 
> > > >   extern int _setmode (int __fd, int __mode);
> > > >   #define setmode(f,m) _setmode((f),(m))
> > > 
> > > Just to be clear:  On 32 bit we should keep the exported symbols, too.
> > > On 64 bit we can drop the non-underscored ones (which just requires
> > > to rebuild gawk for me) and only keep the defines for backward
> > > compatibility.
> > 
> > Like this?
> 
> Almost.  The _setmode needs a tweak, too.  I also think it makes
> sense to rename the functions inside of syscalls.cc:
> [...]

I applied this patch to the 64 bit branch for now.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Christopher Faylor
On Fri, Feb 22, 2013 at 11:02:55AM +0100, Corinna Vinschen wrote:
>On Feb 22 10:51, Corinna Vinschen wrote:
>> On Feb 22 03:40, Yaakov wrote:
>> > On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:
>> > > > access should go, no doubt about it.
>> > > > 
>> > > > For get_osfhandle and setmode I would prefer maintaining backward
>> > > > compatibility with existing applications.  Both variations, with and
>> > > > without underscore are definitely in use.
>> > > > 
>> > > > What about exporting the underscored variants only, but define the
>> > > > non-underscored ones:
>> > > > 
>> > > >   extern long _get_osfhandle(int);
>> > > >   #define get_osfhandle(i) _get_osfhandle(i)
>> > > > 
>> > > >   extern int _setmode (int __fd, int __mode);
>> > > >   #define setmode(f,m) _setmode((f),(m))
>> > > 
>> > > Just to be clear:  On 32 bit we should keep the exported symbols, too.
>> > > On 64 bit we can drop the non-underscored ones (which just requires
>> > > to rebuild gawk for me) and only keep the defines for backward
>> > > compatibility.
>> > 
>> > Like this?
>> 
>> Almost.  The _setmode needs a tweak, too.  I also think it makes
>> sense to rename the functions inside of syscalls.cc:
>> [...]
>
>I applied this patch to the 64 bit branch for now.

I was actually expecting that we'd break the compilation of existing
applications which incorrectly referenced get_osfhandle and setmode (I
have a couple of those).  It's a simple fix if someone recompiles and
it wouldn't be the first time that you'd have to make a source code
change when upreving to a new "OS".  For 32-bit we would need to keep
both in cygwin.din though, of course.

But, if you're going to use defines, why not just simplify them as:

#define get_osfhandle _get_osfhandle
#define setmode _setmode

?

cgf


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Corinna Vinschen
On Feb 22 09:32, Christopher Faylor wrote:
> On Fri, Feb 22, 2013 at 11:02:55AM +0100, Corinna Vinschen wrote:
> >On Feb 22 10:51, Corinna Vinschen wrote:
> >> On Feb 22 03:40, Yaakov wrote:
> >> > On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:
> >> > > > access should go, no doubt about it.
> >> > > > 
> >> > > > For get_osfhandle and setmode I would prefer maintaining backward
> >> > > > compatibility with existing applications.  Both variations, with and
> >> > > > without underscore are definitely in use.
> >> > > > 
> >> > > > What about exporting the underscored variants only, but define the
> >> > > > non-underscored ones:
> >> > > > 
> >> > > >   extern long _get_osfhandle(int);
> >> > > >   #define get_osfhandle(i) _get_osfhandle(i)
> >> > > > 
> >> > > >   extern int _setmode (int __fd, int __mode);
> >> > > >   #define setmode(f,m) _setmode((f),(m))
> >> > > 
> >> > > Just to be clear:  On 32 bit we should keep the exported symbols, too.
> >> > > On 64 bit we can drop the non-underscored ones (which just requires
> >> > > to rebuild gawk for me) and only keep the defines for backward
> >> > > compatibility.
> >> > 
> >> > Like this?
> >> 
> >> Almost.  The _setmode needs a tweak, too.  I also think it makes
> >> sense to rename the functions inside of syscalls.cc:
> >> [...]
> >
> >I applied this patch to the 64 bit branch for now.
> 
> I was actually expecting that we'd break the compilation of existing
> applications which incorrectly referenced get_osfhandle and setmode (I
> have a couple of those).  It's a simple fix if someone recompiles and
> it wouldn't be the first time that you'd have to make a source code
> change when upreving to a new "OS".  For 32-bit we would need to keep
> both in cygwin.din though, of course.

I'm trying to keep up with backward compatibility on the source level
as far as it makes sense (for a given value of "sense").

> But, if you're going to use defines, why not just simplify them as:
> 
> #define get_osfhandle _get_osfhandle
> #define setmode _setmode

I can do that, but I thought error messages would be more meaningful
when using macros with arguments.  Dunno, I was just trying to do
it right.  Shall I still simplify them?


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Christopher Faylor
On Fri, Feb 22, 2013 at 03:44:48PM +0100, Corinna Vinschen wrote:
>On Feb 22 09:32, Christopher Faylor wrote:
>> On Fri, Feb 22, 2013 at 11:02:55AM +0100, Corinna Vinschen wrote:
>> >On Feb 22 10:51, Corinna Vinschen wrote:
>> >> On Feb 22 03:40, Yaakov wrote:
>> >> > On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:
>> >> > > > access should go, no doubt about it.
>> >> > > > 
>> >> > > > For get_osfhandle and setmode I would prefer maintaining backward
>> >> > > > compatibility with existing applications.  Both variations, with and
>> >> > > > without underscore are definitely in use.
>> >> > > > 
>> >> > > > What about exporting the underscored variants only, but define the
>> >> > > > non-underscored ones:
>> >> > > > 
>> >> > > >   extern long _get_osfhandle(int);
>> >> > > >   #define get_osfhandle(i) _get_osfhandle(i)
>> >> > > > 
>> >> > > >   extern int _setmode (int __fd, int __mode);
>> >> > > >   #define setmode(f,m) _setmode((f),(m))
>> >> > > 
>> >> > > Just to be clear:  On 32 bit we should keep the exported symbols, too.
>> >> > > On 64 bit we can drop the non-underscored ones (which just requires
>> >> > > to rebuild gawk for me) and only keep the defines for backward
>> >> > > compatibility.
>> >> > 
>> >> > Like this?
>> >> 
>> >> Almost.  The _setmode needs a tweak, too.  I also think it makes
>> >> sense to rename the functions inside of syscalls.cc:
>> >> [...]
>> >
>> >I applied this patch to the 64 bit branch for now.
>> 
>> I was actually expecting that we'd break the compilation of existing
>> applications which incorrectly referenced get_osfhandle and setmode (I
>> have a couple of those).  It's a simple fix if someone recompiles and
>> it wouldn't be the first time that you'd have to make a source code
>> change when upreving to a new "OS".  For 32-bit we would need to keep
>> both in cygwin.din though, of course.
>
>I'm trying to keep up with backward compatibility on the source level
>as far as it makes sense (for a given value of "sense").

Yeah, but I worry about carrying cruft like this around forever.  I know
it's a mile pain for the person who copmiles programs but it shouldn't
be that big a deal to add an underscore.

>> But, if you're going to use defines, why not just simplify them as:
>> 
>> #define get_osfhandle _get_osfhandle
>> #define setmode _setmode
>
>I can do that, but I thought error messages would be more meaningful
>when using macros with arguments.  Dunno, I was just trying to do
>it right.  Shall I still simplify them?

I don't know.  If you use your method and say, for example setmode(x)
you'll get an error about a macro lacking arguments.  If you said
setmode ((char *) foo) you'd get an error about the '_setmode' function.
If you defined the macro without arguments you'd get a compiler error
referencing '_setmode' in both cases.  I guess I'd want this to be
consistent but I don't really care that much.

cgf


Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Ryan Johnson

On 22/02/2013 9:44 AM, Corinna Vinschen wrote:

On Feb 22 09:32, Christopher Faylor wrote:

On Fri, Feb 22, 2013 at 11:02:55AM +0100, Corinna Vinschen wrote:

On Feb 22 10:51, Corinna Vinschen wrote:

On Feb 22 03:40, Yaakov wrote:

On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:

access should go, no doubt about it.

For get_osfhandle and setmode I would prefer maintaining backward
compatibility with existing applications.  Both variations, with and
without underscore are definitely in use.

What about exporting the underscored variants only, but define the
non-underscored ones:

   extern long _get_osfhandle(int);
   #define get_osfhandle(i) _get_osfhandle(i)

   extern int _setmode (int __fd, int __mode);
   #define setmode(f,m) _setmode((f),(m))

Just to be clear:  On 32 bit we should keep the exported symbols, too.
On 64 bit we can drop the non-underscored ones (which just requires
to rebuild gawk for me) and only keep the defines for backward
compatibility.

Like this?

Almost.  The _setmode needs a tweak, too.  I also think it makes
sense to rename the functions inside of syscalls.cc:
[...]

I applied this patch to the 64 bit branch for now.

I was actually expecting that we'd break the compilation of existing
applications which incorrectly referenced get_osfhandle and setmode (I
have a couple of those).  It's a simple fix if someone recompiles and
it wouldn't be the first time that you'd have to make a source code
change when upreving to a new "OS".  For 32-bit we would need to keep
both in cygwin.din though, of course.

I'm trying to keep up with backward compatibility on the source level
as far as it makes sense (for a given value of "sense").


But, if you're going to use defines, why not just simplify them as:

#define get_osfhandle _get_osfhandle
#define setmode _setmode

I can do that, but I thought error messages would be more meaningful
when using macros with arguments.  Dunno, I was just trying to do
it right.  Shall I still simplify them?
The advantage of going function-form on the macro is that the 
preprocessor is smart enough to leave non-function uses of the 
identifier untouched:


#define foo(x,y) bar(x,y)
...
foo(1, 2); // changed to bar(1,2)
int foo = 10; // left as `foo'

That might matter, e.g. if somebody had a class with a member function 
that used both _setmode (a private class member) and setmode (a local 
variable). Or if that member function were itself called setmode.


On the other hand, the error messages might be slightly more useful with 
an identifier-form macro, depending on what you prefer to see:


#define foo hi
#define bar(x,y) hi(x,y)
int hi(int,int);
...
foo(1); // error: too few arguments to function ‘int hi(int, int)’
 // note: declared here [pointer to the declaration of hi()]
bar(1); // error: macro "bar" requires 2 arguments, but only 1 given

Overall, I favor using function-form macros in this sort of situation, 
because I'd rather not risk surprise changes to identifiers (and the 
macro argument error isn't confusing, just not as complete as the 
function version, because cpp doesn't point you to the offending macro's 
definition).


$0.02
Ryan



Re: [PATCH 64bit] Export symbols with underscore

2013-02-22 Thread Corinna Vinschen
On Feb 22 10:27, Christopher Faylor wrote:
> On Fri, Feb 22, 2013 at 03:44:48PM +0100, Corinna Vinschen wrote:
> >On Feb 22 09:32, Christopher Faylor wrote:
> >> On Fri, Feb 22, 2013 at 11:02:55AM +0100, Corinna Vinschen wrote:
> >> >On Feb 22 10:51, Corinna Vinschen wrote:
> >> >> On Feb 22 03:40, Yaakov wrote:
> >> >> > On Fri, 22 Feb 2013 09:49:51 +0100, Corinna Vinschen wrote:
> >> >> > > > access should go, no doubt about it.
> >> >> > > > 
> >> >> > > > For get_osfhandle and setmode I would prefer maintaining backward
> >> >> > > > compatibility with existing applications.  Both variations, with 
> >> >> > > > and
> >> >> > > > without underscore are definitely in use.
> >> >> > > > 
> >> >> > > > What about exporting the underscored variants only, but define the
> >> >> > > > non-underscored ones:
> >> >> > > > 
> >> >> > > >   extern long _get_osfhandle(int);
> >> >> > > >   #define get_osfhandle(i) _get_osfhandle(i)
> >> >> > > > 
> >> >> > > >   extern int _setmode (int __fd, int __mode);
> >> >> > > >   #define setmode(f,m) _setmode((f),(m))
> >> >> > > 
> >> >> > > Just to be clear:  On 32 bit we should keep the exported symbols, 
> >> >> > > too.
> >> >> > > On 64 bit we can drop the non-underscored ones (which just requires
> >> >> > > to rebuild gawk for me) and only keep the defines for backward
> >> >> > > compatibility.
> >> >> > 
> >> >> > Like this?
> >> >> 
> >> >> Almost.  The _setmode needs a tweak, too.  I also think it makes
> >> >> sense to rename the functions inside of syscalls.cc:
> >> >> [...]
> >> >
> >> >I applied this patch to the 64 bit branch for now.
> >> 
> >> I was actually expecting that we'd break the compilation of existing
> >> applications which incorrectly referenced get_osfhandle and setmode (I
> >> have a couple of those).  It's a simple fix if someone recompiles and
> >> it wouldn't be the first time that you'd have to make a source code
> >> change when upreving to a new "OS".  For 32-bit we would need to keep
> >> both in cygwin.din though, of course.
> >
> >I'm trying to keep up with backward compatibility on the source level
> >as far as it makes sense (for a given value of "sense").
> 
> Yeah, but I worry about carrying cruft like this around forever.  I know
> it's a mile pain for the person who copmiles programs but it shouldn't
> be that big a deal to add an underscore.

Alternatively, we We keep exporting the unloved symbols and add an
__attribute__ ((deprecated)) in the header, as we did for
cygwin_conv_to_win32_path and friends.  

> >> But, if you're going to use defines, why not just simplify them as:
> >> 
> >> #define get_osfhandle _get_osfhandle
> >> #define setmode _setmode
> >
> >I can do that, but I thought error messages would be more meaningful
> >when using macros with arguments.  Dunno, I was just trying to do
> >it right.  Shall I still simplify them?
> 
> I don't know.  If you use your method and say, for example setmode(x)
> you'll get an error about a macro lacking arguments.  If you said
> setmode ((char *) foo) you'd get an error about the '_setmode' function.
> If you defined the macro without arguments you'd get a compiler error
> referencing '_setmode' in both cases.  I guess I'd want this to be
> consistent but I don't really care that much.

Me neither.  I can define them just by name, but that depends on the
above decision.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat