libctru  v2.4.1
env.h
Go to the documentation of this file.
1 /**
2  * @file env.h
3  * @brief Homebrew environment information.
4  */
5 #pragma once
6 
7 /// System run-flags.
8 enum {
9  RUNFLAG_APTWORKAROUND = BIT(0), ///< Use APT workaround.
10  RUNFLAG_APTREINIT = BIT(1), ///< Reinitialize APT.
11  RUNFLAG_APTCHAINLOAD = BIT(2), ///< Chainload APT on return.
12 };
13 
14 /**
15  * @brief Gets whether the application was launched from a homebrew environment.
16  * @return Whether the application was launched from a homebrew environment.
17  */
18 static inline bool envIsHomebrew(void) {
19  extern void* __service_ptr;
20  return __service_ptr != NULL;
21 }
22 
23 /**
24  * @brief Retrieves a handle from the environment handle list.
25  * @param name Name of the handle.
26  * @return The retrieved handle.
27  */
28 Handle envGetHandle(const char* name);
29 
30 /**
31  * @brief Gets the environment-recommended app ID to use with APT.
32  * @return The APT app ID.
33  */
34 static inline u32 envGetAptAppId(void) {
35  extern u32 __apt_appid;
36  return __apt_appid;
37 }
38 
39 /**
40  * @brief Gets the size of the application heap.
41  * @return The application heap size.
42  */
43 static inline u32 envGetHeapSize(void) {
44  extern u32 __ctru_heap_size;
45  return __ctru_heap_size;
46 }
47 
48 /**
49  * @brief Gets the size of the linear heap.
50  * @return The linear heap size.
51  */
52 static inline u32 envGetLinearHeapSize(void) {
53  extern u32 __ctru_linear_heap_size;
54  return __ctru_linear_heap_size;
55 }
56 
57 /**
58  * @brief Gets the environment argument list.
59  * @return The argument list.
60  */
61 static inline const char* envGetSystemArgList(void) {
62  extern const char* __system_arglist;
63  return __system_arglist;
64 }
65 
66 /**
67  * @brief Gets the environment run flags.
68  * @return The run flags.
69  */
70 static inline u32 envGetSystemRunFlags(void) {
71  extern u32 __system_runflags;
72  return __system_runflags;
73 }
static const char * envGetSystemArgList(void)
Gets the environment argument list.
Definition: env.h:61
static u32 envGetAptAppId(void)
Gets the environment-recommended app ID to use with APT.
Definition: env.h:34
static bool envIsHomebrew(void)
Gets whether the application was launched from a homebrew environment.
Definition: env.h:18
@ RUNFLAG_APTREINIT
Reinitialize APT.
Definition: env.h:10
@ RUNFLAG_APTCHAINLOAD
Chainload APT on return.
Definition: env.h:11
@ RUNFLAG_APTWORKAROUND
Use APT workaround.
Definition: env.h:9
static u32 envGetHeapSize(void)
Gets the size of the application heap.
Definition: env.h:43
static u32 envGetSystemRunFlags(void)
Gets the environment run flags.
Definition: env.h:70
Handle envGetHandle(const char *name)
Retrieves a handle from the environment handle list.
static u32 envGetLinearHeapSize(void)
Gets the size of the linear heap.
Definition: env.h:52
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
u32 Handle
Resource handle.
Definition: types.h:41
uint32_t u32
32-bit unsigned integer
Definition: types.h:23