Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
46b35a36
Commit
46b35a36
authored
May 19, 2014
by
Robert McGibbon
Browse files
separate files
parent
4b1c362c
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
42 deletions
+77
-42
openmmapi/include/openmm/Context.h
openmmapi/include/openmm/Context.h
+1
-1
openmmapi/include/openmm/internal/osrngseed.h
openmmapi/include/openmm/internal/osrngseed.h
+2
-34
openmmapi/src/AndersenThermostat.cpp
openmmapi/src/AndersenThermostat.cpp
+1
-1
openmmapi/src/BrownianIntegrator.cpp
openmmapi/src/BrownianIntegrator.cpp
+1
-1
openmmapi/src/CustomIntegrator.cpp
openmmapi/src/CustomIntegrator.cpp
+1
-1
openmmapi/src/LangevinIntegrator.cpp
openmmapi/src/LangevinIntegrator.cpp
+1
-1
openmmapi/src/MonteCarloAnisotropicBarostat.cpp
openmmapi/src/MonteCarloAnisotropicBarostat.cpp
+1
-1
openmmapi/src/MonteCarloBarostat.cpp
openmmapi/src/MonteCarloBarostat.cpp
+1
-1
openmmapi/src/OSRngSeed.cpp
openmmapi/src/OSRngSeed.cpp
+67
-0
openmmapi/src/VariableLangevinIntegrator.cpp
openmmapi/src/VariableLangevinIntegrator.cpp
+1
-1
No files found.
openmmapi/include/openmm/Context.h
View file @
46b35a36
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "internal/windowsExport.h"
#include "internal/windowsExport.h"
#include "internal/
osr
ng
s
eed.h"
#include "internal/
OSR
ng
S
eed.h"
namespace
OpenMM
{
namespace
OpenMM
{
...
...
openmmapi/include/openmm/internal/osrngseed.h
View file @
46b35a36
...
@@ -33,15 +33,7 @@
...
@@ -33,15 +33,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include <stdexcept>
#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
static
HCRYPTPROV
hCryptProv
=
0
;
#pragma comment(lib, "advapi32.lib")
#else
#include <fcntl.h>
#include <unistd.h>
#endif
/**
/**
* Return an integer int for use as a seed for a random number generator.
* Return an integer int for use as a seed for a random number generator.
...
@@ -50,30 +42,6 @@ static HCRYPTPROV hCryptProv = 0;
...
@@ -50,30 +42,6 @@ static HCRYPTPROV hCryptProv = 0;
* this uses CryptGenRandom from the CryptoAPI to get a single int. On other
* this uses CryptGenRandom from the CryptoAPI to get a single int. On other
* platforms (*nix, apple), we read from /dev/urandom
* platforms (*nix, apple), we read from /dev/urandom
*/
*/
int
osrngseed
(
void
)
{
int
osrngseed
(
void
);
int
value
;
#if defined(_WIN32) || defined(__CYGWIN__)
if
(
!::
CryptAcquireContextW
(
&
hCryptProv
,
0
,
0
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
|
CRYPT_SILENT
))
{
throw
std
::
runtime_error
(
"Failed to initialize Windows random API (CryptoGen)"
);
}
if
(
!
CryptGenRandom
(
hCryptProv
,
sizeof
(
int
),
(
BYTE
*
)
&
value
))
{
::
CryptReleaseContext
(
hCryptProv
,
0
);
throw
std
::
runtime_error
(
"Failed to get random numbers"
);
}
if
(
!::
CryptReleaseContext
(
hCryptProv
,
0
))
{
throw
std
::
runtime_error
(
"Failed to release Windows random API context"
);
}
#else
int
m_fd
=
open
(
"/dev/urandom"
,
O_RDONLY
);
if
(
m_fd
==
-
1
)
{
throw
std
::
runtime_error
(
"Failed to open /dev/urandom"
);
}
if
(
read
(
m_fd
,
&
value
,
sizeof
(
int
))
!=
sizeof
(
int
))
{
throw
std
::
runtime_error
(
"Failed to read bytes from /dev/urandom"
);
}
close
(
m_fd
);
#endif
return
value
;
}
#endif
/* OPENMM_OSRNGSEED_H_ */
#endif
/* OPENMM_OSRNGSEED_H_ */
\ No newline at end of file
openmmapi/src/AndersenThermostat.cpp
View file @
46b35a36
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include "openmm/AndersenThermostat.h"
#include "openmm/AndersenThermostat.h"
#include "openmm/internal/AndersenThermostatImpl.h"
#include "openmm/internal/AndersenThermostatImpl.h"
#include "openmm/internal/
osr
ng
s
eed.h"
#include "openmm/internal/
OSR
ng
S
eed.h"
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
...
openmmapi/src/BrownianIntegrator.cpp
View file @
46b35a36
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/
osr
ng
s
eed.h"
#include "openmm/internal/
OSR
ng
S
eed.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <string>
#include <string>
...
...
openmmapi/src/CustomIntegrator.cpp
View file @
46b35a36
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
#include "openmm/OpenMMException.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/
osr
ng
s
eed.h"
#include "openmm/internal/
OSR
ng
S
eed.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <string>
#include <string>
...
...
openmmapi/src/LangevinIntegrator.cpp
View file @
46b35a36
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/
osr
ng
s
eed.h"
#include "openmm/internal/
OSR
ng
S
eed.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <string>
#include <string>
...
...
openmmapi/src/MonteCarloAnisotropicBarostat.cpp
View file @
46b35a36
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include "openmm/MonteCarloAnisotropicBarostat.h"
#include "openmm/internal/MonteCarloAnisotropicBarostatImpl.h"
#include "openmm/internal/MonteCarloAnisotropicBarostatImpl.h"
#include "openmm/internal/
osr
ng
s
eed.h"
#include "openmm/internal/
OSR
ng
S
eed.h"
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
...
openmmapi/src/MonteCarloBarostat.cpp
View file @
46b35a36
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include "openmm/MonteCarloBarostat.h"
#include "openmm/MonteCarloBarostat.h"
#include "openmm/internal/MonteCarloBarostatImpl.h"
#include "openmm/internal/MonteCarloBarostatImpl.h"
#include "openmm/internal/
osr
ng
s
eed.h"
#include "openmm/internal/
OSR
ng
S
eed.h"
using
namespace
OpenMM
;
using
namespace
OpenMM
;
...
...
openmmapi/src/OSRngSeed.cpp
0 → 100644
View file @
46b35a36
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2013 Stanford University and the Authors. *
* Authors: Robert T. McGibbon *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include <stdexcept>
#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
static
HCRYPTPROV
hCryptProv
=
0
;
#pragma comment(lib, "advapi32.lib")
#else
#include <fcntl.h>
#include <unistd.h>
#endif
#include "internal/OSRngSeed.h"
int
osrngseed
(
void
)
{
int
value
;
#if defined(_WIN32) || defined(__CYGWIN__)
if
(
!::
CryptAcquireContextW
(
&
hCryptProv
,
0
,
0
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
|
CRYPT_SILENT
))
{
throw
std
::
runtime_error
(
"Failed to initialize Windows random API (CryptoGen)"
);
}
if
(
!
CryptGenRandom
(
hCryptProv
,
sizeof
(
int
),
(
BYTE
*
)
&
value
))
{
::
CryptReleaseContext
(
hCryptProv
,
0
);
throw
std
::
runtime_error
(
"Failed to get random numbers"
);
}
if
(
!::
CryptReleaseContext
(
hCryptProv
,
0
))
{
throw
std
::
runtime_error
(
"Failed to release Windows random API context"
);
}
#else
int
m_fd
=
open
(
"/dev/urandom"
,
O_RDONLY
);
if
(
m_fd
==
-
1
)
{
throw
std
::
runtime_error
(
"Failed to open /dev/urandom"
);
}
if
(
read
(
m_fd
,
&
value
,
sizeof
(
int
))
!=
sizeof
(
int
))
{
throw
std
::
runtime_error
(
"Failed to read bytes from /dev/urandom"
);
}
close
(
m_fd
);
#endif
return
value
;
}
\ No newline at end of file
openmmapi/src/VariableLangevinIntegrator.cpp
View file @
46b35a36
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/
osr
ng
s
eed.h"
#include "openmm/internal/
OSR
ng
S
eed.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <limits>
#include <limits>
#include <string>
#include <string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment