brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · ee0abbf Raw
65 lines · cpp
1/*2 * kmp_ftn_cdecl.cpp -- Fortran __cdecl linkage support for OpenMP.3 */4 5//===----------------------------------------------------------------------===//6//7// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.8// See https://llvm.org/LICENSE.txt for license information.9// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception10//11//===----------------------------------------------------------------------===//12 13#include "kmp.h"14#include "kmp_affinity.h"15 16#if KMP_OS_WINDOWS17#if defined KMP_WIN_CDECL || !KMP_DYNAMIC_LIB18#define KMP_FTN_ENTRIES KMP_FTN_UPPER19#endif20#elif KMP_OS_UNIX21#define KMP_FTN_ENTRIES KMP_FTN_PLAIN22#endif23 24// Note: This string is not printed when KMP_VERSION=1.25char const __kmp_version_ftncdecl[] =26    KMP_VERSION_PREFIX "Fortran __cdecl OMP support: "27#ifdef KMP_FTN_ENTRIES28                       "yes";29#define FTN_STDCALL /* no stdcall */30#include "kmp_ftn_os.h"31#include "kmp_ftn_entry.h"32 33// FIXME: this is a hack to get the UID functions working for C.34// It will be moved and also made available for Fortran in a follow-up patch.35extern "C" {36const char *FTN_STDCALL omp_get_uid_from_device(int device_num)37    KMP_WEAK_ATTRIBUTE_EXTERNAL;38const char *FTN_STDCALL omp_get_uid_from_device(int device_num) {39#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)40  return nullptr;41#else42  const char *(*fptr)(int);43  if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_uid_from_device")))44    return (*fptr)(device_num);45  // Returns the same string as used by libomptarget46  return "HOST";47#endif48}49int FTN_STDCALL omp_get_device_from_uid(const char *device_uid)50    KMP_WEAK_ATTRIBUTE_EXTERNAL;51int FTN_STDCALL omp_get_device_from_uid(const char *device_uid) {52#if KMP_OS_DARWIN || KMP_OS_WASI || defined(KMP_STUB)53  return omp_invalid_device;54#else55  int (*fptr)(const char *);56  if ((*(void **)(&fptr) = KMP_DLSYM_NEXT("omp_get_device_from_uid")))57    return (*fptr)(device_uid);58  return KMP_EXPAND_NAME(FTN_GET_INITIAL_DEVICE)();59#endif60}61}62#else63                       "no";64#endif /* KMP_FTN_ENTRIES */65