Skip to content

Commit

Permalink
[libobject] Remove the remaining "magenta" strings from kernel/object
Browse files Browse the repository at this point in the history
* Comment tweaks
* magenta_thread_process_name -> get_user_thread_process_name
  * Made its user_thread* param const as well, along with
    ThreadDispatcher::process().

Remaining "magenta" instances refer to public/magenta or to the name of
the project, not to the old libmagenta.

Change-Id: Idf192c92e559c354a823d35b1f641b80caef8d7f
  • Loading branch information
dbort authored and CQ bot account: [email protected] committed Sep 7, 2017
1 parent 90f33bb commit e892dc2
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion kernel/kernel/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ thread_t* thread_create_idle_thread(uint cpu_num) {

void thread_owner_name(thread_t* t, char out_name[THREAD_NAME_LENGTH]) {
if (t->user_thread) {
magenta_thread_process_name(t->user_thread, out_name);
get_user_thread_process_name(t->user_thread, out_name);
return;
}
memcpy(out_name, "kernel", 7);
Expand Down
2 changes: 1 addition & 1 deletion kernel/object/diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,5 +840,5 @@ static int cmd_diagnostics(int argc, const cmd_args* argv, uint32_t flags) {
}

STATIC_COMMAND_START
STATIC_COMMAND("mx", "magenta diagnostics", &cmd_diagnostics)
STATIC_COMMAND("mx", "kernel object diagnostics", &cmd_diagnostics)
STATIC_COMMAND_END(mx);
19 changes: 11 additions & 8 deletions kernel/object/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,27 @@ static handler_status_t exception_handler_worker(uint exception_type,
return HS_NOT_HANDLED;
}

// Dispatches an exception to the appropriate handler.
// Called by arch code when it cannot handle an exception.
// Dispatches an exception to the appropriate handler. Called by arch code
// when it cannot handle an exception.
//
// If we return MX_OK, the caller is expected to resume the thread "as if"
// nothing happened, the handler is expected to have modified state such that
// resumption is possible.
// Otherwise, if we return, the result is MX_ERR_BAD_STATE meaning the thread is
// not a magenta thread.
//
// TODO(dje): Support unwinding from this exception and introducing a
// different exception?
// If we return MX_ERR_BAD_STATE, the current thread is not a user thread
// (i.e., not associated with a ThreadDispatcher).
//
// Otherwise, we cause the current thread to exit and do not return at all.
//
// TODO(dje): Support unwinding from this exception and introducing a different
// exception?
status_t dispatch_user_exception(uint exception_type,
arch_exception_context_t* context) {
LTRACEF("type %u, context %p\n", exception_type, context);

ThreadDispatcher* thread = ThreadDispatcher::GetCurrent();
if (unlikely(!thread)) {
// we're not in magenta thread context, bail
// The current thread is not a user thread; bail.
return MX_ERR_BAD_STATE;
}

Expand Down Expand Up @@ -234,7 +237,7 @@ status_t dispatch_user_exception(uint exception_type,
process->get_name(pname);
char tname[MX_MAX_NAME_LEN];
thread->get_name(tname);
printf("KERN: %s in magenta thread '%s' in process '%s'\n",
printf("KERN: %s in user thread '%s' in process '%s'\n",
excp_type_to_string(exception_type), tname, pname);

arch_dump_exception_context(context);
Expand Down
6 changes: 3 additions & 3 deletions kernel/object/glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ size_t internal::OutstandingHandles() {
static fbl::RefPtr<JobDispatcher> root_job;

// The singleton policy manager, for jobs and processes. This is
// a magenta internal class (not a dispatcher-derived).
// not a Dispatcher, just a plain class.
static PolicyManager* policy_manager;

// Masks for building a Handle's base_value, which ProcessDispatcher
Expand Down Expand Up @@ -453,7 +453,7 @@ static void oom_lowmem(size_t shortfall_bytes) {
});
}

void magenta_init(uint level) TA_NO_THREAD_SAFETY_ANALYSIS {
static void object_glue_init(uint level) TA_NO_THREAD_SAFETY_ANALYSIS {
handle_arena.Init("handles", sizeof(Handle), kMaxHandleCount);
root_job = JobDispatcher::CreateRootJob();
policy_manager = PolicyManager::Create();
Expand All @@ -465,4 +465,4 @@ void magenta_init(uint level) TA_NO_THREAD_SAFETY_ANALYSIS {
oom_lowmem);
}

LK_INIT_HOOK(magenta, magenta_init, LK_INIT_LEVEL_THREADING);
LK_INIT_HOOK(libobject, object_glue_init, LK_INIT_LEVEL_THREADING);
4 changes: 2 additions & 2 deletions kernel/object/include/object/c_user_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ __BEGIN_CDECLS

// This is the interface for LK's thread_owner_name to return the
// name of the thread's process.
// This function is defined in user_thread.cpp.
void magenta_thread_process_name(void* user_thread, char out_name[THREAD_NAME_LENGTH]);
void get_user_thread_process_name(const void* user_thread,
char out_name[THREAD_NAME_LENGTH]);

__END_CDECLS
2 changes: 1 addition & 1 deletion kernel/object/include/object/dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Dispatcher : public fbl::RefCounted<Dispatcher> {

mx_koid_t get_koid() const { return koid_; }

// Updating |handle_count_| is done at the magenta handle management layer.
// Updating |handle_count_| is done at the Handle management layer.
uint32_t* get_handle_count_ptr() { return &handle_count_; }

// Interface for derived classes.
Expand Down
4 changes: 2 additions & 2 deletions kernel/object/include/object/thread_dispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ThreadDispatcher final : public Dispatcher {
// segfault. In linux the signal would be delivered to the thread,
// which would either terminate the process or run a signal handler if
// defined. In magenta this gives the next signal handler in the list
// a crack at // the exception.
// a crack at the exception.
TRY_NEXT,

// The exception has been handled, resume the thread.
Expand Down Expand Up @@ -107,7 +107,7 @@ class ThreadDispatcher final : public Dispatcher {
mx_status_t Resume();

// accessors
ProcessDispatcher* process() { return process_.get(); }
ProcessDispatcher* process() const { return process_.get(); }

FutexNode* futex_node() { return &futex_node_; }
mx_status_t set_name(const char* name, size_t len) final;
Expand Down
6 changes: 4 additions & 2 deletions kernel/object/thread_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,10 @@ mx_status_t ThreadDispatcher::WriteState(uint32_t state_kind, const void* buffer
}
}

void magenta_thread_process_name(void* user_thread, char out_name[MX_MAX_NAME_LEN]) {
ThreadDispatcher* ut = reinterpret_cast<ThreadDispatcher*>(user_thread);
void get_user_thread_process_name(const void* user_thread,
char out_name[MX_MAX_NAME_LEN]) {
const ThreadDispatcher* ut =
reinterpret_cast<const ThreadDispatcher*>(user_thread);
ut->process()->get_name(out_name);
}

Expand Down
6 changes: 3 additions & 3 deletions kernel/object/timer_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ void TimerDispatcher::OnTimerFired() {
}
}


// This could be the last reference so we might need to destroy ourselves.
// In Magenta RefPtrs, the 'delete' is called by the holder of the object.
// Drop the RefCounted reference that was added in Set(). If this was the
// last reference, the RefCounted contract requires that we delete
// ourselves.
if (Release())
delete this;
}

0 comments on commit e892dc2

Please sign in to comment.