Re: [PATCH 1/2] git version --build-options: report the build platform, too

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

>> @@ -390,6 +390,7 @@ const char *help_unknown_cmd(const char *cmd)
>>  
>>  int cmd_version(int argc, const char **argv, const char *prefix)
>>  {
>> +	static char build_platform[] = GIT_BUILD_PLATFORM;
>>  	int build_options = 0;
>>  	const char * const usage[] = {
>>  		N_("git version [<options>]"),
>> @@ -413,6 +414,7 @@ int cmd_version(int argc, const char **argv, const char *prefix)
>>  
>>  	if (build_options) {
>>  		printf("sizeof-long: %d\n", (int)sizeof(long));
>> +		printf("machine: %s\n", build_platform);
>
> Can this use GIT_BUILD_PLATFORM directly instead of going via the indirection
> of a mutable static string?  That is, something like
>
> 		printf("machine: %s\n", GIT_BUILD_PLATFORM);

Good point.  And if this is externally identified as "machine",
probably the macro should also use the same word, not "platform".
We can go either way, as long as we are consistent, though.

>> --- a/help.h
>> +++ b/help.h
>> @@ -33,3 +33,16 @@ extern void list_commands(unsigned int colopts, struct cmdnames *main_cmds, stru
>>   */
>>  extern void help_unknown_ref(const char *ref, const char *cmd, const char *error);
>>  #endif /* HELP_H */
>> +
>> +/*
>> + * identify build platform
>> + */
>> +#ifndef GIT_BUILD_PLATFORM
>> +	#if defined __x86__ || defined __i386__ || defined __i586__ || defined __i686__
>> +		#define GIT_BUILD_PLATFORM "x86"
>> +	#elif defined __x86_64__
>> +		#define GIT_BUILD_PLATFORM "x86_64"
>> +	#else
>> +		#define GIT_BUILD_PLATFORM "unknown"
>> +	#endif
>> +#endif
>
> This code needs to be inside the HELP_H header guard.

Certainly.

Thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux