public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* namespace safety with attributes
@ 2014-07-31 16:07 Eric Blake
  2014-08-01  9:56 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Blake @ 2014-07-31 16:07 UTC (permalink / raw)
  To: cygwin-patches


[-- Attachment #1.1: Type: text/plain, Size: 822 bytes --]

As pointed out here:
https://cygwin.com/ml/cygwin/2014-07/msg00371.html

any use of __attribute__ in a header that can be included by a user
should be namespace-safe, by decorating the attribute arguments with __
(while gcc does a lousy job at documenting it, ALL attributes have a __
counterpart, precisely so that public headers can use attributes without
risk of collision with macros belonging to user namespace).

2014-07-31  Eric Blake  <eblake@redhat.com>

	* include/pthread.h: Decorate attribute names with __, for
	namespace safety.
	* include/cygwin/core_dump.h: Likewise.
	* include/cygwin/cygwin_dll.h: Likewise.
	* include/sys/cygwin.h: Likewise.
	* include/sys/strace.h: Likewise.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: decorate.patch --]
[-- Type: text/x-patch; name="decorate.patch", Size: 7609 bytes --]

Index: include/pthread.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/pthread.h,v
retrieving revision 1.41
diff -u -p -r1.41 pthread.h
--- include/pthread.h	16 Jul 2014 10:21:18 -0000	1.41
+++ include/pthread.h	31 Jul 2014 16:04:05 -0000
@@ -76,7 +76,7 @@ int pthread_attr_getschedpolicy (const p
 int pthread_attr_getscope (const pthread_attr_t *, int *);
 int pthread_attr_getstack (const pthread_attr_t *, void **, size_t *);
 int pthread_attr_getstackaddr (const pthread_attr_t *, void **)
-    __attribute__ ((deprecated));
+    __attribute__ ((__deprecated__));
 int pthread_attr_init (pthread_attr_t *);
 int pthread_attr_setdetachstate (pthread_attr_t *, int);
 int pthread_attr_setguardsize (pthread_attr_t *, size_t);
@@ -88,7 +88,7 @@ int pthread_attr_setscope (pthread_attr_
 #ifdef _POSIX_THREAD_ATTR_STACKADDR
 int pthread_attr_setstack (pthread_attr_t *, void *, size_t);
 int pthread_attr_setstackaddr (pthread_attr_t *, void *)
-    __attribute__ ((deprecated));
+    __attribute__ ((__deprecated__));
 #endif
 
 #ifdef _POSIX_THREAD_ATTR_STACKSIZE
@@ -137,7 +137,7 @@ int pthread_create (pthread_t *, const p
 		    void *(*)(void *), void *);
 int pthread_detach (pthread_t);
 int pthread_equal (pthread_t, pthread_t);
-void pthread_exit (void *) __attribute__ ((noreturn));
+void pthread_exit (void *) __attribute__ ((__noreturn__));
 int pthread_getcpuclockid (pthread_t, clockid_t *);
 int pthread_getschedparam (pthread_t, int *, struct sched_param *);
 void *pthread_getspecific (pthread_key_t);
Index: include/cygwin/core_dump.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/core_dump.h,v
retrieving revision 1.2
diff -u -p -r1.2 core_dump.h
--- include/cygwin/core_dump.h	11 Sep 2001 20:01:01 -0000	1.2
+++ include/cygwin/core_dump.h	31 Jul 2014 16:04:05 -0000
@@ -1,6 +1,6 @@
 /* core_dump.h
 
-   Copyright 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1999, 2000, 2001, 2014 Red Hat, Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -27,7 +27,7 @@ struct win32_core_process_info
   char command_line[1];
 }
 #ifdef __GNUC__
-  __attribute__ ((packed))
+  __attribute__ ((__packed__))
 #endif
 ;
 
@@ -38,7 +38,7 @@ struct win32_core_thread_info
   CONTEXT thread_context;
 }
 #ifdef __GNUC__
-  __attribute__ ((packed))
+  __attribute__ ((__packed__))
 #endif
 ;
 
@@ -49,7 +49,7 @@ struct win32_core_module_info
   char module_name[1];
 }
 #ifdef __GNUC__
-  __attribute__ ((packed))
+  __attribute__ ((__packed__))
 #endif
 ;
 
@@ -64,7 +64,7 @@ struct win32_pstatus
     } data ;
 }
 #ifdef __GNUC__
-  __attribute__ ((packed))
+  __attribute__ ((__packed__))
 #endif
 ;
 
Index: include/cygwin/cygwin_dll.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/cygwin_dll.h,v
retrieving revision 1.12
diff -u -p -r1.12 cygwin_dll.h
--- include/cygwin/cygwin_dll.h	23 Apr 2013 09:44:35 -0000	1.12
+++ include/cygwin/cygwin_dll.h	31 Jul 2014 16:04:05 -0000
@@ -1,6 +1,6 @@
 /* cygwin_dll.h
 
-   Copyright 1998, 1999, 2000, 2001, 2009, 2011, 2012, 2013 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2009, 2011, 2012, 2013, 2014 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -35,9 +35,9 @@ static DWORD storedReason;						      \
 static void* storedPtr;							      \
 int __dynamically_loaded;						      \
 									      \
-static int __dllMain (int a __attribute__ ((unused)),			      \
-		      char **b __attribute__ ((unused)),		      \
-		      char **c __attribute__ ((unused)))		      \
+static int __dllMain (int a __attribute__ ((__unused__)),		      \
+		      char **b __attribute__ ((__unused__)),		      \
+		      char **c __attribute__ ((__unused__)))		      \
 {									      \
   return Entry (storedHandle, storedReason, storedPtr);		              \
 }									      \
Index: include/sys/cygwin.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/sys/cygwin.h,v
retrieving revision 1.108
diff -u -p -r1.108 cygwin.h
--- include/sys/cygwin.h	15 May 2014 11:16:28 -0000	1.108
+++ include/sys/cygwin.h	31 Jul 2014 16:04:05 -0000
@@ -26,21 +26,21 @@ extern "C" {
 /* DEPRECATED INTERFACES.  These are restricted to MAX_PATH length.
    Don't use in modern applications.  They don't exist on x86_64. */
 extern int cygwin_win32_to_posix_path_list (const char *, char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 extern int cygwin_win32_to_posix_path_list_buf_size (const char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 extern int cygwin_posix_to_win32_path_list (const char *, char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 extern int cygwin_posix_to_win32_path_list_buf_size (const char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 extern int cygwin_conv_to_win32_path (const char *, char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 extern int cygwin_conv_to_full_win32_path (const char *, char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 extern int cygwin_conv_to_posix_path (const char *, char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 extern int cygwin_conv_to_full_posix_path (const char *, char *)
-  __attribute__ ((deprecated));
+  __attribute__ ((__deprecated__));
 #endif /* !__x86_64__ */
 
 /* Use these interfaces in favor of the above. */
Index: include/sys/strace.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/sys/strace.h,v
retrieving revision 1.33
diff -u -p -r1.33 strace.h
--- include/sys/strace.h	23 Apr 2013 09:44:35 -0000	1.33
+++ include/sys/strace.h	31 Jul 2014 16:04:05 -0000
@@ -1,7 +1,7 @@
 /* sys/strace.h
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008,
-   2010, 2011, 2012 Red Hat, Inc.
+   2010, 2011, 2012, 2014 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -40,17 +40,17 @@ class strace
   void write (unsigned category, const char *buf, int count);
   unsigned char _active;
 public:
-  void activate (bool) __attribute__ ((regparm (2)));;
+  void activate (bool) __attribute__ ((__regparm__ (2)));;
   strace () {}
   int microseconds ();
   int version;
   int lmicrosec;
   bool execing;
-  void dll_info () __attribute__ ((regparm (1)));
-  void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((regparm(3)))*/;
-  void vprntf (unsigned, const char *func, const char *, va_list ap) /*__attribute__ ((regparm(3)))*/;
-  void wm (int message, int word, int lon) __attribute__ ((regparm(3)));
-  void write_childpid (pid_t) __attribute__ ((regparm (3)));
+  void dll_info () __attribute__ ((__regparm__ (1)));
+  void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((__regparm__(3)))*/;
+  void vprntf (unsigned, const char *func, const char *, va_list ap) /*__attribute__ ((__regparm__(3)))*/;
+  void wm (int message, int word, int lon) __attribute__ ((__regparm__(3)));
+  void write_childpid (pid_t) __attribute__ ((__regparm__ (3)));
   bool attached () const {return _active == 3;}
   bool active () const {return _active & 1;}
   unsigned char& active_val () {return _active;}

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: namespace safety with attributes
  2014-07-31 16:07 namespace safety with attributes Eric Blake
@ 2014-08-01  9:56 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2014-08-01  9:56 UTC (permalink / raw)
  To: cygwin-patches

[-- Attachment #1: Type: text/plain, Size: 957 bytes --]

On Jul 31 10:07, Eric Blake wrote:
> As pointed out here:
> https://cygwin.com/ml/cygwin/2014-07/msg00371.html
> 
> any use of __attribute__ in a header that can be included by a user
> should be namespace-safe, by decorating the attribute arguments with __
> (while gcc does a lousy job at documenting it, ALL attributes have a __
> counterpart, precisely so that public headers can use attributes without
> risk of collision with macros belonging to user namespace).
> 
> 2014-07-31  Eric Blake  <...>
> 
> 	* include/pthread.h: Decorate attribute names with __, for
> 	namespace safety.
> 	* include/cygwin/core_dump.h: Likewise.
> 	* include/cygwin/cygwin_dll.h: Likewise.
> 	* include/sys/cygwin.h: Likewise.
> 	* include/sys/strace.h: Likewise.

Thanks, please apply.


Corinna

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

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-01  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31 16:07 namespace safety with attributes Eric Blake
2014-08-01  9:56 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).