Changes between Version 5 and Version 6 of Faq


Ignore:
Timestamp:
Sep 4, 2006, 1:37:07 AM (18 years ago)
Author:
bird
Comment:

dropped rst, try use same tools as the TracFaq?

Legend:

Unmodified
Added
Removed
Modified
  • Faq

    v5 v6  
    1 {{{
    2 #!rst
    3 ========
    4 LIBC FAQ
    5 ========
     1= kLIBC FAQ =
    62
    7 .. contents::
    8 .. sectnum::
     3----
     4[[PageOutline(2-6,,inline)]]
     5TODO: PageOutline isn't working, investigate!
     6----
    97
    10 -----
    11 
    12 The linker
    13 ===========
     8== The linker ==
    149
    1510
    16 Do you know that ilink 5 screws up when there are many exports?
    17 ---------------------------------------------------------------
     11=== Do you know that ilink 5 screws up when there are many exports? ===
    1812
    19 Yes, I do know. Possible workarounds are
     13
     14Yes, I do know. Possible workarounds are:
    2015  1. Use a different linker, for instance ilink from vac308 or the a.out linker.
    21   1. Reduce the number of exported symbols. For instance use __declspec(dllexport) or set up a generic export filter of some kind.
     16  1. Reduce the number of exported symbols. For instance use {{{__declspec(dllexport)}}} or set up a generic export filter of some kind.
    2217  1. Split up the .dll so the new dlls end up with an acceptable number of exports.
    2318  1. Help me implement LX and OMF backends for binutils (and the gnu linker).
    2419
    2520
    26 ILink : fatal error LNK1002: unrecognized option (ocache:0x02000000)
    27 --------------------------------------------------------------------
     21=== ILink : fatal error LNK1002: unrecognized option (ocache:0x02000000) ===
    2822
    29 You're using the VAC308 ilink, but emxomfld thinks it's VAC365 or ilink 5 and feeds it the /ocache option. There are two soultions:
     23You're using the VAC308 ilink, but emxomfld thinks it's VAC365 or ilink 5 and feeds it the {{{/ocache}}} option. There are two soultions:
    3024  1. Use ilink 5.
    31   2. SET EMXOMFLD_TYPE=VAC308
     25  2. {{{SET EMXOMFLD_TYPE=VAC308}}}
    3226
    3327
    34 Calling conventions
    35 ====================
     28== Calling conventions ==
    3629
    37 What's the story with the underscore?
    38 -------------------------------------
     30=== What's the story with the underscore? ===
    3931
    4032The extra underscore can be said to be inherited from the microsoft compilers, which makes it go back to the early DOS days. [If somebody has a complete history, please update/let me know. bird]
    4133
    42 The OS/2 (and Windows) C ABI (application binary interface) dicates that the __cdecl calling convention shall decorate functions with one leading underscore. To my knowledge most of the windows and OS/2 compilers with the exception of EMX does this. The OS/2 specific _System calling convention is basically the same as __cdecl except that there is no decoration of the function name (there is also the bit about AL containing the parameter count, but nobody really implements this). There are a number of other calling convetions on OS/2, _Optlink (the IBM compilers), watcom register call (todo: name), __stdcall (microsoft windows api), borland probably has one, etc...
     34The OS/2 (and Windows) C ABI (application binary interface) dicates that the {{{__cdecl}}} calling convention shall decorate functions with one leading underscore. To my knowledge most of the windows and OS/2 compilers with the exception of EMX does this. The OS/2 specific {{{_System}}} calling convention is basically the same as {{{__cdecl}}} except that there is no decoration of the function name (there is also the bit about AL containing the parameter count, but nobody really implements this). There are a number of other calling convetions on OS/2, {{{_Optlink}}} (the IBM compilers), watcom register call (todo: name), {{{__stdcall}}} (microsoft windows api), borland probably has one, etc...
    4335
    44 The EMX ports of gcc didn't implement __cdecl according to the OS/2 ABI, they simply omitted the leading underscore. This made _System and __cdecl identical for all practical purposes. With gcc using __cdecl as default, this meant that _System could be completely ignored.
     36The EMX ports of gcc didn't implement {{{__cdecl}}} according to the OS/2 ABI, they simply omitted the leading underscore. This made {{{_System}}} and {{{__cdecl}}} identical for all practical purposes. With gcc using {{{__cdecl}}} as default, this meant that {{{_System}}} could be completely ignored.
    4537
    46 Now, starting with GCC 3.2.2 it became important that GCC could work together with other compilers (for building certain Odin32 dlls and other stuff). So, the OS/2 port was changed to decorate the all names according to the __cdecl ABI just like the microsoft compilers. Unfortunatly, breaks compatibility with EMX, but then GCC 3.2.2 comes with it's own, EMX derived, libc.
     38Now, starting with GCC 3.2.2 it became important that GCC could work together with other compilers (for building certain Odin32 dlls and other stuff). So, the OS/2 port was changed to decorate the all names according to the {{{__cdecl}}} ABI just like the microsoft compilers. Unfortunatly, breaks compatibility with EMX, but then GCC 3.2.2 comes with it's own, EMX derived, libc.
    4739
    4840
    49 How to declare a function so it won't get an underscore?
    50 --------------------------------------------------------
     41=== How to declare a function so it won't get an underscore? ===
     42{{{
     43void _System hello_world(void);
     44}}}
    5145
    52 void _System hello_world(void);
    53 
    54 If you want to compile this with EMX, add -D_System to you compiler commandline or #define _System to some header.
     46If you want to compile this with EMX, add {{{-D_System}}} to you compiler commandline or {{{#define _System}}} to some header.
    5547
    5648
    57 How to declare a variable so it won't get an underscore?
    58 --------------------------------------------------------
     49=== How to declare a variable so it won't get an underscore? ===
    5950
    60 Not really possible. You might use something like int my_variable asm("my_variable"); but that's hardly generic or portable. (todo: check if it's really 'asm' and not some __attribute__.)
     51Not really possible. You might use something like {{{int my_variable asm("my_variable");}}} but that's hardly generic or portable. (todo: check if it's really 'asm' and not some {{{__attribute__}}}.)
    6152
    6253
    6354
    64 End-Of-Line - O_BINARY / O_TEXT
    65 ================================
     55== End-Of-Line - O_BINARY / O_TEXT ==
    6656
    6757
    68 What's the story with the different EOL markers?
    69 -------------------------------------------------
     58=== What's the story with the different EOL markers? ===
    7059
    7160See what wikipedia has to say on the subject of newline: http://en.wikipedia.org/wiki/Newline
    7261
    7362
    74 Why doesn't read(fd, buf, size_of_file) return cbFile?
    75 ---------------------------------------------------
     63=== Why doesn't read(fd, buf, size_of_file) return size_of_file? ===
    7664
    7765Because you have opened the file in text mode and read will convert {{{\r\n}}} sequences to {{{\n}}}. An example (test this):
     
    10290If this is really a binary file and you certainly don't want to have eol conversion, add O_BINARY to the flags open flags ("b" in the case of fopen).
    10391If this is a text file and you wish for eol conversion, you must alter the check for read success. TODO: suggest good ways of doing this.
    104 
    105 }}}