ghaerr / microwindows

The Nano-X Window System
Other
665 stars 91 forks source link

Porting to sel4 #60

Open Ellis2781 opened 3 years ago

Ellis2781 commented 3 years ago

Since the purpose of this project was to be a small and stable window system, I thought this would go great with the ideals of sel4. In attempt to porting this project to the sel4 microkernel I am getting an error compiling however, when i compile for linux I get no such error.

`[1/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winclip2.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/winclip2.c:7: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winclip2.c:7: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

../projects/microwindows/src/mwin/winclip2.c: In function ‘MwSetClipWindow’: ../projects/microwindows/src/mwin/winclip2.c:73:3: warning: implicit declaration of function ‘GdSetClipRegion’; did you mean ‘MwSetClipWindow’? [-Wimplicit-function-declaration] GdSetClipRegion(hdc->psd, NULL); ^~~~~~~ MwSetClipWindow ../projects/microwindows/src/mwin/winclip2.c:80:8: warning: implicit declaration of function ‘GdAllocRectRegion’ [-Wimplicit-function-declaration] vis = GdAllocRectRegion(x, y, x+width, y+height); ^~~~~ ../projects/microwindows/src/mwin/winclip2.c:80:6: warning: assignment to ‘MWCLIPREGION ’ {aka ‘struct ’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion] vis = GdAllocRectRegion(x, y, x+width, y+height); ^ ../projects/microwindows/src/mwin/winclip2.c:85:6: warning: implicit declaration of function ‘GdAllocRegion’ [-Wimplicit-function-declaration] r = GdAllocRegion(); ^~~~~ ../projects/microwindows/src/mwin/winclip2.c:85:4: warning: assignment to ‘MWCLIPREGION ’ {aka ‘struct ’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion] r = GdAllocRegion(); ^ ../projects/microwindows/src/mwin/winclip2.c:114:4: warning: implicit declaration of function ‘GdSetRectRegionIndirect’; did you mean ‘CreateRectRgnIndirect’? [-Wimplicit-function-declaration] GdSetRectRegionIndirect(r, &sibwp->winrect); ^~~~~~~ CreateRectRgnIndirect ../projects/microwindows/src/mwin/winclip2.c:115:4: warning: implicit declaration of function ‘GdSubtractRegion’; did you mean ‘SubtractRect’? [-Wimplicit-function-declaration] GdSubtractRegion(vis, vis, r); ^~~~ SubtractRect ../projects/microwindows/src/mwin/winclip2.c:146:3: warning: implicit declaration of function ‘GdIntersectRegion’; did you mean ‘IntersectRect’? [-Wimplicit-function-declaration] GdIntersectRegion(vis, vis, wp->update); ^~~~~ IntersectRect ../projects/microwindows/src/mwin/winclip2.c:161:2: warning: implicit declaration of function ‘GdDestroyRegion’; did you mean ‘MwDestroyWindow’? [-Wimplicit-function-declaration] GdDestroyRegion(r); ^~~~~~~ MwDestroyWindow [3/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winclip.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/winclip2.c:7, from ../projects/microwindows/src/mwin/winclip.c:4: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winclip2.c:7, from ../projects/microwindows/src/mwin/winclip.c:4: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

[4/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winevent.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/winevent.c:13: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winevent.c:13: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

[5/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/windefw.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/windefw.c:10: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/windefw.c:10: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

[6/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winexpos.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/winexpos.c:11: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winexpos.c:11: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

[7/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winfont.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/winfont.c:8: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winfont.c:8: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

[8/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winclip1.c.obj FAILED: projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winclip1.c.obj /usr/bin/ccache /usr/bin/gcc --sysroot=/host/build -I../projects/microwindows/src/include -I../projects/microwindows/src/mwin/../include -Iprojects/musllibc/build-temp/stage/include -m64 -march=nehalem -D__KERNEL_64__ -g -nostdinc -fno-pic -fno-pie -fno-stack-protector -fno-asynchronous-unwind-tables -ftls-model=local-exec -mtls-direct-seg-refs -std=gnu11 -MD -MT projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winclip1.c.obj -MF projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winclip1.c.obj.d -o projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winclip1.c.obj -c ../projects/microwindows/src/mwin/winclip1.c In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/winclip1.c:5: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winclip1.c:5: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

../projects/microwindows/src/mwin/winclip1.c: In function ‘MwSetClipWindow’: ../projects/microwindows/src/mwin/winclip1.c:37:23: error: ‘MAX_CLIPRECTS’ undeclared (first use in this function); did you mean ‘MWCLIPRECT’? MWCLIPRECT cliprects[MAX_CLIPRECTS]; / clip rectangles / ^~~~~ MWCLIPRECT ../projects/microwindows/src/mwin/winclip1.c:37:23: note: each undeclared identifier is reported only once for each function it appears in ../projects/microwindows/src/mwin/winclip1.c:89:3: warning: implicit declaration of function ‘GdSetClipRects’; did you mean ‘MwSplitClipRect’? [-Wimplicit-function-declaration] GdSetClipRects(hdc->psd, 1, cliprects); ^~~~~~ MwSplitClipRect ../projects/microwindows/src/mwin/winclip1.c: In function ‘MwExcludeClipRect’: ../projects/microwindows/src/mwin/winclip1.c:176:18: error: ‘MAX_CLIPRECTS’ undeclared (first use in this function); did you mean ‘MWCLIPRECT’? if (newcount > MAX_CLIPRECTS - 3) { ^~~~~ MWCLIPRECT [10/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winmain2.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/winmain2.c:7: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winmain2.c:7: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

[13/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/winres.c.obj In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/winres.c:15: ../projects/microwindows/src/mwin/winres.c: In function ‘mwResCompare’: ../projects/microwindows/src/include/windef.h:175:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))

                                  ^

../projects/microwindows/src/mwin/winres.c:67:7: note: in expansion of macro ‘HIWORD’ if ((HIWORD(res1) == 0xFFFF) || (HIWORD(res2) == 0xFFFF)) // OK: Not pointer. Checks high word of resource DWORD. ^~ ../projects/microwindows/src/include/windef.h:175:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))

                                  ^

../projects/microwindows/src/mwin/winres.c:67:35: note: in expansion of macro ‘HIWORD’ if ((HIWORD(res1) == 0xFFFF) || (HIWORD(res2) == 0xFFFF)) // OK: Not pointer. Checks high word of resource DWORD. ^~ ../projects/microwindows/src/mwin/winres.c: In function ‘mwIsSameType’: ../projects/microwindows/src/include/windef.h:175:38: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))

                                  ^

../projects/microwindows/src/mwin/winres.c:261:6: note: in expansion of macro ‘HIWORD’ if (HIWORD(id) == 0xFFFF) { ^~ ../projects/microwindows/src/mwin/winres.c:268:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] if (w == LOWORD((DWORD) id)) ^ ../projects/microwindows/src/include/windef.h:174:37: note: in definition of macro ‘LOWORD’

define LOWORD(l) ((WORD)(l))

                                 ^

../projects/microwindows/src/mwin/winres.c: In function ‘resDialogTemplate’: ../projects/microwindows/src/mwin/winres.c:541:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] extra++ = (WORD)menu; // OK: No string menus yet, menu id always passed as WORD. ^ ../projects/microwindows/src/mwin/winres.c:542:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] extra++ = (WORD)classname; // OK: No string classes yet, class id always passed as WORD. ^ [15/263] Building C object projects/microwindows/src/mwin/CMakeFiles/mwin.dir/wingdi.c.obj In file included from ../projects/microwindows/src/include/winres.h:14, from ../projects/microwindows/src/include/windows.h:26, from ../projects/microwindows/src/mwin/wingdi.c:7: projects/musllibc/build-temp/stage/include/stdio.h:27: warning: "NULL" redefined

define NULL ((void*)0)

In file included from ../projects/microwindows/src/include/windows.h:21, from ../projects/microwindows/src/mwin/wingdi.c:7: ../projects/microwindows/src/include/windef.h:22: note: this is the location of the previous definition

define NULL ((void *)0)

../projects/microwindows/src/mwin/wingdi.c: In function ‘FillRect’: ../projects/microwindows/src/mwin/wingdi.c:787:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] crFill = GetSysColor((int)obr-1); // OK: Not pointer. Convert to int then decrement.`

Also to note, sel4 is based on the cmake build system

ghaerr commented 3 years ago

Hello @Ellis2781,

Also to note, sel4 is based on the cmake build system

Yes, this is likely the cause of the build error(s). Because of the particular way that the Makefiles and config files are setup, one can't just compile all *.c files, as some are not used due to the large number of configuration options.

In this particular case, it appears that both devclip1.c and devclip2.c are being compiled. However, looking at engine/devclip.c:

#include "device.h"

#if DYNAMICREGIONS
#include "devclip2.c"
#else
#include "devclip1.c"
#endif

Only one of the .c files should be compiled, which in your case, should probably be devclip2.c, which uses the newer dynamic regions handling code.

Is there a way to use the existing Microwindows make system on sel4 to get the basic system running, before moving to cmake, or is that not possible? A look at include/mwconfig.h, ./config, Arch.rules and Makefile.rules files will show the large number of options that may need to be specially handled by cmake. I haven't used cmake to build the project before.

Other than that, we can probably change a few things to greatly reduce the number of compile-time warnings for the time being. I would also suggest only compiling one of the Win32 (MWIN) or nano-X APIs at first, due to other complexities involved, depending on how sel4 handles client/server executables. Both APIs can be made to work as single executables, but nano-X requires more special configuration (LINK_APP_INTO_SERVER=Y in config). This graphics system includes two wholly-separate graphics APIs which architecturally sit on top of a graphics engine, which sits on top of specialized driver files which talk to the OS. This is described a bit more in http://microwindows.org/microwindows_architecture.html and http://microwindows.org/faq.html.

Thank you!