Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime restructuring #155

Merged
merged 3 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ EXTRACT_XISO = $(NXDK_DIR)/tools/extract-xiso/extract-xiso
TOOLS = cxbe vp20compiler fp20compiler extract-xiso
NXDK_CFLAGS = -target i386-pc-win32 -march=pentium3 \
-ffreestanding -nostdlib -fno-builtin -fno-exceptions \
-I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt \
-I$(NXDK_DIR)/lib -I$(NXDK_DIR)/lib/xboxrt/libc_extensions \
-I$(NXDK_DIR)/lib/hal \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This include path shouldn't be added in my opinion.

We should force people to explicitly use hal/<...>.h so they know which APIs belong to this legacy API.
This is also helpful when we do libraryization as people can explicitly see which libs they use directly.

Unfortunately, at this point, it's still necessary because:

/lib/pdclib/platform/xbox/functions/assert/assert.c:2:10: fatal error: 
      'debug.h' file not found
#include <debug.h>

We should fix this in the future.

-isystem $(NXDK_DIR)/lib/pdclib/include \
-I$(NXDK_DIR)/lib/pdclib/platform/xbox/include \
-I$(NXDK_DIR)/lib/winapi \
Expand Down
5 changes: 2 additions & 3 deletions lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ USB_SRCS := \
$(NXDK_DIR)/lib/usb/misc/malloc.c

SRCS += \
$(wildcard $(NXDK_DIR)/lib/xboxrt/*.c) \
$(shell find $(NXDK_DIR)/lib/pdclib/functions/ -name "*.c") \
$(shell find $(NXDK_DIR)/lib/pdclib/platform/xbox/ -name "*.c") \
$(shell find $(NXDK_DIR)/lib/pdclib/platform/xbox/ -name "*.s") \
$(wildcard $(NXDK_DIR)/lib/xlibc-rt/*.c) \
$(wildcard $(NXDK_DIR)/lib/xlibc-rt/*.s) \
$(wildcard $(NXDK_DIR)/lib/hal/*.c) \
$(wildcard $(NXDK_DIR)/lib/winapi/*.c) \
$(wildcard $(NXDK_DIR)/lib/pbkit/*.c) \
$(USB_SRCS)

include $(NXDK_DIR)/lib/xboxrt/Makefile
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/xboxrt/debug.h → lib/hal/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Debug output scrolling code submitted by Robin Mulloy
//
//
#ifndef XBOXRT_DEBUG
#define XBOXRT_DEBUG
#ifndef HAL_DEBUG_H
#define HAL_DEBUG_H

#if defined(__cplusplus)
extern "C"
Expand Down
2 changes: 1 addition & 1 deletion lib/hal/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string.h>
#include <hal/fileio.h>
#include <xboxkrnl/xboxkrnl.h>
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <stdbool.h>

// #define DEBUG
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/hal/xbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <xboxkrnl/xboxkrnl.h>

#include <stdio.h>
#include <xboxrt/debug.h>
#include <hal/debug.h>

#define KernelMode 0

Expand Down
2 changes: 1 addition & 1 deletion lib/net/pktdrv/pktdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//mess with fpu unless you save and restore fpu processor state)

#include <hal/xbox.h>
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <xboxkrnl/xboxkrnl.h>

#include "string.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/pbkit/pbkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <hal/xbox.h>
#include <hal/io.h>
#include <xboxkrnl/xboxkrnl.h>
#include <xboxrt/debug.h>
#include <hal/debug.h>

#include "pbkit.h"
#include "outer.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/sdl/SDL2
16 changes: 16 additions & 0 deletions lib/xboxrt/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
SRCS += \
$(NXDK_DIR)/lib/xboxrt/libc_extensions/stat.c \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sidenote: This file is currently entirely dead code (disabled by #if 0). Do we intend to revive it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure. Afaik Win32 has it, so it's probably a good idea to implement this properly, and some libc++ filesystem code wants to have that, too (although that code in libc++ is broken anyway atm). Should I eventually do it, I'd to it from scratch though and on top of winapi functions.
Afaik we only keep stat.c around because it forms a pair with stat.h and that one is required by our usb code.

Copy link
Member

@JayFoxRox JayFoxRox Sep 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MS extensions (aiming for POSIX compatibility probably) are usually prefixed, so it would be _stat. The UNIX and POSIX variants aren't usually prefixed: stat. Win32 would probably use GetFileAttributes instead (also see #161).

I think it's more interesting to fix on winapi support (which has been going quite well), and we could probably use old mingw / cygwin wrappers in the future (the new ones seem to use _stat32 from the MS CRT, but I believe they used to use Winapi directly).

stat.h can definitely stay for now (at least it declares 1 type). I'm still not sure what to do with stat.c - for this PR, I'm fine with just keeping it around.

$(NXDK_DIR)/lib/xboxrt/libc_extensions/strings.c \
$(NXDK_DIR)/lib/xboxrt/libc_extensions/wchar.c \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_alldiv.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_allmul.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_allrem.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_allshl.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_allshr.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_aulldiv.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_aullrem.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_aullshl.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_aullshr.s \
$(NXDK_DIR)/lib/xboxrt/c_runtime/_fltused.c \
$(NXDK_DIR)/lib/xboxrt/c_runtime/check_stack.c \
$(NXDK_DIR)/lib/xboxrt/c_runtime/chkstk.s
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion samples/hello++/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <pbkit/pbkit.h>
#include <hal/video.h>
#include <windows.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/hello/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <pbkit/pbkit.h>
#include <hal/video.h>
#include <hal/xbox.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/mesh/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <strings.h>
#include <windows.h>
#include <xboxkrnl/xboxkrnl.h>
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include "math3d.h"

static uint32_t *alloc_vertices;
Expand Down
2 changes: 1 addition & 1 deletion samples/sdl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
freely.
*/
/* Simple program: Create a native window and attach an SDL renderer */
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <pbkit/pbkit.h>
#include <hal/xbox.h>
#include <hal/video.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/sdl_ttf/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <pbkit/pbkit.h>
#include <hal/xbox.h>
#include <hal/video.h>
Expand Down
2 changes: 1 addition & 1 deletion samples/triangle/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <string.h>
#include <strings.h>
#include <xboxkrnl/xboxkrnl.h>
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <windows.h>

static uint32_t *alloc_vertices;
Expand Down
2 changes: 1 addition & 1 deletion samples/winapi_filefind/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <xboxrt/debug.h>
#include <hal/debug.h>
#include <pbkit/pbkit.h>
#include <hal/video.h>
#include <hal/xbox.h>
Expand Down