[PATCH 3/7] Add getauxval.

Richard Henderson rth@twiddle.net
Mon May 21 18:43:00 GMT 2012


On 05/21/12 11:07, Roland McGrath wrote:
>> +unsigned long
>> +__getauxval (unsigned long type)
> 
> We never use implicit 'int' in glibc code.
> Always write 'unsigned long int', never 'unsigned long'.
> 
> In the sys/auxv.h you committed, there is a comment for the function, which
> is good.  But...
> 
>> /* Return the value associated with an Elf*_auxv_t type from the auxv list
>>    passed to the program on startup.  If __type was not present in the auxv
> 
> In a comment referring to a parameter declared as "__foo", we write "FOO".
> So "TYPE" here.
> 
>>    list, returns zero.  */
>> extern unsigned long getauxval (unsigned long __type)
> 
> And no implicit 'int' in the types here.
> 
> Also, since sys/auxv.h uses __BEGIN_DECLS it ought to #include <sys/cdefs.h>
> itself rather than expecting those macros to be available by some other
> indirectio inclusion.

Ok.  Committed the following to fix all of the above.


r~
-------------- next part --------------
        * misc/getauxval.c (__getauxval): Use unsigned long int.
        * misc/sys/auxv.h: Include <sys/cdefs.h>.
        (getauxval): Use unsigned long int.



diff --git a/misc/getauxval.c b/misc/getauxval.c
index a3338ee..bff4560 100644
--- a/misc/getauxval.c
+++ b/misc/getauxval.c
@@ -19,8 +19,8 @@
 #include <ldsodefs.h>
 
 
-unsigned long
-__getauxval (unsigned long type)
+unsigned long int
+__getauxval (unsigned long int type)
 {
   ElfW(auxv_t) *p;
 
diff --git a/misc/sys/auxv.h b/misc/sys/auxv.h
index a70fb37..34df04a 100644
--- a/misc/sys/auxv.h
+++ b/misc/sys/auxv.h
@@ -20,14 +20,15 @@
 #define _SYS_AUXV_H 1
 
 #include <elf.h>
+#include <sys/cdefs.h>
 #include <bits/hwcap.h>
 
 __BEGIN_DECLS
 
 /* Return the value associated with an Elf*_auxv_t type from the auxv list
-   passed to the program on startup.  If __type was not present in the auxv
+   passed to the program on startup.  If TYPE was not present in the auxv
    list, returns zero.  */
-extern unsigned long getauxval (unsigned long __type)
+extern unsigned long int getauxval (unsigned long int __type)
   __THROW __attribute_const__;
 
 __END_DECLS


More information about the Libc-alpha mailing list