Include only what is really necessary...

add pragma once in every header, etc.
This commit is contained in:
TuxSH 2018-01-22 01:07:11 +01:00 committed by plutoo
parent 5a67f0909d
commit 5abc4873d8
88 changed files with 319 additions and 71 deletions

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
static inline void* armGetTls(void) {
void* ret;
__asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret));

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
#define BINDER_FIRST_CALL_TRANSACTION 0x1
typedef struct {

View File

@ -1,5 +1,4 @@
#pragma once
#include <switch/gfx/nvioctl.h>
typedef struct {

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
/// Converts red, green, blue, and alpha components to packed RGBA8.
#define RGBA8(r,g,b,a) (((r)&0xff)|(((g)&0xff)<<8)|(((b)&0xff)<<16)|(((a)&0xff)<<24))

View File

@ -1,3 +1,5 @@
#pragma once
//The below defines are from Linux kernel ioctl.h.
#define _IOC_NRBITS 8

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
Result nvgfxInitialize(void);
void nvgfxExit(void);
Result nvgfxEventWait(u32 syncpt_id, u32 threshold, s32 timeout);

View File

@ -1,4 +1,5 @@
#pragma once
#include <switch/types.h>
typedef struct {
u32 arch; // 0x120 (NVGPU_GPU_ARCH_GM200)

View File

@ -1,5 +1,6 @@
#include <string.h>
#include <switch.h>
#pragma once
#include <switch/result.h>
#include <switch/gfx/binder.h>
typedef struct {
u8 payload[0x400];

View File

@ -1,4 +1,9 @@
// Copyright 2017 plutoo
#pragma once
#include <switch/arm.h>
#include <switch/result.h>
#include <switch/kernel/svc.h>
#define SFCI_MAGIC 0x49434653
#define SFCO_MAGIC 0x4f434653

View File

@ -1,4 +1,7 @@
// Copyright 2017 plutoo
#pragma once
#include <switch/types.h>
bool kernelAbove200(void);
bool kernelAbove300(void);
bool kernelAbove400(void);

View File

@ -1,4 +1,6 @@
// Copyright 2018 plutoo
#pragma once
#include <switch/types.h>
typedef enum {
JitType_CodeMemory,

View File

@ -1,6 +1,7 @@
// Copyright 2017 plutoo
#pragma once
#include <sys/lock.h>
#include <switch/types.h> // not needed in this file, still including it
typedef _LOCK_T Mutex;
typedef _LOCK_RECURSIVE_T RMutex;

View File

@ -1,4 +1,6 @@
// Copyright 2018 plutoo
#pragma once
#include <switch/types.h>
void randomGet(u8* buf, size_t len);
u64 randomGet64(void);

View File

@ -1,4 +1,6 @@
// Copyright 2018 plutoo
#pragma once
#include <switch/kernel/mutex.h>
typedef struct {
RMutex r;

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
typedef struct {
Handle handle;
size_t size;

View File

@ -3,8 +3,7 @@
* @brief Syscall wrappers.
*/
#pragma once
#include "../types.h"
#include <switch/types.h>
/// Pseudo handle for the current process
#define CUR_PROCESS_HANDLE 0xFFFF8001

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
typedef struct {
Handle handle;
void* stack_mem;

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
typedef struct {
Handle handle;
size_t size;

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
void* virtmemReserve(size_t size);
void virtmemFree(void* addr, size_t size);

View File

@ -3,7 +3,7 @@
* @brief Switch result code tools
*/
#pragma once
#include "types.h"
#include <switch/types.h>
/// Checks whether a result code indicates success.
#define R_SUCCEEDED(res) ((res)==0)

View File

@ -15,8 +15,7 @@
* @endcode
*/
#pragma once
#include <switch.h>
#include <switch/types.h>
#define CONSOLE_ESC(x) "\x1b[" #x
#define CONSOLE_RESET CONSOLE_ESC(0m)

View File

@ -3,6 +3,7 @@
* @brief FS driver.
*/
#pragma once
#include <switch/services/fs.h>
//NOTE: This is currently not usable.

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
Result usbCommsInitialize(void);
void usbCommsExit(void);

View File

@ -1,4 +1,6 @@
// Copyright 2018 plutoo
#pragma once
#include <switch/types.h>
typedef struct {
u32 Key;

View File

@ -4,8 +4,8 @@
*/
#pragma once
#include <stdint.h>
#include <sys/types.h>
#include <switch/types.h>
/** Convert a UTF-8 sequence into a UTF-32 codepoint
*

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
Result accountInitialize(void);
void accountExit(void);
Handle accountGetSessionService(void);

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
/// These are used internally by applet.
Result apmInitialize(void);

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
typedef enum {
AppletType_None = -2,
AppletType_Default = -1,

View File

@ -1,3 +1,7 @@
#pragma once
#include <switch/types.h>
#include <switch/kernel/tmem.h>
struct bsd_sockaddr_in {
u8 sin_len;
u8 sin_family;

View File

@ -1 +1,4 @@
#pragma once
#include <switch/types.h>
__attribute__((noreturn)) void fatalSimple(Result err);

View File

@ -1,4 +1,7 @@
// Copyright 2017 plutoo
#pragma once
#include <switch/types.h>
#include <switch/services/sm.h>
// We use wrapped handles for type safety.

View File

@ -1,5 +1,8 @@
#pragma once
#include <assert.h>
#include <switch/types.h>
#include <switch/services/sm.h>
// Begin enums and output structs

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
typedef enum {
NVSERVTYPE_Default = -1,
NVSERVTYPE_Application = 0,

View File

@ -1,3 +1,6 @@
#pragma once
#include <switch/types.h>
// Copyright 2017 plutoo
Result pmdmntInitialize(void);
Result pmdmntStartProcess(u64 pid);

View File

@ -1,3 +1,8 @@
#pragma once
#include <switch/types.h>
#include <switch/kernel/svc.h>
#include <switch/ipc.h>
typedef enum {
ServiceType_Uninitialized,
ServiceType_Normal,

View File

@ -1,3 +1,7 @@
#pragma once
#include <switch/types.h>
#include <switch/services/sm.h>
/// usb:ds Switch-as-device<>host USB comms, see also here: http://switchbrew.org/index.php?title=USB_services
/// Names starting with "libusb" were changed to "usb" to avoid collision with actual libusb if it's ever used.

View File

@ -1,3 +1,7 @@
#pragma once
#include <switch/types.h>
#include <switch/services/sm.h>
typedef struct {
u64 display_id;
char display_name[0x40];

View File

@ -65,7 +65,7 @@ typedef enum {
#define NORETURN __attribute__((noreturn))
#define IGNORE_ARG(x) (void)(x)
#ifndef LIBCTRU_NO_DEPRECATION
#ifndef LIBNX_NO_DEPRECATION
/// Flags a function as deprecated.
#define DEPRECATED __attribute__ ((deprecated))
#else

View File

@ -1,5 +1,9 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/kernel/detect.h>
#include <switch/gfx/binder.h>
void binderCreateSession(Binder *session, Handle sessionHandle, s32 id)
{

View File

@ -1,5 +1,9 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/gfx/parcel.h>
#include <switch/gfx/buffer_producer.h>
// This implements the version of Android IGraphicBufferProducer used by Switch.
// Hence names/params etc here are based on Android IGraphicBufferProducer.cpp.

View File

@ -1,5 +1,14 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/fatal.h>
#include <switch/services/vi.h>
#include <switch/services/applet.h>
#include <switch/services/nv.h>
#include <switch/gfx/binder.h>
#include <switch/gfx/buffer_producer.h>
#include <switch/gfx/nvgfx.h>
#include <switch/gfx/gfx.h>
static bool g_gfxInitialized = 0;
static ViDisplay g_gfxDisplay;

View File

@ -1,5 +1,9 @@
#include <switch.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/nv.h>
#include <switch/gfx/ioctl.h>
#include <switch/gfx/nvioctl.h>
Result nvioctlChannel_SetNvmapFd(u32 fd, u32 nvmap_fd) {
struct {

View File

@ -1,5 +1,9 @@
#include <switch.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/nv.h>
#include <switch/gfx/ioctl.h>
#include <switch/gfx/nvioctl.h>
Result nvioctlNvhostAsGpu_BindChannel(u32 fd, u32 channel_fd) {
struct {

View File

@ -1,5 +1,9 @@
#include <switch.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/nv.h>
#include <switch/gfx/ioctl.h>
#include <switch/gfx/nvioctl.h>
Result nvioctlNvhostCtrlGpu_ZCullGetCtxSize(u32 fd, u32 *out) {
Result rc = 0;

View File

@ -1,5 +1,9 @@
#include <switch.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/nv.h>
#include <switch/gfx/ioctl.h>
#include <switch/gfx/nvioctl.h>
Result nvioctlNvhostCtrl_EventSignal(u32 fd, u32 event_id) {
struct {

View File

@ -1,5 +1,9 @@
#include <switch.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/nv.h>
#include <switch/gfx/ioctl.h>
#include <switch/gfx/nvioctl.h>
Result nvioctlNvmap_Create(u32 fd, u32 size, u32 *nvmap_handle) {
Result rc=0;

View File

@ -1,6 +1,14 @@
#include <string.h>
#include <malloc.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/arm.h>
#include <switch/result.h>
#include <switch/kernel/svc.h>
#include <switch/services/nv.h>
#include <switch/gfx/binder.h>
#include <switch/gfx/buffer_producer.h>
#include <switch/gfx/nvioctl.h>
#include <switch/gfx/nvgfx.h>
//#include "nvgfx_gpu_gpfifo_data0_bin.h"

View File

@ -1,5 +1,6 @@
#include <string.h>
#include <switch.h>
#include <switch/result.h>
#include <switch/gfx/parcel.h>
//This implements Android Parcel, hence names etc here are based on Android Parcel.cpp.

View File

@ -1,6 +1,7 @@
#pragma once
#include <sys/reent.h>
#include <switch.h>
#include <switch/arm.h>
#include <switch/types.h>
#include <switch/kernel/thread.h>
#define THREADVARS_MAGIC 0x21545624 // !TV$

View File

@ -1,5 +1,7 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <switch/types.h>
#include <switch/kernel/detect.h>
#include <switch/kernel/svc.h>
static bool g_IsAbove200;
static bool g_IsAbove300;

View File

@ -1,7 +1,14 @@
// Copyright 2018 plutoo
#include <switch.h>
#include <malloc.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/runtime/env.h>
#include <switch/kernel/svc.h>
#include <switch/kernel/detect.h>
#include <switch/kernel/virtmem.h>
#include <switch/kernel/jit.h>
Result jitCreate(Jit* j, size_t size)
{
JitType type;

View File

@ -1,5 +1,6 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <switch/kernel/svc.h>
#include <switch/kernel/mutex.h>
#include "../internal.h"
#define HAS_LISTENERS 0x40000000

View File

@ -6,7 +6,13 @@
Modified by plutoo.
*/
#include <switch.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/fatal.h>
#include <switch/kernel/mutex.h>
#include <switch/kernel/svc.h>
#include <switch/kernel/random.h>
#define ROTL32(x, n) (((x) << (n)) | ((x) >> (32-(n))))

View File

@ -1,5 +1,6 @@
// Copyright 2018 plutoo
#include <switch.h>
#include <switch/kernel/mutex.h>
#include <switch/kernel/rwlock.h>
void rwlockReadLock(RwLock* r) {
rmutexLock(&r->r);

View File

@ -1,6 +1,10 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <malloc.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/kernel/svc.h>
#include <switch/kernel/virtmem.h>
#include <switch/kernel/shmem.h>
Result shmemCreate(SharedMemory* s, size_t size, Permission local_perm, Permission remote_perm)
{

View File

@ -1,6 +1,11 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <malloc.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/kernel/svc.h>
#include <switch/kernel/virtmem.h>
#include <switch/kernel/thread.h>
#include "../internal.h"
extern const u8 __tdata_lma[];

View File

@ -1,6 +1,10 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <malloc.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/kernel/svc.h>
#include <switch/kernel/tmem.h>
#include <switch/kernel/virtmem.h>
Result tmemCreate(TransferMemory* t, size_t size, Permission perm)
{

View File

@ -1,4 +1,10 @@
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/fatal.h>
#include <switch/kernel/detect.h>
#include <switch/kernel/mutex.h>
#include <switch/kernel/svc.h>
#include <switch/kernel/virtmem.h>
typedef struct {
u64 start;

View File

@ -1,7 +1,7 @@
#include <switch.h>
#include <string.h>
#include <ctype.h>
#include <switch/result.h>
#include <switch/kernel/svc.h>
// System globals we define here
int __system_argc;

View File

@ -1,7 +1,9 @@
#include <stdio.h>
#include <string.h>
#include <sys/iosupport.h>
#include <switch.h>
#include <switch/runtime/devices/console.h>
#include <switch/kernel/svc.h>
#include <switch/gfx/gfx.h>
#include "default_font_bin.h"

View File

@ -8,7 +8,9 @@
#include <sys/param.h>
#include <unistd.h>
#include <switch.h>
#include <switch/runtime/devices/fs_dev.h>
#include <switch/runtime/util/utf.h>
#include <switch/services/fs.h>
/*! @internal

View File

@ -1,6 +1,10 @@
#include <string.h>
#include <malloc.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/services/fatal.h>
#include <switch/services/usb.h>
#include <switch/runtime/devices/usb_comms.h>
static bool g_usbCommsInitialized = false;

View File

@ -1,4 +1,5 @@
#include <switch.h>
#include <switch/result.h>
#include <switch/services/fatal.h>
#include <elf.h>
void __nx_dynamic(uintptr_t base, const Elf64_Dyn* dyn)

View File

@ -1,5 +1,8 @@
// Copyright 2018 plutoo
#include <switch.h>
#include <string.h>
#include <switch/runtime/env.h>
#include <switch/services/sm.h>
#include <switch/services/fatal.h>
static bool g_isNso = false;
static Handle g_mainThreadHandle = INVALID_HANDLE;

View File

@ -1,4 +1,11 @@
#include <switch.h>
#include <switch/types.h>
#include <switch/runtime/env.h>
#include <switch/services/sm.h>
#include <switch/services/fatal.h>
#include <switch/services/fs.h>
#include <switch/services/hid.h>
#include <switch/services/applet.h>
void __nx_exit(int rc);

View File

@ -1,9 +1,14 @@
#include <switch.h>
#include <string.h>
#include <sys/iosupport.h>
#include <sys/time.h>
#include <sys/lock.h>
#include <sys/reent.h>
#include "../internal.h"
#include <switch/types.h>
#include <switch/runtime/env.h>
#include <switch/kernel/mutex.h>
#include <switch/services/fatal.h>
#include <switch/result.h>
void __attribute__((weak)) NORETURN __libnx_exit(int rc);

View File

@ -1,5 +1,4 @@
#include "switch/types.h"
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
decode_utf16(uint32_t *out,

View File

@ -1,4 +1,4 @@
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
decode_utf8(uint32_t *out,

View File

@ -1,4 +1,4 @@
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
encode_utf16(uint16_t *out,

View File

@ -1,4 +1,4 @@
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
encode_utf8(uint8_t *out,

View File

@ -1,5 +1,4 @@
#include "switch/types.h"
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
utf16_to_utf32(uint32_t *out,

View File

@ -1,5 +1,4 @@
#include "switch/types.h"
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
utf16_to_utf8(uint8_t *out,

View File

@ -1,5 +1,5 @@
#include "switch/types.h"
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
utf32_to_utf16(uint16_t *out,

View File

@ -1,5 +1,4 @@
#include "switch/types.h"
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
utf32_to_utf8(uint8_t *out,

View File

@ -1,5 +1,4 @@
#include "switch/types.h"
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
utf8_to_utf16(uint16_t *out,

View File

@ -1,5 +1,4 @@
#include "switch/types.h"
#include "switch/runtime/util/utf.h"
#include <switch/runtime/util/utf.h>
ssize_t
utf8_to_utf32(uint32_t *out,

View File

@ -1,5 +1,6 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/services/acc.h>
#include <switch/services/sm.h>
static Service g_accSrv;

View File

@ -1,5 +1,8 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/apm.h>
#include <switch/services/sm.h>
static Service g_apmSrv;
static Service g_apmISession;

View File

@ -1,5 +1,12 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/fatal.h>
#include <switch/services/applet.h>
#include <switch/services/apm.h>
#include <switch/services/sm.h>
#include <switch/kernel/detect.h>
__attribute__((weak)) u32 __nx_applet_type = AppletType_Default;
__attribute__((weak)) bool __nx_applet_auto_notifyrunning = true;

View File

@ -1,5 +1,11 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/bsd.h>
#include <switch/services/sm.h>
#include <switch/kernel/shmem.h>
#include <switch/kernel/rwlock.h>
static Service g_bsdSrv;
static Service g_bsdMonitor;

View File

@ -1,5 +1,11 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/fatal.h>
#include <switch/services/sm.h>
#include <switch/kernel/detect.h>
#include <switch/kernel/svc.h>
void fatalSimple(Result err) {
Result rc = 0;

View File

@ -1,5 +1,10 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <string.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/fs.h>
#include <switch/services/sm.h>
static Service g_fsSrv;

View File

@ -1,5 +1,12 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/applet.h>
#include <switch/services/hid.h>
#include <switch/services/sm.h>
#include <switch/kernel/shmem.h>
#include <switch/kernel/rwlock.h>
static Service g_hidSrv;
static Service g_hidIAppletResource;

View File

@ -1,5 +1,12 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/applet.h>
#include <switch/gfx/ioctl.h>
#include <switch/services/nv.h>
#include <switch/services/sm.h>
#include <switch/kernel/tmem.h>
static Service g_nvSrv;
static size_t g_nvIpcBufferSize = 0;

View File

@ -1,5 +1,9 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/pm.h>
#include <switch/services/sm.h>
static Service g_pmdmntSrv;

View File

@ -1,5 +1,9 @@
// Copyright 2017 plutoo
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/fatal.h>
#include <switch/services/sm.h>
static Handle g_smHandle = INVALID_HANDLE;

View File

@ -1,5 +1,10 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/kernel/detect.h>
#include <switch/services/usb.h>
#include <switch/services/sm.h>
#define TOTAL_INTERFACES 4
#define TOTAL_ENDPOINTS 15*2

View File

@ -1,5 +1,10 @@
#include <string.h>
#include <switch.h>
#include <switch/types.h>
#include <switch/result.h>
#include <switch/ipc.h>
#include <switch/services/applet.h>
#include <switch/services/vi.h>
#include <switch/kernel/detect.h>
static Service g_viSrv;