Re: [PATCH 4/3] Introduce 'convert_path_to_git()'

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

 



Haven't been following this thread, so I don't know what the context is
here, but the brain teaser caught my eye.

On Tue, 2009-05-19 at 08:20 -0400, Jens Kilian wrote:
> Junio C Hamano <gitster <at> pobox.com> writes:
> > "Ugly" is not quite the word I am looking for.  "My gut feels that there
> > has to be a way to write this more cleanly, but I am frustrated that I
> > cannot come up with one" might be the word...
> 
> How about this:
> 
> #include <stdio.h>
> 

-#define MAGIC(type)  ((~(type)0 / (type)0xff) << 7)
+#define MAGIC(type)  ((type)(~(type)0 / 0xffU << 7))

> #define TEST(type) printf(#type " %llx\n", (unsigned long long)MAGIC(type))
> 
> int
> main(void)
> {
> /*TEST(unsigned char);  Doesn't work, and I'm too lazy to find out why. */
>   TEST(unsigned int);
>   TEST(unsigned long);
>   TEST(unsigned long long);
>   return 0;
> }
> 

--John

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]