<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>chys&#039;s random notes &#187; Uncategorized</title>
	<atom:link href="http://en.chys.info/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://en.chys.info</link>
	<description>Study more problems; Talk less of isms.</description>
	<lastBuildDate>Tue, 27 Dec 2011 11:56:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Increasing the size of a VirtualBox vdi virtual drive</title>
		<link>http://en.chys.info/2011/12/increasing-the-size-of-a-virtualbox-vdi-virtual-drive/</link>
		<comments>http://en.chys.info/2011/12/increasing-the-size-of-a-virtualbox-vdi-virtual-drive/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 11:56:38 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[VirtualBox]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=905</guid>
		<description><![CDATA[VBoxManage modifyhd Win7.vdi --resize SizeInMiB Then go into the guest OS and create new partitions or extend existing partitions. Related posts: Shrink an LVM partition Why VirtualBox window is transparent&#8230; Disk size needed to compile OpenOffice<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2008/10/shrink-an-lvm-partition/' rel='bookmark' title='Shrink an LVM partition'>Shrink an LVM partition</a></li>
<li><a href='http://en.chys.info/2008/10/why-virtualbox-window-is-transparent/' rel='bookmark' title='Why VirtualBox window is transparent&#8230;'>Why VirtualBox window is transparent&#8230;</a></li>
<li><a href='http://en.chys.info/2008/10/disk-size-needed-to-compile-openoffice/' rel='bookmark' title='Disk size needed to compile OpenOffice'>Disk size needed to compile OpenOffice</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><code>VBoxManage modifyhd Win7.vdi --resize SizeInMiB</code><br />
Then go into the guest OS and create new partitions or extend existing partitions.</p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2008/10/shrink-an-lvm-partition/' rel='bookmark' title='Shrink an LVM partition'>Shrink an LVM partition</a></li>
<li><a href='http://en.chys.info/2008/10/why-virtualbox-window-is-transparent/' rel='bookmark' title='Why VirtualBox window is transparent&#8230;'>Why VirtualBox window is transparent&#8230;</a></li>
<li><a href='http://en.chys.info/2008/10/disk-size-needed-to-compile-openoffice/' rel='bookmark' title='Disk size needed to compile OpenOffice'>Disk size needed to compile OpenOffice</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2011/12/increasing-the-size-of-a-virtualbox-vdi-virtual-drive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A problem with pipes in Python 3</title>
		<link>http://en.chys.info/2011/11/a-problem-with-pipes-in-python-3/</link>
		<comments>http://en.chys.info/2011/11/a-problem-with-pipes-in-python-3/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 09:00:30 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=901</guid>
		<description><![CDATA[The most disturbing change from Python 2 to 3 definitely is not the print() function; nor that some functions which used to return lists now return iterators; nor the removal of __cmp__; but the transition to Unicode. I&#8217;m completely supportive of the transition per se, but I&#8217;m disappointed that they&#8217;re trying to compel us to [...]<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2009/08/cmp-should-be-reintroduced-to-python/' rel='bookmark' title='__cmp__ should be reintroduced to Python'>__cmp__ should be reintroduced to Python</a></li>
<li><a href='http://en.chys.info/2008/10/another-vmware-problem/' rel='bookmark' title='Another VMware problem'>Another VMware problem</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The most disturbing <a href="http://docs.python.org/release/3.0.1/whatsnew/3.0.html">change from Python 2 to 3</a> definitely is not the <code>print()</code> function; nor that some functions which used to return lists now return iterators; nor the <a href="/2009/08/cmp-should-be-reintroduced-to-python/">removal of <code>__cmp__</code></a>; but the transition to Unicode.</p>
<p>I&#8217;m completely supportive of the transition <em>per se</em>, but I&#8217;m disappointed that they&#8217;re trying to compel us to use Unicode by dropping useful functionalities for byte-streams/8-byte strings. For example, <code>bytes</code> has no <a href="http://www.python.org/dev/peps/pep-3101/"><code>format</code></a> or <a href="http://docs.python.org/release/2.5.2/lib/typesseq-strings.html"><code>%</code></a> in Python 3.</p>
<p>I have some code like this:</p>
<blockquote><pre>
proc = <a href="http://docs.python.org/release/3.1.3/library/subprocess.html">subprocess</a>.Popen((....), stdout=subprocess.PIPE)
for line in proc.stdout:
    ...
</pre>
</blockquote>
<p>I found that, on Linux, this code snippet is almost 10 times slower in Python 3 than in Python 2. Then I <a href="http://en.wikipedia.org/wiki/Strace">strace</a>&#8216;d the code and found Python 3 is passing length 1 to <a href="http://linux.die.net/man/2/read"><code>read</code></a>, incurring thousands of times more system calls than Python 2. Are you kidding me? I was forced to use something like <code>proc.stdout.read(...)</code>.</p>
<p>I understand this is not the direct result of the transition to Unicode, but it is somehow related.</p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2009/08/cmp-should-be-reintroduced-to-python/' rel='bookmark' title='__cmp__ should be reintroduced to Python'>__cmp__ should be reintroduced to Python</a></li>
<li><a href='http://en.chys.info/2008/10/another-vmware-problem/' rel='bookmark' title='Another VMware problem'>Another VMware problem</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2011/11/a-problem-with-pipes-in-python-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intel announces AVX2</title>
		<link>http://en.chys.info/2011/06/intel-announces-avx2/</link>
		<comments>http://en.chys.info/2011/06/intel-announces-avx2/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 06:38:01 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[hardware]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=898</guid>
		<description><![CDATA[The documentation is available for download. The instruction set war is still there &#8211; Intel still doesn&#8217;t plan to support many XOP features of AMD; also Intel still plans to use FMA3 while AMD uses FMA4. Nevertheless, this time Intel is at least not making the war even worse. In addition to extending most SSE2/SSE3/SSE4 [...]<hr/>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>The documentation is available for <a href="http://software.intel.com/file/36945">download</a>.</p>
<p>The <a href="http://www.agner.org/optimize/blog/read.php?i=25">instruction set war</a> is still there &#8211; Intel still doesn&#8217;t plan to support many <a href="http://en.wikipedia.org/wiki/XOP_instruction_set">XOP</a> features of AMD; also Intel still plans to use <a href="http://en.wikipedia.org/wiki/FMA_instruction_set">FMA3</a> while AMD uses FMA4. Nevertheless, this time Intel is at least not making the war even worse. In addition to extending most SSE2/SSE3/SSE4 instructions to 256 bits (this is no surprise), they copied BMI (with an extension called BMI2) and <a href="http://en.wikipedia.org/wiki/CVT16_instruction_set">CVT16</a> from AMD. If I recall correctly, Intel had never copied so many instructions from AMD at once, with the notable exception of x86-64.</p>
<hr/><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2011/06/intel-announces-avx2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integer division</title>
		<link>http://en.chys.info/2011/05/integer-division/</link>
		<comments>http://en.chys.info/2011/05/integer-division/#comments</comments>
		<pubDate>Wed, 25 May 2011 07:31:46 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++0x]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=890</guid>
		<description><![CDATA[C89 and C++98 say the result of an integer division where the divisor and/or dividend is negative is implementation defined. This reflects that early hardware implemented integer divisions differently. According to C89/C++98, we may have either (-3)/2 == -1 (round toward zero) or (-3)/2 == -2 (round toward negative infinity). It appears round toward zero [...]<hr/>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>C89 and C++98 say the result of an integer division where the divisor and/or dividend is negative is <a href="http://gcc.gnu.org/onlinedocs/gcc-3.3.6/cpp/Implementation_002ddefined-behavior.html">implementation defined</a>. This reflects that early hardware implemented integer divisions differently.</p>
<p>According to C89/C++98, we may have either <code>(-3)/2 == -1</code> (round toward zero) or <code>(-3)/2 == -2</code> (round toward negative infinity).</p>
<p>It appears <em>round toward zero</em> has become the overwhelming <em>de facto</em> standard now, adopted by both hardware and software vendors. Now both C and C++ explicitly require round toward zero in their new standards (C99 and <a href="http://en.wikipedia.org/wiki/C++0x">C++2011</a>*).</p>
<p>Division of negative integers has always been a complicated problem. Fortran mandated the same round-toward-zero mode much earlier than C/C++; so did Java. Python, on the other hand, has required round toward -∞ (i.e. <code>(-3)//2 == -2</code>) from its beginning. Everybody, nevertheless, agrees that <code>a/b*b + a%b == a</code> should always hold.</p>
<p>* C++0x has yet to be officially approved. Hopefully it will be approved within this year and known as C++2011. I&#8217;m using this name prematurely.</p>
<hr/><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2011/05/integer-division/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A hack to strace -f</title>
		<link>http://en.chys.info/2011/03/a-hack-to-strace-f/</link>
		<comments>http://en.chys.info/2011/03/a-hack-to-strace-f/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 13:22:20 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[multithread]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=886</guid>
		<description><![CDATA[I have a multithreaded program which I would like to strace for debugging purpose. My program sometimes calls (fork and exec) an external program, which in turn calls a setuid program. Because my program is multithreaded, I cannot omit the “-f” flag (also trace child threads and processes) when using strace. And because all children, [...]<hr/>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I have a multithreaded program which I would like to <a href="http://en.wikipedia.org/wiki/Strace">strace</a> for debugging purpose. My program sometimes calls (fork and exec) an external program, which in turn calls a <a href="http://www.aquaphoenix.com/ref/gnu_c_library/libc_438.html">setuid program</a>.</p>
<p>Because my program is multithreaded, I cannot omit the “<code>-f</code>” flag (also trace child threads and processes) when using strace. And because all children, including the setuid program, are traced, setuid fails. (Yes, I am aware that strace claims it is possible to trace setuid programs, but the trick does not work for me, probably because the setuid program is not directly executed by strace.)</p>
<p>Fortunately, the <code><a href="http://linux.die.net/man/2/clone">clone</a></code> system call has many useful flags. It works fine for me when I substitute calls to <code><a href="http://linux.die.net/man/2/fork">fork()</a></code> with:</p>
<blockquote><p><code>(pid_t) syscall (__NR_clone, CLONE_UNTRACED|SIGCHLD, NULL);<br />
</code></p></blockquote>
<p>(Yes, <code>SIGCHLD</code>, not <code>CLONE_SIGCHLD</code>. It&#8217;s not a typo.)</p>
<p>I guess there may be better solutions, without modifying the program being traced?</p>
<hr/><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2011/03/a-hack-to-strace-f/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Concatenate PDF files in Linux</title>
		<link>http://en.chys.info/2010/12/concatenate-pdf-files-in-linux/</link>
		<comments>http://en.chys.info/2010/12/concatenate-pdf-files-in-linux/#comments</comments>
		<pubDate>Sun, 26 Dec 2010 11:52:22 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=880</guid>
		<description><![CDATA[Some people recommend using convert or gs. However, there is a major problem with them &#8211; all text and vector graphics become raster graphics. pdftk (PDF ToolKit) is a better solution &#8211; it keeps text and vector graphics. We just have to use this command: pdftk *.pdf cat output result.pdf PDF Shuffler, written in Python [...]<hr/>
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Some people recommend using <a href="http://linux.die.net/man/1/convert">convert</a> or <a href="http://linux.die.net/man/1/gs">gs</a>. However, there is a major problem with them &#8211; all text and vector graphics become <a href="http://en.wikipedia.org/wiki/Raster_graphics">raster graphics</a>.</p>
<p><a href="http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/">pdftk</a> (PDF ToolKit) is a better solution &#8211; it keeps text and vector graphics. We just have to use this command:</p>
<blockquote><pre>pdftk *.pdf cat output result.pdf</pre>
</blockquote>
<p><a href="http://sourceforge.net/projects/pdfshuffler/">PDF Shuffler</a>, written in Python and based on <a href="http://poppler.freedesktop.org/">poppler</a>, also does the trick, and has a nice GUI.</p>
<p>However, there are drawbacks for both pdftk and PDF Shuffler:</p>
<ul>
<li>pdftk only supports ASCII filenames. So it&#8217;s a bit inconvenient for non-English users like me.</li>
<li>PDF Shuffler is <em>way</em> too slow. I tried concatenating several files (approx. 1000 pages), and it kept running for more than 10 minutes before I hit Ctrl-C; pdftk finished the same task in just a few seconds.</li>
</ul>
<hr/><p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2010/12/concatenate-pdf-files-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.note.GNU-stack</title>
		<link>http://en.chys.info/2010/12/note-gnu-stack/</link>
		<comments>http://en.chys.info/2010/12/note-gnu-stack/#comments</comments>
		<pubDate>Sat, 25 Dec 2010 07:16:17 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=870</guid>
		<description><![CDATA[GCC always appends one line to any assembler file (.s) file it generates: .section .note.GNU-stack,"",@progbits Literally, it adds an empty section named .note.GNU-stack to the object file, but it actually serves a hint to the linker* that code in this object file does not require an executable stack. GNU assembler also accepts command-line option “--noexecstack”, [...]<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2009/04/dynamic-library-symlinks/' rel='bookmark' title='Dynamic library symlinks'>Dynamic library symlinks</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>GCC always appends one line to any assembler file (.s) file it generates:</p>
<blockquote><pre>	.section	.note.GNU-stack,"",@progbits</pre>
</blockquote>
<p>Literally, it adds an empty section named <code>.note.GNU-stack</code> to the object file, but it actually serves a hint to the linker* that code in <em>this</em> object file does <em>not</em> require an executable stack. GNU assembler also accepts command-line option “<code>--noexecstack</code>”, which has the same effect.</p>
<p>If <em>every</em> object file contains a section of this name, the linker knows the whole program does not need an executable stack, and the resulting executable will run with a non-executable stack if the OS and underlying hardware support it (see also <a href="http://en.wikipedia.org/wiki/NX_bit">NX bit</a>).</p>
<p>Why is this important? In practice, virtually no program needs an executable stack (hackers may sometimes use it, though), but <a href="http://en.wikipedia.org/wiki/Buffer_overflow">buffer overflow attacks</a> frequently insert and run code in stacks. A non-executable stack helps improve security without any overhead.</p>
<p>* GNU linker only.</p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2009/04/dynamic-library-symlinks/' rel='bookmark' title='Dynamic library symlinks'>Dynamic library symlinks</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2010/12/note-gnu-stack/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert PDF to images in Linux</title>
		<link>http://en.chys.info/2010/12/convert-pdf-to-images-in-linux/</link>
		<comments>http://en.chys.info/2010/12/convert-pdf-to-images-in-linux/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 14:36:58 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=864</guid>
		<description><![CDATA[Just use convert, the universal image converter shipped with ImageMagick. convert a.pdf a.png And we get as many PNG files as there are pages in the PDF. They converted files are named a-0.png, a-1.png, &#8230; We can also use it the other way around: convert a.jpg b.png c.gif abc.pdf This will combine the three images [...]<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2010/12/concatenate-pdf-files-in-linux/' rel='bookmark' title='Concatenate PDF files in Linux'>Concatenate PDF files in Linux</a></li>
<li><a href='http://en.chys.info/2008/12/migrating-to-ext4/' rel='bookmark' title='Migrating to EXT4'>Migrating to EXT4</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just use <code><a href="http://linux.die.net/man/1/convert">convert</a></code>, the universal image converter shipped with <a href="http://www.imagemagick.org">ImageMagick</a>.</p>
<blockquote><p><code>convert a.pdf a.png</code></p></blockquote>
<p>And we get as many PNG files as there are pages in the PDF. They converted files are named <code>a-0.png</code>, <code>a-1.png</code>, &#8230;</p>
<p>We can also use it the other way around:</p>
<blockquote><p>convert a.jpg b.png c.gif abc.pdf</p></blockquote>
<p>This will combine the three images into one PDF file. Very flexible.</p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2010/12/concatenate-pdf-files-in-linux/' rel='bookmark' title='Concatenate PDF files in Linux'>Concatenate PDF files in Linux</a></li>
<li><a href='http://en.chys.info/2008/12/migrating-to-ext4/' rel='bookmark' title='Migrating to EXT4'>Migrating to EXT4</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2010/12/convert-pdf-to-images-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>man 3 sleep</title>
		<link>http://en.chys.info/2010/10/man-3-sleep/</link>
		<comments>http://en.chys.info/2010/10/man-3-sleep/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 14:17:32 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[multithread]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=843</guid>
		<description><![CDATA[The man page of sleep(3) used to say: sleep() makes the calling process sleep until seconds seconds have elapsed or a signal arrives which is not ignored. [Old version; color added] Now it says: sleep() makes the calling thread sleep until seconds seconds have elapsed or a signal arrives which is not ignored. [New version] [...]<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2010/03/errno-as-thread-identifier/' rel='bookmark' title='&lt;code&gt;&amp;errno&lt;/code&gt; as thread identifier'><code>&amp;errno</code> as thread identifier</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The man page of <code>sleep</code>(3) used to say:</p>
<blockquote><p><strong>sleep</strong>() makes the calling <font color="red">process</font> sleep until <em>seconds</em> seconds have elapsed or a signal arrives which is not ignored. [<a href="http://linux.die.net/man/3/sleep">Old version</a>; color added]</p></blockquote>
<p>Now it says:</p>
<blockquote><p><strong>sleep</strong>() makes the calling <font color="red">thread</font> sleep until <em>seconds</em> seconds have elapsed or a signal arrives which is not ignored. [<a href="http://www.kernel.org/doc/man-pages/online/pages/man3/sleep.3.html">New version</a>]</p></blockquote>
<p>Alas, they finally did the right thing &#8211; we have waited for at least 5 years. This change happened some time between versions 3.23 and 3.26.  </p>
<p>There is indeed no reason to use &#8220;process&#8221; anymore, at least since the emergence of Linux 2.6 and <a href="http://en.wikipedia.org/wiki/Native_POSIX_Thread_Library">NPTL</a>. As far as I know, this very sentence has confused many newbie Linux programmers who are not familiar with the history of Linux multithreading, and has led some to firmly believe there is no &#8220;real&#8221; thread or threads are actually processes under Linux, a statement which was probably right for the obsolete implementation <a href="http://en.wikipedia.org/wiki/LinuxThreads">LinuxThreads</a>, but definitely wrong today.</p>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2010/03/errno-as-thread-identifier/' rel='bookmark' title='&lt;code&gt;&amp;errno&lt;/code&gt; as thread identifier'><code>&amp;errno</code> as thread identifier</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2010/10/man-3-sleep/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Reference to array</title>
		<link>http://en.chys.info/2010/09/reference-to-array/</link>
		<comments>http://en.chys.info/2010/09/reference-to-array/#comments</comments>
		<pubDate>Sun, 26 Sep 2010 13:43:18 +0000</pubDate>
		<dc:creator>chys</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C/C++]]></category>

		<guid isPermaLink="false">http://en.chys.info/?p=840</guid>
		<description><![CDATA[I recall Microsoft uses this trick in some of its headers. I believe it&#8217;s something like this: template &#60;size_t _Size&#62; inline char *strcpy (char (&#038;dst)[_Size], const char *src) { &#160;&#160;&#160;&#160;strcpy_s (dst, _Size, src); &#160;&#160;&#160;&#160;return dst; } Related posts: GCC #pragma pack bug An Rvalue Reference Issue Rvalue reference<hr/>
Related posts:<ol>
<li><a href='http://en.chys.info/2008/12/gcc-pragma-pack-bug/' rel='bookmark' title='GCC #pragma pack bug'>GCC #pragma pack bug</a></li>
<li><a href='http://en.chys.info/2009/11/an-rvalue-reference-issue/' rel='bookmark' title='An Rvalue Reference Issue'>An Rvalue Reference Issue</a></li>
<li><a href='http://en.chys.info/2009/06/rvalue-reference/' rel='bookmark' title='Rvalue reference'>Rvalue reference</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recall Microsoft uses this trick in some of its headers. I believe it&#8217;s something like this:</p>
<blockquote><p>
<code>template &lt;size_t _Size&gt; inline</code><br />
<code>char *strcpy (char (&#038;dst)[_Size], const char *src)</code><br />
<code>{</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://msdn.microsoft.com/en-us/library/td1esda9%28v=VS.100%29.aspx">strcpy_s</a> (dst, _Size, src);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;return dst;</code><br />
<code>}</code>
</p></blockquote>
<hr/><p>Related posts:<ol>
<li><a href='http://en.chys.info/2008/12/gcc-pragma-pack-bug/' rel='bookmark' title='GCC #pragma pack bug'>GCC #pragma pack bug</a></li>
<li><a href='http://en.chys.info/2009/11/an-rvalue-reference-issue/' rel='bookmark' title='An Rvalue Reference Issue'>An Rvalue Reference Issue</a></li>
<li><a href='http://en.chys.info/2009/06/rvalue-reference/' rel='bookmark' title='Rvalue reference'>Rvalue reference</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://en.chys.info/2010/09/reference-to-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

