-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
386fix #4076
Closed
+417
−54
Closed
386fix #4076
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4c6940f
WIP: Fix for 32 bit, but now only 32bit compatible. Will need to figu…
6efde55
Fix: UseWinTimestamps is now configurable
srclosson 77f45ba
Updated readme.md
srclosson af43fc0
Changes made wrt https://github.com/influxdata/telegraf/pull/4076/files
srclosson 930ea8e
Updated readme from nodename to computer
srclosson 4559ff9
Oone more documentation update found and fixed
srclosson ae0c16e
Fix: Moved item nodename declaration to computer. Made sure not to ta…
srclosson c271d08
Revert: Line fix
srclosson cbd85c7
Update: Feedback from code review
srclosson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright (c) 2010 The win Authors. All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions | ||
// are met: | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// 3. The names of the authors may not be used to endorse or promote products | ||
// derived from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR | ||
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
// This is the official list of 'win' authors for copyright purposes. | ||
// | ||
// Alexander Neumann <[email protected]> | ||
// Joseph Watson <[email protected]> | ||
// Kevin Pors <[email protected]> | ||
|
||
// +build windows | ||
|
||
package win_perf_counters | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
type SYSTEMTIME struct { | ||
wYear uint16 | ||
wMonth uint16 | ||
wDayOfWeek uint16 | ||
wDay uint16 | ||
wHour uint16 | ||
wMinute uint16 | ||
wSecond uint16 | ||
wMilliseconds uint16 | ||
} | ||
|
||
type FILETIME struct { | ||
dwLowDateTime uint32 | ||
dwHighDateTime uint32 | ||
} | ||
|
||
var ( | ||
// Library | ||
libkrnDll *syscall.DLL | ||
|
||
// Functions | ||
krn_FileTimeToSystemTime *syscall.Proc | ||
krn_FileTimeToLocalFileTime *syscall.Proc | ||
krn_LocalFileTimeToFileTime *syscall.Proc | ||
krn_WideCharToMultiByte *syscall.Proc | ||
) | ||
|
||
func init() { | ||
libkrnDll = syscall.MustLoadDLL("Kernel32.dll") | ||
|
||
krn_FileTimeToSystemTime = libkrnDll.MustFindProc("FileTimeToSystemTime") | ||
krn_FileTimeToLocalFileTime = libkrnDll.MustFindProc("FileTimeToLocalFileTime") | ||
krn_LocalFileTimeToFileTime = libkrnDll.MustFindProc("LocalFileTimeToFileTime") | ||
krn_WideCharToMultiByte = libkrnDll.MustFindProc("WideCharToMultiByte") | ||
} | ||
|
||
// CURRENTLY UNUSED: But may be useful in the future | ||
// | ||
// The windows native call for converting a 16-bit wide character string (UTF-16) to a null terminated string. | ||
// | ||
// Note: If you call the function and not pass in an out string, the return value will be the length of the | ||
// input string. | ||
// Example usage: | ||
// cc, err := WideCharToMultiByte(65001, 0, s, -1, nil, 0) | ||
// if err != nil { | ||
// fmt.Println("CONVERSION ERROR: ", err) | ||
// } | ||
// | ||
// fmt.Println("Length bytes: ", cc) | ||
// n, err := WideCharToMultiByte(65001, 0, s, 1<<29, &outStr[0], 1<<29) | ||
// if err != nil { | ||
// fmt.Println("CONVERSION ERROR: ", err) | ||
// } | ||
// fmt.Println("Converted bytes: ", n) | ||
// | ||
func WideCharToMultiByte(codePage uint32, dwFlags uint32, wchar *uint16, nwchar int32, str *byte, nstr int32) (nwrite int32, err error) { | ||
r0, _, e1 := krn_WideCharToMultiByte.Call( | ||
uintptr(codePage), | ||
uintptr(dwFlags), | ||
uintptr(unsafe.Pointer(str)), | ||
uintptr(nstr), | ||
uintptr(unsafe.Pointer(wchar)), | ||
uintptr(nwchar), | ||
) | ||
|
||
nwrite = int32(r0) | ||
if nwrite == 0 { | ||
if e1 != nil { | ||
err = errnoErr(e1.(syscall.Errno)) | ||
} else { | ||
err = syscall.EINVAL | ||
} | ||
} | ||
|
||
return nwrite, err | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark this as optional