mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
ae65e281f3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
//===- support.go - Bindings for support ----------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines bindings for the support component.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
package llvm
|
|
|
|
/*
|
|
#include "llvm-c/Support.h"
|
|
#include "SupportBindings.h"
|
|
#include <stdlib.h>
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"errors"
|
|
"unsafe"
|
|
)
|
|
|
|
// Loads a dynamic library such that it may be used as an LLVM plugin.
|
|
// See llvm::sys::DynamicLibrary::LoadLibraryPermanently.
|
|
func LoadLibraryPermanently(lib string) error {
|
|
var errstr *C.char
|
|
libstr := C.CString(lib)
|
|
defer C.free(unsafe.Pointer(libstr))
|
|
C.LLVMLoadLibraryPermanently2(libstr, &errstr)
|
|
if errstr != nil {
|
|
err := errors.New(C.GoString(errstr))
|
|
C.free(unsafe.Pointer(errstr))
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Parse the given arguments using the LLVM command line parser.
|
|
// See llvm::cl::ParseCommandLineOptions.
|
|
func ParseCommandLineOptions(args []string, overview string) {
|
|
argstrs := make([]*C.char, len(args))
|
|
for i, arg := range args {
|
|
argstrs[i] = C.CString(arg)
|
|
defer C.free(unsafe.Pointer(argstrs[i]))
|
|
}
|
|
overviewstr := C.CString(overview)
|
|
defer C.free(unsafe.Pointer(overviewstr))
|
|
C.LLVMParseCommandLineOptions(C.int(len(args)), &argstrs[0], overviewstr)
|
|
}
|