Home | History | Annotate | Download | only in core
      1 // Copyright 2018 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "base/time/time.h"
      6 #include "mojo/core/core.h"
      7 #include "mojo/core/entrypoints.h"
      8 #include "mojo/public/c/system/core.h"
      9 #include "mojo/public/c/system/thunks.h"
     10 
     11 extern "C" {
     12 
     13 namespace {
     14 
     15 MojoResult InitializeImpl(const struct MojoInitializeOptions* options) {
     16   mojo::core::InitializeCore();
     17   return MOJO_RESULT_OK;
     18 }
     19 
     20 MojoSystemThunks g_thunks = {0};
     21 
     22 }  // namespace
     23 
     24 #if defined(WIN32)
     25 #define EXPORT_FROM_MOJO_CORE __declspec(dllexport)
     26 #else
     27 #define EXPORT_FROM_MOJO_CORE __attribute__((visibility("default")))
     28 #endif
     29 
     30 EXPORT_FROM_MOJO_CORE void MojoGetSystemThunks(MojoSystemThunks* thunks) {
     31   if (!g_thunks.size) {
     32     g_thunks = mojo::core::GetSystemThunks();
     33     g_thunks.Initialize = InitializeImpl;
     34   }
     35 
     36   // Since this is the first version of the library, no valid system API
     37   // implementation can request fewer thunks than we have available.
     38   CHECK_GE(thunks->size, g_thunks.size);
     39   memcpy(thunks, &g_thunks, g_thunks.size);
     40 }
     41 
     42 }  // extern "C"
     43