Subject: PATCH: Compile Linux kernel with g++
From: SBPM Marc GINGOLD <[email-masked]>
Date: Thu, 1 Jul 93 14:23:21 GMT
Newsgroups: comp.os.linux.announce

Tristan GINGOLD is speaking:
(Excuse me if there are english mistakes, I'm frensh)

Here is a patch against linux 99.10 that allow you to compile linux kernel
 using cc1plus, i.e. c++.

What does the patch do ?
 o changes Makefiles & config.in to allow you to select your compilator
   If you choose c++ :
  o adds the '-x c++' flag to CFLAGS so that it should use c++
  o adds '-DCPLUSPLUS' for all .S files
 o Some .S files are divided in 2 parts: 1 for c, 1 for c++
 o '::' becomes ': :' (look at the asm fonctions...)
 o keywords of c++ are changed like in X11
    so 'new' becomes 'c_new'           (see fs code)
       'template' becomes 'c_template'
       'this' becomes 'c_this'
       'private' becomes 'c_private'   (see net code)
    I hasn't thought a lot !
 o prototypes become better
    There were a lot of errors about sys_close(u_int) ( and not int )
    Some pointers were not good in linux/fs/xiafs
 o Makes type and name differents: Do not allow to do 'struct foo foo'.
 o Structures are 'unrolled' 
    For an example see linux/include/linux/wait.h
 o Changes about the sys_call_table:
    It was in linux/include/linux/sys.h, included only by linux/kernel/sched.c
    Now, it is in linux/kernel/call_table.S
    Why? All the function were reprototyped as int xxxx(void), which was not
	true. So g++ can't link them. If I reprototyped them with the good
	prototype, I can't compile because the prototypes are differents.
    So I have made a table, in assembly. Becareful when you change it...
 o sys_call.S have been changed a lot so as to link with c++ fonctions
    names.
 o You can compile as if the patch doesn't exist. (Euh, nearly)
 o Perhaps something else ?
 o Makefiles are changed: They all include make.conf, which contains all the
    variables. So, to configure you must edit make.conf and not Makefile.
    This change allows you to do make in any directory. So You don't have all
    your memory used by make. (Useful with 4Mo).
 o Linux++ ( It can be a name ) works with gcc 2.4.3.

What doesn't it do ?
 o doesn't change FPU-emu. FPU-emu is still compiled with gcc. But it's
    linked with the other code so I change the function name ( e.g. printk
    becomes print__FPCce). Because FPU-emu is rather independant and because
    it contains a lot of asm code, I didn't change it.
 o doesn't compile faster, but you can use fastmake. See README
 o It doesn't use c++ feature ( e.g. class)
    just a start point.

Raisons to patch:
 o you can compile with gcc as before.
 o It forces people to write better code
 o compiling with c++ produces a lot of warnigs, mainly about pointer
 o it is a start point.
 o the kernel is *not* bigger: it has exactly the same size.

To applied this patch, do in /usr/src/linux :
patch -p0 < ../linux.diff

What will linux++ allow ?
 o polymorphism: several functions may have the same name, if the type of
   their arguments are differents. So, you can rename put_fs_long,
   put_fs_word and put_fs_byte by put_fs(char, char *), put_fs(short, short *)
   and put_fs(long, long *) or a better name. C++ will choose the good
   function. With that, some bugs are avoided and the sources are cleared (At
   least for me and perhaps for newbies :-)
 o classes: structure with data and functions. Make the code clearer. See a
   good manual. Classes can be used for driver, fs code (with heritage), and 
   perhaps table of processus... Classes make C++ an OO language.
 o Perhaps we can use the others functionnalities (like new), but it's not
   sure

C++ is a language of 90' whereas C is a language of 80'. Current year: 1993 :-)
Because we don't use all features of C++, linux++ would be rather easy to
 understand

The patch is also put in incoming at tsx-11.mit.edu

--
Send submissions for comp.os.linux.announce to: [email-masked]