aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-07 16:23:27 +0000
committerlloyd <[email protected]>2010-09-07 16:23:27 +0000
commitb9534e818f443c6439c294ee694fa0774bc6d79b (patch)
treedfa8fa636ced4123ed1691b1477fdd094e61a532 /src
parentd8fcd41ea72d7e00924bb78baa698565de825844 (diff)
parentad3427826a6dc2113142f1fbee158d79cd3e046d (diff)
propagate from branch 'net.randombit.botan' (head fb78974f57bc3065d8537ebeb5210c86e74e9bb1)
to branch 'net.randombit.botan.c++0x' (head dcb30c0029c7e44a75d0d8b859447a6c9df97cde)
Diffstat (limited to 'src')
-rw-r--r--src/alloc/alloc_mmap/mmap_mem.cpp4
-rw-r--r--src/build-data/cc/sunstudio.txt (renamed from src/build-data/cc/sunwspro.txt)4
-rw-r--r--src/entropy/unix_procs/es_unix.cpp15
-rw-r--r--src/entropy/unix_procs/es_unix.h2
-rw-r--r--src/entropy/unix_procs/unix_src.cpp46
-rw-r--r--src/utils/mlock.cpp4
-rw-r--r--src/utils/stl_util.h5
7 files changed, 48 insertions, 32 deletions
diff --git a/src/alloc/alloc_mmap/mmap_mem.cpp b/src/alloc/alloc_mmap/mmap_mem.cpp
index a2059a6ea..2b27b2908 100644
--- a/src/alloc/alloc_mmap/mmap_mem.cpp
+++ b/src/alloc/alloc_mmap/mmap_mem.cpp
@@ -120,11 +120,11 @@ void MemoryMapping_Allocator::dealloc_block(void* ptr, u32bit n)
{
std::memset(ptr, PATTERNS[j], n);
- if(::msync(ptr, n, MS_SYNC))
+ if(::msync((char*)ptr, n, MS_SYNC))
throw MemoryMapping_Failed("Sync operation failed");
}
- if(::munmap(ptr, n))
+ if(::munmap((char*)ptr, n))
throw MemoryMapping_Failed("Could not unmap file");
}
diff --git a/src/build-data/cc/sunwspro.txt b/src/build-data/cc/sunstudio.txt
index bd86ade33..987f85e67 100644
--- a/src/build-data/cc/sunwspro.txt
+++ b/src/build-data/cc/sunstudio.txt
@@ -1,4 +1,4 @@
-macro_name SUN_WORKSHOP
+macro_name SUN_STUDIO
binary_name CC
@@ -18,6 +18,8 @@ shared_flags "-KPIC"
warning_flags "+w"
lang_flags "+p -D__EXTENSIONS__"
+ar_command "CC -xar -o"
+
makefile_style unix
<so_link_flags>
diff --git a/src/entropy/unix_procs/es_unix.cpp b/src/entropy/unix_procs/es_unix.cpp
index 039479308..5756f93dd 100644
--- a/src/entropy/unix_procs/es_unix.cpp
+++ b/src/entropy/unix_procs/es_unix.cpp
@@ -9,6 +9,7 @@
#include <botan/internal/unix_cmd.h>
#include <botan/parsing.h>
#include <algorithm>
+
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/resource.h>
@@ -22,7 +23,12 @@ namespace {
* Sort ordering by priority
*/
bool Unix_Program_Cmp(const Unix_Program& a, const Unix_Program& b)
- { return (a.priority < b.priority); }
+ {
+ if(a.priority == b.priority)
+ return (a.name_and_args < b.name_and_args);
+
+ return (a.priority < b.priority);
+ }
}
@@ -32,7 +38,8 @@ bool Unix_Program_Cmp(const Unix_Program& a, const Unix_Program& b)
Unix_EntropySource::Unix_EntropySource(const std::vector<std::string>& path) :
PATH(path)
{
- add_default_sources(sources);
+ std::vector<Unix_Program> default_sources = get_default_sources();
+ add_sources(&default_sources[0], default_sources.size());
}
/**
@@ -74,10 +81,8 @@ void Unix_EntropySource::poll(Entropy_Accumulator& accum)
accum.add(::getpid(), 0);
accum.add(::getppid(), 0);
accum.add(::getuid(), 0);
- accum.add(::geteuid(), 0);
- accum.add(::getegid(), 0);
+ accum.add(::getgid(), 0);
accum.add(::getpgrp(), 0);
- accum.add(::getsid(0), 0);
struct ::rusage usage;
::getrusage(RUSAGE_SELF, &usage);
diff --git a/src/entropy/unix_procs/es_unix.h b/src/entropy/unix_procs/es_unix.h
index 03496b364..415cce9fe 100644
--- a/src/entropy/unix_procs/es_unix.h
+++ b/src/entropy/unix_procs/es_unix.h
@@ -27,7 +27,7 @@ class Unix_EntropySource : public EntropySource
void add_sources(const Unix_Program[], u32bit);
Unix_EntropySource(const std::vector<std::string>& path);
private:
- static void add_default_sources(std::vector<Unix_Program>&);
+ static std::vector<Unix_Program> get_default_sources();
void fast_poll(Entropy_Accumulator& accum);
const std::vector<std::string> PATH;
diff --git a/src/entropy/unix_procs/unix_src.cpp b/src/entropy/unix_procs/unix_src.cpp
index a72ecf055..51af6bd40 100644
--- a/src/entropy/unix_procs/unix_src.cpp
+++ b/src/entropy/unix_procs/unix_src.cpp
@@ -12,50 +12,54 @@ namespace Botan {
/**
* Default Commands for Entropy Gathering
*/
-void Unix_EntropySource::add_default_sources(std::vector<Unix_Program>& srcs)
+std::vector<Unix_Program> Unix_EntropySource::get_default_sources()
{
- srcs.push_back(Unix_Program("vmstat", 1));
- srcs.push_back(Unix_Program("vmstat -s", 1));
- srcs.push_back(Unix_Program("pfstat", 1));
+ std::vector<Unix_Program> srcs;
+
srcs.push_back(Unix_Program("netstat -in", 1));
+ srcs.push_back(Unix_Program("pfstat", 1));
+ srcs.push_back(Unix_Program("vmstat -s", 1));
+ srcs.push_back(Unix_Program("vmstat", 1));
+ srcs.push_back(Unix_Program("arp -a -n", 2));
+ srcs.push_back(Unix_Program("ifconfig -a", 2));
srcs.push_back(Unix_Program("iostat", 2));
+ srcs.push_back(Unix_Program("ipcs -a", 2));
srcs.push_back(Unix_Program("mpstat", 2));
+ srcs.push_back(Unix_Program("netstat -an", 2));
+ srcs.push_back(Unix_Program("netstat -s", 2));
srcs.push_back(Unix_Program("nfsstat", 2));
srcs.push_back(Unix_Program("portstat", 2));
- srcs.push_back(Unix_Program("arp -a -n", 2));
- srcs.push_back(Unix_Program("ifconfig -a", 2));
+ srcs.push_back(Unix_Program("procinfo -a", 2));
srcs.push_back(Unix_Program("pstat -T", 2));
srcs.push_back(Unix_Program("pstat -s", 2));
srcs.push_back(Unix_Program("uname -a", 2));
srcs.push_back(Unix_Program("uptime", 2));
- srcs.push_back(Unix_Program("ipcs -a", 2));
- srcs.push_back(Unix_Program("procinfo -a", 2));
- srcs.push_back(Unix_Program("sysinfo", 3));
srcs.push_back(Unix_Program("listarea", 3));
srcs.push_back(Unix_Program("listdev", 3));
-
- srcs.push_back(Unix_Program("who", 3));
- srcs.push_back(Unix_Program("finger", 3));
- srcs.push_back(Unix_Program("netstat -s", 3));
- srcs.push_back(Unix_Program("netstat -an", 3));
srcs.push_back(Unix_Program("ps -A", 3));
- srcs.push_back(Unix_Program("mailstats", 3));
- srcs.push_back(Unix_Program("rpcinfo -p localhost", 3));
+ srcs.push_back(Unix_Program("sysinfo", 3));
+
+ srcs.push_back(Unix_Program("finger", 4));
+ srcs.push_back(Unix_Program("mailstats", 4));
+ srcs.push_back(Unix_Program("rpcinfo -p localhost", 4));
+ srcs.push_back(Unix_Program("who", 4));
- srcs.push_back(Unix_Program("dmesg", 4));
- srcs.push_back(Unix_Program("ls -alni /tmp", 4));
- srcs.push_back(Unix_Program("ls -alni /proc", 4));
srcs.push_back(Unix_Program("df -l", 4));
+ srcs.push_back(Unix_Program("dmesg", 4));
srcs.push_back(Unix_Program("last -5", 4));
+ srcs.push_back(Unix_Program("ls -alni /proc", 4));
+ srcs.push_back(Unix_Program("ls -alni /tmp", 4));
srcs.push_back(Unix_Program("pstat -f", 4));
- srcs.push_back(Unix_Program("ps aux", 5));
srcs.push_back(Unix_Program("ps -elf", 5));
+ srcs.push_back(Unix_Program("ps aux", 5));
+ srcs.push_back(Unix_Program("lsof -n", 6));
srcs.push_back(Unix_Program("sar -A", 6));
- srcs.push_back(Unix_Program("lsof", 6));
+
+ return srcs;
}
}
diff --git a/src/utils/mlock.cpp b/src/utils/mlock.cpp
index bc6ddc67e..ce5ae8aed 100644
--- a/src/utils/mlock.cpp
+++ b/src/utils/mlock.cpp
@@ -31,7 +31,7 @@ bool has_mlock()
bool lock_mem(void* ptr, u32bit bytes)
{
#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
- return (::mlock(ptr, bytes) == 0);
+ return (::mlock((char*)ptr, bytes) == 0);
#elif defined(BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK)
return (::VirtualLock(ptr, bytes) != 0);
#else
@@ -45,7 +45,7 @@ bool lock_mem(void* ptr, u32bit bytes)
void unlock_mem(void* ptr, u32bit bytes)
{
#if defined(BOTAN_TARGET_OS_HAS_POSIX_MLOCK)
- ::munlock(ptr, bytes);
+ ::munlock((char*)ptr, bytes);
#elif defined(BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK)
::VirtualUnlock(ptr, bytes);
#endif
diff --git a/src/utils/stl_util.h b/src/utils/stl_util.h
index 4cc081733..0d672fc50 100644
--- a/src/utils/stl_util.h
+++ b/src/utils/stl_util.h
@@ -43,7 +43,12 @@ template<typename K, typename V>
void multimap_insert(std::multimap<K, V>& multimap,
const K& key, const V& value)
{
+#if defined(BOTAN_BUILD_COMPILER_IS_SUN_STUDIO)
+ // Work around a strange bug in Sun Studio
+ multimap.insert(std::make_pair<const K, V>(key, value));
+#else
multimap.insert(std::make_pair(key, value));
+#endif
}
}