use __attribute__((const)) for errno and pthread_self if __GNUC__ is defined
authorRich Felker <dalias@aerifal.cx>
Tue, 7 Jun 2011 00:12:42 +0000 (20:12 -0400)
committerRich Felker <dalias@aerifal.cx>
Tue, 7 Jun 2011 00:12:42 +0000 (20:12 -0400)
this is not too ugly and should result in significant code size and
performance improvements for many programs.

include/errno.h
include/pthread.h

index d9c2c9c..9d68033 100644 (file)
@@ -7,6 +7,9 @@ extern "C" {
 
 #include <bits/errno.h>
 
+#ifdef __GNUC__
+__attribute__((const))
+#endif
 extern int *__errno_location(void);
 #define errno (*__errno_location())
 
index 5d97ebf..a0af20f 100644 (file)
@@ -76,6 +76,9 @@ int pthread_detach(pthread_t);
 void pthread_exit(void *);
 int pthread_join(pthread_t, void **);
 
+#ifdef __GNUC__
+__attribute__((const))
+#endif
 pthread_t pthread_self(void);
 int pthread_equal(pthread_t, pthread_t);