Converted curenv calls into an opaque macro
[akaros.git] / include / env.h
index d6adb2c..6a3012e 100644 (file)
@@ -24,6 +24,12 @@ void (IN_HANDLER env_destroy)(env_t *SAFE e);        // Does not return if e == curenv
 // Temporary scheduler function
 void   schedule(void);
 
+/*
+ * Allows the kernel to figure out what process is running on its core.
+ * Can be used just like a pointer to a struct process.
+ */
+#define current (curenvs[lapic_get_id()])
+
 int    envid2env(envid_t envid, env_t **env_store, bool checkperm);
 // The following three functions do not return
 void   (IN_HANDLER env_run)(env_t *e) __attribute__((noreturn));
@@ -37,8 +43,10 @@ void run_env_handler(trapframe_t *tf, void* data);
 #define ENV_CREATE(x)                  ({                                             \
        extern uint8_t _binary_obj_user_apps_##x##_start[],                        \
                _binary_obj_user_apps_##x##_size[];                                    \
-       env_create(_binary_obj_user_apps_##x##_start,                              \
+       env_t *e = env_create(_binary_obj_user_apps_##x##_start,                   \
                (int)_binary_obj_user_apps_##x##_size);                                \
+       e->env_status = ENV_RUNNABLE;                                              \
+       e;                                                                         \
 })
 
 #endif // !ROS_KERN_ENV_H