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 d9c2c9c73099a5161c3d6568f41a3f8e000ce752..9d6803383cac9d6f244a35de6b1e05c3808c9f3d 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 5d97ebf61c804c7639886f4104f6b2db57265a34..a0af20fe38e769ad787c6ec4310b6ad49d7bb44e 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);