~ubuntu-branches/ubuntu/intrepid/perl-doc-html/intrepid

« back to all changes in this revision

Viewing changes to c2ph.html

  • Committer: Bazaar Package Importer
  • Author(s): Roberto C. Sanchez
  • Date: 2008-05-17 20:14:19 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080517201419-qgbuogq2ckkdisyi
Tags: 5.10.0-2
Supersede botched upload of 5.10.0-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
      <h2>Links:</h2>
55
55
      <ul>
56
56
        <li><a href="http://search.cpan.org">CPAN</a></li>
 
57
        <li><a href="http://www.perl.org">Perl.org</a></li>
57
58
        <li><a href="http://www.perl.com">Perl.com</a></li>
58
 
        <li><a href="http://www.perl.org">Perl.org</a></li>
 
59
        <li><a href="http://perlbuzz.com">Perl Buzz</a></li>
 
60
        <li><a href="http://www.perlfoundation.org/perl5/index.cgi">Perl 5 Wiki</a></li>
 
61
        <li><a href="http://jobs.perl.org">Perl Jobs</a></li>
59
62
        <li><a href="http://www.pm.org">Perl Mongers</a></li>
60
63
        <li><a href="http://www.perlmonks.org">Perl Monks</a></li>
61
64
        <li><a href="http://planet.perl.org">Planet Perl</a></li>
65
68
      <ul>
66
69
        <li>Site maintained by<br><a href="http://perl.jonallen.info">Jon Allen</a>
67
70
            (<a href="http://perl.jonallen.info">JJ</a>)</li>
68
 
        <li class="spaced">Last updated on<br>23 April 2006</li>
 
71
        <li class="spaced">Last updated on<br>23 December 2007</li>
69
72
        <li class="spaced">See the <a href="http://perl.jonallen.info/projects/perldoc">project page</a> for
70
73
        more details</li>
71
74
      </ul>
76
79
    <div id="centerContent">
77
80
      <div id="contentHeader">
78
81
        <div id="contentHeaderLeft"><a href="#" onClick="showLeft()">Show navigation</a></div>
79
 
        <div id="contentHeaderCentre">-- Perl 5.8.8 documentation --</div>
 
82
        <div id="contentHeaderCentre">-- Perl 5.10.0 documentation --</div>
80
83
        <div id="contentHeaderRight"><a href="#" onClick="showRight()">Show toolbar</a></div>
81
84
      </div>
82
85
      <div id="breadCrumbs"><a href="index.html">Home</a> &gt; <a href="index-utilities.html">Utilities</a> &gt; c2ph</div>
83
86
      <script language="JavaScript">fromSearch();</script>
84
87
      <div id="contentBody"><div class="title_container"><div class="page_title">c2ph</div></div><ul><li><a href="#NAME">NAME</a><li><a href="#SYNOPSIS">SYNOPSIS</a><ul><li><a href="#OPTIONS">OPTIONS</a></ul><li><a href="#DESCRIPTION">DESCRIPTION</a></ul><a name="NAME"></a><h1>NAME</h1>
85
 
<p>c2ph, pstruct - Dump C structures as generated from <code class="inline">cc -g -S</code>
 
88
<p>c2ph, pstruct - Dump C structures as generated from <code class="inline"><span class="w">cc</span> -g -S</code>
86
89
 stabs</p>
87
90
<a name="SYNOPSIS"></a><h1>SYNOPSIS</h1>
88
 
<pre class="verbatim">    c2ph <span class="s">[</span>-dpnP<span class="s">]</span> <span class="s">[</span>var=val<span class="s">]</span> <span class="s">[</span>files ...<span class="s">]</span></pre>
 
91
<pre class="verbatim">    <span class="w">c2ph</span> <span class="s">[</span>-<span class="w">dpnP</span><span class="s">]</span> <span class="s">[</span><span class="w">var</span>=<span class="w">val</span><span class="s">]</span> <span class="s">[</span><span class="w">files</span> ...<span class="s">]</span></pre>
89
92
<a name="OPTIONS"></a><h2>OPTIONS</h2>
90
93
<pre class="verbatim">    <span class="j">Options:</span></pre>
91
94
<pre class="verbatim">    -w    wide; short for: type_width=45 member_width=35 offset_width=8
92
 
    -x  hex; short for:  offset_fmt=x offset_width=08 size_fmt=x size_width=04</pre><pre class="verbatim">    -n        <a class="l_k" href="functions/do.html">do</a> not generate perl code  <span class="s">(</span>default when invoked as pstruct<span class="s">)</span>
93
 
    -p  generate perl code         <span class="s">(</span>default when invoked as c2ph<span class="s">)</span>
94
 
    -v  generate perl code<span class="cm">,</span> with C decls as comments</pre>
95
 
<pre class="verbatim">    -i    <a class="l_k" href="functions/do.html">do</a> NOT recompute sizes for intrinsic datatypes
96
 
    -a  <a class="l_k" href="functions/dump.html">dump</a> information on intrinsics also</pre>
97
 
<pre class="verbatim">    -t    <span class="i">trace</span> execution
98
 
    -d  <span class="i">spew</span> reams of debugging output</pre>
99
 
<pre class="verbatim">    -slist  give comma-separated list a structures to <a class="l_k" href="functions/dump.html">dump</a></pre>
 
95
    -x  hex; short for:  offset_fmt=x offset_width=08 size_fmt=x size_width=04</pre><pre class="verbatim">    -<span class="w">n</span> <a class="l_k" href="functions/do.html">do</a> not <span class="w">generate</span> <span class="w">perl</span> <span class="w">code</span>  <span class="s">(</span><span class="w">default</span> when <span class="w">invoked</span> <span class="w">as</span> <span class="w">pstruct</span><span class="s">)</span>
 
96
    -<span class="w">p</span>   <span class="w">generate</span> <span class="w">perl</span> <span class="w">code</span>         <span class="s">(</span><span class="w">default</span> when <span class="w">invoked</span> <span class="w">as</span> <span class="w">c2ph</span><span class="s">)</span>
 
97
    -<span class="w">v</span>   <span class="w">generate</span> <span class="w">perl</span> <span class="w">code</span><span class="cm">,</span> <span class="w">with</span> <span class="w">C</span> <span class="w">decls</span> <span class="w">as</span> <span class="w">comments</span></pre>
 
98
<pre class="verbatim">    -<span class="w">i</span>     <a class="l_k" href="functions/do.html">do</a> <span class="w">NOT</span> <span class="w">recompute</span> <span class="w">sizes</span> for <span class="w">intrinsic</span> <span class="w">datatypes</span>
 
99
    -<span class="w">a</span>   <a class="l_k" href="functions/dump.html">dump</a> <span class="w">information</span> <span class="w">on</span> <span class="w">intrinsics</span> <span class="w">also</span></pre>
 
100
<pre class="verbatim">    -t    <span class="w">trace</span> <span class="w">execution</span>
 
101
    -d  <span class="w">spew</span> <span class="w">reams</span> <span class="w">of</span> <span class="w">debugging</span> <span class="w">output</span></pre>
 
102
<pre class="verbatim">    -<span class="w">slist</span>  <span class="w">give</span> <span class="w">comma</span>-<span class="w">separated</span> <span class="w">list</span> <span class="w">a</span> <span class="w">structures</span> <span class="w">to</span> <a class="l_k" href="functions/dump.html">dump</a></pre>
100
103
<a name="DESCRIPTION"></a><h1>DESCRIPTION</h1>
101
104
<p>The following is the old c2ph.doc documentation by Tom Christiansen
102
105
&lt;tchrist@perl.com&gt;
192
195
<p>As you see, the name of the package is the name of the structure.  Regular
193
196
fields are just their own names.  Plus the following accessor functions are
194
197
provided for your convenience:</p>
195
 
<pre class="verbatim">    struct        This takes <a class="l_k" href="functions/no.html">no</a> arguments<span class="cm">,</span> and is merely the number of first-level
196
 
                elements in the structure.  You would <a class="l_k" href="functions/use.html">use</a> this for indexing
197
 
                into arrays of structures<span class="cm">,</span> perhaps like this</pre>
 
198
<pre class="verbatim">    <span class="w">struct</span> <span class="w">This</span> <span class="w">takes</span> <a class="l_k" href="functions/no.html">no</a> <span class="w">arguments</span><span class="cm">,</span> and <span class="w">is</span> <span class="w">merely</span> <span class="w">the</span> <span class="w">number</span> <span class="w">of</span> <span class="w">first</span>-<span class="w">level</span>
 
199
                <span class="w">elements</span> <span class="w">in</span> <span class="w">the</span> <span class="w">structure</span>.  <span class="w">You</span> <span class="w">would</span> <a class="l_k" href="functions/use.html">use</a> <span class="w">this</span> for <span class="w">indexing</span>
 
200
                <span class="w">into</span> <span class="w">arrays</span> <span class="w">of</span> <span class="w">structures</span><span class="cm">,</span> <span class="w">perhaps</span> <span class="w">like</span> <span class="w">this</span></pre>
198
201
<pre class="verbatim">              <span class="i">$usec</span> = <span class="i">$u</span>[ <span class="i">&amp;user&#39;u_utimer</span>
199
202
                                + <span class="s">(</span><span class="i">&amp;ITIMER_VIRTUAL</span> * <span class="i">&amp;itimerval&#39;struct</span><span class="s">)</span>
200
203
                                + <span class="i">&amp;itimerval&#39;it_value</span>
201
204
                                + <span class="i">&amp;timeval&#39;tv_usec</span>
202
205
                              ]<span class="sc">;</span></pre>
203
 
<pre class="verbatim">    sizeof        Returns the <a class="l_w" href="bytes.html">bytes</a> in the structure<span class="cm">,</span> or the member if
204
 
                you pass it an argument<span class="cm">,</span> such as</pre>
 
206
<pre class="verbatim">    <span class="w">sizeof</span>         <span class="w">Returns</span> <span class="w">the</span> <span class="w">bytes</span> <span class="w">in</span> <span class="w">the</span> <span class="w">structure</span><span class="cm">,</span> or <span class="w">the</span> <span class="w">member</span> if
 
207
                <span class="w">you</span> <span class="w">pass</span> <span class="w">it</span> <span class="w">an</span> <span class="w">argument</span><span class="cm">,</span> <span class="w">such</span> <span class="w">as</span></pre>
205
208
<pre class="verbatim">                  <span class="i">&amp;rusage&#39;sizeof</span><span class="s">(</span><span class="i">&amp;rusage&#39;ru_utime</span><span class="s">)</span></pre>
206
209
<pre class="verbatim">    typedef       This is the perl format definition for passing to pack and
207
210
                unpack.  If you ask for the typedef of a nothing, you get
208
211
                the whole structure, otherwise you get that of the member
209
212
                you ask for.  Padding is taken care of, as is the magic to
210
213
                guarantee that a union is unpacked into all its aliases.
211
 
                Bitfields are not quite yet supported however.</pre><pre class="verbatim">    offsetof  This function is the byte offset into the array of that
212
 
                member.  You may wish to <a class="l_k" href="functions/use.html">use</a> this for indexing directly
213
 
                into the packed structure with <a class="l_k" href="functions/vec.html">vec</a><span class="s">(</span><span class="s">)</span> if you&#39;re too lazy
214
 
                to <a class="l_k" href="functions/unpack.html">unpack</a> it.</pre>
215
 
<pre class="verbatim">    typeof        Not to be confused with the typedef accessor function<span class="cm">,</span> this
216
 
                one returns the C type of that field.  This would allow
217
 
                you to <a class="l_k" href="functions/print.html">print</a> <span class="i">out</span> a nice structured pretty <a class="l_k" href="functions/print.html">print</a> <span class="i">of</span> some
218
 
                structure without knoning anything about it beforehand.
219
 
                No args to this one is a noop.  Someday I&#39;ll post such
220
 
                a thing to <a class="l_k" href="functions/dump.html">dump</a> out your u structure for you.</pre>
 
214
                Bitfields are not quite yet supported however.</pre><pre class="verbatim">    <span class="w">offsetof</span>   <span class="w">This</span> <span class="w">function</span> <span class="w">is</span> <span class="w">the</span> <span class="w">byte</span> <span class="w">offset</span> <span class="w">into</span> <span class="w">the</span> <span class="w">array</span> <span class="w">of</span> <span class="w">that</span>
 
215
                <span class="w">member</span>.  <span class="w">You</span> <span class="w">may</span> <span class="w">wish</span> <span class="w">to</span> <a class="l_k" href="functions/use.html">use</a> <span class="w">this</span> for <span class="w">indexing</span> <span class="w">directly</span>
 
216
                <span class="w">into</span> <span class="w">the</span> <span class="w">packed</span> <span class="w">structure</span> <span class="w">with</span> <a class="l_k" href="functions/vec.html">vec</a><span class="s">(</span><span class="s">)</span> if <span class="w">you&#39;re</span> <span class="w">too</span> <span class="w">lazy</span>
 
217
                <span class="w">to</span> <a class="l_k" href="functions/unpack.html">unpack</a> <span class="w">it</span>.</pre>
 
218
<pre class="verbatim">    <span class="w">typeof</span> <span class="w">Not</span> <span class="w">to</span> <span class="w">be</span> <span class="w">confused</span> <span class="w">with</span> <span class="w">the</span> <span class="w">typedef</span> <span class="w">accessor</span> <span class="w">function</span><span class="cm">,</span> <span class="w">this</span>
 
219
                <span class="w">one</span> <span class="w">returns</span> <span class="w">the</span> <span class="w">C</span> <span class="w">type</span> <span class="w">of</span> <span class="w">that</span> <span class="w">field</span>.  <span class="w">This</span> <span class="w">would</span> <span class="w">allow</span>
 
220
                <span class="w">you</span> <span class="w">to</span> <a class="l_k" href="functions/print.html">print</a> <span class="i">out</span> <span class="w">a</span> <span class="w">nice</span> <span class="w">structured</span> <span class="w">pretty</span> <a class="l_k" href="functions/print.html">print</a> <span class="i">of</span> <span class="w">some</span>
 
221
                <span class="w">structure</span> <span class="w">without</span> <span class="w">knoning</span> <span class="w">anything</span> <span class="w">about</span> <span class="w">it</span> <span class="w">beforehand</span>.
 
222
                <span class="w">No</span> <span class="w">args</span> <span class="w">to</span> <span class="w">this</span> <span class="w">one</span> <span class="w">is</span> <span class="w">a</span> <span class="w">noop</span>.  <span class="w">Someday</span> <span class="w">I&#39;ll</span> <span class="w">post</span> <span class="w">such</span>
 
223
                <span class="w">a</span> <span class="w">thing</span> <span class="w">to</span> <a class="l_k" href="functions/dump.html">dump</a> <span class="w">out</span> <span class="w">your</span> <span class="w">u</span> <span class="w">structure</span> for <span class="w">you</span>.</pre>
221
224
<p>The way I see this being used is like basically this:</p>
222
225
<pre class="verbatim">  % h2ph &lt;some_include_file.h  &gt;  /usr/lib/perl/tmp.ph
223
226
        % c2ph  some_include_file.h  &gt;&gt; /usr/lib/perl/tmp.ph
230
233
of the stabs on the fly, and then account for micro differences between my
231
234
compiler and gcc.</p>
232
235
<p>Anyway, here it is.  Should run on perl v4 or greater.  Maybe less.</p>
233
 
<pre class="verbatim"> --tom</pre>
 
236
<pre class="verbatim"> --<span class="w">tom</span></pre>
234
237
</div>
235
238
      <div id="contentFooter"><a href="http://www.perl.org"><img src="perlpowered.png" border=0></a></div>
236
239
    </div>
248
251
          <!--<select name="r"><option value="1" selected>Go to top result<option value="0">Show results list</select>-->
249
252
        </form>
250
253
      </p>
 
254
      <script language="JavaScript" type="text/javascript" src="/perl-version.js"></script>
251
255
      <h2>Labels:</h2>
252
256
      <p>
253
257
        <a href="#" onClick="addLabel('c2ph','c2ph.html')">Add this page</a>